1 // Preprocessor directives can be added at the beginning (Can't store them in AST)
3 /****************************************************************************
4 ===========================================================================
6 ===========================================================================
7 ****************************************************************************/
8 #if !defined(__ECERE_H__)
18 #define ECERE_APP_INTRO(c) \
21 loadTranslatedStrings(null, MODULE_NAME); \
22 Instance_evolve(&app, class_ ## c);
24 #define ECERE_APP_OUTRO \
25 unloadTranslatedStrings(MODULE_NAME); \
28 #define GUIAPP_INTRO ECERE_APP_INTRO(GuiApplication)
32 #define Class eC_Class
33 #define Instance eC_Instance
34 #define Module eC_Module
36 #define Surface eC_Surface
37 #define FontResource eC_FontResource
38 #define BitmapResource eC_BitmapResource
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
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; })
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); })
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; })
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; })
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
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)
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
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)
102 struct Size { int w, h; };
103 struct Point { int x, y; };
106 typedef struct Size Size;
107 typedef struct Point Point;
109 /****************************************************************************
111 ****************************************************************************/
113 typedef uint32 Color;
117 typedef Color SystemColor;
121 enum SystemColor : Color
126 formColor = COLOR(229, 234, 245)
129 ///////////// Surface Class /////////////////////////////////////////////////
131 typedef Instance Surface;
133 extern Class * class_Surface;
136 extern Method * method_Surface_writeTextf;
138 extern void (* Surface_writeTextf)(Surface s, int x, int y, const char * format, ...);
141 ///////////// FontResource Class /////////////////////////////////////////////////
142 extern Class * class_FontResource;
144 typedef Instance FontResource;
147 extern Property * property_FontResource_faceName;
148 extern Property * property_FontResource_size;
149 extern Property * property_FontResource_outlineSize;
150 extern Property * property_FontResource_outlineFade;
152 extern void (* FontResource_set_faceName)(FontResource f, constString v);
153 extern constString (* FontResource_get_faceName)(FontResource f);
155 extern void (* FontResource_set_size)(FontResource f, float v);
156 extern float (* FontResource_get_size)(FontResource f);
158 extern void (* FontResource_set_outlineSize)(FontResource f, float v);
159 extern float (* FontResource_get_outlineSize)(FontResource f);
161 extern void (* FontResource_set_outlineFade)(FontResource f, float v);
162 extern float (* FontResource_get_outlineFade)(FontResource f);
164 extern void (* FontResource_set_bold)(FontResource f, bool v);
165 extern bool (* FontResource_get_bold)(FontResource f);
167 extern void (* FontResource_set_italic)(FontResource f, bool v);
168 extern bool (* FontResource_get_italic)(FontResource f);
170 ///////////// BitmapResource Class /////////////////////////////////////////////////
171 extern Class * class_BitmapResource;
173 typedef Instance BitmapResource;
176 extern Property * property_BitmapResource_fileName;
178 extern void (* BitmapResource_set_fileName)(BitmapResource f, constString v);
179 extern constString (* BitmapResource_get_fileName)(BitmapResource f);
181 /****************************************************************************
183 ****************************************************************************/
185 // Bit Class Typedefs
186 typedef uint32 Modifiers;
187 typedef uint32 BorderBits;
191 typedef BorderBits BorderStyle;
195 typedef int64 DialogResult;
201 enum DialogResult : int64
203 enum enum_DialogResult
213 enum BorderStyle : BorderBits
215 enum enum_BorderStyle
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
233 #if !defined(__cplusplus)
234 typedef enum AnchorValueType AnchorValueType;
237 enum AnchorValueType { /*none, */offset = 1, relative, middleRelative, cascade, vTiled, hTiled };
239 typedef struct AnchorValue AnchorValue;
242 AnchorValueType type;
251 typedef struct MiddleAnchorValue MiddleAnchorValue;
252 struct MiddleAnchorValue
254 AnchorValueType type;
263 typedef struct Anchor Anchor;
266 union { AnchorValue left; MiddleAnchorValue horz; };
267 union { AnchorValue top; MiddleAnchorValue vert; };
268 AnchorValue right, bottom;
271 ///////////// Window Class /////////////////////////////////////////////////
272 typedef Instance Window;
274 extern Class * class_Window;
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;
290 extern void (* Window_set_borderStyle)(Window w, BorderStyle v);
291 extern BorderStyle (* Window_get_borderStyle)(Window w);
293 extern void (* Window_set_size)(Window w, const Size * v);
294 extern void (* Window_get_size)(Window w, Size * v);
296 extern void (* Window_set_clientSize)(Window w, const Size * v);
297 extern void (* Window_get_clientSize)(Window w, Size * v);
299 extern void (* Window_set_hasClose)(Window w, bool v);
300 extern bool (* Window_get_hasClose)(Window w);
302 extern void (* Window_set_hasMaximize)(Window w, bool v);
303 extern bool (* Window_get_hasMaximize)(Window w);
305 extern void (* Window_set_hasMinimize)(Window w, bool v);
306 extern bool (* Window_get_hasMinimize)(Window w);
308 extern void (* Window_set_parent)(Window w, Window v);
309 extern Window (* Window_get_parent)(Window w);
311 extern void (* Window_set_background)(Window w, Color v);
312 extern Color (* Window_get_background)(Window w);
314 extern void (* Window_set_foreground)(Window w, Color v);
315 extern Color (* Window_get_foreground)(Window w);
317 extern void (* Window_set_position)(Window w, const Point * v);
318 extern void (* Window_get_position)(Window w, Point * v);
320 extern void (* Window_set_anchor)(Window w, const Anchor * v);
321 extern void (* Window_get_anchor)(Window w, Anchor * v);
323 extern void (* Window_set_font)(Window w, FontResource v);
324 extern FontResource (* Window_get_font)(Window w);
326 extern void (* Window_set_caption)(Window w, constString v);
327 extern constString (* Window_get_caption)(Window w);
329 extern void (* Window_set_displayDriver)(Window w, constString v);
330 extern constString (* Window_get_displayDriver)(Window w);
333 extern DialogResult (* Window_modal)(Window);
335 extern Method * method_Window_modal;
337 extern bool (* Window_create)(Window);
339 extern Method * method_Window_create;
341 extern Method * method_Window_onCreate;
343 extern int Window_onCreate_vTblID;
344 extern int Window_onRedraw_vTblID;
346 ///////////// Label Class /////////////////////////////////////////////////
347 extern Class * class_Label;
349 typedef Instance Label;
351 ///////////// MessageBox Class /////////////////////////////////////////////////
352 typedef Window MessageBox;
354 extern Class * class_MessageBox;
357 extern Property * property_MessageBox_contents;
359 extern void (* MessageBox_set_contents)(MessageBox m, constString v);
360 extern constString (* MessageBox_get_contents)(MessageBox m);
362 ///////////// Button Class /////////////////////////////////////////////////
363 typedef Window Button;
365 extern Class * class_Button;
368 extern int Button_notifyClicked_vTblID;
371 extern Class * class_ToolButton;
373 ///////////// Picture Class /////////////////////////////////////////////////
374 typedef Window Picture;
376 extern Class * class_Picture;
378 extern Property * property_Picture_image;
380 extern void (* Picture_set_image)(Picture p, BitmapResource v);
381 extern constString (* Picture_get_image)(Picture p);
383 ///////////// DataBox Class /////////////////////////////////////////////////
384 typedef Window DataBox;
386 ///////////// GuiApplication Class /////////////////////////////////////////////////
387 extern Class * class_GuiApplication;
389 typedef Instance GuiApplication;
391 extern int GuiApplication_cycle_vTblID;
393 Module ecere_init(Module fromModule);
402 #undef GuiApplication
405 #undef BitmapResource