UNPKG

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