177 } |
177 } |
178 |
178 |
179 void UiGridContainer::Add(FrameworkElement control, UiBool fill) { |
179 void UiGridContainer::Add(FrameworkElement control, UiBool fill) { |
180 GridLength gl; |
180 GridLength gl; |
181 |
181 |
182 int hexpand = FALSE; |
182 bool hexpand = false; |
183 int vexpand = FALSE; |
183 bool vexpand = false; |
|
184 bool hfill = false; |
|
185 bool vfill = false; |
|
186 if(layout.fill != UI_LAYOUT_UNDEFINED) { |
|
187 fill = ui_lb2bool(layout.fill); |
|
188 } |
184 if (layout.hexpand != UI_LAYOUT_UNDEFINED) { |
189 if (layout.hexpand != UI_LAYOUT_UNDEFINED) { |
185 hexpand = layout.hexpand; |
190 hexpand = layout.hexpand; |
|
191 hfill = true; |
186 } |
192 } |
187 if (layout.vexpand != UI_LAYOUT_UNDEFINED) { |
193 if (layout.vexpand != UI_LAYOUT_UNDEFINED) { |
188 vexpand = layout.vexpand; |
194 vexpand = layout.vexpand; |
|
195 vfill = true; |
|
196 } |
|
197 if (fill) { |
|
198 hfill = true; |
|
199 vfill = true; |
189 } |
200 } |
190 |
201 |
191 // create new RowDefinition for the new line |
202 // create new RowDefinition for the new line |
192 if (layout.newline || y == -1) { |
203 if (layout.newline || y == -1) { |
193 x = 0; |
204 x = 0; |
201 gl.GridUnitType = GridUnitType::Auto; |
212 gl.GridUnitType = GridUnitType::Auto; |
202 gl.Value = 0; |
213 gl.Value = 0; |
203 } |
214 } |
204 rowdef.Height(gl); |
215 rowdef.Height(gl); |
205 grid.RowDefinitions().Append(rowdef); |
216 grid.RowDefinitions().Append(rowdef); |
|
217 } else if (vexpand) { |
|
218 // adjust row |
|
219 gl.GridUnitType = GridUnitType::Star; |
|
220 gl.Value = 1; |
|
221 grid.RowDefinitions().GetAt(y).Height(gl); |
206 } |
222 } |
207 |
223 |
208 // create new columndefinition, if a new column is added |
224 // create new columndefinition, if a new column is added |
209 if (x == cols) { |
225 if (x == cols) { |
210 if (hexpand) { |
226 if (hexpand) { |
217 } |
233 } |
218 ColumnDefinition coldef = ColumnDefinition(); |
234 ColumnDefinition coldef = ColumnDefinition(); |
219 coldef.Width(gl); |
235 coldef.Width(gl); |
220 grid.ColumnDefinitions().Append(coldef); |
236 grid.ColumnDefinitions().Append(coldef); |
221 cols++; |
237 cols++; |
|
238 } else if(hexpand) { |
|
239 // adjust column |
|
240 gl.GridUnitType = GridUnitType::Star; |
|
241 gl.Value = 1; |
|
242 grid.ColumnDefinitions().GetAt(x).Width(gl); |
222 } |
243 } |
223 |
244 |
224 // add control |
245 // add control |
225 control.HorizontalAlignment(HorizontalAlignment::Stretch); |
246 if (hfill) { |
226 control.VerticalAlignment(VerticalAlignment::Stretch); |
247 control.HorizontalAlignment(HorizontalAlignment::Stretch); |
|
248 } |
|
249 if (vfill) { |
|
250 control.VerticalAlignment(VerticalAlignment::Stretch); |
|
251 } |
227 |
252 |
228 if (layout.colspan > 0) { |
253 if (layout.colspan > 0) { |
229 grid.SetColumnSpan(control, layout.colspan); |
254 grid.SetColumnSpan(control, layout.colspan); |
230 } |
255 } |
231 if (layout.rowspan > 0) { |
256 if (layout.rowspan > 0) { |