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 UI_TREE_H
30 #define UI_TREE_H
31
32 #include "toolkit.h"
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 typedef struct UiModel UiModel;
39 typedef struct UiListCallbacks UiListCallbacks;
40 typedef struct UiListDnd UiListDnd;
41
42 typedef struct UiListArgs UiListArgs;
43 typedef struct UiSourceListArgs UiSourceListArgs;
44
45 typedef struct UiSubList UiSubList;
46 typedef struct UiSubListItem UiSubListItem;
47
48 typedef enum UiModelType {
49 UI_STRING =
0,
50 UI_STRING_FREE,
51 UI_INTEGER,
52 UI_ICON,
53 UI_ICON_TEXT,
54 UI_ICON_TEXT_FREE
55 } UiModelType;
56
57 struct UiModel {
58
59
60
61 int columns;
62
63
64
65
66
67 UiModelType *types;
68
69
70
71
72
73 char **titles;
74
75
76
77
78 int *columnsize;
79
80
81
82
83
84
85
86 void*(*getvalue)(
void*,
int);
87 };
88
89 struct UiListCallbacks {
90
91
92
93 ui_callback activate;
94
95
96
97
98 ui_callback selection;
99
100
101
102
103 void *userdata;
104 };
105
106 struct UiListArgs {
107 UiTri fill;
108 UiBool hexpand;
109 UiBool vexpand;
110 UiBool hfill;
111 UiBool vfill;
112 int colspan;
113 int rowspan;
114 const char *name;
115 const char *style_class;
116
117 UiList* list;
118 const char* varname;
119 UiModel* model;
120 ui_getvaluefunc getvalue;
121 ui_callback onactivate;
122 void* onactivatedata;
123 ui_callback onselection;
124 void* onselectiondata;
125 ui_callback ondragstart;
126 void* ondragstartdata;
127 ui_callback ondragcomplete;
128 void* ondragcompletedata;
129 ui_callback ondrop;
130 void* ondropsdata;
131 UiBool multiselection;
132 UiMenuBuilder *contextmenu;
133
134 const int *groups;
135 };
136
137 typedef void (*ui_sublist_getvalue_func)(
void *sublist_userdata,
void *rowdata,
int index, UiSubListItem *item);
138
139 struct UiSubList {
140 UiList *value;
141 const char *varname;
142 const char *header;
143 UiBool separator;
144 void *userdata;
145 };
146
147
148
149
150
151
152 struct UiSubListItem {
153 char *icon;
154 char *label;
155 char *button_icon;
156 char *button_label;
157 char *badge;
158 void *eventdata;
159 };
160
161 struct UiSourceListArgs {
162 UiTri fill;
163 UiBool hexpand;
164 UiBool vexpand;
165 UiBool hfill;
166 UiBool vfill;
167 int colspan;
168 int rowspan;
169 const char *name;
170 const char *style_class;
171
172 const int *groups;
173
174
175
176
177
178
179
180
181 UiSubList *sublists;
182
183
184
185
186
187 size_t numsublists;
188
189
190
191
192
193 ui_sublist_getvalue_func getvalue;
194
195
196
197
198 ui_callback onactivate;
199 void *onactivatedata;
200
201
202
203
204 ui_callback onbuttonclick;
205 void *onbuttonclickdata;
206 };
207
208 #define UI_SUBLIST(...) (UiSubList){
__VA_ARGS__ }
209 #define UI_SUBLISTS(...) (UiSubList[]){
__VA_ARGS__, (UiSubList){
NULL,
NULL,
NULL,
0} }
210
211
212 UIEXPORT UiModel* ui_model(UiContext *ctx, ...);
213 UIEXPORT UiModel* ui_model_copy(UiContext *ctx, UiModel* model);
214 UIEXPORT void ui_model_free(UiContext *ctx, UiModel *mi);
215
216 #define ui_listview(obj, ...) ui_listview_create(obj, (UiListArgs) {
__VA_ARGS__ } )
217 #define ui_table(obj, ...) ui_table_create(obj, (UiListArgs) {
__VA_ARGS__ } )
218 #define ui_combobox(obj, ...) ui_combobox_create(obj, (UiListArgs) {
__VA_ARGS__ } )
219 #define ui_breadcrumbbar(obj, ...) ui_breadcrumbbar_create(obj, (UiListArgs) {
__VA_ARGS__ } )
220 #define ui_sourcelist(obj, ...) ui_sourcelist_create(obj, (UiSourceListArgs) {
__VA_ARGS__ } )
221
222 UIEXPORT UIWIDGET ui_listview_create(UiObject* obj, UiListArgs args);
223 UIEXPORT UIWIDGET ui_table_create(UiObject* obj, UiListArgs args);
224 UIEXPORT UIWIDGET ui_combobox_create(UiObject* obj, UiListArgs args);
225 UIEXPORT UIWIDGET ui_breadcrumbbar_create(UiObject* obj, UiListArgs args);
226
227 UIEXPORT UIWIDGET ui_sourcelist_create(UiObject *obj, UiSourceListArgs args);
228
229
230 #ifdef __cplusplus
231 }
232 #endif
233
234 #endif
235
236