0 | 11 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,177 @@ |
1 |
+/* |
|
2 |
+ * widgetlib.h |
|
3 |
+ * |
|
4 |
+ * UI toolkit for C modelled after Tk |
|
5 |
+ * |
|
6 |
+ * HEADER FILE |
|
7 |
+ * |
|
8 |
+ * Author: Dario Rodriguez antartica@whereismybit.com |
|
9 |
+ * This program in licensed under the terms of the MIT/X license. |
|
10 |
+ */ |
|
11 |
+ |
|
12 |
+#ifndef WIDGETLIB_H |
|
13 |
+#define WIDGETLIB_H |
|
14 |
+ |
|
15 |
+#include <stdarg.h> |
|
16 |
+ |
|
17 |
+typedef struct xywh_t { |
|
18 |
+ int x; |
|
19 |
+ int y; |
|
20 |
+ int w; |
|
21 |
+ int h; |
|
22 |
+} xywh_t; |
|
23 |
+ |
|
24 |
+typedef struct wh_t { |
|
25 |
+ int w; |
|
26 |
+ int h; |
|
27 |
+} wh_t; |
|
28 |
+ |
|
29 |
+typedef enum wianchor_t { |
|
30 |
+ anchor_center=0, |
|
31 |
+ anchor_nw, |
|
32 |
+ anchor_n, |
|
33 |
+ anchor_ne, |
|
34 |
+ anchor_w, |
|
35 |
+ anchor_e, |
|
36 |
+ anchor_sw, |
|
37 |
+ anchor_s, |
|
38 |
+ anchor_se, |
|
39 |
+} wianchor_t; |
|
40 |
+ |
|
41 |
+typedef enum wifill_t { |
|
42 |
+ fill_none=0, |
|
43 |
+ fill_x, |
|
44 |
+ fill_y, |
|
45 |
+ fill_both, |
|
46 |
+} wifill_t; |
|
47 |
+ |
|
48 |
+typedef struct wiplace_t { |
|
49 |
+ int enabled; |
|
50 |
+ xywh_t xywh; |
|
51 |
+ int flag_whfromparent; |
|
52 |
+} wiplace_t; |
|
53 |
+ |
|
54 |
+typedef struct wiconf_t { |
|
55 |
+ char *name; |
|
56 |
+ int sizevalue; |
|
57 |
+ int usedvalue; |
|
58 |
+ char *value; |
|
59 |
+ int flag_var; /* value contains autovarname */ |
|
60 |
+ int flag_image; /* images are also vars (flag_var should also be set) */ |
|
61 |
+ wh_t image; |
|
62 |
+ void (*callback)(void *wi, char *toplevelname, char *widgetname, char *confname); |
|
63 |
+} wiconf_t; |
|
64 |
+ |
|
65 |
+typedef struct widget_t { |
|
66 |
+ int sizename; |
|
67 |
+ int usedname; |
|
68 |
+ char *name; |
|
69 |
+ char *classname; |
|
70 |
+ int sizeclassdata; |
|
71 |
+ char *classdata; |
|
72 |
+ wiplace_t place; |
|
73 |
+ xywh_t box; |
|
74 |
+ xywh_t padipadbox; |
|
75 |
+ xywh_t displaybox; |
|
76 |
+ int pad_left; |
|
77 |
+ int pad_right; |
|
78 |
+ int pad_top; |
|
79 |
+ int pad_bottom; |
|
80 |
+ int ipad_left; |
|
81 |
+ int ipad_right; |
|
82 |
+ int ipad_top; |
|
83 |
+ int ipad_bottom; |
|
84 |
+ wianchor_t anchor; |
|
85 |
+ wifill_t fill; |
|
86 |
+ int sizeconfs; |
|
87 |
+ int usedconfs; |
|
88 |
+ wiconf_t **confs; |
|
89 |
+} widget_t; |
|
90 |
+ |
|
91 |
+typedef struct witoplevel_t { |
|
92 |
+ char *toplevelname; |
|
93 |
+ widget_t rootwidget; |
|
94 |
+ int sizewidgets; |
|
95 |
+ int usedwidgets; |
|
96 |
+ widget_t **widgets; |
|
97 |
+ int sizebufwidgets; |
|
98 |
+ int usedbufwidgets; |
|
99 |
+ widget_t **bufwidgets; |
|
100 |
+ int sizeconfs; |
|
101 |
+ int usedconfs; |
|
102 |
+ wiconf_t **confs; |
|
103 |
+} witoplevel_t; |
|
104 |
+ |
|
105 |
+typedef struct wialias_t { |
|
106 |
+ char *alias; |
|
107 |
+ int sizepath; |
|
108 |
+ int usedpath; |
|
109 |
+ char *path; |
|
110 |
+} wialias_t; |
|
111 |
+ |
|
112 |
+typedef struct wivar_t { |
|
113 |
+ char *autovarname; |
|
114 |
+ int sizevardata; |
|
115 |
+ int usedvardata; |
|
116 |
+ char *vardata; |
|
117 |
+} wivar_t; |
|
118 |
+ |
|
119 |
+typedef enum wiclassoptype_t { |
|
120 |
+ classop_initclass=0, |
|
121 |
+ classop_freeclass, |
|
122 |
+ classop_initinstance, |
|
123 |
+ classop_freeinstance, |
|
124 |
+ classop_render, |
|
125 |
+} wiclassoptype_t; |
|
126 |
+ |
|
127 |
+typedef struct wiclassop_t { |
|
128 |
+ wiclassoptype_t op; |
|
129 |
+} wiclassop_t; |
|
130 |
+ |
|
131 |
+typedef struct wiclass_t { |
|
132 |
+ char *classname; |
|
133 |
+ int sizeclassglobaldata; |
|
134 |
+ char *classglobaldata; |
|
135 |
+ void (*classcallback)(void *wi, struct wiclass_t *cl, widget_t *widget, wiclassop_t *op); |
|
136 |
+} wiclass_t; |
|
137 |
+ |
|
138 |
+typedef struct wi_t { |
|
139 |
+ int sizeclasses; |
|
140 |
+ int usedclasses; |
|
141 |
+ wiclass_t *classes; |
|
142 |
+ int sizetoplevels; |
|
143 |
+ int usedltoplevels; |
|
144 |
+ witoplevel_t *toplevels; |
|
145 |
+ int currenttoplevel; |
|
146 |
+ int sizealiases; |
|
147 |
+ int usedaliases; |
|
148 |
+ wialias_t **aliases; |
|
149 |
+ int sizevars; |
|
150 |
+ int usedvars; |
|
151 |
+ wivar_t **vars; |
|
152 |
+} wi_t; |
|
153 |
+ |
|
154 |
+wi_t wi_init(void); |
|
155 |
+void wi_free(wi_t *wi); |
|
156 |
+ |
|
157 |
+int wi_class_register(wi_t *wi, char *classname, void (*classcallback)(void *wi, wiclass_t *cl, widget_t *widget, wiclassop_t *op)); |
|
158 |
+int wi_class_unregister(wi_t *wi, char *classname); |
|
159 |
+ |
|
160 |
+int wi_toplevel_set(wi_t *wi, char *name); |
|
161 |
+int wi_toplevel_destroy(wi_t *wi, char *name); |
|
162 |
+ |
|
163 |
+char *wi_add(wi_t *wi, char *debugfile, int debugline, char *class, char *path, char *format,...); |
|
164 |
+char *wi_config(wi_t *wi, char *debugfile, int debugline, char *path, char *format,...); |
|
165 |
+int wi_pack(wi_t *wi, char *debugfile, int debugline, char *path, char *format,...); |
|
166 |
+int wi_destroy(wi_t *wi, char *path); |
|
167 |
+ |
|
168 |
+int wi_alias_set(wi_t *wi, char *alias, char *path); |
|
169 |
+int wi_alias_unset(wi_t *wi, char *alias); |
|
170 |
+ |
|
171 |
+int wi_tree_move(wi_t *wi, char *path, char *newparent); |
|
172 |
+ |
|
173 |
+int wi_var_updated(wi_t *wi, char *vardata, int sizevardata); |
|
174 |
+int wi_var_destroy(wi_t *wi, char *vardata, int sizevardata); |
|
175 |
+ |
|
176 |
+#endif |
|
177 |
+ |