--- a/ui/motif/container.c Wed Feb 26 21:19:54 2025 +0100 +++ b/ui/motif/container.c Wed Feb 26 21:33:57 2025 +0100 @@ -143,13 +143,20 @@ Widget grid = XtCreateManagedWidget(args.name ? args.name : "gridcontainer", gridClass, parent, xargs, n); ctn->add(ctn, grid); - UiContainerX *container = ui_grid_container(obj, grid); + UiContainerX *container = ui_grid_container(obj, grid, args.def_hexpand, args.def_vexpand, args.def_hfill, args.def_vfill); uic_object_push_container(obj, container); return grid; } -UiContainerX* ui_grid_container(UiObject *obj, Widget grid) { +UiContainerX* ui_grid_container( + UiObject *obj, + Widget grid, + UiBool def_hexpand, + UiBool def_vexpand, + UiBool def_hfill, + UiBool def_vfill) +{ UiGridContainer *ctn = ui_malloc(obj->ctx, sizeof(UiGridContainer)); memset(ctn, 0, sizeof(UiBoxContainer)); ctn->container.prepare = ui_grid_container_prepare; @@ -157,6 +164,10 @@ ctn->container.widget = grid; ctn->x = 0; ctn->y = 0; + ctn->def_hexpand = def_hexpand; + ctn->def_vexpand = def_vexpand; + ctn->def_hfill = def_hfill; + ctn->def_vfill = def_vfill; return (UiContainerX*)ctn; } @@ -177,23 +188,54 @@ XtSetArg(args[a], gridRowspan, ctn->layout.rowspan); a++; } - if(grid->container.layout.fill == UI_ON) { - grid->container.layout.hfill = TRUE; - grid->container.layout.vfill = TRUE; - grid->container.layout.hexpand = TRUE; - grid->container.layout.vexpand = TRUE; + int hexpand = FALSE; + int vexpand = FALSE; + int hfill = FALSE; + int vfill = FALSE; + if(!ctn->layout.override_defaults) { + if(grid->def_hexpand) { + hexpand = TRUE; + hfill = TRUE; + } else if(grid->def_hfill) { + hfill = TRUE; + } + if(grid->def_vexpand) { + vexpand = TRUE; + vfill = TRUE; + } else if(grid->def_vfill) { + vfill = TRUE; + } } - if(grid->container.layout.hfill) { + if(ctn->layout.hexpand) { + hexpand = TRUE; + hfill = TRUE; + } else if(ctn->layout.hfill) { + hfill = TRUE; + } + if(ctn->layout.vexpand) { + vexpand = TRUE; + vfill = TRUE; + } else if(ctn->layout.vfill) { + vfill = TRUE; + } + if(ctn->layout.fill == UI_ON) { + hexpand = TRUE; + vexpand = TRUE; + hfill = TRUE; + vfill = TRUE; + } + + if(hfill) { XtSetArg(args[a], gridHFill, TRUE); a++; } - if(grid->container.layout.vfill) { + if(vfill) { XtSetArg(args[a], gridVFill, TRUE); a++; } - if(grid->container.layout.hexpand) { + if(hexpand) { XtSetArg(args[a], gridHExpand, TRUE); a++; } - if(grid->container.layout.vexpand) { + if(vexpand) { XtSetArg(args[a], gridVExpand, TRUE); a++; }