add form widget to a window to fix layout problems (Motif) newapi

Tue, 31 Dec 2024 17:22:16 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 31 Dec 2024 17:22:16 +0100
branch
newapi
changeset 424
51e856688fba
parent 423
02bafb660eb2
child 425
effdc7283337

add form widget to a window to fix layout problems (Motif)

application/main.c file | annotate | diff | comparison | revisions
ui/motif/Grid.c file | annotate | diff | comparison | revisions
ui/motif/container.c file | annotate | diff | comparison | revisions
ui/motif/window.c file | annotate | diff | comparison | revisions
--- a/application/main.c	Tue Dec 31 16:21:57 2024 +0100
+++ b/application/main.c	Tue Dec 31 17:22:16 2024 +0100
@@ -564,7 +564,39 @@
     wdata->path = ui_string_new(obj->ctx, NULL);
     obj->window = wdata;
     
-    ui_button(obj, .label = "Add Item", .onclick = action_button);
+    /*
+    ui_button(obj, .label = "Add Item", .onclick = action_button, .name = "mybutton1");
+    ui_button(obj, .label = "Test2", .name = "mybutton2");
+    ui_button(obj, .label = "Test3", .name = "mybutton3");
+    ui_hbox0(obj) {
+        ui_button(obj, .label = "hbutton1");
+        ui_button(obj, .label = "hbutton2");
+        ui_button(obj, .label = "hbutton3", .fill = UI_ON);
+        ui_button(obj, .label = "hbutton4");
+        ui_button(obj, .label = "hbutton5");
+        
+    }
+    ui_button(obj, .label = "Test4", .name = "mybutton4", .fill = UI_ON);
+    ui_button(obj, .label = "end");
+    */
+    
+    ui_grid(obj, .columnspacing = 10, .rowspacing = 20, .fill = UI_ON) {
+        ui_button(obj, .label = "Add Item", .onclick = action_button, .name = "mybutton1");
+        ui_newline(obj);
+        ui_button(obj, .label = "Line 2 B1");
+        ui_button(obj, .label = "Line 2 B2");
+        ui_button(obj, .label = "Line 2 B3");
+        ui_newline(obj);
+        ui_button(obj, .label = "Line 3", .colspan = 3, .hfill = TRUE, .vexpand = TRUE, .vfill = TRUE);
+        ui_newline(obj);
+        ui_button(obj, .label = "Line 4 B1");
+        ui_button(obj, .label = "Line 4 B2");
+        ui_button(obj, .label = "Line 4 B3");
+        ui_button(obj, .label = "Line 4 B4", .hexpand = TRUE, .hfill = TRUE);
+        ui_button(obj, .label = "Line EOL");
+        ui_newline(obj);
+        ui_button(obj, .colspan = 5, .hfill = TRUE);
+    }
     
     ui_show(obj);
 }
--- a/ui/motif/Grid.c	Tue Dec 31 16:21:57 2024 +0100
+++ b/ui/motif/Grid.c	Tue Dec 31 17:22:16 2024 +0100
@@ -367,6 +367,8 @@
     int req_width = 0;
     int req_height = 0;
     
+    //printf("container width: %d\n", (int)w->core.width);
+    
     // calculate the minimum size requirements for all columns and rows
     // we need to run this 2 times: for widgets without colspan/rowspan first
     // and then again for colspan/rowspan > 1
@@ -491,6 +493,13 @@
         if(!w->mywidget.sizerequest) {
             Dimension actual_width, actual_height;
             w->mywidget.sizerequest = TRUE;
+            
+            //XtWidgetGeometry request;
+            //request.width = req_width;
+            //request.request_mode = CWWidth;
+            //XtWidgetGeometry reply;
+            //XtGeometryResult result = XtMakeGeometryRequest((Widget)w, &request, &reply);
+            
             XtMakeResizeRequest((Widget)w, req_width, req_height, &actual_width, &actual_height);
             w->mywidget.sizerequest = FALSE;
             //printf("size request: %d %d\n", (int)actual_width, (int)actual_height);
--- a/ui/motif/container.c	Tue Dec 31 16:21:57 2024 +0100
+++ b/ui/motif/container.c	Tue Dec 31 17:22:16 2024 +0100
@@ -128,8 +128,6 @@
     Arg xargs[16];
     int n = 0;
     
-    XtSetArg(xargs[n], XmNbackground, 0); n++;
-    
     UiContainerPrivate *ctn = ui_obj_container(obj);
     UI_APPLY_LAYOUT(ctn->layout, args);
     
--- a/ui/motif/window.c	Tue Dec 31 16:21:57 2024 +0100
+++ b/ui/motif/window.c	Tue Dec 31 17:22:16 2024 +0100
@@ -107,7 +107,15 @@
     Widget frame = XmCreateFrame(window, "window_frame", args, n);
     XtManageChild(frame);
     
-    Widget vbox = XtCreateManagedWidget("window_vbox", gridClass, frame, NULL, 0);
+    Widget form = XmCreateForm(frame, "window_form", args, 0);
+    XtManageChild(form);
+    
+    n = 0;
+    XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
+    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
+    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
+    XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
+    Widget vbox = XtCreateManagedWidget("window_vbox", gridClass, form, args, n);
     UiContainerX *container = ui_box_container(obj, vbox, UI_BOX_VERTICAL);
     uic_object_push_container(obj, container);
     

mercurial