swing-ui 0.1.25 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +5 -4
  2. package/README.md +144 -7
  3. package/SwingUI.js +2611 -0
  4. package/classes/Arc.js +185 -0
  5. package/classes/Button.js +55 -0
  6. package/classes/CheckBox.js +33 -0
  7. package/classes/CheckBoxMenuItem.js +24 -0
  8. package/classes/ComboBox.js +329 -0
  9. package/classes/ComponentContainer.js +828 -0
  10. package/classes/ContextMenu.js +141 -0
  11. package/classes/DocumentEditor.js +168 -0
  12. package/classes/Ellipse.js +76 -0
  13. package/classes/InternalWindow.js +397 -0
  14. package/classes/InternalWindowContainer.js +93 -0
  15. package/classes/Label.js +52 -0
  16. package/classes/Line.js +105 -0
  17. package/classes/List.js +452 -0
  18. package/classes/MediaPlayer.js +504 -0
  19. package/classes/Menu.js +74 -0
  20. package/classes/MenuBar.js +56 -0
  21. package/classes/MenuItem.js +92 -0
  22. package/classes/Panel.js +50 -0
  23. package/classes/PasswordField.js +47 -0
  24. package/classes/Polygon.js +236 -0
  25. package/classes/Polyline.js +240 -0
  26. package/classes/ProgressBar.js +62 -0
  27. package/classes/RadioButton.js +110 -0
  28. package/classes/RadioButtonMenuItem.js +106 -0
  29. package/classes/Rectangle.js +199 -0
  30. package/classes/ScrollPane.js +53 -0
  31. package/classes/ScrollableComponent.js +141 -0
  32. package/classes/Separator.js +24 -0
  33. package/classes/Shape.js +584 -0
  34. package/classes/ShapeContainer.js +231 -0
  35. package/classes/Slider.js +172 -0
  36. package/classes/Spinner.js +172 -0
  37. package/classes/SplitView.js +82 -0
  38. package/classes/Stroke.js +115 -0
  39. package/classes/Table.js +982 -0
  40. package/classes/Tabs.js +228 -0
  41. package/classes/TextArea.js +125 -0
  42. package/classes/TextComponent.js +207 -0
  43. package/classes/TextField.js +128 -0
  44. package/classes/TextShape.js +123 -0
  45. package/classes/ToggleButton.js +147 -0
  46. package/classes/ToolBar.js +120 -0
  47. package/classes/TrayIcon.js +54 -0
  48. package/classes/Tree.js +569 -0
  49. package/classes/UIComponent.js +2113 -0
  50. package/classes/Window.js +609 -0
  51. package/enums.js +298 -0
  52. package/fonts.conf +32 -0
  53. package/functions.js +254 -0
  54. package/icon.png +0 -0
  55. package/index.js +109 -4
  56. package/jar/gui-11.jar +0 -0
  57. package/jar/lib/flatlaf.jar +0 -0
  58. package/jar/lib/jna.jar +0 -0
  59. package/package.json +58 -33
  60. package/typedefs.js +973 -0
  61. package/types/SwingUI.d.ts +727 -0
  62. package/types/classes/Arc.d.ts +111 -0
  63. package/types/classes/Button.d.ts +38 -0
  64. package/types/classes/CheckBox.d.ts +22 -0
  65. package/types/classes/CheckBoxMenuItem.d.ts +18 -0
  66. package/types/classes/ComboBox.d.ts +172 -0
  67. package/types/classes/ComponentContainer.d.ts +131 -0
  68. package/types/classes/ContextMenu.d.ts +74 -0
  69. package/types/classes/DocumentEditor.d.ts +95 -0
  70. package/types/classes/Ellipse.d.ts +34 -0
  71. package/types/classes/InternalWindow.d.ts +163 -0
  72. package/types/classes/InternalWindowContainer.d.ts +36 -0
  73. package/types/classes/Label.d.ts +33 -0
  74. package/types/classes/Line.d.ts +48 -0
  75. package/types/classes/List.d.ts +223 -0
  76. package/types/classes/MediaPlayer.d.ts +381 -0
  77. package/types/classes/Menu.d.ts +43 -0
  78. package/types/classes/MenuBar.d.ts +26 -0
  79. package/types/classes/MenuItem.d.ts +57 -0
  80. package/types/classes/Panel.d.ts +28 -0
  81. package/types/classes/PasswordField.d.ts +22 -0
  82. package/types/classes/Polygon.d.ts +93 -0
  83. package/types/classes/Polyline.d.ts +96 -0
  84. package/types/classes/ProgressBar.d.ts +36 -0
  85. package/types/classes/RadioButton.d.ts +70 -0
  86. package/types/classes/RadioButtonMenuItem.d.ts +71 -0
  87. package/types/classes/Rectangle.d.ts +82 -0
  88. package/types/classes/ScrollPane.d.ts +23 -0
  89. package/types/classes/ScrollableComponent.d.ts +81 -0
  90. package/types/classes/Separator.d.ts +14 -0
  91. package/types/classes/Shape.d.ts +223 -0
  92. package/types/classes/ShapeContainer.d.ts +92 -0
  93. package/types/classes/Slider.d.ts +107 -0
  94. package/types/classes/Spinner.d.ts +129 -0
  95. package/types/classes/SplitView.d.ts +47 -0
  96. package/types/classes/Stroke.d.ts +99 -0
  97. package/types/classes/Table.d.ts +652 -0
  98. package/types/classes/Tabs.d.ts +118 -0
  99. package/types/classes/TextArea.d.ts +45 -0
  100. package/types/classes/TextComponent.d.ts +136 -0
  101. package/types/classes/TextField.d.ts +94 -0
  102. package/types/classes/TextShape.d.ts +73 -0
  103. package/types/classes/ToggleButton.d.ts +84 -0
  104. package/types/classes/ToolBar.d.ts +82 -0
  105. package/types/classes/TrayIcon.d.ts +43 -0
  106. package/types/classes/Tree.d.ts +354 -0
  107. package/types/classes/UIComponent.d.ts +945 -0
  108. package/types/classes/Window.d.ts +334 -0
  109. package/types/enums.d.ts +437 -0
  110. package/types/functions.d.ts +109 -0
  111. package/types/index.d.ts +188 -0
  112. package/types/typedefs.d.ts +1626 -0
  113. package/ui-process-manager.js +317 -0
  114. package/video-devices-linux.sh +72 -0
  115. package/video-devices-mac.sh +33 -0
  116. package/CHANGES.md +0 -3
