ui/win32/container.h

changeset 112
c3f2f16fa4b8
parent 108
77254bd6dccb
--- a/ui/win32/container.h	Sat Oct 04 14:54:25 2025 +0200
+++ b/ui/win32/container.h	Sun Oct 19 21:20:08 2025 +0200
@@ -1,5 +1,5 @@
 /*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
  * Copyright 2025 Olaf Wintermann. All rights reserved.
  *
@@ -27,36 +27,19 @@
  */
 
 #ifndef CONTAINER_H
-
-#include "../ui/container.h"
-
 #define CONTAINER_H
 
-#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
-
-typedef struct UiLayout UiLayout;
+#include "../ui/container.h"
+#include "toolkit.h"
+#include "grid.h"
 
-struct UiLayout {
-    UiBool       fill;
-    UiBool       newline;
-    char         *label;
-    UiBool       hexpand;
-    UiBool       vexpand;
-    UiBool       hfill;
-    UiBool       vfill;
-    UiBool       override_defaults;
-    int          width;
-    int          colspan;
-    int          rowspan;
-};
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct UiContainerPrivate    UiContainerPrivate;
+typedef struct UiGridLayoutContainer UiGridLayoutContainer;
+typedef struct UiBoxContainer        UiBoxContainer;
 
 enum UiBoxOrientation {
     UI_BOX_VERTICAL = 0,
@@ -70,8 +53,6 @@
 };
 typedef enum UiContainerType UiContainerType;
 
-typedef struct UiContainerPrivate UiContainerPrivate;
-
 typedef struct UiRect {
     int x;
     int y;
@@ -82,10 +63,50 @@
 
 struct UiContainerPrivate {
     UiContainerX    container;
-    void            (*prepare)(UiContainerPrivate*, UiRect*);
-    void            (*add)(UiContainerPrivate*, UiRect*, W32Widget*);
+    HWND            (*parent)(UiContainerPrivate*);
+    void            (*add)(UiContainerPrivate*, W32Widget*, UiLayout*);
     UiContainerType type;
-    UiLayout        layout;
+    HWND            hwnd;
+};
+
+struct UiBoxContainer {
+    UiContainerPrivate container;
+    UiGridLayout *layout;
+    UiBoxOrientation orientation;
+    int x;
+    int y;
 };
 
+struct UiGridLayoutContainer {
+    UiContainerPrivate container;
+    UiGridLayout *layout;
+    int x;
+    int y;
+    UiBool def_hexpand;
+    UiBool def_vexpand;
+    UiBool def_hfill;
+    UiBool def_vfill;
+};
+
+UiContainerPrivate* ui_obj_container(UiObject *obj);
+HWND ui_container_get_parent(UiContainerPrivate *ctn);
+void ui_container_add(UiContainerPrivate *ctn, W32Widget *widget, UiLayout *layout);
+
+W32Size ui_grid_layout_get_preferred_size(W32Widget *widget);
+
+UiContainerX* ui_box_container_create(UiObject *obj, HWND hwnd, UiBoxOrientation orientation, short spacing, GridEdgeInsets padding);
+void ui_box_container_add(UiContainerPrivate *ctn, W32Widget *widget, UiLayout *layout);
+
+UiContainerX* ui_grid_container_create(
+    UiObject *obj,
+    HWND hwnd,
+    short columnspacing,
+    short rowspacing,
+    GridEdgeInsets padding);
+void ui_grid_container_add(UiContainerPrivate *ctn, W32Widget *widget, UiLayout *layout);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif //CONTAINER_H

mercurial