ui/qt/container.h

changeset 519
8884c7fbe4cb
parent 516
4b31c74666d7
child 520
ea1bba55de44
--- a/ui/qt/container.h	Wed Mar 26 21:15:20 2025 +0100
+++ b/ui/qt/container.h	Wed Mar 26 21:47:04 2025 +0100
@@ -30,6 +30,7 @@
 #define	CONTAINER_H
 
 #include "toolkit.h"
+#include "../ui/container.h"
 #include "window.h"
 
 #include <string.h>
@@ -39,7 +40,71 @@
 #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_obj_container(obj) (UiContainerPrivate*)obj->container_end
+
+typedef enum UiLayoutBool {
+    UI_LAYOUT_UNDEFINED = 0,
+    UI_LAYOUT_TRUE,
+    UI_LAYOUT_FALSE,
+} UiLayoutBool;
+
+typedef struct UiLayout UiLayout;
+struct UiLayout {
+    UiTri        fill;
+    UiBool       newline;
+    char         *label;
+    UiBool       hexpand;
+    UiBool       vexpand;
+    UiBool       hfill;
+    UiBool       vfill;
+    UiBool       override_defaults;
+    int          width;
+    int          colspan;
+    int          rowspan;
+};
+
+struct UiContainerPrivate {
+    UiLayout layout; 
+    UIWIDGET current;
+
+    virtual void add(QWidget *widget, bool fill) = 0;
+};
+
+class UiBoxContainer : public UiContainerPrivate {
+public:
+    QBoxLayout  *box;
+    bool        hasStretchedWidget = false;
+    QSpacerItem *space;
+    
+    UiBoxContainer(QBoxLayout *box);
+    
+    virtual void add(QWidget *widget, bool fill);
+};
+
+class UiGridContainer : public UiContainerPrivate {
+public:
+    QGridLayout *grid;
+    int x = 0;
+    int y = 0;
+    
+    UiGridContainer(QGridLayout *grid, int margin, int columnspacing, int rowspacing);
+    
+    virtual void add(QWidget *widget, bool fill);
+};
 
 
 #endif	/* CONTAINER_H */

mercurial