ui/win32/container.h

changeset 112
c3f2f16fa4b8
parent 108
77254bd6dccb
equal deleted inserted replaced
111:81c4f73236a4 112:c3f2f16fa4b8
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 W32Size ui_grid_layout_get_preferred_size(W32Widget *widget);
96
97 UiContainerX* ui_box_container_create(UiObject *obj, HWND hwnd, UiBoxOrientation orientation, short spacing, GridEdgeInsets padding);
98 void ui_box_container_add(UiContainerPrivate *ctn, W32Widget *widget, UiLayout *layout);
99
100 UiContainerX* ui_grid_container_create(
101 UiObject *obj,
102 HWND hwnd,
103 short columnspacing,
104 short rowspacing,
105 GridEdgeInsets padding);
106 void ui_grid_container_add(UiContainerPrivate *ctn, W32Widget *widget, UiLayout *layout);
107
108 #ifdef __cplusplus
109 }
110 #endif
111
91 #endif //CONTAINER_H 112 #endif //CONTAINER_H

mercurial