4.27 kBTypeScriptView Raw
1import { LayoutBase } from '../layout-base';
2import { View } from '../../core/view';
3import { Property } from '../../core/properties';
4
5/**
6 * Defines row/column specific properties that apply to GridLayout elements.
7 */
8export class ItemSpec {
9 constructor();
10 constructor(value: number, type: GridUnitType);
11
12 /**
13 * Gets the actual length of an ItemSpec.
14 */
15 actualLength: number;
16
17 /**
18 * Returns unit type of this ItemSpec instance.
19 */
20 gridUnitType: GridUnitType;
21
22 /**
23 * Returns true if this ItemSpec instance holds
24 * an absolute (pixel) value.
25 */
26 isAbsolute: boolean;
27
28 /**
29 * Returns true if this GridLength instance is
30 * automatic (not specified).
31 */
32 isAuto: boolean;
33
34 /**
35 * Returns true if this ItemSpec instance holds weighted proportion
36 * of available space.
37 */
38 isStar: boolean;
39
40 /**
41 * Returns value part of this ItemSpec instance.
42 */
43 value: number;
44}
45
46/**
47 * Defines a rectangular layout area that consists of columns and rows.
48 */
49export class GridLayout extends LayoutBase {
50 /**
51 * Gets the value of the Column attached property from a given View.
52 */
53 static getColumn(view: View): number;
54
55 /**
56 * Sets the value of the Column attached property to a given View.
57 */
58 static setColumn(view: View, value: number): void;
59
60 /**
61 * Gets the value of the ColumnSpan attached property from a given View.
62 */
63 static getColumnSpan(view: View): number;
64
65 /**
66 * Sets the value of the ColumnSpan attached property to a given View.
67 */
68 static setColumnSpan(view: View, value: number): void;
69
70 /**
71 * Gets the value of the Row attached property from a given View.
72 */
73 static getRow(view: View): number;
74
75 /**
76 * Sets the value of the Row attached property to a given View.
77 */
78 static setRow(view: View, value: number): void;
79
80 /**
81 * Gets the value of the RowSpan attached property from a given View.
82 */
83 static getRowSpan(view: View): number;
84
85 /**
86 * Sets the value of the RowSpan attached property to a given View.
87 */
88 static setRowSpan(view: View, value: number): void;
89
90 /**
91 * Adds a column specification to a GridLayout.
92 */
93 public addColumn(itemSpec: ItemSpec): void;
94
95 /**
96 * Adds a row specification to a GridLayout.
97 */
98 public addRow(itemSpec: ItemSpec): void;
99
100 /**
101 * Adds a child at specific cell in GridLayout. Optional rowSpan and columnSpan attributes
102 */
103 public addChildAtCell(view: View, row: number, column: number, rowSpan?: number, columnSpan?: number): void;
104
105 /**
106 * Removes a column specification from a GridLayout.
107 */
108 public removeColumn(itemSpec: ItemSpec): void;
109
110 /**
111 * Removes all column specifications from a GridLayout.
112 */
113 public removeColumns(): void;
114
115 /**
116 * Removes a row specification from a GridLayout.
117 */
118 public removeRow(itemSpec: ItemSpec): void;
119
120 /**
121 * Removes all row specifications from a GridLayout.
122 */
123 public removeRows(): void;
124
125 /**
126 * Gets array of column specifications defined on this instance of GridLayout.
127 */
128 public getColumns(): Array<ItemSpec>;
129
130 /**
131 * Gets array of row specifications defined on this instance of GridLayout.
132 */
133 public getRows(): Array<ItemSpec>;
134
135 //@private
136 /**
137 * @private
138 */
139 public _onRowAdded(itemSpec: ItemSpec): void;
140 /**
141 * @private
142 */
143 public _onColumnAdded(itemSpec: ItemSpec): void;
144 /**
145 * @private
146 */
147 public _onRowRemoved(itemSpec: ItemSpec, index: number): void;
148 /**
149 * @private
150 */
151 public _onColumnRemoved(itemSpec: ItemSpec, index: number): void;
152 //@endprivate
153}
154
155/**
156 * Represents the observable property backing the column property.
157 */
158export const columnProperty: Property<View, number>;
159
160/**
161 * Represents the observable property backing the columnSpan property.
162 */
163export const columnSpanProperty: Property<View, number>;
164
165/**
166 * Represents the observable property backing the row property.
167 */
168export const rowProperty: Property<View, number>;
169
170/**
171 * Represents the observable property backing the rowSpan property.
172 */
173export const rowSpanProperty: Property<View, number>;
174
175export type GridUnitType = 'pixel' | 'star' | 'auto';
176export namespace GridUnitType {
177 export const PIXEL: 'pixel';
178 export const STAR: 'star';
179 export const AUTO: 'auto';
180 export function isValid(value: any): boolean;
181 export function parse(value: string): GridUnitType;
182}