154 grid->x = 0; |
154 grid->x = 0; |
155 grid->y++; |
155 grid->y++; |
156 ct->layout.newline = FALSE; |
156 ct->layout.newline = FALSE; |
157 } |
157 } |
158 |
158 |
159 gtk_table_attach(GTK_TABLE(ct->widget), widget, grid->x, grid->x+1, grid->y, grid->y+1, GTK_FILL, GTK_FILL, 0, 0); |
159 int hexpand = FALSE; |
|
160 int vexpand = FALSE; |
|
161 if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) { |
|
162 hexpand = ct->layout.hexpand; |
|
163 } |
|
164 if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) { |
|
165 vexpand = ct->layout.vexpand; |
|
166 } |
|
167 GtkAttachOptions xoptions = hexpand ? GTK_FILL | GTK_EXPAND : GTK_FILL; |
|
168 GtkAttachOptions yoptions = vexpand ? GTK_FILL | GTK_EXPAND : GTK_FILL; |
|
169 |
|
170 gtk_table_attach(GTK_TABLE(ct->widget), widget, grid->x, grid->x+1, grid->y, grid->y+1, xoptions, yoptions, 0, 0); |
160 grid->x++; |
171 grid->x++; |
161 int nw = grid->x > grid->width ? grid->x : grid->width; |
172 int nw = grid->x > grid->width ? grid->x : grid->width; |
162 if(grid->x > grid->width || grid->y > grid->height) { |
173 if(grid->x > grid->width || grid->y > grid->height) { |
163 grid->width = nw; |
174 grid->width = nw; |
164 grid->height = grid->y + 1; |
175 grid->height = grid->y + 1; |
221 return ui_grid_sp(obj, 0, 0, 0); |
232 return ui_grid_sp(obj, 0, 0, 0); |
222 } |
233 } |
223 |
234 |
224 UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) { |
235 UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) { |
225 UiContainer *ct = uic_get_current_container(obj); |
236 UiContainer *ct = uic_get_current_container(obj); |
|
237 GtkWidget *widget; |
226 |
238 |
227 #ifdef UI_GTK3 |
239 #ifdef UI_GTK3 |
228 GtkWidget *grid = gtk_grid_new(); |
240 GtkWidget *grid = gtk_grid_new(); |
229 gtk_grid_set_column_spacing(GTK_GRID(grid), columnspacing); |
241 gtk_grid_set_column_spacing(GTK_GRID(grid), columnspacing); |
230 gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing); |
242 gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing); |
236 gtk_widget_set_margin_right(grid, margin); |
248 gtk_widget_set_margin_right(grid, margin); |
237 #endif |
249 #endif |
238 gtk_widget_set_margin_top(grid, margin); |
250 gtk_widget_set_margin_top(grid, margin); |
239 gtk_widget_set_margin_bottom(grid, margin); |
251 gtk_widget_set_margin_bottom(grid, margin); |
240 |
252 |
|
253 widget = grid; |
241 #elif defined(UI_GTK2) |
254 #elif defined(UI_GTK2) |
242 GtkWidget *grid = gtk_table_new(1, 1, FALSE); |
255 GtkWidget *grid = gtk_table_new(1, 1, FALSE); |
243 #endif |
256 |
244 ct->add(ct, grid, TRUE); |
257 gtk_table_set_col_spacings(GTK_TABLE(grid), columnspacing); |
|
258 gtk_table_set_row_spacings(GTK_TABLE(grid), rowspacing); |
|
259 |
|
260 if(margin > 0) { |
|
261 GtkWidget *a = gtk_alignment_new(0.5, 0.5, 1, 1); |
|
262 gtk_alignment_set_padding(GTK_ALIGNMENT(a), margin, margin, margin, margin); |
|
263 gtk_container_add(GTK_CONTAINER(a), grid); |
|
264 widget = a; |
|
265 } else { |
|
266 widget = grid; |
|
267 } |
|
268 #endif |
|
269 ct->add(ct, widget, TRUE); |
245 |
270 |
246 UiObject *newobj = uic_object_new(obj, grid); |
271 UiObject *newobj = uic_object_new(obj, grid); |
247 newobj->container = ui_grid_container(obj, grid); |
272 newobj->container = ui_grid_container(obj, grid); |
248 uic_obj_add(obj, newobj); |
273 uic_obj_add(obj, newobj); |
249 |
274 |
250 return grid; |
275 return widget; |
251 } |
276 } |
252 |
277 |
253 UIWIDGET ui_tabview(UiObject *obj) { |
278 UIWIDGET ui_tabview(UiObject *obj) { |
254 GtkWidget *tabview = gtk_notebook_new(); |
279 GtkWidget *tabview = gtk_notebook_new(); |
255 gtk_notebook_set_show_border(GTK_NOTEBOOK(tabview), FALSE); |
280 gtk_notebook_set_show_border(GTK_NOTEBOOK(tabview), FALSE); |