1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #ifndef CONTAINER_H
30 #define CONTAINER_H
31
32 #include "../ui/toolkit.h"
33 #include "../ui/container.h"
34 #include <string.h>
35
36 #include <cx/allocator.h>
37 #include <cx/hash_map.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 #define ui_reset_layout(layout) memset(&(layout),
0,
sizeof(UiLayout))
44 #define ui_lb2bool(b) ((b) ==
UI_LAYOUT_TRUE ?
TRUE :
FALSE)
45 #define ui_bool2lb(b) ((b) ?
UI_LAYOUT_TRUE :
UI_LAYOUT_FALSE)
46
47 typedef void (*ui_container_add_f)(UiContainer*, GtkWidget*, UiBool);
48
49 typedef struct UiDocumentView UiDocumentView;
50
51 typedef struct UiLayout UiLayout;
52 typedef enum UiLayoutBool UiLayoutBool;
53
54 enum UiLayoutBool {
55 UI_LAYOUT_UNDEFINED =
0,
56 UI_LAYOUT_TRUE,
57 UI_LAYOUT_FALSE,
58 };
59
60 struct UiLayout {
61 UiLayoutBool fill;
62 UiBool newline;
63 char *label;
64 UiBool hexpand;
65 UiBool vexpand;
66 UiBool hfill;
67 UiBool vfill;
68 int width;
69 int colspan;
70 int rowspan;
71 };
72
73 struct UiContainer {
74 GtkWidget *widget;
75 UIMENU menu;
76 GtkWidget *current;
77
78 void (*add)(UiContainer*, GtkWidget*, UiBool);
79 UiLayout layout;
80
81 int close;
82 };
83
84 typedef struct UiBoxContainer {
85 UiContainer container;
86 UiSubContainerType type;
87 UiBool has_fill;
88 } UiBoxContainer;
89
90 typedef struct UiGridContainer {
91 UiContainer container;
92 int x;
93 int y;
94 #ifdef UI_GTK2
95 int width;
96 int height;
97 #endif
98 } UiGridContainer;
99
100
101
102
103
104
105
106
107
108
109
110 typedef struct UiTabViewContainer {
111 UiContainer container;
112 } UiTabViewContainer;
113
114 typedef void (*ui_select_tab_func)(
UIWIDGET widget,
int tab);
115 typedef void (*ui_add_tab_func)(
UIWIDGET widget,
int index,
const char *name,
UIWIDGET child);
116
117 typedef struct UiGtkTabView {
118 UiObject *obj;
119 GtkWidget *widget;
120 ui_select_tab_func select_tab;
121 ui_select_tab_func remove_tab;
122 ui_add_tab_func add_tab;
123 UiSubContainerType subcontainer;
124 int margin;
125 int spacing;
126 int columnspacing;
127 int rowspacing;
128 } UiGtkTabView;
129
130 typedef struct UiHeaderbarContainer {
131 UiContainer container;
132 GtkWidget *centerbox;
133 int part;
134 UiHeaderbarAlternative alternative;
135 } UiHeaderbarContainer;
136
137 typedef struct UiGtkItemListContainer {
138 UiObject *parent;
139 GtkWidget *widget;
140 UiContainer *container;
141 void (*create_ui)(UiObject *,
int,
void *,
void *);
142 void *userdata;
143 UiSubContainerType subcontainer;
144 CxMap *current_items;
145 int margin;
146 int spacing;
147 int columnspacing;
148 int rowspacing;
149 bool remove_items;
150 } UiGtkItemListContainer;
151
152 GtkWidget* ui_gtk_vbox_new(
int spacing);
153 GtkWidget* ui_gtk_hbox_new(
int spacing);
154
155 GtkWidget* ui_subcontainer_create(
156 UiSubContainerType type,
157 UiObject *newobj,
158 int spacing,
159 int columnspacing,
160 int rowspacing,
161 int margin);
162
163 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame);
164 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
165
166 GtkWidget* ui_box_set_margin(GtkWidget *box,
int margin);
167 UIWIDGET ui_box_create(UiObject *obj, UiContainerArgs args, UiSubContainerType type);
168
169 UiContainer* ui_box_container(UiObject *obj, GtkWidget *box, UiSubContainerType type);
170 void ui_box_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
171
172 GtkWidget* ui_create_grid_widget(
int colspacing,
int rowspacing);
173 UiContainer* ui_grid_container(UiObject *obj, GtkWidget *grid);
174 void ui_grid_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
175
176 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame);
177 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
178
179 UiContainer* ui_expander_container(UiObject *obj, GtkWidget *expander);
180 void ui_expander_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
181
182 UiContainer* ui_scrolledwindow_container(UiObject *obj, GtkWidget *scrolledwindow);
183 void ui_scrolledwindow_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
184
185 UiContainer* ui_tabview_container(UiObject *obj, GtkWidget *tabview);
186 void ui_tabview_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
187
188 void ui_paned_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
189
190 void ui_split_container_add1(UiContainer *ct, GtkWidget *widget, UiBool fill);
191 void ui_split_container_add2(UiContainer *ct, GtkWidget *widget, UiBool fill);
192
193 UiGtkTabView* ui_widget_get_tabview_data(
UIWIDGET tabview);
194
195 void ui_gtk_notebook_select_tab(GtkWidget *widget,
int tab);
196
197 #if GTK_CHECK_VERSION(
3,
10,
0)
198 UiContainer* ui_headerbar_container(UiObject *obj, GtkWidget *headerbar);
199 void ui_headerbar_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
200 #endif
201
202 UiContainer* ui_headerbar_fallback_container(UiObject *obj, GtkWidget *headerbar);
203 void ui_headerbar_fallback_container_add(UiContainer *ct, GtkWidget *widget, UiBool fill);
204
205 #ifdef __cplusplus
206 }
207 #endif
208
209 #endif
210
211