251 |
251 |
252 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
252 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
253 FRAME_SET_CHILD(ct->widget, widget); |
253 FRAME_SET_CHILD(ct->widget, widget); |
254 } |
254 } |
255 |
255 |
|
256 UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander) { |
|
257 UiContainer *ct = cxCalloc( |
|
258 obj->ctx->allocator, |
|
259 1, |
|
260 sizeof(UiContainer)); |
|
261 ct->widget = expander; |
|
262 ct->add = ui_expander_container_add; |
|
263 return ct; |
|
264 } |
|
265 |
|
266 void ui_expander_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
|
267 EXPANDER_SET_CHILD(ct->widget, widget); |
|
268 } |
|
269 |
|
270 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
|
271 // TODO: check if the widget implements GtkScrollable |
|
272 SCROLLEDWINDOW_SET_CHILD(ct->widget, widget); |
|
273 ui_reset_layout(ct->layout); |
|
274 ct->current = widget; |
|
275 } |
|
276 |
256 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow) { |
277 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow) { |
257 UiContainer *ct = cxCalloc( |
278 UiContainer *ct = cxCalloc( |
258 obj->ctx->allocator, |
279 obj->ctx->allocator, |
259 1, |
280 1, |
260 sizeof(UiContainer)); |
281 sizeof(UiContainer)); |
261 ct->widget = scrolledwindow; |
282 ct->widget = scrolledwindow; |
262 ct->add = ui_scrolledwindow_container_add; |
283 ct->add = ui_scrolledwindow_container_add; |
263 return ct; |
284 return ct; |
264 } |
|
265 |
|
266 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
|
267 // TODO: check if the widget implements GtkScrollable |
|
268 SCROLLEDWINDOW_SET_CHILD(ct->widget, widget); |
|
269 ui_reset_layout(ct->layout); |
|
270 ct->current = widget; |
|
271 } |
285 } |
272 |
286 |
273 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) { |
287 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview) { |
274 UiTabViewContainer *ct = cxCalloc( |
288 UiTabViewContainer *ct = cxCalloc( |
275 obj->ctx->allocator, |
289 obj->ctx->allocator, |
381 FRAME_SET_CHILD(frame, sub); |
395 FRAME_SET_CHILD(frame, sub); |
382 } else { |
396 } else { |
383 newobj->widget = frame; |
397 newobj->widget = frame; |
384 newobj->container = ui_frame_container(obj, frame); |
398 newobj->container = ui_frame_container(obj, frame); |
385 } |
399 } |
|
400 current->container->add(current->container, frame, FALSE); |
|
401 uic_obj_add(obj, newobj); |
386 |
402 |
387 return frame; |
403 return frame; |
|
404 } |
|
405 |
|
406 UIEXPORT UIWIDGET ui_expander_create(UiObject *obj, UiFrameArgs args) { |
|
407 UiObject* current = uic_current_obj(obj); |
|
408 UI_APPLY_LAYOUT1(current, args); |
|
409 |
|
410 GtkWidget *expander = gtk_expander_new(args.label); |
|
411 gtk_expander_set_expanded(GTK_EXPANDER(expander), args.isexpanded); |
|
412 UiObject *newobj = uic_object_new(obj, expander); |
|
413 GtkWidget *sub = ui_subcontainer_create(args.subcontainer, newobj, args.spacing, args.columnspacing, args.rowspacing, args.margin); |
|
414 if(sub) { |
|
415 EXPANDER_SET_CHILD(expander, sub); |
|
416 } else { |
|
417 newobj->widget = expander; |
|
418 newobj->container = ui_expander_container(obj, expander); |
|
419 } |
|
420 current->container->add(current->container, expander, FALSE); |
|
421 uic_obj_add(obj, newobj); |
|
422 |
|
423 return expander; |
388 } |
424 } |
389 |
425 |
390 |
426 |
391 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) { |
427 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) { |
392 UiObject* current = uic_current_obj(obj); |
428 UiObject* current = uic_current_obj(obj); |