| 53 |
53 |
| 54 void ui_container_add(UiContainerPrivate *container, Widget widget) { |
54 void ui_container_add(UiContainerPrivate *container, Widget widget) { |
| 55 container->add(container, widget); |
55 container->add(container, widget); |
| 56 } |
56 } |
| 57 |
57 |
| |
58 void ui_container_apply_grid_margin( |
| |
59 Arg *args, |
| |
60 int *n, |
| |
61 int margin_left, int margin_right, int margin_top, int margin_bottom) |
| |
62 { |
| |
63 int c = *n; |
| |
64 XtSetArg(args[c], gridMarginLeft, margin_left); c++; |
| |
65 XtSetArg(args[c], gridMarginRight, margin_right); c++; |
| |
66 XtSetArg(args[c], gridMarginTop, margin_top); c++; |
| |
67 XtSetArg(args[c], gridMarginBottom, margin_bottom); c++; |
| |
68 *n = c; |
| |
69 } |
| 58 |
70 |
| 59 /* ---------------------------- Box Container ---------------------------- */ |
71 /* ---------------------------- Box Container ---------------------------- */ |
| 60 |
72 |
| 61 static UIWIDGET box_create(UiObject *obj, UiContainerArgs *args, UiBoxOrientation orientation) { |
73 static UIWIDGET box_create(UiObject *obj, UiContainerArgs *args, UiBoxOrientation orientation) { |
| 62 UiContainerPrivate *ctn = ui_obj_container(obj); |
74 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 64 |
76 |
| 65 Arg xargs[16]; |
77 Arg xargs[16]; |
| 66 int n = 0; |
78 int n = 0; |
| 67 |
79 |
| 68 if(orientation == UI_BOX_VERTICAL) { |
80 if(orientation == UI_BOX_VERTICAL) { |
| 69 //XtSetArg(xargs[n], gridRowSpacing, args->spacing); n++; |
81 XtSetArg(xargs[n], gridRowSpacing, args->spacing); n++; |
| 70 } else { |
82 } else { |
| 71 //XtSetArg(xargs[n], gridColumnSpacing, args->spacing); n++; |
83 XtSetArg(xargs[n], gridColumnSpacing, args->spacing); n++; |
| 72 } |
84 } |
| 73 |
85 |
| 74 Widget parent = ui_container_prepare(ctn, &layout, xargs, &n); |
86 Widget parent = ui_container_prepare(ctn, &layout, xargs, &n); |
| 75 Widget grid = XtCreateManagedWidget(args->name ? args->name : "boxcontainer", gridClass, parent, xargs, n); |
87 Widget grid = XtCreateManagedWidget(args->name ? args->name : "boxcontainer", gridClass, parent, xargs, n); |
| 76 ctn->add(ctn, grid); |
88 ctn->add(ctn, grid); |
| 100 ctn->n = 0; |
112 ctn->n = 0; |
| 101 return (UiContainerX*)ctn; |
113 return (UiContainerX*)ctn; |
| 102 } |
114 } |
| 103 |
115 |
| 104 static Widget ui_box_container_prepare(UiBoxContainer *box, UiLayout *layout, Arg *args, int *n) { |
116 static Widget ui_box_container_prepare(UiBoxContainer *box, UiLayout *layout, Arg *args, int *n) { |
| 105 int a = *n; |
117 ui_container_apply_grid_margin(args, n, layout->margin_left, layout->margin_right, layout->margin_top, layout->margin_bottom); |
| 106 box->n++; |
118 box->n++; |
| 107 return box->container.widget; |
119 return box->container.widget; |
| 108 } |
120 } |
| 109 |
121 |
| 110 Widget ui_vbox_prepare(UiContainerPrivate *ctn, UiLayout *layout, Arg *args, int *n) { |
122 Widget ui_vbox_prepare(UiContainerPrivate *ctn, UiLayout *layout, Arg *args, int *n) { |
| 149 |
161 |
| 150 UiContainerPrivate *ctn = ui_obj_container(obj); |
162 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 151 UiLayout layout = UI_ARGS2LAYOUT(args); |
163 UiLayout layout = UI_ARGS2LAYOUT(args); |
| 152 |
164 |
| 153 Widget parent = ui_container_prepare(ctn, &layout, xargs, &n); |
165 Widget parent = ui_container_prepare(ctn, &layout, xargs, &n); |
| 154 XtSetArg(xargs[n], gridMargin, args->margin); n++; |
|
| 155 XtSetArg(xargs[n], gridColumnSpacing, args->columnspacing); n++; |
166 XtSetArg(xargs[n], gridColumnSpacing, args->columnspacing); n++; |
| 156 XtSetArg(xargs[n], gridRowSpacing, args->rowspacing); n++; |
167 XtSetArg(xargs[n], gridRowSpacing, args->rowspacing); n++; |
| 157 Widget grid = XtCreateManagedWidget(args->name ? args->name : "gridcontainer", gridClass, parent, xargs, n); |
168 Widget grid = XtCreateManagedWidget(args->name ? args->name : "gridcontainer", gridClass, parent, xargs, n); |
| 158 ui_container_add(ctn, grid); |
169 ui_container_add(ctn, grid); |
| 159 |
170 |
| 216 if(layout->vexpand) { |
227 if(layout->vexpand) { |
| 217 XtSetArg(args[a], gridVExpand, TRUE); a++; |
228 XtSetArg(args[a], gridVExpand, TRUE); a++; |
| 218 } |
229 } |
| 219 |
230 |
| 220 *n = a; |
231 *n = a; |
| |
232 ui_container_apply_grid_margin(args, n, layout->margin_left, layout->margin_right, layout->margin_top, layout->margin_bottom); |
| 221 return ctn->widget; |
233 return ctn->widget; |
| 222 } |
234 } |
| 223 |
235 |
| 224 void ui_grid_container_add(UiContainerPrivate *ctn, Widget widget) { |
236 void ui_grid_container_add(UiContainerPrivate *ctn, Widget widget) { |
| 225 UiGridContainer *grid = (UiGridContainer*)ctn; |
237 UiGridContainer *grid = (UiGridContainer*)ctn; |
| 235 |
247 |
| 236 UiContainerPrivate *ctn = ui_obj_container(obj); |
248 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 237 UiLayout layout = UI_ARGS2LAYOUT(args); |
249 UiLayout layout = UI_ARGS2LAYOUT(args); |
| 238 |
250 |
| 239 Widget parent = ui_container_prepare(ctn, &layout, xargs, &n); |
251 Widget parent = ui_container_prepare(ctn, &layout, xargs, &n); |
| |
252 if(args->width > 0) { |
| |
253 XtSetArg(xargs[n], XmNwidth, args->width); n++; |
| |
254 } |
| |
255 if(args->height > 0) { |
| |
256 XtSetArg(xargs[n], XmNheight, args->height); n++; |
| |
257 } |
| 240 |
258 |
| 241 char *name = args->name ? (char*)args->name : "frame"; |
259 char *name = args->name ? (char*)args->name : "frame"; |
| 242 Widget frame = XmCreateFrame(parent, name, xargs, 6); |
260 Widget frame = XmCreateFrame(parent, name, xargs, n); |
| 243 XtManageChild(frame); |
261 XtManageChild(frame); |
| 244 ui_container_add(ctn, frame); |
262 ui_container_add(ctn, frame); |
| 245 |
263 |
| 246 if(args->label) { |
264 if(args->label) { |
| 247 XmString s = XmStringCreateLocalized((char*)args->label); |
265 XmString s = XmStringCreateLocalized((char*)args->label); |
| 257 uic_object_push_container(obj, container); |
275 uic_object_push_container(obj, container); |
| 258 |
276 |
| 259 UiContainerArgs sub_args = { |
277 UiContainerArgs sub_args = { |
| 260 .spacing = args->spacing, |
278 .spacing = args->spacing, |
| 261 .columnspacing = args->columnspacing, |
279 .columnspacing = args->columnspacing, |
| 262 .rowspacing = args->rowspacing |
280 .rowspacing = args->rowspacing, |
| |
281 .margin = args->padding |
| 263 }; |
282 }; |
| 264 switch(args->subcontainer) { |
283 switch(args->subcontainer) { |
| 265 default: break; |
284 default: break; |
| 266 case UI_CONTAINER_VBOX: { |
285 case UI_CONTAINER_VBOX: { |
| 267 ui_vbox_create(obj, &sub_args); |
286 ui_vbox_create(obj, &sub_args); |
| 332 XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); |
351 XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); |
| 333 int numbuttons = cxListSize(tabview->tabs); |
352 int numbuttons = cxListSize(tabview->tabs); |
| 334 if(numbuttons == 0) { |
353 if(numbuttons == 0) { |
| 335 return; |
354 return; |
| 336 } |
355 } |
| |
356 width--; |
| 337 int button_width = width / numbuttons; |
357 int button_width = width / numbuttons; |
| 338 int x = 0; |
358 int x = 0; |
| 339 |
359 |
| 340 CxIterator i = cxListIterator(tabview->tabs); |
360 CxIterator i = cxListIterator(tabview->tabs); |
| 341 cx_foreach(UiTab *, tab, i) { |
361 cx_foreach(UiTab *, tab, i) { |
| 342 if(i.index + 1 == numbuttons) { |
362 if(i.index + 1 == numbuttons) { |
| 343 button_width = width - x; |
363 button_width = width - x; |
| 344 } |
364 } |
| 430 tabview->remove = ui_motif_tabview_remove; |
450 tabview->remove = ui_motif_tabview_remove; |
| 431 tabview->tabs = cxArrayListCreate(obj->ctx->allocator, cx_cmp_ptr, sizeof(UiTab), 8); |
451 tabview->tabs = cxArrayListCreate(obj->ctx->allocator, cx_cmp_ptr, sizeof(UiTab), 8); |
| 432 tabview->current_index = -1; |
452 tabview->current_index = -1; |
| 433 |
453 |
| 434 UiTabViewContainer *ct = ui_malloc(obj->ctx, sizeof(UiTabViewContainer)); |
454 UiTabViewContainer *ct = ui_malloc(obj->ctx, sizeof(UiTabViewContainer)); |
| |
455 memset(ct, 0, sizeof(UiTabViewContainer)); |
| 435 ct->container.widget = form; |
456 ct->container.widget = form; |
| 436 ct->container.type = UI_CONTAINER_TABVIEW; |
457 ct->container.type = UI_CONTAINER_TABVIEW; |
| 437 ct->container.prepare = ui_tabview_container_prepare; |
458 ct->container.prepare = ui_tabview_container_prepare; |
| 438 ct->container.add = ui_tabview_container_add; |
459 ct->container.add = ui_tabview_container_add; |
| 439 ct->tabview = tabview; |
460 ct->tabview = tabview; |
| 680 |
701 |
| 681 Arg xargs[16]; |
702 Arg xargs[16]; |
| 682 int n = 0; |
703 int n = 0; |
| 683 |
704 |
| 684 XtSetArg(xargs[n], XmNscrollingPolicy, XmAUTOMATIC); n++; |
705 XtSetArg(xargs[n], XmNscrollingPolicy, XmAUTOMATIC); n++; |
| |
706 if(args->width > 0) { |
| |
707 XtSetArg(xargs[n], XmNwidth, args->width); n++; |
| |
708 } |
| |
709 if(args->height > 0) { |
| |
710 XtSetArg(xargs[n], XmNheight, args->height); n++; |
| |
711 } |
| 685 |
712 |
| 686 Widget parent = ui_container_prepare(ctn, &layout, xargs, &n); |
713 Widget parent = ui_container_prepare(ctn, &layout, xargs, &n); |
| 687 Widget scrolledwindow = XmCreateScrolledWindow(parent, "scrolledwindow", xargs, n); |
714 Widget scrolledwindow = XmCreateScrolledWindow(parent, "scrolledwindow", xargs, n); |
| 688 ui_container_add(ctn, scrolledwindow); |
715 ui_container_add(ctn, scrolledwindow); |
| 689 |
716 |