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