f658d1ff8bd4c096aed64dd969e1de4a8651d85b
[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 #define BitmapResource  eC_BitmapResource
39
40 #define Window          eC_Window
41 #define DataBox         eC_DataBox
42 #define Button          eC_Button
43 #define Picture         eC_Picture
44 #define Label           eC_Label
45 #define MessageBox      eC_MessageBox
46 #define GuiApplication  eC_GuiApplication
47
48 // Virtual Method Calls
49 #define Window_onCreate(x)    ({  eC_Window i = x; \
50                                   bool (* method)(eC_Window) = (bool (*)(eC_Instance))(i ? i->_vTbl : class_Window->_vTbl)[Window_onCreate_vTblID]; \
51                                   method ? method(i) : true; })
52
53 #define Window_onRedraw(x, s) ({  eC_Window i = x; \
54                                   void (* method)(eC_Window, eC_Surface) = (void (*)(eC_Window, eC_Surface))(i ? i->_vTbl : class_Window->_vTbl)[Window_onRedraw_vTblID]; \
55                                   if(method) method(i, s); })
56
57 #define Button_notifyClicked(t, m, b, x, y, mods)    ({ eC_Button i = t; \
58                                                       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]; \
59                                                       method ? method(m, b, x, y, mods) : true; })
60
61 #define GuiApplication_cycle(x)    ({  eC_GuiApplication i = x; \
62                                   bool (* method)(eC_GuiApplication) = (bool (*)(eC_Instance))(i ? i->_vTbl : class_GuiApplication->_vTbl)[GuiApplication_cycle_vTblID]; \
63                                   method ? method(i) : true; })
64
65 // Bit Class Member Access
66 #define COLOR_r_MASK       0x00FF0000
67 #define COLOR_r_SHIFT      16
68 #define COLOR_g_MASK       0x0000FF00
69 #define COLOR_g_SHIFT      8
70 #define COLOR_b_MASK       0x000000FF
71 #define COLOR_b_SHIFT      0
72
73 #define COLOR(r, g, b)     ((((Color)(r)) << COLOR_r_SHIFT) | ((Color)(g) << COLOR_g_SHIFT) | ((Color)(b)) << COLOR_b_SHIFT)
74 #define COLOR_r(x)         ((((Color)(x)) & COLOR_r_MASK) >> COLOR_r_SHIFT)
75 #define COLOR_g(x)         ((((Color)(x)) & COLOR_g_MASK) >> COLOR_g_SHIFT)
76 #define COLOR_b(x)         ((((Color)(x)) & COLOR_b_MASK) >> COLOR_b_SHIFT)
77 #define COLOR_SET_r(x, r)  (x) = ((Color)(x) & ~((Color)COLOR_r_MASK)) | (((Color)(r)) << COLOR_r_SHIFT)
78 #define COLOR_SET_g(x, g)  (x) = ((Color)(x) & ~((Color)COLOR_g_MASK)) | (((Color)(g)) << COLOR_g_SHIFT)
79 #define COLOR_SET_b(x, b)  (x) = ((Color)(x) & ~((Color)COLOR_b_MASK)) | (((Color)(b)) << COLOR_b_SHIFT)
80
81 #define BORDERBITS_contour_MASK  0x00000001
82 #define BORDERBITS_contour_SHIFT 0
83 #define BORDERBITS_fixed_MASK    0x00000002
84 #define BORDERBITS_fixed_SHIFT   1
85 #define BORDERBITS_sizable_MASK  0x00000004
86 #define BORDERBITS_sizable_SHIFT 2
87 #define BORDERBITS_deep_MASK     0x00000008
88 #define BORDERBITS_deep_SHIFT    3
89 #define BORDERBITS_bevel_MASK    0x00000010
90 #define BORDERBITS_bevel_SHIFT   4
91 #define BORDERBITS_thin_MASK     0x00000020
92 #define BORDERBITS_thin_SHIFT    5
93
94 #define BORDERBITS_contour(x)    ((((BorderBits)(x)) & BORDERBITS_contour_MASK) >> BORDERBITS_contours_SHIFT)
95 #define BORDERBITS_fixed(x)      ((((BorderBits)(x)) & BORDERBITS_fixed_MASK) >> BORDERBITS_fixed_SHIFT)
96 #define BORDERBITS_sizable(x)    ((((BorderBits)(x)) & BORDERBITS_sizable_MASK) >> BORDERBITS_sizable_SHIFT)
97 #define BORDERBITS_deep(x)       ((((BorderBits)(x)) & BORDERBITS_deep_MASK) >> BORDERBITS_deep_SHIFT)
98 #define BORDERBITS_bevel(x)      ((((BorderBits)(x)) & BORDERBITS_bevel_MASK) >> BORDERBITS_bevel_SHIFT)
99 #define BORDERBITS_thin(x)       ((((BorderBits)(x)) & BORDERBITS_thin_MASK) >> BORDERBITS_thin_SHIFT)
100
101 // Structs
102 struct Size { int w, h; };
103 struct Point { int x, y; };
104
105 // Struct Typedefs
106 typedef struct Size Size;
107 typedef struct Point Point;
108
109 /****************************************************************************
110    ecere::gfx Namespace
111 ****************************************************************************/
112 // Color Bit Class
113 typedef uint32 Color;
114
115 // System Color Enum
116 #if !CPP11
117 typedef Color SystemColor;
118 #endif
119
120 #if CPP11
121 enum SystemColor : Color
122 #else
123 enum enum_Color
124 #endif
125 {
126    formColor = COLOR(229, 234, 245)
127 };
128
129 ///////////// Surface Class /////////////////////////////////////////////////
130
131 typedef Instance Surface;
132
133 extern Class * class_Surface;
134
135 // Methods
136 extern Method * method_Surface_writeTextf;
137
138 extern void (* Surface_writeTextf)(Surface s, int x, int y, const char * format, ...);
139
140
141 ///////////// FontResource Class /////////////////////////////////////////////////
142 extern Class * class_FontResource;
143
144 typedef Instance FontResource;
145
146 // Properties
147 extern Property * property_FontResource_faceName;
148 extern Property * property_FontResource_size;
149 extern Property * property_FontResource_outlineSize;
150 extern Property * property_FontResource_outlineFade;
151
152 extern void (* FontResource_set_faceName)(FontResource f, constString v);
153 extern constString (* FontResource_get_faceName)(FontResource f);
154
155 extern void (* FontResource_set_size)(FontResource f, float v);
156 extern float (* FontResource_get_size)(FontResource f);
157
158 extern void (* FontResource_set_outlineSize)(FontResource f, float v);
159 extern float (* FontResource_get_outlineSize)(FontResource f);
160
161 extern void (* FontResource_set_outlineFade)(FontResource f, float v);
162 extern float (* FontResource_get_outlineFade)(FontResource f);
163
164 extern void (* FontResource_set_bold)(FontResource f, bool v);
165 extern bool (* FontResource_get_bold)(FontResource f);
166
167 extern void (* FontResource_set_italic)(FontResource f, bool v);
168 extern bool (* FontResource_get_italic)(FontResource f);
169
170 ///////////// BitmapResource Class /////////////////////////////////////////////////
171 extern Class * class_BitmapResource;
172
173 typedef Instance BitmapResource;
174
175 // Properties
176 extern Property * property_BitmapResource_fileName;
177
178 extern void (* BitmapResource_set_fileName)(BitmapResource f, constString v);
179 extern constString (* BitmapResource_get_fileName)(BitmapResource f);
180
181 /****************************************************************************
182    ecere::gui Namespace
183 ****************************************************************************/
184
185 // Bit Class Typedefs
186 typedef uint32 Modifiers;
187 typedef uint32 BorderBits;
188
189 // Enum Typedefs
190 #if !CPP11
191 typedef BorderBits BorderStyle;
192 #endif
193
194 #if !CPP11
195 typedef int64 DialogResult;
196 #endif
197
198 // Enumerations
199
200 #if CPP11
201 enum DialogResult : int64
202 #else
203 enum enum_DialogResult
204 #endif
205 {
206    cancel = 0,
207    yes = 1,
208    no = 2,
209    ok = 3
210 };
211
212 #if CPP11
213 enum BorderStyle : BorderBits
214 #else
215 enum enum_BorderStyle
216 #endif
217 {
218    none,
219    contour      = BORDERBITS_contour_MASK,
220    fixed        = BORDERBITS_fixed_MASK | contour,
221    sizable      = BORDERBITS_sizable_MASK | fixed,
222    thin         = BORDERBITS_thin_MASK | fixed,
223    sizableThin  = BORDERBITS_sizable_MASK | thin,
224    deep         = BORDERBITS_deep_MASK,
225    bevel        = BORDERBITS_bevel_MASK,
226    sizableDeep  = sizable|deep,
227    sizableBevel = sizable|bevel,
228    fixedDeep    = fixed|deep,
229    fixedBevel   = fixed|bevel,
230    deepContour  = deep|contour
231 };
232
233 #if !defined(__cplusplus)
234 typedef enum AnchorValueType AnchorValueType;
235 #endif
236
237 enum AnchorValueType { /*none, */offset = 1, relative, middleRelative, cascade, vTiled, hTiled };
238
239 typedef struct AnchorValue AnchorValue;
240 struct AnchorValue
241 {
242    AnchorValueType type;
243
244    union
245    {
246       int distance;
247       float percent;
248    };
249 };
250
251 typedef struct MiddleAnchorValue MiddleAnchorValue;
252 struct MiddleAnchorValue
253 {
254    AnchorValueType type;
255
256    union
257    {
258       int distance;
259       float percent;
260    };
261 };
262
263 typedef struct Anchor Anchor;
264 struct Anchor
265 {
266    union { AnchorValue left; MiddleAnchorValue horz; };
267    union { AnchorValue top; MiddleAnchorValue vert; };
268    AnchorValue right, bottom;
269 };
270
271 ///////////// Window Class /////////////////////////////////////////////////
272 typedef Instance Window;
273
274 extern Class * class_Window;
275
276 // Properties
277 extern Property * property_Window_caption;
278 extern Property * property_Window_caption;
279 extern Property * property_Window_size;
280 extern Property * property_Window_clientSize;
281 extern Property * property_Window_hasClose;
282 extern Property * property_Window_hasMinimize;
283 extern Property * property_Window_hasMaximize;
284 extern Property * property_Window_borderStyle;
285 extern Property * property_Window_background;
286 extern Property * property_Window_parent;
287 extern Property * property_Window_position;
288 extern Property * property_Window_font;
289
290 extern void (* Window_set_borderStyle)(Window w, BorderStyle v);
291 extern BorderStyle (* Window_get_borderStyle)(Window w);
292
293 extern void (* Window_set_size)(Window w, const Size * v);
294 extern void (* Window_get_size)(Window w, Size * v);
295
296 extern void (* Window_set_clientSize)(Window w, const Size * v);
297 extern void (* Window_get_clientSize)(Window w, Size * v);
298
299 extern void (* Window_set_hasClose)(Window w, bool v);
300 extern bool (* Window_get_hasClose)(Window w);
301
302 extern void (* Window_set_hasMaximize)(Window w, bool v);
303 extern bool (* Window_get_hasMaximize)(Window w);
304
305 extern void (* Window_set_hasMinimize)(Window w, bool v);
306 extern bool (* Window_get_hasMinimize)(Window w);
307
308 extern void (* Window_set_parent)(Window w, Window v);
309 extern Window (* Window_get_parent)(Window w);
310
311 extern void (* Window_set_background)(Window w, Color v);
312 extern Color (* Window_get_background)(Window w);
313
314 extern void (* Window_set_foreground)(Window w, Color v);
315 extern Color (* Window_get_foreground)(Window w);
316
317 extern void (* Window_set_position)(Window w, const Point * v);
318 extern void (* Window_get_position)(Window w, Point * v);
319
320 extern void (* Window_set_anchor)(Window w, const Anchor * v);
321 extern void (* Window_get_anchor)(Window w, Anchor * v);
322
323 extern void (* Window_set_font)(Window w, FontResource v);
324 extern FontResource (* Window_get_font)(Window w);
325
326 extern void (* Window_set_caption)(Window w, constString v);
327 extern constString (* Window_get_caption)(Window w);
328
329 extern void (* Window_set_displayDriver)(Window w, constString v);
330 extern constString (* Window_get_displayDriver)(Window w);
331
332 // Methods
333 extern DialogResult (* Window_modal)(Window);
334
335 extern Method * method_Window_modal;
336
337 extern bool (* Window_create)(Window);
338
339 extern Method * method_Window_create;
340
341 extern Method * method_Window_onCreate;
342
343 extern int Window_onCreate_vTblID;
344 extern int Window_onRedraw_vTblID;
345
346 ///////////// Label Class /////////////////////////////////////////////////
347 extern Class * class_Label;
348
349 typedef Instance Label;
350
351 ///////////// MessageBox Class /////////////////////////////////////////////////
352 typedef Window MessageBox;
353
354 extern Class * class_MessageBox;
355
356 // Properties
357 extern Property * property_MessageBox_contents;
358
359 extern void (* MessageBox_set_contents)(MessageBox m, constString v);
360 extern constString (* MessageBox_get_contents)(MessageBox m);
361
362 ///////////// Button Class /////////////////////////////////////////////////
363 typedef Window Button;
364
365 extern Class * class_Button;
366
367 // Method IDs
368 extern int Button_notifyClicked_vTblID;
369
370
371 extern Class * class_ToolButton;
372
373 ///////////// Picture Class /////////////////////////////////////////////////
374 typedef Window Picture;
375
376 extern Class * class_Picture;
377
378 extern Property * property_Picture_image;
379
380 extern void (* Picture_set_image)(Picture p, BitmapResource v);
381 extern constString (* Picture_get_image)(Picture p);
382
383 ///////////// DataBox Class /////////////////////////////////////////////////
384 typedef Window DataBox;
385
386 ///////////// GuiApplication Class /////////////////////////////////////////////////
387 extern Class * class_GuiApplication;
388
389 typedef Instance GuiApplication;
390
391 extern int GuiApplication_cycle_vTblID;
392
393 Module ecere_init(Module fromModule);
394
395 #ifdef __cplusplus
396    #undef Button
397    #undef MessageBox
398    #undef Label
399    #undef Window
400    #undef DataBox
401    #undef Picture
402    #undef GuiApplication
403
404    #undef FontResource
405    #undef BitmapResource
406    #undef Surface
407
408    #undef Module
409    #undef Class
410    #undef Instance
411 };
412 #endif
413
414 #endif