ui/qt/container.h

changeset 103
6606616eca9f
parent 0
2483f517c562
child 108
77254bd6dccb
--- a/ui/qt/container.h	Tue Feb 25 21:11:00 2025 +0100
+++ b/ui/qt/container.h	Sat Apr 05 16:46:11 2025 +0200
@@ -30,6 +30,7 @@
 #define	CONTAINER_H
 
 #include "toolkit.h"
+#include "../ui/container.h"
 #include "window.h"
 
 #include <string.h>
@@ -39,37 +40,52 @@
 #include <QStackedWidget>
 #include <QSplitter>
 
+#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.override_defaults = args.override_defaults; \
+    layout.colspan = args.colspan; \
+    layout.rowspan = args.rowspan
+
+#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)
-#define ui_reset_layout(layout) memset(&(layout), 0, sizeof(UiLayout))
 
-typedef struct UiLayout UiLayout;
+#define ui_obj_container(obj) (UiContainerPrivate*)((UiContainerX*)obj->container_end)->container
 
-enum UiLayoutBool {
+typedef enum UiLayoutBool {
     UI_LAYOUT_UNDEFINED = 0,
     UI_LAYOUT_TRUE,
     UI_LAYOUT_FALSE,
-};
-typedef enum UiLayoutBool UiLayoutBool;
+} UiLayoutBool;
 
+typedef struct UiLayout UiLayout;
 struct UiLayout {
-    UiLayoutBool fill;
-    bool newline;
-    char *label;
-    bool hexpand;
-    bool vexpand;
-    int  gridwidth;
+    UiTri        fill;
+    UiBool       newline;
+    char         *label;
+    UiBool       hexpand;
+    UiBool       vexpand;
+    UiBool       hfill;
+    UiBool       vfill;
+    UiBool       override_defaults;
+    int          width;
+    int          colspan;
+    int          rowspan;
 };
 
-struct UiContainer {
+struct UiContainerPrivate {
     UiLayout layout; 
     UIWIDGET current;
-    QMenu    *menu;
 
     virtual void add(QWidget *widget, bool fill) = 0;
+    virtual void end() {}
 };
 
-class UiBoxContainer : public UiContainer {
+class UiBoxContainer : public UiContainerPrivate {
 public:
     QBoxLayout  *box;
     bool        hasStretchedWidget = false;
@@ -80,40 +96,36 @@
     virtual void add(QWidget *widget, bool fill);
 };
 
-class UiGridContainer : public UiContainer {
+class UiGridContainer : public UiContainerPrivate {
 public:
     QGridLayout *grid;
     int x = 0;
     int y = 0;
+    bool def_hexpand;
+    bool def_vexpand;
+    bool def_hfill;
+    bool def_vfill;
+    bool col_expanding = false;
+    bool row_expanding = false;
+    int max_x;
+    int max_y;
     
-    UiGridContainer(QGridLayout *grid, int margin, int columnspacing, int rowspacing);
+    UiGridContainer(
+            QGridLayout *grid,
+            int margin,
+            int columnspacing,
+            int rowspacing,
+            bool def_hexpand,
+            bool def_vexpand,
+            bool def_hfill,
+            bool def_vfill);
     
     virtual void add(QWidget *widget, bool fill);
-};
-
-class UiTabViewContainer : public UiContainer {
-public:
-    QTabWidget *tabwidget;
-    
-    UiTabViewContainer(QTabWidget *tabwidget);
-    virtual void add(QWidget *widget, bool fill);
+    virtual void end();
 };
 
-class UiStackContainer : public UiContainer {
-public:
-    QStackedWidget *stack;
-    
-    UiStackContainer(QStackedWidget *stack);
-    virtual void add(QWidget *widget, bool fill);
-};
+void ui_container_add(UiObject *obj, UiContainerPrivate *ct);
 
-class UiSidebarContainer : public UiContainer {
-public:
-    QSplitter *splitter;
-    
-    UiSidebarContainer(QSplitter *splitter);
-    virtual void add(QWidget *widget, bool fill);
-};
 
 #endif	/* CONTAINER_H */
 

mercurial