1 | import { IDisposable } from '@lumino/disposable';
|
2 | import { Message } from '@lumino/messaging';
|
3 | import { Widget } from './widget';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export declare abstract class Layout implements Iterable<Widget>, IDisposable {
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 | constructor(options?: Layout.IOptions);
|
25 | /**
|
26 | * Dispose of the resources held by the layout.
|
27 | *
|
28 | * #### Notes
|
29 | * This should be reimplemented to clear and dispose of the widgets.
|
30 | *
|
31 | * All reimplementations should call the superclass method.
|
32 | *
|
33 | * This method is called automatically when the parent is disposed.
|
34 | */
|
35 | dispose(): void;
|
36 | /**
|
37 | * Test whether the layout is disposed.
|
38 | */
|
39 | get isDisposed(): boolean;
|
40 | /**
|
41 | * Get the parent widget of the layout.
|
42 | */
|
43 | get parent(): Widget | null;
|
44 | /**
|
45 | * Set the parent widget of the layout.
|
46 | *
|
47 | * #### Notes
|
48 | * This is set automatically when installing the layout on the parent
|
49 | * widget. The parent widget should not be set directly by user code.
|
50 | */
|
51 | set parent(value: Widget | null);
|
52 | /**
|
53 | * Get the fit policy for the layout.
|
54 | *
|
55 | * #### Notes
|
56 | * The fit policy controls the computed size constraints which are
|
57 | * applied to the parent widget by the layout.
|
58 | *
|
59 | * Some layout implementations may ignore the fit policy.
|
60 | */
|
61 | get fitPolicy(): Layout.FitPolicy;
|
62 | /**
|
63 | * Set the fit policy for the layout.
|
64 | *
|
65 | * #### Notes
|
66 | * The fit policy controls the computed size constraints which are
|
67 | * applied to the parent widget by the layout.
|
68 | *
|
69 | * Some layout implementations may ignore the fit policy.
|
70 | *
|
71 | * Changing the fit policy will clear the current size constraint
|
72 | * for the parent widget and then re-fit the parent.
|
73 | */
|
74 | set fitPolicy(value: Layout.FitPolicy);
|
75 | /**
|
76 | * Create an iterator over the widgets in the layout.
|
77 | *
|
78 | * @returns A new iterator over the widgets in the layout.
|
79 | *
|
80 | * #### Notes
|
81 | * This abstract method must be implemented by a subclass.
|
82 | */
|
83 | abstract [Symbol.iterator](): IterableIterator<Widget>;
|
84 | /**
|
85 | * Remove a widget from the layout.
|
86 | *
|
87 | * @param widget - The widget to remove from the layout.
|
88 | *
|
89 | * #### Notes
|
90 | * A widget is automatically removed from the layout when its `parent`
|
91 | * is set to `null`. This method should only be invoked directly when
|
92 | * removing a widget from a layout which has yet to be installed on a
|
93 | * parent widget.
|
94 | *
|
95 | * This method should *not* modify the widget's `parent`.
|
96 | */
|
97 | abstract removeWidget(widget: Widget): void;
|
98 | /**
|
99 | * Process a message sent to the parent widget.
|
100 | *
|
101 | * @param msg - The message sent to the parent widget.
|
102 | *
|
103 | * #### Notes
|
104 | * This method is called by the parent widget to process a message.
|
105 | *
|
106 | * Subclasses may reimplement this method as needed.
|
107 | */
|
108 | processParentMessage(msg: Message): void;
|
109 | /**
|
110 | * Perform layout initialization which requires the parent widget.
|
111 | *
|
112 | * #### Notes
|
113 | * This method is invoked immediately after the layout is installed
|
114 | * on the parent widget.
|
115 | *
|
116 | * The default implementation reparents all of the widgets to the
|
117 | * layout parent widget.
|
118 | *
|
119 | * Subclasses should reimplement this method and attach the child
|
120 | * widget nodes to the parent widget's node.
|
121 | */
|
122 | protected init(): void;
|
123 | /**
|
124 | * A message handler invoked on a `'resize'` message.
|
125 | *
|
126 | * #### Notes
|
127 | * The layout should ensure that its widgets are resized according
|
128 | * to the specified layout space, and that they are sent a `'resize'`
|
129 | * message if appropriate.
|
130 | *
|
131 | * The default implementation of this method sends an `UnknownSize`
|
132 | * resize message to all widgets.
|
133 | *
|
134 | * This may be reimplemented by subclasses as needed.
|
135 | */
|
136 | protected onResize(msg: Widget.ResizeMessage): void;
|
137 | /**
|
138 | * A message handler invoked on an `'update-request'` message.
|
139 | *
|
140 | * #### Notes
|
141 | * The layout should ensure that its widgets are resized according
|
142 | * to the available layout space, and that they are sent a `'resize'`
|
143 | * message if appropriate.
|
144 | *
|
145 | * The default implementation of this method sends an `UnknownSize`
|
146 | * resize message to all widgets.
|
147 | *
|
148 | * This may be reimplemented by subclasses as needed.
|
149 | */
|
150 | protected onUpdateRequest(msg: Message): void;
|
151 | /**
|
152 | * A message handler invoked on a `'before-attach'` message.
|
153 | *
|
154 | * #### Notes
|
155 | * The default implementation of this method forwards the message
|
156 | * to all widgets. It assumes all widget nodes are attached to the
|
157 | * parent widget node.
|
158 | *
|
159 | * This may be reimplemented by subclasses as needed.
|
160 | */
|
161 | protected onBeforeAttach(msg: Message): void;
|
162 | /**
|
163 | * A message handler invoked on an `'after-attach'` message.
|
164 | *
|
165 | * #### Notes
|
166 | * The default implementation of this method forwards the message
|
167 | * to all widgets. It assumes all widget nodes are attached to the
|
168 | * parent widget node.
|
169 | *
|
170 | * This may be reimplemented by subclasses as needed.
|
171 | */
|
172 | protected onAfterAttach(msg: Message): void;
|
173 | /**
|
174 | * A message handler invoked on a `'before-detach'` message.
|
175 | *
|
176 | * #### Notes
|
177 | * The default implementation of this method forwards the message
|
178 | * to all widgets. It assumes all widget nodes are attached to the
|
179 | * parent widget node.
|
180 | *
|
181 | * This may be reimplemented by subclasses as needed.
|
182 | */
|
183 | protected onBeforeDetach(msg: Message): void;
|
184 | /**
|
185 | * A message handler invoked on an `'after-detach'` message.
|
186 | *
|
187 | * #### Notes
|
188 | * The default implementation of this method forwards the message
|
189 | * to all widgets. It assumes all widget nodes are attached to the
|
190 | * parent widget node.
|
191 | *
|
192 | * This may be reimplemented by subclasses as needed.
|
193 | */
|
194 | protected onAfterDetach(msg: Message): void;
|
195 | /**
|
196 | * A message handler invoked on a `'before-show'` message.
|
197 | *
|
198 | * #### Notes
|
199 | * The default implementation of this method forwards the message to
|
200 | * all non-hidden widgets. It assumes all widget nodes are attached
|
201 | * to the parent widget node.
|
202 | *
|
203 | * This may be reimplemented by subclasses as needed.
|
204 | */
|
205 | protected onBeforeShow(msg: Message): void;
|
206 | /**
|
207 | * A message handler invoked on an `'after-show'` message.
|
208 | *
|
209 | * #### Notes
|
210 | * The default implementation of this method forwards the message to
|
211 | * all non-hidden widgets. It assumes all widget nodes are attached
|
212 | * to the parent widget node.
|
213 | *
|
214 | * This may be reimplemented by subclasses as needed.
|
215 | */
|
216 | protected onAfterShow(msg: Message): void;
|
217 | /**
|
218 | * A message handler invoked on a `'before-hide'` message.
|
219 | *
|
220 | * #### Notes
|
221 | * The default implementation of this method forwards the message to
|
222 | * all non-hidden widgets. It assumes all widget nodes are attached
|
223 | * to the parent widget node.
|
224 | *
|
225 | * This may be reimplemented by subclasses as needed.
|
226 | */
|
227 | protected onBeforeHide(msg: Message): void;
|
228 | /**
|
229 | * A message handler invoked on an `'after-hide'` message.
|
230 | *
|
231 | * #### Notes
|
232 | * The default implementation of this method forwards the message to
|
233 | * all non-hidden widgets. It assumes all widget nodes are attached
|
234 | * to the parent widget node.
|
235 | *
|
236 | * This may be reimplemented by subclasses as needed.
|
237 | */
|
238 | protected onAfterHide(msg: Message): void;
|
239 | /**
|
240 | * A message handler invoked on a `'child-removed'` message.
|
241 | *
|
242 | * #### Notes
|
243 | * This will remove the child widget from the layout.
|
244 | *
|
245 | * Subclasses should **not** typically reimplement this method.
|
246 | */
|
247 | protected onChildRemoved(msg: Widget.ChildMessage): void;
|
248 | /**
|
249 | * A message handler invoked on a `'fit-request'` message.
|
250 | *
|
251 | * #### Notes
|
252 | * The default implementation of this handler is a no-op.
|
253 | */
|
254 | protected onFitRequest(msg: Message): void;
|
255 | /**
|
256 | * A message handler invoked on a `'child-shown'` message.
|
257 | *
|
258 | * #### Notes
|
259 | * The default implementation of this handler is a no-op.
|
260 | */
|
261 | protected onChildShown(msg: Widget.ChildMessage): void;
|
262 | /**
|
263 | * A message handler invoked on a `'child-hidden'` message.
|
264 | *
|
265 | * #### Notes
|
266 | * The default implementation of this handler is a no-op.
|
267 | */
|
268 | protected onChildHidden(msg: Widget.ChildMessage): void;
|
269 | private _disposed;
|
270 | private _fitPolicy;
|
271 | private _parent;
|
272 | }
|
273 | /**
|
274 | * The namespace for the `Layout` class statics.
|
275 | */
|
276 | export declare namespace Layout {
|
277 | |
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 | type FitPolicy = |
287 |
|
288 | 'set-no-constraint'
|
289 | |
290 |
|
291 |
|
292 | | 'set-min-size';
|
293 | |
294 |
|
295 |
|
296 | interface IOptions {
|
297 | |
298 |
|
299 |
|
300 |
|
301 |
|
302 | fitPolicy?: FitPolicy;
|
303 | }
|
304 | |
305 |
|
306 |
|
307 | type HorizontalAlignment = 'left' | 'center' | 'right';
|
308 | |
309 |
|
310 |
|
311 | type VerticalAlignment = 'top' | 'center' | 'bottom';
|
312 | |
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 | function getHorizontalAlignment(widget: Widget): HorizontalAlignment;
|
330 | |
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 |
|
349 |
|
350 |
|
351 | function setHorizontalAlignment(widget: Widget, value: HorizontalAlignment): void;
|
352 | |
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 | function getVerticalAlignment(widget: Widget): VerticalAlignment;
|
370 | |
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 | function setVerticalAlignment(widget: Widget, value: VerticalAlignment): void;
|
392 | }
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 | export declare class LayoutItem implements IDisposable {
|
403 | |
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 | constructor(widget: Widget);
|
413 | /**
|
414 | * Dispose of the the layout item.
|
415 | *
|
416 | * #### Notes
|
417 | * This will reset the positioning of the widget.
|
418 | */
|
419 | dispose(): void;
|
420 | /**
|
421 | * The widget managed by the layout item.
|
422 | */
|
423 | readonly widget: Widget;
|
424 | /**
|
425 | * The computed minimum width of the widget.
|
426 | *
|
427 | * #### Notes
|
428 | * This value can be updated by calling the `fit` method.
|
429 | */
|
430 | get minWidth(): number;
|
431 | /**
|
432 | * The computed minimum height of the widget.
|
433 | *
|
434 | * #### Notes
|
435 | * This value can be updated by calling the `fit` method.
|
436 | */
|
437 | get minHeight(): number;
|
438 | /**
|
439 | * The computed maximum width of the widget.
|
440 | *
|
441 | * #### Notes
|
442 | * This value can be updated by calling the `fit` method.
|
443 | */
|
444 | get maxWidth(): number;
|
445 | /**
|
446 | * The computed maximum height of the widget.
|
447 | *
|
448 | * #### Notes
|
449 | * This value can be updated by calling the `fit` method.
|
450 | */
|
451 | get maxHeight(): number;
|
452 | /**
|
453 | * Whether the layout item is disposed.
|
454 | */
|
455 | get isDisposed(): boolean;
|
456 | /**
|
457 | * Whether the managed widget is hidden.
|
458 | */
|
459 | get isHidden(): boolean;
|
460 | /**
|
461 | * Whether the managed widget is visible.
|
462 | */
|
463 | get isVisible(): boolean;
|
464 | /**
|
465 | * Whether the managed widget is attached.
|
466 | */
|
467 | get isAttached(): boolean;
|
468 | /**
|
469 | * Update the computed size limits of the managed widget.
|
470 | */
|
471 | fit(): void;
|
472 | /**
|
473 | * Update the position and size of the managed widget.
|
474 | *
|
475 | * @param left - The left edge position of the layout box.
|
476 | *
|
477 | * @param top - The top edge position of the layout box.
|
478 | *
|
479 | * @param width - The width of the layout box.
|
480 | *
|
481 | * @param height - The height of the layout box.
|
482 | */
|
483 | update(left: number, top: number, width: number, height: number): void;
|
484 | private _top;
|
485 | private _left;
|
486 | private _width;
|
487 | private _height;
|
488 | private _minWidth;
|
489 | private _minHeight;
|
490 | private _maxWidth;
|
491 | private _maxHeight;
|
492 | private _disposed;
|
493 | }
|