| 41 |
41 |
| 42 |
42 |
| 43 |
43 |
| 44 /* ---------------------------- Box Container ---------------------------- */ |
44 /* ---------------------------- Box Container ---------------------------- */ |
| 45 |
45 |
| 46 static UIWIDGET box_create(UiObject *obj, UiContainerArgs args, UiBoxOrientation orientation) { |
46 static UIWIDGET box_create(UiObject *obj, UiContainerArgs *args, UiBoxOrientation orientation) { |
| 47 UiContainerPrivate *ctn = ui_obj_container(obj); |
47 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 48 UI_APPLY_LAYOUT(ctn->layout, args); |
48 UI_APPLY_LAYOUT(ctn->layout, args); |
| 49 |
49 |
| 50 Arg xargs[16]; |
50 Arg xargs[16]; |
| 51 int n = 0; |
51 int n = 0; |
| 52 |
52 |
| 53 if(orientation == UI_BOX_VERTICAL) { |
53 if(orientation == UI_BOX_VERTICAL) { |
| 54 //XtSetArg(xargs[n], gridRowSpacing, args.spacing); n++; |
54 //XtSetArg(xargs[n], gridRowSpacing, args->spacing); n++; |
| 55 } else { |
55 } else { |
| 56 //XtSetArg(xargs[n], gridColumnSpacing, args.spacing); n++; |
56 //XtSetArg(xargs[n], gridColumnSpacing, args->spacing); n++; |
| 57 } |
57 } |
| 58 |
58 |
| 59 Widget parent = ctn->prepare(ctn, xargs, &n); |
59 Widget parent = ctn->prepare(ctn, xargs, &n); |
| 60 Widget grid = XtCreateManagedWidget(args.name ? args.name : "boxcontainer", gridClass, parent, xargs, n); |
60 Widget grid = XtCreateManagedWidget(args->name ? args->name : "boxcontainer", gridClass, parent, xargs, n); |
| 61 ctn->add(ctn, grid); |
61 ctn->add(ctn, grid); |
| 62 |
62 |
| 63 UiContainerX *container = ui_box_container(obj, grid, orientation); |
63 UiContainerX *container = ui_box_container(obj, grid, orientation); |
| 64 uic_object_push_container(obj, container); |
64 uic_object_push_container(obj, container); |
| 65 |
65 |
| 66 return grid; |
66 return grid; |
| 67 } |
67 } |
| 68 |
68 |
| 69 // public |
69 // public |
| 70 UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs args) { |
70 UIWIDGET ui_vbox_create(UiObject *obj, UiContainerArgs *args) { |
| 71 return box_create(obj, args, UI_BOX_VERTICAL); |
71 return box_create(obj, args, UI_BOX_VERTICAL); |
| 72 } |
72 } |
| 73 |
73 |
| 74 // public |
74 // public |
| 75 UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs args) { |
75 UIWIDGET ui_hbox_create(UiObject *obj, UiContainerArgs *args) { |
| 76 return box_create(obj, args, UI_BOX_HORIZONTAL); |
76 return box_create(obj, args, UI_BOX_HORIZONTAL); |
| 77 } |
77 } |
| 78 |
78 |
| 79 UiContainerX* ui_box_container(UiObject *obj, Widget grid, UiBoxOrientation orientation) { |
79 UiContainerX* ui_box_container(UiObject *obj, Widget grid, UiBoxOrientation orientation) { |
| 80 UiBoxContainer *ctn = ui_malloc(obj->ctx, sizeof(UiBoxContainer)); |
80 UiBoxContainer *ctn = ui_malloc(obj->ctx, sizeof(UiBoxContainer)); |
| 127 |
127 |
| 128 |
128 |
| 129 /* ---------------------------- Grid Container ---------------------------- */ |
129 /* ---------------------------- Grid Container ---------------------------- */ |
| 130 |
130 |
| 131 // public |
131 // public |
| 132 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs args) { |
132 UIWIDGET ui_grid_create(UiObject *obj, UiContainerArgs *args) { |
| 133 Arg xargs[16]; |
133 Arg xargs[16]; |
| 134 int n = 0; |
134 int n = 0; |
| 135 |
135 |
| 136 UiContainerPrivate *ctn = ui_obj_container(obj); |
136 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 137 UI_APPLY_LAYOUT(ctn->layout, args); |
137 UI_APPLY_LAYOUT(ctn->layout, args); |
| 138 |
138 |
| 139 Widget parent = ctn->prepare(ctn, xargs, &n); |
139 Widget parent = ctn->prepare(ctn, xargs, &n); |
| 140 XtSetArg(xargs[n], gridMargin, args.margin); n++; |
140 XtSetArg(xargs[n], gridMargin, args->margin); n++; |
| 141 XtSetArg(xargs[n], gridColumnSpacing, args.columnspacing); n++; |
141 XtSetArg(xargs[n], gridColumnSpacing, args->columnspacing); n++; |
| 142 XtSetArg(xargs[n], gridRowSpacing, args.rowspacing); n++; |
142 XtSetArg(xargs[n], gridRowSpacing, args->rowspacing); n++; |
| 143 Widget grid = XtCreateManagedWidget(args.name ? args.name : "gridcontainer", gridClass, parent, xargs, n); |
143 Widget grid = XtCreateManagedWidget(args->name ? args->name : "gridcontainer", gridClass, parent, xargs, n); |
| 144 ctn->add(ctn, grid); |
144 ctn->add(ctn, grid); |
| 145 |
145 |
| 146 UiContainerX *container = ui_grid_container(obj, grid, args.def_hexpand, args.def_vexpand, args.def_hfill, args.def_vfill); |
146 UiContainerX *container = ui_grid_container(obj, grid, args->def_hexpand, args->def_vexpand, args->def_hfill, args->def_vfill); |
| 147 uic_object_push_container(obj, container); |
147 uic_object_push_container(obj, container); |
| 148 |
148 |
| 149 return grid; |
149 return grid; |
| 150 } |
150 } |
| 151 |
151 |
| 306 Widget tab = tabview->current_tab->tab_button; |
306 Widget tab = tabview->current_tab->tab_button; |
| 307 XFillRectangle(dpy, XtWindow(widget), tabview->gc, tab->core.x, tab->core.height, tab->core.width, 4); |
307 XFillRectangle(dpy, XtWindow(widget), tabview->gc, tab->core.x, tab->core.height, tab->core.width, 4); |
| 308 } |
308 } |
| 309 } |
309 } |
| 310 |
310 |
| 311 UIWIDGET ui_tabview_create(UiObject *obj, UiTabViewArgs args) { |
311 UIWIDGET ui_tabview_create(UiObject *obj, UiTabViewArgs *args) { |
| 312 Arg xargs[16]; |
312 Arg xargs[16]; |
| 313 int n = 0; |
313 int n = 0; |
| 314 |
314 |
| 315 UiContainerPrivate *ctn = ui_obj_container(obj); |
315 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 316 UI_APPLY_LAYOUT(ctn->layout, args); |
316 UI_APPLY_LAYOUT(ctn->layout, args); |
| 319 // form |
319 // form |
| 320 // - tabbar (Drawing Area) |
320 // - tabbar (Drawing Area) |
| 321 // - content (Frame) |
321 // - content (Frame) |
| 322 UiMotifTabView *tabview = malloc(sizeof(UiMotifTabView)); |
322 UiMotifTabView *tabview = malloc(sizeof(UiMotifTabView)); |
| 323 memset(tabview, 0, sizeof(UiMotifTabView)); |
323 memset(tabview, 0, sizeof(UiMotifTabView)); |
| 324 char *name = args.name ? (char*)args.name : "tabview"; |
324 char *name = args->name ? (char*)args->name : "tabview"; |
| 325 XtSetArg(xargs[n], XmNuserData, tabview); n++; |
325 XtSetArg(xargs[n], XmNuserData, tabview); n++; |
| 326 Widget parent = ctn->prepare(ctn, xargs, &n); |
326 Widget parent = ctn->prepare(ctn, xargs, &n); |
| 327 Widget form = XmCreateForm(parent, name, xargs, n); |
327 Widget form = XmCreateForm(parent, name, xargs, n); |
| 328 XtManageChild(form); |
328 XtManageChild(form); |
| 329 |
329 |
| 352 // setup tabview object, that holds all relevant objects |
352 // setup tabview object, that holds all relevant objects |
| 353 tabview->obj = obj; |
353 tabview->obj = obj; |
| 354 tabview->form = form; |
354 tabview->form = form; |
| 355 tabview->tabbar = tabbar; |
355 tabview->tabbar = tabbar; |
| 356 tabview->content = content; |
356 tabview->content = content; |
| 357 tabview->tabview = args.tabview; |
357 tabview->tabview = args->tabview; |
| 358 tabview->subcontainer = args.subcontainer; |
358 tabview->subcontainer = args->subcontainer; |
| 359 tabview->select = ui_motif_tabview_select; |
359 tabview->select = ui_motif_tabview_select; |
| 360 tabview->add = ui_motif_tabview_add_tab; |
360 tabview->add = ui_motif_tabview_add_tab; |
| 361 tabview->remove = ui_motif_tabview_remove; |
361 tabview->remove = ui_motif_tabview_remove; |
| 362 tabview->tabs = cxArrayListCreate(obj->ctx->allocator, cx_cmp_ptr, sizeof(UiTab), 8); |
362 tabview->tabs = cxArrayListCreate(obj->ctx->allocator, cx_cmp_ptr, sizeof(UiTab), 8); |
| 363 tabview->current_index = -1; |
363 tabview->current_index = -1; |
| 367 ct->container.type = UI_CONTAINER_TABVIEW; |
367 ct->container.type = UI_CONTAINER_TABVIEW; |
| 368 ct->container.prepare = ui_tabview_container_prepare; |
368 ct->container.prepare = ui_tabview_container_prepare; |
| 369 ct->container.add = ui_tabview_container_add; |
369 ct->container.add = ui_tabview_container_add; |
| 370 ct->tabview = tabview; |
370 ct->tabview = tabview; |
| 371 |
371 |
| 372 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_INTEGER); |
372 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_INTEGER); |
| 373 if(var) { |
373 if(var) { |
| 374 UiInteger *i = var->value; |
374 UiInteger *i = var->value; |
| 375 i->obj = tabview; |
375 i->obj = tabview; |
| 376 i->get = ui_tabview_get; |
376 i->get = ui_tabview_get; |
| 377 i->set = ui_tabview_set; |
377 i->set = ui_tabview_set; |
| 603 ctn->add = ui_scrolledwindow_add; |
603 ctn->add = ui_scrolledwindow_add; |
| 604 ctn->widget = scrolledwindow; |
604 ctn->widget = scrolledwindow; |
| 605 return (UiContainerX*)ctn; |
605 return (UiContainerX*)ctn; |
| 606 } |
606 } |
| 607 |
607 |
| 608 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs args) { |
608 UIWIDGET ui_scrolledwindow_create(UiObject* obj, UiFrameArgs *args) { |
| 609 UiContainerPrivate *ctn = ui_obj_container(obj); |
609 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 610 UI_APPLY_LAYOUT(ctn->layout, args); |
610 UI_APPLY_LAYOUT(ctn->layout, args); |
| 611 |
611 |
| 612 Arg xargs[16]; |
612 Arg xargs[16]; |
| 613 int n = 0; |
613 int n = 0; |