UNPKG

6.16 kBTypeScriptView Raw
1import { Message } from '@lumino/messaging';
2import { PanelLayout } from './panellayout';
3import { Widget } from './widget';
4/**
5 * A layout which arranges its widgets in a single row or column.
6 */
7export declare class BoxLayout extends PanelLayout {
8 /**
9 * Construct a new box layout.
10 *
11 * @param options - The options for initializing the layout.
12 */
13 constructor(options?: BoxLayout.IOptions);
14 /**
15 * Dispose of the resources held by the layout.
16 */
17 dispose(): void;
18 /**
19 * Get the layout direction for the box layout.
20 */
21 get direction(): BoxLayout.Direction;
22 /**
23 * Set the layout direction for the box layout.
24 */
25 set direction(value: BoxLayout.Direction);
26 /**
27 * Get the content alignment for the box layout.
28 *
29 * #### Notes
30 * This is the alignment of the widgets in the layout direction.
31 *
32 * The alignment has no effect if the widgets can expand to fill the
33 * entire box layout.
34 */
35 get alignment(): BoxLayout.Alignment;
36 /**
37 * Set the content alignment for the box layout.
38 *
39 * #### Notes
40 * This is the alignment of the widgets in the layout direction.
41 *
42 * The alignment has no effect if the widgets can expand to fill the
43 * entire box layout.
44 */
45 set alignment(value: BoxLayout.Alignment);
46 /**
47 * Get the inter-element spacing for the box layout.
48 */
49 get spacing(): number;
50 /**
51 * Set the inter-element spacing for the box layout.
52 */
53 set spacing(value: number);
54 /**
55 * Perform layout initialization which requires the parent widget.
56 */
57 protected init(): void;
58 /**
59 * Attach a widget to the parent's DOM node.
60 *
61 * @param index - The current index of the widget in the layout.
62 *
63 * @param widget - The widget to attach to the parent.
64 *
65 * #### Notes
66 * This is a reimplementation of the superclass method.
67 */
68 protected attachWidget(index: number, widget: Widget): void;
69 /**
70 * Move a widget in the parent's DOM node.
71 *
72 * @param fromIndex - The previous index of the widget in the layout.
73 *
74 * @param toIndex - The current index of the widget in the layout.
75 *
76 * @param widget - The widget to move in the parent.
77 *
78 * #### Notes
79 * This is a reimplementation of the superclass method.
80 */
81 protected moveWidget(fromIndex: number, toIndex: number, widget: Widget): void;
82 /**
83 * Detach a widget from the parent's DOM node.
84 *
85 * @param index - The previous index of the widget in the layout.
86 *
87 * @param widget - The widget to detach from the parent.
88 *
89 * #### Notes
90 * This is a reimplementation of the superclass method.
91 */
92 protected detachWidget(index: number, widget: Widget): void;
93 /**
94 * A message handler invoked on a `'before-show'` message.
95 */
96 protected onBeforeShow(msg: Message): void;
97 /**
98 * A message handler invoked on a `'before-attach'` message.
99 */
100 protected onBeforeAttach(msg: Message): void;
101 /**
102 * A message handler invoked on a `'child-shown'` message.
103 */
104 protected onChildShown(msg: Widget.ChildMessage): void;
105 /**
106 * A message handler invoked on a `'child-hidden'` message.
107 */
108 protected onChildHidden(msg: Widget.ChildMessage): void;
109 /**
110 * A message handler invoked on a `'resize'` message.
111 */
112 protected onResize(msg: Widget.ResizeMessage): void;
113 /**
114 * A message handler invoked on an `'update-request'` message.
115 */
116 protected onUpdateRequest(msg: Message): void;
117 /**
118 * A message handler invoked on a `'fit-request'` message.
119 */
120 protected onFitRequest(msg: Message): void;
121 /**
122 * Fit the layout to the total size required by the widgets.
123 */
124 private _fit;
125 /**
126 * Update the layout position and size of the widgets.
127 *
128 * The parent offset dimensions should be `-1` if unknown.
129 */
130 private _update;
131 private _fixed;
132 private _spacing;
133 private _dirty;
134 private _sizers;
135 private _items;
136 private _box;
137 private _alignment;
138 private _direction;
139}
140/**
141 * The namespace for the `BoxLayout` class statics.
142 */
143export declare namespace BoxLayout {
144 /**
145 * A type alias for a box layout direction.
146 */
147 type Direction = 'left-to-right' | 'right-to-left' | 'top-to-bottom' | 'bottom-to-top';
148 /**
149 * A type alias for a box layout alignment.
150 */
151 type Alignment = 'start' | 'center' | 'end' | 'justify';
152 /**
153 * An options object for initializing a box layout.
154 */
155 interface IOptions {
156 /**
157 * The direction of the layout.
158 *
159 * The default is `'top-to-bottom'`.
160 */
161 direction?: Direction;
162 /**
163 * The content alignment of the layout.
164 *
165 * The default is `'start'`.
166 */
167 alignment?: Alignment;
168 /**
169 * The spacing between items in the layout.
170 *
171 * The default is `4`.
172 */
173 spacing?: number;
174 }
175 /**
176 * Get the box layout stretch factor for the given widget.
177 *
178 * @param widget - The widget of interest.
179 *
180 * @returns The box layout stretch factor for the widget.
181 */
182 function getStretch(widget: Widget): number;
183 /**
184 * Set the box layout stretch factor for the given widget.
185 *
186 * @param widget - The widget of interest.
187 *
188 * @param value - The value for the stretch factor.
189 */
190 function setStretch(widget: Widget, value: number): void;
191 /**
192 * Get the box layout size basis for the given widget.
193 *
194 * @param widget - The widget of interest.
195 *
196 * @returns The box layout size basis for the widget.
197 */
198 function getSizeBasis(widget: Widget): number;
199 /**
200 * Set the box layout size basis for the given widget.
201 *
202 * @param widget - The widget of interest.
203 *
204 * @param value - The value for the size basis.
205 */
206 function setSizeBasis(widget: Widget, value: number): void;
207}