102 obj->ctx->mempool, |
102 obj->ctx->mempool, |
103 1, |
103 1, |
104 sizeof(UiGridContainer)); |
104 sizeof(UiGridContainer)); |
105 ct->container.widget = grid; |
105 ct->container.widget = grid; |
106 ct->container.add = ui_grid_container_add; |
106 ct->container.add = ui_grid_container_add; |
|
107 #ifdef UI_GTK2 |
|
108 ct->width = 0; |
|
109 ct->height = 1; |
|
110 #endif |
107 return (UiContainer*)ct; |
111 return (UiContainer*)ct; |
108 } |
112 } |
109 |
113 |
|
114 #ifdef UI_GTK3 |
110 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
115 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
111 UiGridContainer *grid = (UiGridContainer*)ct; |
116 UiGridContainer *grid = (UiGridContainer*)ct; |
112 |
117 |
113 if(ct->layout.newline) { |
118 if(ct->layout.newline) { |
114 grid->x = 0; |
119 grid->x = 0; |
119 gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, 1, 1); |
124 gtk_grid_attach(GTK_GRID(ct->widget), widget, grid->x, grid->y, 1, 1); |
120 grid->x++; |
125 grid->x++; |
121 |
126 |
122 ui_reset_layout(ct->layout); |
127 ui_reset_layout(ct->layout); |
123 } |
128 } |
|
129 #endif |
|
130 #ifdef UI_GTK2 |
|
131 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
|
132 UiGridContainer *grid = (UiGridContainer*)ct; |
|
133 |
|
134 if(ct->layout.newline) { |
|
135 grid->x = 0; |
|
136 grid->y++; |
|
137 ct->layout.newline = FALSE; |
|
138 } |
|
139 |
|
140 gtk_table_attach(GTK_TABLE(ct->widget), widget, grid->x, grid->x+1, grid->y, grid->y+1, GTK_FILL, GTK_FILL, 0, 0); |
|
141 grid->x++; |
|
142 int nw = grid->x > grid->width ? grid->x : grid->width; |
|
143 if(grid->x > grid->width || grid->y > grid->height) { |
|
144 grid->width = nw; |
|
145 grid->height = grid->y + 1; |
|
146 gtk_table_resize(GTK_TABLE(ct->widget), grid->width, grid->height); |
|
147 } |
|
148 } |
|
149 #endif |
124 |
150 |
125 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) { |
151 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) { |
126 UiTabViewContainer *ct = ucx_mempool_calloc( |
152 UiTabViewContainer *ct = ucx_mempool_calloc( |
127 obj->ctx->mempool, |
153 obj->ctx->mempool, |
128 1, |
154 1, |
167 } |
193 } |
168 |
194 |
169 UIWIDGET ui_grid(UiObject *obj) { |
195 UIWIDGET ui_grid(UiObject *obj) { |
170 UiContainer *ct = uic_get_current_container(obj); |
196 UiContainer *ct = uic_get_current_container(obj); |
171 |
197 |
|
198 #ifdef UI_GTK3 |
172 GtkWidget *grid = gtk_grid_new(); |
199 GtkWidget *grid = gtk_grid_new(); |
|
200 #elif defined(UI_GTK2) |
|
201 GtkWidget *grid = gtk_table_new(1, 1, FALSE); |
|
202 #endif |
173 ct->add(ct, grid, TRUE); |
203 ct->add(ct, grid, TRUE); |
174 |
204 |
175 UiObject *newobj = uic_object_new(obj, grid); |
205 UiObject *newobj = uic_object_new(obj, grid); |
176 newobj->container = ui_grid_container(obj, grid); |
206 newobj->container = ui_grid_container(obj, grid); |
177 uic_obj_add(obj, newobj); |
207 uic_obj_add(obj, newobj); |