66 #else |
66 #else |
67 return gtk_hbox_new(FALSE, spacing); |
67 return gtk_hbox_new(FALSE, spacing); |
68 #endif |
68 #endif |
69 } |
69 } |
70 |
70 |
|
71 GtkWidget* ui_subcontainer_create( |
|
72 UiSubContainerType type, |
|
73 UiObject *newobj, |
|
74 int spacing, |
|
75 int columnspacing, |
|
76 int rowspacing, |
|
77 int margin) |
|
78 { |
|
79 GtkWidget *sub = NULL; |
|
80 GtkWidget *add = NULL; |
|
81 switch(type) { |
|
82 default: { |
|
83 sub = ui_gtk_vbox_new(spacing); |
|
84 add = ui_box_set_margin(sub, margin); |
|
85 newobj->container = ui_box_container(newobj, sub, type); |
|
86 newobj->widget = sub; |
|
87 break; |
|
88 } |
|
89 case UI_CONTAINER_HBOX: { |
|
90 sub = ui_gtk_hbox_new(spacing); |
|
91 add = ui_box_set_margin(sub, margin); |
|
92 newobj->container = ui_box_container(newobj, sub, type); |
|
93 newobj->widget = sub; |
|
94 break; |
|
95 } |
|
96 case UI_CONTAINER_GRID: { |
|
97 sub = ui_create_grid_widget(columnspacing, rowspacing); |
|
98 add = ui_box_set_margin(sub, margin); |
|
99 newobj->container = ui_grid_container(newobj, sub); |
|
100 newobj->widget = sub; |
|
101 break; |
|
102 } |
|
103 case UI_CONTAINER_NO_SUB: { |
|
104 break; |
|
105 } |
|
106 } |
|
107 return add; |
|
108 } |
71 |
109 |
72 |
110 |
73 /* -------------------- Box Container -------------------- */ |
111 /* -------------------- Box Container -------------------- */ |
74 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type) { |
112 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type) { |
75 UiBoxContainer *ct = cxCalloc( |
113 UiBoxContainer *ct = cxCalloc( |
199 ui_reset_layout(ct->layout); |
237 ui_reset_layout(ct->layout); |
200 ct->current = widget; |
238 ct->current = widget; |
201 } |
239 } |
202 #endif |
240 #endif |
203 |
241 |
|
242 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) { |
|
243 UiContainer *ct = cxCalloc( |
|
244 obj->ctx->allocator, |
|
245 1, |
|
246 sizeof(UiContainer)); |
|
247 ct->widget = frame; |
|
248 ct->add = ui_frame_container_add; |
|
249 return ct; |
|
250 } |
|
251 |
|
252 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill) { |
|
253 FRAME_SET_CHILD(ct->widget, widget); |
|
254 } |
|
255 |
204 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow) { |
256 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow) { |
205 UiContainer *ct = cxCalloc( |
257 UiContainer *ct = cxCalloc( |
206 obj->ctx->allocator, |
258 obj->ctx->allocator, |
207 1, |
259 1, |
208 sizeof(UiContainer)); |
260 sizeof(UiContainer)); |
316 uic_obj_add(obj, newobj); |
368 uic_obj_add(obj, newobj); |
317 |
369 |
318 return widget; |
370 return widget; |
319 } |
371 } |
320 |
372 |
|
373 UIWIDGET ui_frame_create(UiObject *obj, UiFrameArgs args) { |
|
374 UiObject* current = uic_current_obj(obj); |
|
375 UI_APPLY_LAYOUT1(current, args); |
|
376 |
|
377 GtkWidget *frame = gtk_frame_new(args.label); |
|
378 UiObject *newobj = uic_object_new(obj, frame); |
|
379 GtkWidget *sub = ui_subcontainer_create(args.subcontainer, newobj, args.spacing, args.columnspacing, args.rowspacing, args.margin); |
|
380 if(sub) { |
|
381 FRAME_SET_CHILD(frame, sub); |
|
382 } else { |
|
383 newobj->widget = frame; |
|
384 newobj->container = ui_frame_container(obj, frame); |
|
385 } |
|
386 |
|
387 return frame; |
|
388 } |
|
389 |
321 |
390 |
322 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) { |
391 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) { |
323 UiObject* current = uic_current_obj(obj); |
392 UiObject* current = uic_current_obj(obj); |
324 UI_APPLY_LAYOUT1(current, args); |
393 UI_APPLY_LAYOUT1(current, args); |
325 |
394 |
327 ui_set_name_and_style(sw, args.name, args.style_class); |
396 ui_set_name_and_style(sw, args.name, args.style_class); |
328 GtkWidget *widget = ui_box_set_margin(sw, args.margin); |
397 GtkWidget *widget = ui_box_set_margin(sw, args.margin); |
329 current->container->add(current->container, widget, TRUE); |
398 current->container->add(current->container, widget, TRUE); |
330 |
399 |
331 UiObject *newobj = uic_object_new(obj, sw); |
400 UiObject *newobj = uic_object_new(obj, sw); |
332 GtkWidget *sub; |
401 GtkWidget *sub = ui_subcontainer_create(args.subcontainer, newobj, args.spacing, args.columnspacing, args.rowspacing, args.margin); |
333 switch(args.subcontainer) { |
402 if(sub) { |
334 default: { |
403 SCROLLEDWINDOW_SET_CHILD(sw, sub); |
335 sub = ui_gtk_vbox_new(args.spacing); |
404 } else { |
336 GtkWidget *widget = ui_box_set_margin(sub, args.margin); |
405 newobj->widget = sw; |
337 SCROLLEDWINDOW_SET_CHILD(sw, widget); |
406 newobj->container = ui_scrolledwindow_container(obj, sw); |
338 |
407 } |
339 newobj->container = ui_box_container(newobj, sub, args.subcontainer); |
|
340 break; |
|
341 } |
|
342 case UI_CONTAINER_HBOX: { |
|
343 sub = ui_gtk_hbox_new(args.spacing); |
|
344 GtkWidget *widget = ui_box_set_margin(sub, args.margin); |
|
345 SCROLLEDWINDOW_SET_CHILD(sw, widget); |
|
346 |
|
347 newobj->container = ui_box_container(newobj, sub, args.subcontainer); |
|
348 break; |
|
349 } |
|
350 case UI_CONTAINER_GRID: { |
|
351 sub = ui_create_grid_widget(args.columnspacing, args.rowspacing); |
|
352 GtkWidget *widget = ui_box_set_margin(sub, args.margin); |
|
353 SCROLLEDWINDOW_SET_CHILD(sw, widget); |
|
354 |
|
355 newobj->container = ui_grid_container(newobj, sub); |
|
356 break; |
|
357 } |
|
358 case UI_CONTAINER_NO_SUB: { |
|
359 sub = sw; |
|
360 newobj->container = ui_scrolledwindow_container(obj, sw); |
|
361 } |
|
362 } |
|
363 newobj->widget = sub; |
|
364 |
|
365 |
408 |
366 uic_obj_add(obj, newobj); |
409 uic_obj_add(obj, newobj); |
367 |
410 |
368 return sw; |
411 return sw; |
369 } |
412 } |