forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
photonui.d.ts
435 lines (351 loc) · 11.4 KB
/
photonui.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
// Type definitions for PhotonUI v1.0.0
// Project: https://github.com/wanadev/PhotonUI
// Definitions by: Florent Poujol <https://github.com/florentpoujol/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module photonui {
// Base
module Helpers {
function escapeHtml(string: string): void;
function uuid4(): string;
function cleanNode(node: HTMLElement): void;
function getAbsolutePosition(element: HTMLElement|string): { x: number; y: number };
function numberToCssSize(value: number, defaultValue?: number, nullValue?: string): string;
}
class Base {
constructor(params?: { [key: string]: any });
destroy(): void;
registerCallback(id: string, wEvent: string, callback: Function, thisArg: any): void;
removeCallback(id: string): void;
}
class Widget extends Base {
absolutePosition: { x: number; y: number; }; // readonly
contextMenu: PopupWindow;
contextMenuName: string;
html: HTMLElement; // readonly
layoutOptions: { [key: string]: any };
name: string;
offsetWidth: number; // readonly
offsetHeight: number; // readonly
parent: Widget;
parentName: string;
tooltip: string;
visible: boolean;
show(): void;
hide(): void;
unparent(): void;
addClass(className: string): void;
removeClass(className: string): void;
static getWidget(name: string): Widget;
static domInsert(widget: Widget, element?: HTMLElement|string): void;
}
// Methods
function domInsert(widget: Widget, element?: HTMLElement|string): void;
function getWidget(name: string): Widget;
//Widgets
class FileManager extends Base {
acceptedExts: string[];
acceptedMimes: string[];
dropZone: HTMLElement;
multiselect: boolean;
open(): void;
}
class Translation extends Base {
locale: string;
addCatalogs(catalogs: { [key: string]: any }): void;
guessUserLanguage(): string;
gettext(string: string, replacements?: { [key: string]: string }): string;
lazyGettext(string: string, replacements?: { [key: string]: string }): string;
enableDomScan(enable: boolean): void;
updateDomTranslation(): void;
}
class AccelManager extends Base {
addAccel(id: string, keys: string, callback: Function, safe?: boolean): void;
removeAccel(id: string): void;
}
class MouseManager extends Base {
constructor(params?: { [key: string]: any });
constructor(element?: Widget|HTMLElement, params?: { [key: string]: any });
element: HTMLElement;
threshold: number;
action: string; // readonly
btnLeft: boolean; // readonly
btnMiddle: boolean; // readonly
btnRight: boolean; // readonly
button: string; // readonly
pageX: number; // readonly
pageY: number; // readonly
x: number; // readonly
y: number; // readonly
deltaX: number; // readonly
deltaY: number; // readonly
}
// -----------------------------------
class BaseIcon extends Widget {}
class FAIcon extends BaseIcon {
constructor(params?: { [key: string]: any });
constructor(name: string, params?: { [key: string]: any });
color: string;
iconName: string;
size: string;
}
class SpriteIcon extends BaseIcon {
constructor(params?: { [key: string]: any });
constructor(name: string, params?: { [key: string]: any });
icon: string;
iconName: string;
spriteSheetName: string;
}
// -----------------------------------
class Image extends Widget {
width: number;
height: number;
url: string;
}
class SpriteSheet extends Base {
name: string;
imageUrl: string;
size: string;
icons: { [iconName: string]: number[] };
addIcon(iconName: string, x: number, y: number): void;
removeIcon(iconName: string): void;
getIconPosition(iconName: string): { x: number; y: number; };
getIconCSS(iconName: string): string;
static getSpriteSheet(name: string): SpriteSheet;
}
class Canvas extends Widget {
canvas: HTMLElement;
interactiveMode: HTMLElement;
width: number;
height: number;
getContext(contextId: string): any;
setContext(contextId: string): void;
supportsContext(contextId: string): boolean;
toBlod(imageFormat: string): any; // returns Blob
toBlodHD(imageFormat: string): any; // returns Blob
toDataUrl(imageFormat: string): string;
toDataUrlHD(imageFormat: string): string;
transferControlToProxy(): void;
}
class Label extends Widget {
constructor(params?: { [key: string]: any });
constructor(name: string, params?: { [key: string]: any });
forInput: Field|CheckBox;
forInputName: string;
text: string;
textAlign: string;
}
class Text extends Widget {
rawHtml: string;
text: string;
}
class ProgressBar extends Widget {
orientation: string;
pulsate: boolean;
textVisible: boolean;
value: number;
}
class Separator extends Widget {
orientation: string;
}
class Button extends Widget {
appearance: string; // normal | flat
buttonColor: string;
leftIconName: string;
leftIcon: BaseIcon;
leftIconVisible: boolean;
rightIconName: string;
rightIcon: BaseIcon;
rightIconVisible: boolean;
text: string;
textVisible: boolean;
}
class ColorButton extends Widget {
color: Color;
dialogOnly: boolean;
value: string;
}
class CheckBox extends Widget {
value: boolean;
}
class Switch extends CheckBox {}
class ToggleButton extends CheckBox {}
// -----------------------------------
class Color extends Base {
constructor(color: string);
constructor(params?: { [key: string]: any });
hexString: string;
rgbString: string; // readonly
rgbaString: string; // readonly
red: number;
green: number;
blue: number;
alpha: number;
hue: number;
saturation: number;
brightness: number;
setRGB(red: number, green: number, blue: number): void;
getRGB(): number[];
setRGBA(red: number, green: number, blue: number, alpha: number): void;
getRGBA(): number[];
setHSB(hue: number, saturation: number, brightness: number): void;
}
class ColorPalette extends Widget {
color: Color;
palette: Array<string[]>;
value: string;
static palette: Array<string[]>;
}
class ColorPicker extends Widget {
color: Color;
value: string;
}
// -----------------------------------
class Field extends Widget {
placeholder: string;
value: boolean;
}
class NumericField extends Field {
min: number;
max: number;
step: number;
decimalDigits: number;
decimalSymbol: string;
}
class Slider extends NumericField {
fieldVisible: boolean;
}
class TextAreaField extends Field {
cols: number;
rows: number;
}
class TextField extends Field {
type: string; // text, password, email, search, tel, url
}
// -----------------------------------
class Select extends Widget {
children: Widget[];
childrenNames: string[];
iconVisible: boolean;
placeholder: string;
popupWidth: number;
popupHeight: number;
popupMaxWidth: number;
popupMinWidth: number;
popupMaxHeight: number;
popupMinHeight: number;
popupOffsetWidth: number; // readonly
popupOffsetHeight: number; // readonly
popupPadding: number;
value: any; // string (maybe)
addChild(widget: Widget, layoutOptions?: any): void;
}
class FontSelect extends Select {
fonts: string[];
addFont(fontName: string): void;
}
// -----------------------------------
class Container extends Widget {
child: Widget;
childName: string;
containerNode: HTMLElement; // readonly
horizontalChildExpansion: boolean;
verticalChildExpansion: boolean;
removeChild(widget: Widget): void;
}
class Layout extends Container {
children: Widget[];
childrenNames: string[];
addChild(widget: Widget, layoutOptions?: { [key: string]: any }): void;
empty(): void;
}
class BoxLayout extends Layout {
horizontalPadding: number;
verticalPadding: number;
orientation: string;
spacing: number;
}
class FluidLayout extends Layout {
horizontalPadding: number;
verticalPadding: number;
}
class GridLayout extends Layout {
horizontalPadding: number;
verticalPadding: number;
horizontalSpacing: number;
verticalSpacing: number;
}
class Menu extends Layout {
iconVisible: boolean;
}
class MenuItem extends Menu {
active: boolean;
icon: BaseIcon;
iconName: string;
text: string;
value: any; // string (maybe)
}
class SubMenuItem extends MenuItem {
menu: Menu;
menuName: string;
}
// -----------------------------------
class Viewport extends Container {
width: number;
minWidth: number;
maxWidth: number;
height: number;
minHeight: number;
maxHeight: number;
padding: number;
horizontalScrollbar: boolean;
verticalScrollbar: boolean;
}
// -----------------------------------
class BaseWindow extends Container {
width: number;
minWidth: number;
maxWidth: number;
height: number;
minHeight: number;
maxHeight: number;
padding: number;
position: { x: number; y: number };
x: number;
y: number;
center(): void;
}
class PopupWindow extends BaseWindow {
popupXY(x: number, y: number): void;
popupWidget(widget: Widget): void;
}
class PopupMenu extends PopupWindow {}
class Window extends BaseWindow {
closeButtonVisible: boolean;
modal: boolean;
movable: boolean;
title: string;
moveToFront(): void;
moveToBack(): void;
}
class Dialog extends Window {
buttons: Widget[];
buttonNames: string[];
addButton(widget: Widget, layoutOptions: any): void;
removeButton(widget: Widget): void;
}
class ColorPickerDialog extends Dialog {
color: Color;
}
// -----------------------------------
class TabItem extends Container {
tabHtml: HTMLElement; // readonly
title: string;
}
class TabLayout extends Layout {
activeTab: Widget;
activeTabName: string;
padding: number;
tabsPosition: string; // top, bottom, left, right
}
}
declare function _(string: string, replacements?: { [key: string]: string }): string; // alias of Translation.lazyGettext()