ui/gtk/container.c

changeset 99
ea1a2d5de765
parent 94
d51e334c1439
child 100
d276306d801f
equal deleted inserted replaced
98:efaae97bd95b 99:ea1a2d5de765
121 grid->x = 0; 121 grid->x = 0;
122 grid->y++; 122 grid->y++;
123 ct->layout.newline = FALSE; 123 ct->layout.newline = FALSE;
124 } 124 }
125 125
126 if(ct->layout.fill != UI_LAYOUT_UNDEFINED) { 126 int hexpand = FALSE;
127 fill = ui_lb2bool(ct->layout.fill); 127 int vexpand = FALSE;
128 } 128 if(ct->layout.hexpand != UI_LAYOUT_UNDEFINED) {
129 if(fill) { 129 hexpand = ct->layout.hexpand;
130 }
131 if(ct->layout.vexpand != UI_LAYOUT_UNDEFINED) {
132 vexpand = ct->layout.vexpand;
133 }
134
135 if(hexpand) {
130 gtk_widget_set_hexpand(widget, TRUE); 136 gtk_widget_set_hexpand(widget, TRUE);
137 }
138 if(vexpand) {
139 gtk_widget_set_vexpand(widget, TRUE);
131 } 140 }
132 141
133 gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, 1, 1); 142 gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, 1, 1);
134 grid->x++; 143 grid->x++;
135 144
207 216
208 return hbox; 217 return hbox;
209 } 218 }
210 219
211 UIWIDGET ui_grid(UiObject *obj) { 220 UIWIDGET ui_grid(UiObject *obj) {
212 return ui_grid_sp(obj, 0, 0); 221 return ui_grid_sp(obj, 0, 0, 0);
213 } 222 }
214 223
215 UIWIDGET ui_grid_sp(UiObject *obj, int columnspacing, int rowspacing) { 224 UIWIDGET ui_grid_sp(UiObject *obj, int margin, int columnspacing, int rowspacing) {
216 UiContainer *ct = uic_get_current_container(obj); 225 UiContainer *ct = uic_get_current_container(obj);
217 226
218 #ifdef UI_GTK3 227 #ifdef UI_GTK3
219 GtkWidget *grid = gtk_grid_new(); 228 GtkWidget *grid = gtk_grid_new();
220 gtk_grid_set_column_spacing(GTK_GRID(grid), columnspacing); 229 gtk_grid_set_column_spacing(GTK_GRID(grid), columnspacing);
221 gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing); 230 gtk_grid_set_row_spacing(GTK_GRID(grid), rowspacing);
231 #if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION >= 12
232 gtk_widget_set_margin_start(grid, margin);
233 gtk_widget_set_margin_end(grid, margin);
234 #else
235 gtk_widget_set_margin_left(grid, margin);
236 gtk_widget_set_margin_right(grid, margin);
237 #endif
238 gtk_widget_set_margin_top(grid, margin);
239 gtk_widget_set_margin_bottom(grid, margin);
222 240
223 #elif defined(UI_GTK2) 241 #elif defined(UI_GTK2)
224 GtkWidget *grid = gtk_table_new(1, 1, FALSE); 242 GtkWidget *grid = gtk_table_new(1, 1, FALSE);
225 #endif 243 #endif
226 ct->add(ct, grid, TRUE); 244 ct->add(ct, grid, TRUE);
313 UiObject *tab = g_object_get_qdata(G_OBJECT(page), q); 331 UiObject *tab = g_object_get_qdata(G_OBJECT(page), q);
314 if(!tab) { 332 if(!tab) {
315 return; 333 return;
316 } 334 }
317 335
318 printf("page_change: %d\n", page_num); 336 //printf("page_change: %d\n", page_num);
319 UiContext *ctx = tab->ctx; 337 UiContext *ctx = tab->ctx;
320 ctx->parent->set_document(ctx->parent, ctx->document); 338 ctx->parent->set_document(ctx->parent, ctx->document);
321 } 339 }
322 340
323 UiTabbedPane* ui_tabbed_document_view(UiObject *obj) { 341 UiTabbedPane* ui_tabbed_document_view(UiObject *obj) {
387 void ui_layout_fill(UiObject *obj, UiBool fill) { 405 void ui_layout_fill(UiObject *obj, UiBool fill) {
388 UiContainer *ct = uic_get_current_container(obj); 406 UiContainer *ct = uic_get_current_container(obj);
389 ct->layout.fill = ui_bool2lb(fill); 407 ct->layout.fill = ui_bool2lb(fill);
390 } 408 }
391 409
410 void ui_layout_hexpand(UiObject *obj, UiBool expand) {
411 UiContainer *ct = uic_get_current_container(obj);
412 ct->layout.hexpand = ui_bool2lb(expand);
413 }
414
415 void ui_layout_vexpand(UiObject *obj, UiBool expand) {
416 UiContainer *ct = uic_get_current_container(obj);
417 ct->layout.vexpand = ui_bool2lb(expand);
418 }
419
392 void ui_newline(UiObject *obj) { 420 void ui_newline(UiObject *obj) {
393 UiContainer *ct = uic_get_current_container(obj); 421 UiContainer *ct = uic_get_current_container(obj);
394 ct->layout.newline = TRUE; 422 ct->layout.newline = TRUE;
395 } 423 }
424

mercurial