UNPKG

7.16 kBTypeScriptView Raw
1import { IIterator } from '@lumino/algorithm';
2import { Message } from '@lumino/messaging';
3import { Layout } from './layout';
4import { Widget } from './widget';
5/**
6 * A layout which arranges its widgets in a grid.
7 */
8export declare class GridLayout extends Layout {
9 /**
10 * Construct a new grid layout.
11 *
12 * @param options - The options for initializing the layout.
13 */
14 constructor(options?: GridLayout.IOptions);
15 /**
16 * Dispose of the resources held by the layout.
17 */
18 dispose(): void;
19 /**
20 * Get the number of rows in the layout.
21 */
22 /**
23 * Set the number of rows in the layout.
24 *
25 * #### Notes
26 * The minimum row count is `1`.
27 */
28 rowCount: number;
29 /**
30 * Get the number of columns in the layout.
31 */
32 /**
33 * Set the number of columns in the layout.
34 *
35 * #### Notes
36 * The minimum column count is `1`.
37 */
38 columnCount: number;
39 /**
40 * Get the row spacing for the layout.
41 */
42 /**
43 * Set the row spacing for the layout.
44 */
45 rowSpacing: number;
46 /**
47 * Get the column spacing for the layout.
48 */
49 /**
50 * Set the col spacing for the layout.
51 */
52 columnSpacing: number;
53 /**
54 * Get the stretch factor for a specific row.
55 *
56 * @param index - The row index of interest.
57 *
58 * @returns The stretch factor for the row.
59 *
60 * #### Notes
61 * This returns `-1` if the index is out of range.
62 */
63 rowStretch(index: number): number;
64 /**
65 * Set the stretch factor for a specific row.
66 *
67 * @param index - The row index of interest.
68 *
69 * @param value - The stretch factor for the row.
70 *
71 * #### Notes
72 * This is a no-op if the index is out of range.
73 */
74 setRowStretch(index: number, value: number): void;
75 /**
76 * Get the stretch factor for a specific column.
77 *
78 * @param index - The column index of interest.
79 *
80 * @returns The stretch factor for the column.
81 *
82 * #### Notes
83 * This returns `-1` if the index is out of range.
84 */
85 columnStretch(index: number): number;
86 /**
87 * Set the stretch factor for a specific column.
88 *
89 * @param index - The column index of interest.
90 *
91 * @param value - The stretch factor for the column.
92 *
93 * #### Notes
94 * This is a no-op if the index is out of range.
95 */
96 setColumnStretch(index: number, value: number): void;
97 /**
98 * Create an iterator over the widgets in the layout.
99 *
100 * @returns A new iterator over the widgets in the layout.
101 */
102 iter(): IIterator<Widget>;
103 /**
104 * Add a widget to the grid layout.
105 *
106 * @param widget - The widget to add to the layout.
107 *
108 * #### Notes
109 * If the widget is already contained in the layout, this is no-op.
110 */
111 addWidget(widget: Widget): void;
112 /**
113 * Remove a widget from the grid layout.
114 *
115 * @param widget - The widget to remove from the layout.
116 *
117 * #### Notes
118 * A widget is automatically removed from the layout when its `parent`
119 * is set to `null`. This method should only be invoked directly when
120 * removing a widget from a layout which has yet to be installed on a
121 * parent widget.
122 *
123 * This method does *not* modify the widget's `parent`.
124 */
125 removeWidget(widget: Widget): void;
126 /**
127 * Perform layout initialization which requires the parent widget.
128 */
129 protected init(): void;
130 /**
131 * Attach a widget to the parent's DOM node.
132 *
133 * @param widget - The widget to attach to the parent.
134 */
135 protected attachWidget(widget: Widget): void;
136 /**
137 * Detach a widget from the parent's DOM node.
138 *
139 * @param widget - The widget to detach from the parent.
140 */
141 protected detachWidget(widget: Widget): void;
142 /**
143 * A message handler invoked on a `'before-show'` message.
144 */
145 protected onBeforeShow(msg: Message): void;
146 /**
147 * A message handler invoked on a `'before-attach'` message.
148 */
149 protected onBeforeAttach(msg: Message): void;
150 /**
151 * A message handler invoked on a `'child-shown'` message.
152 */
153 protected onChildShown(msg: Widget.ChildMessage): void;
154 /**
155 * A message handler invoked on a `'child-hidden'` message.
156 */
157 protected onChildHidden(msg: Widget.ChildMessage): void;
158 /**
159 * A message handler invoked on a `'resize'` message.
160 */
161 protected onResize(msg: Widget.ResizeMessage): void;
162 /**
163 * A message handler invoked on an `'update-request'` message.
164 */
165 protected onUpdateRequest(msg: Message): void;
166 /**
167 * A message handler invoked on a `'fit-request'` message.
168 */
169 protected onFitRequest(msg: Message): void;
170 /**
171 * Fit the layout to the total size required by the widgets.
172 */
173 private _fit;
174 /**
175 * Update the layout position and size of the widgets.
176 *
177 * The parent offset dimensions should be `-1` if unknown.
178 */
179 private _update;
180 private _dirty;
181 private _rowSpacing;
182 private _columnSpacing;
183 private _items;
184 private _rowStarts;
185 private _columnStarts;
186 private _rowSizers;
187 private _columnSizers;
188 private _box;
189}
190/**
191 * The namespace for the `GridLayout` class statics.
192 */
193export declare namespace GridLayout {
194 /**
195 * An options object for initializing a grid layout.
196 */
197 interface IOptions extends Layout.IOptions {
198 /**
199 * The initial row count for the layout.
200 *
201 * The default is `1`.
202 */
203 rowCount?: number;
204 /**
205 * The initial column count for the layout.
206 *
207 * The default is `1`.
208 */
209 columnCount?: number;
210 /**
211 * The spacing between rows in the layout.
212 *
213 * The default is `4`.
214 */
215 rowSpacing?: number;
216 /**
217 * The spacing between columns in the layout.
218 *
219 * The default is `4`.
220 */
221 columnSpacing?: number;
222 }
223 /**
224 * An object which holds the cell configuration for a widget.
225 */
226 interface ICellConfig {
227 /**
228 * The row index for the widget.
229 */
230 readonly row: number;
231 /**
232 * The column index for the widget.
233 */
234 readonly column: number;
235 /**
236 * The row span for the widget.
237 */
238 readonly rowSpan: number;
239 /**
240 * The column span for the widget.
241 */
242 readonly columnSpan: number;
243 }
244 /**
245 * Get the cell config for the given widget.
246 *
247 * @param widget - The widget of interest.
248 *
249 * @returns The cell config for the widget.
250 */
251 function getCellConfig(widget: Widget): ICellConfig;
252 /**
253 * Set the cell config for the given widget.
254 *
255 * @param widget - The widget of interest.
256 *
257 * @param value - The value for the cell config.
258 */
259 function setCellConfig(widget: Widget, value: Partial<ICellConfig>): void;
260}
261//# sourceMappingURL=gridlayout.d.ts.map
\No newline at end of file