b6399a238a37a3fb5f0f11265522d6cda1c67dc4
[sdk] / bindings / c / ecere.h
1 // Preprocessor directives can be added at the beginning (Can't store them in AST)
2
3 /****************************************************************************
4 ===========================================================================
5    Ecere Module
6 ===========================================================================
7 ****************************************************************************/
8 #if !defined(__ECERE_H__)
9 #define __ECERE_H__
10
11 #ifdef __cplusplus
12 extern "C"
13 {
14 #endif
15
16 #include "eC.h"
17
18 #define ECERE_APP_INTRO(c) \
19       APP_INTRO \
20       ecere_init(app); \
21       loadTranslatedStrings(null, MODULE_NAME); \
22       Instance_evolve(&app, class_ ## c);
23
24 #define ECERE_APP_OUTRO \
25       unloadTranslatedStrings(MODULE_NAME); \
26       APP_OUTRO
27
28 #define GUIAPP_INTRO ECERE_APP_INTRO(GuiApplication)
29
30 // GENERATED:
31
32 #define Class           eC_Class
33 #define Instance        eC_Instance
34 #define Module          eC_Module
35
36 #define Surface         eC_Surface
37 #define FontResource    eC_FontResource
38
39 #define Window          eC_Window
40 #define Button          eC_Button
41 #define Label           eC_Label
42 #define MessageBox      eC_MessageBox
43 #define GuiApplication  eC_GuiApplication
44
45 // Virtual Method Calls
46 #define Window_onCreate(x)    ({  eC_Window i = x; \
47                                   bool (* method)(eC_Window) = (bool (*)(eC_Instance))(i ? i->_vTbl : class_Window->_vTbl)[Window_onCreate_vTblID]; \
48                                   method ? method(i) : true; })
49
50 #define Window_onRedraw(x, s) ({  eC_Window i = x; \
51                                   void (* method)(eC_Window, eC_Surface) = (void (*)(eC_Window, eC_Surface))(i ? i->_vTbl : class_Window->_vTbl)[Window_onRedraw_vTblID]; \
52                                   if(method) method(i, s); })
53
54 #define Button_notifyClicked(t, m, b, x, y, mods)    ({ eC_Button i = t; \
55                                                       bool (* method)(eC_Window, eC_Button, int, int, Modifiers) = (bool (*)(eC_Window, eC_Button, int, int, Modifiers))(i ? i->_vTbl : class_Button->_vTbl)[Button_notifyClicked_vTblID]; \
56                                                       method ? method(m, b, x, y, mods) : true; })
57
58 // Bit Class Member Access
59 #define COLOR_r_MASK       0x00FF0000
60 #define COLOR_r_SHIFT      16
61 #define COLOR_g_MASK       0x0000FF00
62 #define COLOR_g_SHIFT      8
63 #define COLOR_b_MASK       0x000000FF
64 #define COLOR_b_SHIFT      0
65
66 #define COLOR(r, g, b)     ((((Color)(r)) << COLOR_r_SHIFT) | ((Color)(g) << COLOR_g_SHIFT) | ((Color)(b)) << COLOR_b_SHIFT)
67 #define COLOR_r(x)         ((((Color)(x)) & COLOR_r_MASK) >> COLOR_r_SHIFT)
68 #define COLOR_g(x)         ((((Color)(x)) & COLOR_g_MASK) >> COLOR_g_SHIFT)
69 #define COLOR_b(x)         ((((Color)(x)) & COLOR_b_MASK) >> COLOR_b_SHIFT)
70 #define COLOR_SET_r(x, r)  (x) = ((Color)(x) & ~((Color)COLOR_r_MASK)) | (((Color)(r)) << COLOR_r_SHIFT)
71 #define COLOR_SET_g(x, g)  (x) = ((Color)(x) & ~((Color)COLOR_g_MASK)) | (((Color)(g)) << COLOR_g_SHIFT)
72 #define COLOR_SET_b(x, b)  (x) = ((Color)(x) & ~((Color)COLOR_b_MASK)) | (((Color)(b)) << COLOR_b_SHIFT)
73
74 #define BORDERBITS_contour_mask  0x00000001
75 #define BORDERBITS_contour_shift 0
76 #define BORDERBITS_fixed_mask    0x00000002
77 #define BORDERBITS_fixed_shift   1
78 #define BORDERBITS_sizable_mask  0x00000004
79 #define BORDERBITS_sizable_shift 2
80 #define BORDERBITS_deep_mask     0x00000008
81 #define BORDERBITS_deep__shift   3
82 #define BORDERBITS_bevel_mask    0x00000010
83 #define BORDERBITS_bevel_shift   4
84 #define BORDERBITS_thin_mask     0x00000020
85 #define BORDERBITS_thin_shift    5
86
87 #define BORDERBITS_contour(x)    ((((BorderBits)(x)) & BORDERBITS_contour_MASK) >> BORDERBITS_contours_SHIFT)
88 #define BORDERBITS_fixed(x)      ((((BorderBits)(x)) & BORDERBITS_fixed_MASK) >> BORDERBITS_fixed_SHIFT)
89 #define BORDERBITS_sizable(x)    ((((BorderBits)(x)) & BORDERBITS_sizable_MASK) >> BORDERBITS_sizable_SHIFT)
90 #define BORDERBITS_deep(x)       ((((BorderBits)(x)) & BORDERBITS_deep_MASK) >> BORDERBITS_deep_SHIFT)
91 #define BORDERBITS_bevel(x)      ((((BorderBits)(x)) & BORDERBITS_bevel_MASK) >> BORDERBITS_bevel_SHIFT)
92 #define BORDERBITS_thin(x)       ((((BorderBits)(x)) & BORDERBITS_thin_MASK) >> BORDERBITS_thin_SHIFT)
93
94 // Structs
95 struct Size { int w, h; };
96 struct Point { int x, y; };
97
98 // Struct Typedefs
99 typedef struct Size Size;
100 typedef struct Point Point;
101
102 /****************************************************************************
103    ecere::gfx Namespace
104 ****************************************************************************/
105 // Color Bit Class
106 typedef uint32 Color;
107
108 // System Color Enum
109 #if !CPP11
110 typedef Color SystemColor;
111 #endif
112
113 enum SystemColor
114 #if CPP11
115    : Color
116 #endif
117 {
118    formColor = COLOR(229, 234, 245)
119 };
120
121 ///////////// Surface Class /////////////////////////////////////////////////
122
123 typedef Instance Surface;
124
125 extern Class * class_Surface;
126
127 // Methods
128 extern Method * method_Surface_writeTextf;
129
130 extern void (* Surface_writeTextf)(Surface s, int x, int y, const char * format, ...);
131
132
133 ///////////// FontResource Class /////////////////////////////////////////////////
134 extern Class * class_FontResource;
135
136 typedef Instance FontResource;
137
138 // Properties
139 extern Property * property_FontResource_faceName;
140 extern Property * property_FontResource_size;
141
142 extern void (* FontResource_set_faceName)(FontResource f, constString v);
143 extern constString (* FontResource_get_faceName)(FontResource f);
144
145 extern void (* FontResource_set_size)(FontResource f, float v);
146 extern float (* FontResource_get_size)(FontResource f);
147
148 extern void (* FontResource_set_bold)(FontResource f, bool v);
149 extern bool (* FontResource_get_bold)(FontResource f);
150
151 extern void (* FontResource_set_italic)(FontResource f, bool v);
152 extern bool (* FontResource_get_italic)(FontResource f);
153
154 /****************************************************************************
155    ecere::gui Namespace
156 ****************************************************************************/
157
158 // Bit Class Typedefs
159 typedef uint32 Modifiers;
160 typedef uint32 BorderBits;
161
162 // Enum Typedefs
163 #if !CPP11
164 typedef BorderBits BorderStyle;
165 #endif
166
167 #if !CPP11
168 typedef int64 DialogResult;
169 #endif
170
171 // Enumerations
172 enum DialogResult
173 #if CPP11
174    : int64
175 #endif
176 {
177    cancel = 0,
178    yes = 1,
179    no = 2,
180    ok = 3
181 };
182
183 enum BorderStyle
184 #if CPP11
185    : BorderBits
186 #endif
187 {
188    none,
189    contour      = BORDERBITS_contour_mask,
190    fixed        = BORDERBITS_fixed_mask | contour,
191    sizable      = BORDERBITS_sizable_mask | fixed,
192    thin         = BORDERBITS_thin_mask | fixed,
193    sizableThin  = BORDERBITS_sizable_mask | thin,
194    deep         = BORDERBITS_deep_mask,
195    bevel        = BORDERBITS_bevel_mask,
196    sizableDeep  = sizable|deep,
197    sizableBevel = sizable|bevel,
198    fixedDeep    = fixed|deep,
199    fixedBevel   = fixed|bevel,
200    deepContour  = deep|contour
201 };
202
203 ///////////// Window Class /////////////////////////////////////////////////
204 typedef Instance Window;
205
206 extern Class * class_Window;
207
208 // Properties
209 extern Property * property_Window_caption;
210 extern Property * property_Window_caption;
211 extern Property * property_Window_size;
212 extern Property * property_Window_clientSize;
213 extern Property * property_Window_hasClose;
214 extern Property * property_Window_hasMinimize;
215 extern Property * property_Window_hasMaximize;
216 extern Property * property_Window_borderStyle;
217 extern Property * property_Window_background;
218 extern Property * property_Window_parent;
219 extern Property * property_Window_position;
220 extern Property * property_Window_font;
221
222 extern void (* Window_set_borderStyle)(Window w, BorderStyle v);
223 extern BorderStyle (* Window_get_borderStyle)(Window w);
224
225 extern void (* Window_set_size)(Window w, const Size * v);
226 extern void (* Window_get_size)(Window w, Size * v);
227
228 extern void (* Window_set_clientSize)(Window w, const Size * v);
229 extern void (* Window_get_clientSize)(Window w, Size * v);
230
231 extern void (* Window_set_hasClose)(Window w, bool v);
232 extern bool (* Window_get_hasClose)(Window w);
233
234 extern void (* Window_set_hasMaximize)(Window w, bool v);
235 extern bool (* Window_get_hasMaximize)(Window w);
236
237 extern void (* Window_set_hasMinimize)(Window w, bool v);
238 extern bool (* Window_get_hasMinimize)(Window w);
239
240 extern void (* Window_set_parent)(Window w, Window v);
241 extern Window (* Window_get_parent)(Window w);
242
243 extern void (* Window_set_background)(Window w, Color v);
244 extern Color (* Window_get_background)(Window w);
245
246 extern void (* Window_set_position)(Window w, const Point * v);
247 extern void (* Window_get_position)(Window w, Point * v);
248
249 extern void (* Window_set_font)(Window w, FontResource v);
250 extern FontResource (* Window_get_font)(Window w);
251
252 extern void (* Window_set_caption)(Window w, constString v);
253 extern constString (* Window_get_caption)(Window w);
254
255 // Methods
256 extern DialogResult (* Window_modal)(Window);
257
258 extern Method * method_Window_modal;
259 extern Method * method_Window_onCreate;
260
261 extern int Window_onCreate_vTblID;
262 extern int Window_onRedraw_vTblID;
263
264 ///////////// Label Class /////////////////////////////////////////////////
265 extern Class * class_Label;
266
267 typedef Instance Label;
268
269 ///////////// MessageBox Class /////////////////////////////////////////////////
270 typedef Window MessageBox;
271
272 extern Class * class_MessageBox;
273
274 // Properties
275 extern Property * property_MessageBox_contents;
276
277 extern void (* MessageBox_set_contents)(MessageBox m, constString v);
278 extern constString (* MessageBox_get_contents)(MessageBox m);
279
280 ///////////// Button Class /////////////////////////////////////////////////
281 typedef Window Button;
282
283 extern Class * class_Button;
284
285 // Method IDs
286 extern int Button_notifyClicked_vTblID;
287
288
289 extern Class * class_ToolButton;
290
291 ///////////// GuiApplication Class /////////////////////////////////////////////////
292 extern Class * class_GuiApplication;
293
294 typedef Instance GuiApplication;
295
296 Module ecere_init(Module fromModule);
297
298 #ifdef __cplusplus
299    #undef Button
300    #undef MessageBox
301    #undef Label
302    #undef Window
303    #undef GuiApplication
304
305    #undef FontResource
306    #undef Surface
307
308    #undef Module
309    #undef Class
310    #undef Instance
311 };
312 #endif
313
314 #endif