ui/motif/container.c

changeset 115
e57ca2747782
parent 113
dde28a806552
--- a/ui/motif/container.c	Sun Dec 07 20:00:33 2025 +0100
+++ b/ui/motif/container.c	Sat Dec 13 15:58:58 2025 +0100
@@ -55,6 +55,18 @@
     container->add(container, widget);
 }
 
+void ui_container_apply_grid_margin(
+        Arg *args,
+        int *n,
+        int margin_left, int margin_right, int margin_top, int margin_bottom)
+{
+    int c = *n;
+    XtSetArg(args[c], gridMarginLeft, margin_left); c++;
+    XtSetArg(args[c], gridMarginRight, margin_right); c++;
+    XtSetArg(args[c], gridMarginTop, margin_top); c++;
+    XtSetArg(args[c], gridMarginBottom, margin_bottom); c++;
+    *n = c;
+}
 
 /* ---------------------------- Box Container ---------------------------- */
 
@@ -66,9 +78,9 @@
     int n = 0;
     
     if(orientation == UI_BOX_VERTICAL) {
-        //XtSetArg(xargs[n], gridRowSpacing, args->spacing); n++;
+        XtSetArg(xargs[n], gridRowSpacing, args->spacing); n++;
     } else {
-        //XtSetArg(xargs[n], gridColumnSpacing, args->spacing); n++;
+        XtSetArg(xargs[n], gridColumnSpacing, args->spacing); n++;
     }
     
     Widget parent = ui_container_prepare(ctn, &layout, xargs, &n);
@@ -102,7 +114,7 @@
 }
 
 static Widget ui_box_container_prepare(UiBoxContainer *box, UiLayout *layout, Arg *args, int *n) {
-    int a = *n;
+    ui_container_apply_grid_margin(args, n, layout->margin_left, layout->margin_right, layout->margin_top, layout->margin_bottom);
     box->n++;
     return box->container.widget;
 }
@@ -151,7 +163,6 @@
     UiLayout layout = UI_ARGS2LAYOUT(args);
     
     Widget parent = ui_container_prepare(ctn, &layout, xargs, &n);
-    XtSetArg(xargs[n], gridMargin, args->margin); n++;
     XtSetArg(xargs[n], gridColumnSpacing, args->columnspacing); n++;
     XtSetArg(xargs[n], gridRowSpacing, args->rowspacing); n++;
     Widget grid = XtCreateManagedWidget(args->name ? args->name : "gridcontainer", gridClass, parent, xargs, n);
@@ -218,6 +229,7 @@
     }
     
     *n = a;
+    ui_container_apply_grid_margin(args, n, layout->margin_left, layout->margin_right, layout->margin_top, layout->margin_bottom);
     return ctn->widget;
 }
 
@@ -237,9 +249,15 @@
     UiLayout layout = UI_ARGS2LAYOUT(args);
     
     Widget parent = ui_container_prepare(ctn, &layout, xargs, &n);
+    if(args->width > 0) {
+        XtSetArg(xargs[n], XmNwidth, args->width); n++;
+    }
+    if(args->height > 0) {
+        XtSetArg(xargs[n], XmNheight, args->height); n++;
+    }
     
     char *name = args->name ? (char*)args->name : "frame";
-    Widget frame = XmCreateFrame(parent, name, xargs, 6);
+    Widget frame = XmCreateFrame(parent, name, xargs, n);
     XtManageChild(frame);
     ui_container_add(ctn, frame);
     
@@ -259,7 +277,8 @@
     UiContainerArgs sub_args = {
         .spacing = args->spacing,
         .columnspacing = args->columnspacing,
-        .rowspacing = args->rowspacing
+        .rowspacing = args->rowspacing,
+        .margin = args->padding
     };
     switch(args->subcontainer) {
         default: break;
@@ -334,9 +353,10 @@
     if(numbuttons == 0) {
         return;
     }
+    width--;
     int button_width = width / numbuttons;
     int x = 0;
-    
+        
     CxIterator i = cxListIterator(tabview->tabs);
     cx_foreach(UiTab *, tab, i) {
         if(i.index + 1 == numbuttons) {
@@ -432,6 +452,7 @@
     tabview->current_index = -1;
     
     UiTabViewContainer *ct = ui_malloc(obj->ctx, sizeof(UiTabViewContainer));
+    memset(ct, 0, sizeof(UiTabViewContainer));
     ct->container.widget = form;
     ct->container.type = UI_CONTAINER_TABVIEW;
     ct->container.prepare = ui_tabview_container_prepare;
@@ -682,6 +703,12 @@
     int n = 0;
     
     XtSetArg(xargs[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
+    if(args->width > 0) {
+        XtSetArg(xargs[n], XmNwidth, args->width); n++;
+    }
+    if(args->height > 0) {
+        XtSetArg(xargs[n], XmNheight, args->height); n++;
+    }
     
     Widget parent = ui_container_prepare(ctn, &layout, xargs, &n);
     Widget scrolledwindow = XmCreateScrolledWindow(parent, "scrolledwindow", xargs, n);

mercurial