@@ -0,0 +1,334 @@
1
+ /**
2
+ * Window UI component that extends ShapesContainer class which extends UIComponent.
3
+ * For more methods for this component check ShapesContainer and UIComponent classes.
4
+ *
5
+ * @glass
6
+ * @global
7
+ * @example <h2>To create a new custom window class (recommended way for main window):</h2>
8
+ * class MyWindow extends Window
9
+ * {
10
+ * constructor()
11
+ * {
12
+ * super("My New Application"); //
13
+ * }
14
+ * }
15
+ *
16
+ * // appWindow1 will be accessible globally.
17
+ * globalThis.appWindow1 = new MyWindow();
18
+ */
19
+ export class Window extends ShapeContainer {
20
+ /**
21
+ * Represents the behavior when a close button is clicked or close() method is called.
22
+ * Applies to {@link Window} and {@link InternalWindow} components.
23
+ *
24
+ * @readonly
25
+ * @enum {number}
26
+ * @property {number} Nothing - Do nothing; the close button has no effect. WindowEvent with type "closing" still gets emitted to report intent to close.
27
+ * @property {number} Hide - Hide the window instead of closing it.
28
+ * @property {number} Dispose - Release window resources and remove it from display. Emits 2 WindowEvent events, with type "closing" and with "close".
29
+ * @property {number} Exit - Terminate the entire application. Emits 2 WindowEvent events, with type "closing" and with "close".
30
+ * @see Window
31
+ * @see InternalWindow
32
+ * @example
33
+ * window.closeOperation(Window.CloseOperation.Exit); // setting most common window close operation
34
+ */
35
+ static readonly CloseOperation: Readonly<{
36
+ Nothing: 0;
37
+ Hide: 1;
38
+ Dispose: 2;
39
+ Exit: 3;
40
+ }>;
41
+ /**
42
+ * Represents the display state of a {@link Window}. Pass one of these values to {@link Window#state} to get or set the Window's current state.
43
+ *
44
+ * @readonly
45
+ * @enum {number}
46
+ * @property {number} Normal - The window is in its default, restored state (not minimized or maximized).
47
+ * @property {number} Minimized - The window is collapsed to the taskbar or dock.
48
+ * @property {number} Maximized - The window is expanded to fill the entire application area on the screen.
49
+ * @property {number} MaximizedHorizontally - The window is maximized horizontally but not vertically. Doesn't apply to {@link InternalWindow} component.
50
+ * @property {number} MaximizedVertically - The window is maximized vertically but not horizontally. Doesn't apply to {@link InternalWindow} component.
51
+ * @see Window#state
52
+ * @see Window#minimize
53
+ * @see Window#maximize
54
+ * @see InternalWindow#state
55
+ * @example <h2>Checking and setting Window state</h2>
56
+ * if(window.state() === Window.State.Minimized)
57
+ * {
58
+ * window.state(Window.State.Normal);
59
+ * }
60
+ */
61
+ static readonly State: Readonly<{
62
+ Normal: 0;
63
+ Minimized: 1;
64
+ Maximized: 2;
65
+ MaximizedHorizontally: 3;
66
+ MaximizedVertically: 4;
67
+ }>;
68
+ /**
69
+ * Represents the type of the window. Used when creating or modifying a window's appearance or behavior.
70
+ *
71
+ * @readonly
72
+ * @enum {number}
73
+ * @property {number} Normal - A standard, resizable window with borders, title bar and a taskbar button.
74
+ * @property {number} Borderless - A window with a task bar button, but without border and title bar.
75
+ * @property {number} Utility - A smaller utility window without a taskbar button, typically used for tools or palettes.
76
+ * @property {number} Popup - A popup window, usually without a title bar, borders and taskbar button.
77
+ * @see Window#type
78
+ * @example
79
+ * let window = ne Window("New window", parent_window, Window.Type.Utility);
80
+ */
81
+ static readonly Type: Readonly<{
82
+ Normal: 0;
83
+ Borderless: 1;
84
+ Utility: 2;
85
+ Popup: 3;
86
+ }>;
87
+ _shapes: any[];
88
+ temp_token: undefined;
89
+ /**
90
+ * Returns Window component that is set as an owner of this Window, or `null` if owner Window was not set.
91
+ *
92
+ * @readonly
93
+ * @type {Window|null}
94
+ */
95
+ readonly get owner(): Window | null;
96
+ /**
97
+ * Gets the current Window type.
98
+ *
99
+ * @readonly
100
+ * @type {Window.Type}
101
+ * @see Window#Type
102
+ */
103
+ readonly get type(): Readonly<{
104
+ Normal: 0;
105
+ Borderless: 1;
106
+ Utility: 2;
107
+ Popup: 3;
108
+ }>;
109
+ /**
110
+ * Returns the size of the screen that the Window occupies. If the Window is not on any screen, then returns default screen's size. If the Window was never displayed on a screen, then `null` is returned.
111
+ *
112
+ * @readonly
113
+ * @type {Size}
114
+ */
115
+ readonly get screenSize(): Size;
116
+ /**
117
+ * Returns an offset of each side of content pane of the Window relative to Window's edges. See example below:
118
+ *
119
+ * @readonly
120
+ * @type {Object}
121
+ * @example
122
+ * // Returned object format:
123
+ * {
124
+ * top: number,
125
+ * right: number,
126
+ * bottom: number,
127
+ * left: number
128
+ * }
129
+ */
130
+ readonly get innerOffset(): Object;
131
+ /**
132
+ * Sets or gets the operation to perform when a Window close button is clicked by a user or a close() method is called on this Window.
133
+ *
134
+ * @param {Window.CloseOperation} [operation] - One of Window.CloseOperation enum values. Default is Window.CloseOperation.Close.
135
+ * @return {Window|Window.CloseOperation} Returns `this` component if argument is provided, otherwise returns value.
136
+ */
137
+ closeOperation(...args: any[]): Window | Readonly<{
138
+ Nothing: 0;
139
+ Hide: 1;
140
+ Dispose: 2;
141
+ Exit: 3;
142
+ }>;
143
+ /**
144
+ * Gets, registers or unregisters an event handler for when the state of the Window changes between normal, minimized, maximized.
145
+ *
146
+ * @param {function(WindowStateEvent): any} [callback] - The event handler function receiving {@link WindowStateEvent} event object.
147
+ * @param {boolean} [remove=false] - Set to `true` to unregister the event handler.
148
+ * @returns {this}
149
+ * @see Window#State
150
+ * @example
151
+ * // Example event object:
152
+ * const e = {
153
+ * target: Window, // The component that triggered the event.
154
+ * type: string, // `change`
155
+ * oldValue: Window.State, // Previous state
156
+ * newValue: Window.State, // New state
157
+ * interactive: boolean // Indicates if the state was changed by user's interaction with window
158
+ * };
159
+ */
160
+ onStateChange(...args: any[]): this;
161
+ /**
162
+ * Gets, registers or unregisters an event handler for window events, such as activate, deactivate, closed, etc.
163
+ *
164
+ * @param {function(WindowEvent): any} [callback] - The event handler function receiving {@link WindowEvent} event object.
165
+ * @param {boolean} [remove=false] - Set to `true` to unregister the event handler.
166
+ * @returns {this}
167
+ *
168
+ * @example
169
+ * // Example event object:
170
+ * const e = {
171
+ * target: Window, // The component that triggered the event.
172
+ * type: string, // `activate`, `deactivate`, `minimize`, `restore`, `closing`, `close`, `show`
173
+ * interactive: boolean // Indicates if triggered by user's interaction with window
174
+ * };
175
+ */
176
+ onWindowEvents(...args: any[]): this;
177
+ /**
178
+ * Performs previously specified close operation on this Window.
179
+ * To specify what operation should be performed use closeOperation(Window.CloseOperation.[Nothing|Exit|Hide|Dispose])
180
+ *
181
+ * @return {Window} Returns this window component
182
+ */
183
+ close(): Window;
184
+ /**
185
+ * Shows a dialog window asking user to confirm your message. User has an option to press OK or Cancel, which result in returned values `true` or `false` respectively.
186
+ *
187
+ * @param {string} message - Message to show in dialog window.
188
+ * @return {boolean} Returns `boolean` indicating if user confirmed the message or not.
189
+ */
190
+ confirm(message: string): boolean;
191
+ /**
192
+ * Opens file/directory chooser dialog window. Check example for all possible options.
193
+ *
194
+ * @param {FileChooserOptions} options - JSON Object with valid options. See example for full list of options.
195
+ * @returns {string|string[]|null} Returns `string` path if `multiple` option is `false`, `string[]` if `multiple` option is `true`, or `null` if file chooser was closed without making a selection.
196
+ * @example
197
+ * window.chooseFile({
198
+ * directory: false, // `true` for Directory selection, `false` for Files.
199
+ * save: true, // `true` for `Save` dialog box, `false` for `Open`.
200
+ * multiple: false, // [true|false] to be able to select multiple files/folders.
201
+ * hidden:false, // [true|false] to show hidden files.
202
+ * filter:"Documents:doc,docx,txt,rtf|Music:mp3,m4a,ogg,wma|Images:gif,jpg,jpeg,bmp,webp", // File extension can have multiple "." characters, such as "file.d.ts".
203
+ * path:"Initial-Path/file.ext" // Default path to open in the dialog window.
204
+ * });
205
+ * @see FileChooserOptions
206
+ */
207
+ chooseFile(options: FileChooserOptions): string | string[] | null;
208
+ /**
209
+ * Opens color chooser dialog window.
210
+ *
211
+ * @param {string} [title] - Dialog window title text
212
+ * @param {string} [initial_color] - Default color to show in dialog window before a new one is chosen.
213
+ * @returns {string|null} Returns a string of a chosen color.
214
+ */
215
+ chooseColor(title?: string, initial_color?: string): string | null;
216
+ /**
217
+ * Opens font chooser dialog window.
218
+ *
219
+ * @param {string} [title] - Dialog window title text
220
+ * @param {Object} [initial_font] - Pre-fills dialog window with specified font properties.
221
+ * @returns {Object|null} Returns a new chosen font object or `null` if font was not selected.
222
+ */
223
+ chooseFont(title?: string, initial_font?: Object): Object | null;
224
+ /**
225
+ * Sets or get a window state. Use one of these enum values: Window.State.[Normal|Minimized|Maximized|MaximizedHorizontally|MaximizedVertically]
226
+ *
227
+ * @param {Window.State} [state] - Setting new window state
228
+ * @returns {Window.State|Window} Returns `this` Window if argument is provided, otherwise returns current state.
229
+ * @see Window#State
230
+ * @example
231
+ * window.state(Window.State.Maximized);
232
+ * if(window.state() === Window.State.Maximized) console.log("It works!");
233
+ */
234
+ state(...args: any[]): Readonly<{
235
+ Normal: 0;
236
+ Minimized: 1;
237
+ Maximized: 2;
238
+ MaximizedHorizontally: 3;
239
+ MaximizedVertically: 4;
240
+ }> | Window;
241
+ /**
242
+ * Convenience method to minimize the Window by setting Window state to Window.State.Minimized.
243
+ *
244
+ * @return {Window} Returns `this` Window.
245
+ * @see Window#State
246
+ * @see Window#state
247
+ * @see Window#maximize
248
+ */
249
+ minimize(): Window;
250
+ /**
251
+ * Convenience method to maximize the Window by setting Window state to Window.State.Maximized.
252
+ *
253
+ * @return {Window} Returns `this` Window.
254
+ * @see Window#State
255
+ * @see Window#state
256
+ * @see Window#minimize
257
+ */
258
+ maximize(): Window;
259
+ /**
260
+ * Sets or returns the index or the screen that the Window is on.
261
+ *
262
+ * @args {number} [index] - Index of the screen where to move this Window. To get a list of screens with indexes use ui.screens().
263
+ * @return {Window|number} Returns `this` Window if argument is provided, otherwise returns index of the screen this Window is on.
264
+ */
265
+ screen(...args: any[]): Window | number;
266
+ /**
267
+ * Sets or gets a default button in this window form. On some systems like Windows OS default button has a different look than other buttons.
268
+ *
269
+ * @param {Button} button - The button that should be default on this Window. Only last assigned button gets to be default.
270
+ * @return {Button|undefined}
271
+ */
272
+ defaultButton(...args: any[]): Button | undefined;
273
+ /**
274
+ * Sets or gets a size of content container of this Window (doesn't include the size of the window borders and a menu bar like size() function does).
275
+ *
276
+ * @param {number|Size} [width_or_size] - Width integer or a Size object as a sole parameter.
277
+ * @param {number} [height] - Integer height value (required if the first argument is a numeric width).
278
+ * @return {Size|Window} Returns `this` Window if called with parameters, otherwise returns the inner size.
279
+ * @see Size
280
+ */
281
+ innerSize(...args: any[]): Size | Window;
282
+ /**
283
+ * Indicates the minimum size the content container of the Window it can be resized to. It overrides previously set minSize() value.
284
+ *
285
+ * @param {number|Size} width_or_size - Width, or a Size formatted object as a sole parameter.
286
+ * @param {number} height - Height of the component.
287
+ * @returns {Size|Window|null} If called without parameters, current minimum inner Size is returned or `null` if it wasn't previously set; otherwise returns `this` component instance for chaining.
288
+ * @see Window#maxInnerSize
289
+ * @see UIComponent#minSize
290
+ * @see Size
291
+ */
292
+ minInnerSize(...args: any[]): Size | Window | null;
293
+ /**
294
+ * Indicates the maximum size the content container of the Window it can be resized to. It overrides previously set maxSize() value.
295
+ *
296
+ * @param {number|Size} width_or_size - Width, or a Size formatted object as a sole parameter.
297
+ * @param {number} height - Height of the component.
298
+ * @returns {Size|Window|null} If called without parameters, current maximum inner Size is returned or `null` if it wasn't previously set; otherwise returns `this` component instance for chaining.
299
+ * @see Window#minInnerSize
300
+ * @see UIComponent#maxSize
301
+ * @see Size
302
+ */
303
+ maxInnerSize(...args: any[]): Size | Window | null;
304
+ /**
305
+ * Sets or gets whether window should always stay on top of other windows.
306
+ *
307
+ * @param {boolean} [value] - Set Window to be on top or not
308
+ * @return {Window|boolean} Returns `this` Window if arguments are supplied, otherwise returns `boolean` value.
309
+ */
310
+ alwaysOnTop(...args: any[]): Window | boolean;
311
+ /**
312
+ * Sets or gets the main menu bar for the top of the Window. On macOS, this menu bar appears in the system's top menu bar.
313
+ *
314
+ * @param {MenuBar} [bar] - The `MenuBar` to set as the primary menu bar.
315
+ * @returns {Window|MenuBar|null} Returns the `Window` instance when setting a menu bar; otherwise, returns the currently set `MenuBar`, or `null` if none is set.
316
+ */
317
+ menuBar(...args: any[]): Window | MenuBar | null;
318
+ /**
319
+ * Sets of get whether the window may be resized by end user.
320
+ *
321
+ * @param {boolean} [value] - Enables/disables resizing
322
+ * @return {Window|boolean} Returns `this` Window if argument is supplied, otherwise returns `boolean` value.
323
+ */
324
+ resizable(...args: any[]): Window | boolean;
325
+ /**
326
+ * Sets or gets component opacity float value between 0 and 1 inclusive. Opacity can be set only to Windo with types {@link Window.Type.Borderless} or {@link Window.Type.Popup}.
327
+ *
328
+ * @param {number} [opacity] - A number between 0 and 1 inclusive.
329
+ * @return {number|this} If `opacity` argument is provided, `this` component is returned, otherwise opacity `number` is returned.
330
+ */
331
+ opacity(...args: any[]): number | this;
332
+ #private;
333
+ }
334
+ import { ShapeContainer } from "./ShapeContainer.js";