--- a/ui/motif/container.h Wed Dec 04 08:57:35 2024 +0100 +++ b/ui/motif/container.h Wed Dec 04 18:31:22 2024 +0100 @@ -37,26 +37,37 @@ #ifdef __cplusplus extern "C" { #endif - -#define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) -typedef struct MotifTabbedPane MotifTabbedPane; -typedef struct UiTab UiTab; -typedef struct UiBoxContainer UiBoxContainer; -typedef struct UiGridContainer UiGridContainer; -typedef struct UiTabViewContainer UiTabViewContainer; -typedef struct UiLayout UiLayout; +#define UI_APPLY_LAYOUT(layout, args) \ + layout.fill = args.fill; \ + layout.hexpand = args.hexpand; \ + layout.vexpand = args.vexpand; \ + layout.hfill = args.hfill; \ + layout.vfill = args.vfill; \ + layout.colspan = args.colspan; \ + layout.rowspan = args.rowspan + +typedef enum UiBoxOrientation UiBoxOrientation; + +#define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout)) +#define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE) +#define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE) -typedef Widget (*ui_container_add_f)(UiContainer*, Arg*, int*, UiBool); - -typedef enum UiLayoutBool UiLayoutBool; -typedef enum UiBoxOrientation UiBoxOrientation; +#define ui_obj_container(obj) (UiContainerPrivate*)obj->container_end + +typedef struct UiLayout UiLayout; - -enum UiLayoutBool { - UI_LAYOUT_UNDEFINED = 0, - UI_LAYOUT_TRUE, - UI_LAYOUT_FALSE, +struct UiLayout { + UiTri fill; + UiBool newline; + char *label; + UiBool hexpand; + UiBool vexpand; + UiBool hfill; + UiBool vfill; + int width; + int colspan; + int rowspan; }; enum UiBoxOrientation { @@ -64,93 +75,32 @@ UI_BOX_HORIZONTAL }; -struct UiLayout { - UiLayoutBool fill; - UiBool newline; - char *label; - UiBool hexpand; - UiBool vexpand; - int gridwidth; -}; +typedef struct UiContainerPrivate UiContainerPrivate; -struct UiContainer { - Widget widget; - Widget (*prepare)(UiContainer*, Arg *, int*, UiBool); - void (*add)(UiContainer*, Widget); - UiLayout layout; - Widget current; - Widget menu; -}; -struct UiBoxContainer { - UiContainer container; - Widget prev_widget; - UiBool has_fill; - UiBoxOrientation orientation; - int margin; - int spacing; -}; - -struct UiGridContainer { - UiContainer container; - CxList *lines; - CxList *current; - int columnspacing; - int rowspacing; -}; - -struct UiTabViewContainer { - UiContainer container; - UiContext *context; - Widget widget; - CxList *tabs; - Widget current; +struct UiContainerPrivate { + UiContainerX container; + Widget (*prepare)(UiContainerPrivate*, Arg *, int*); + void (*add)(UiContainerPrivate*, Widget); + Widget widget; + UiLayout layout; }; -struct MotifTabbedPane { - UiTabbedPane view; - Widget tabbar; - CxList *tabs; - UiTab *current; - int index; - Pixel bg1; - Pixel bg2; - int height; -}; - -struct UiTab { - MotifTabbedPane *tabbedpane; - UiObject *content; - Widget tab_button; -}; - - -UiContainer* ui_frame_container(UiObject *obj, Widget frame); -Widget ui_frame_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); -void ui_frame_container_add(UiContainer *ct, Widget widget); +typedef struct UiBoxContainer { + UiContainerPrivate container; + Dimension n; +} UiBoxContainer; -UiContainer* ui_box_container(UiObject *obj, Widget box, int margin, int spacing, UiBoxOrientation orientation); -Widget ui_box_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); -void ui_box_container_add(UiContainer *ct, Widget widget); - -UiContainer* ui_grid_container(UiObject *obj, Widget form, int columnspacing, int rowspacing); -Widget ui_grid_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); -void ui_grid_container_add(UiContainer *ct, Widget widget); +typedef struct UiGridContainer { + UiContainerPrivate container; + int x; + int y; +} UiGridContainer; -UiContainer* ui_scrolledwindow_container(UiObject *obj, Widget scrolledwindow); -Widget ui_scrolledwindow_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); -void ui_scrolledwindow_container_add(UiContainer *ct, Widget widget); - -UiContainer* ui_tabview_container(UiObject *obj, Widget rowcolumn); -Widget ui_tabview_container_prepare(UiContainer *ct, Arg *args, int *n, UiBool fill); -void ui_tabview_container_add(UiContainer *ct, Widget widget); - -void ui_tab_button_callback(Widget widget, UiTab *tab, XtPointer d); -void ui_change_tab(MotifTabbedPane *pane, UiTab *tab); - -void ui_tab_set_document(UiContext *ctx, void *document); -void ui_tab_detach_document(UiContext *ctx); - +UiContainerX* ui_box_container(UiObject *obj, Widget grid, UiBoxOrientation orientation); +Widget ui_vbox_prepare(UiContainerPrivate *ctn, Arg *args, int *n); +Widget ui_hbox_prepare(UiContainerPrivate *ctn, Arg *args, int *n); +void ui_box_container_add(UiContainerPrivate *ctn, Widget widget); #ifdef __cplusplus }