ui/win32/container.h

changeset 827
eae5b817aa47
parent 818
8185cd761897
child 841
651cf2c59dd9
equal deleted inserted replaced
826:e596cfc1ca46 827:eae5b817aa47
1 /* 1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 * 3 *
4 * Copyright 2025 Olaf Wintermann. All rights reserved. 4 * Copyright 2025 Olaf Wintermann. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef CONTAINER_H 29 #ifndef CONTAINER_H
30 #define CONTAINER_H
30 31
31 #include "../ui/container.h" 32 #include "../ui/container.h"
33 #include "toolkit.h"
34 #include "grid.h"
32 35
33 #define CONTAINER_H 36 #ifdef __cplusplus
37 extern "C" {
38 #endif
34 39
35 #define UI_APPLY_LAYOUT(layout, args) \ 40 typedef struct UiContainerPrivate UiContainerPrivate;
36 layout.fill = args->fill; \ 41 typedef struct UiGridLayoutContainer UiGridLayoutContainer;
37 layout.hexpand = args->hexpand; \ 42 typedef struct UiBoxContainer UiBoxContainer;
38 layout.vexpand = args->vexpand; \
39 layout.hfill = args->hfill; \
40 layout.vfill = args->vfill; \
41 layout.override_defaults = args->override_defaults; \
42 layout.colspan = args->colspan; \
43 layout.rowspan = args->rowspan
44
45 typedef struct UiLayout UiLayout;
46
47 struct UiLayout {
48 UiBool fill;
49 UiBool newline;
50 char *label;
51 UiBool hexpand;
52 UiBool vexpand;
53 UiBool hfill;
54 UiBool vfill;
55 UiBool override_defaults;
56 int width;
57 int colspan;
58 int rowspan;
59 };
60 43
61 enum UiBoxOrientation { 44 enum UiBoxOrientation {
62 UI_BOX_VERTICAL = 0, 45 UI_BOX_VERTICAL = 0,
63 UI_BOX_HORIZONTAL 46 UI_BOX_HORIZONTAL
64 }; 47 };
68 UI_CONTAINER_GENERIC = 0, 51 UI_CONTAINER_GENERIC = 0,
69 UI_CONTAINER_TABVIEW 52 UI_CONTAINER_TABVIEW
70 }; 53 };
71 typedef enum UiContainerType UiContainerType; 54 typedef enum UiContainerType UiContainerType;
72 55
73 typedef struct UiContainerPrivate UiContainerPrivate;
74
75 typedef struct UiRect { 56 typedef struct UiRect {
76 int x; 57 int x;
77 int y; 58 int y;
78 int width; 59 int width;
79 int height; 60 int height;
80 } UiRect; 61 } UiRect;
81 62
82 63
83 struct UiContainerPrivate { 64 struct UiContainerPrivate {
84 UiContainerX container; 65 UiContainerX container;
85 void (*prepare)(UiContainerPrivate*, UiRect*); 66 HWND (*parent)(UiContainerPrivate*);
86 void (*add)(UiContainerPrivate*, UiRect*, W32Widget*); 67 void (*add)(UiContainerPrivate*, W32Widget*, UiLayout*);
87 UiContainerType type; 68 UiContainerType type;
88 UiLayout layout; 69 HWND hwnd;
89 }; 70 };
90 71
72 struct UiBoxContainer {
73 UiContainerPrivate container;
74 UiGridLayout *layout;
75 UiBoxOrientation orientation;
76 int x;
77 int y;
78 };
79
80 struct UiGridLayoutContainer {
81 UiContainerPrivate container;
82 UiGridLayout *layout;
83 int x;
84 int y;
85 UiBool def_hexpand;
86 UiBool def_vexpand;
87 UiBool def_hfill;
88 UiBool def_vfill;
89 };
90
91 UiContainerPrivate* ui_obj_container(UiObject *obj);
92 HWND ui_container_get_parent(UiContainerPrivate *ctn);
93 void ui_container_add(UiContainerPrivate *ctn, W32Widget *widget, UiLayout *layout);
94
95 UiContainerX* ui_box_container_create(UiObject *obj, HWND hwnd, UiBoxOrientation orientation, short spacing, GridEdgeInsets padding);
96 void ui_box_container_add(UiContainerPrivate *ctn, W32Widget *widget, UiLayout *layout);
97
98 UiContainerX* ui_grid_container_create(
99 UiObject *obj,
100 HWND hwnd,
101 short columnspacing,
102 short rowspacing,
103 GridEdgeInsets padding);
104 void ui_grid_container_add(UiContainerPrivate *ctn, W32Widget *widget, UiLayout *layout);
105
106 #ifdef __cplusplus
107 }
108 #endif
109
91 #endif //CONTAINER_H 110 #endif //CONTAINER_H

mercurial