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
39 #define Window eC_Window
40 #define DataBox eC_DataBox
41 #define Button eC_Button
42 #define Label eC_Label
43 #define MessageBox eC_MessageBox
44 #define GuiApplication eC_GuiApplication
46 // Virtual Method Calls
47 #define Window_onCreate(x) ({ eC_Window i = x; \
48 bool (* method)(eC_Window) = (bool (*)(eC_Instance))(i ? i->_vTbl : class_Window->_vTbl)[Window_onCreate_vTblID]; \
49 method ? method(i) : true; })
51 #define Window_onRedraw(x, s) ({ eC_Window i = x; \
52 void (* method)(eC_Window, eC_Surface) = (void (*)(eC_Window, eC_Surface))(i ? i->_vTbl : class_Window->_vTbl)[Window_onRedraw_vTblID]; \
53 if(method) method(i, s); })
55 #define Button_notifyClicked(t, m, b, x, y, mods) ({ eC_Button i = t; \
56 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]; \
57 method ? method(m, b, x, y, mods) : true; })
59 // Bit Class Member Access
60 #define COLOR_r_MASK 0x00FF0000
61 #define COLOR_r_SHIFT 16
62 #define COLOR_g_MASK 0x0000FF00
63 #define COLOR_g_SHIFT 8
64 #define COLOR_b_MASK 0x000000FF
65 #define COLOR_b_SHIFT 0
67 #define COLOR(r, g, b) ((((Color)(r)) << COLOR_r_SHIFT) | ((Color)(g) << COLOR_g_SHIFT) | ((Color)(b)) << COLOR_b_SHIFT)
68 #define COLOR_r(x) ((((Color)(x)) & COLOR_r_MASK) >> COLOR_r_SHIFT)
69 #define COLOR_g(x) ((((Color)(x)) & COLOR_g_MASK) >> COLOR_g_SHIFT)
70 #define COLOR_b(x) ((((Color)(x)) & COLOR_b_MASK) >> COLOR_b_SHIFT)
71 #define COLOR_SET_r(x, r) (x) = ((Color)(x) & ~((Color)COLOR_r_MASK)) | (((Color)(r)) << COLOR_r_SHIFT)
72 #define COLOR_SET_g(x, g) (x) = ((Color)(x) & ~((Color)COLOR_g_MASK)) | (((Color)(g)) << COLOR_g_SHIFT)
73 #define COLOR_SET_b(x, b) (x) = ((Color)(x) & ~((Color)COLOR_b_MASK)) | (((Color)(b)) << COLOR_b_SHIFT)
75 #define BORDERBITS_contour_mask 0x00000001
76 #define BORDERBITS_contour_shift 0
77 #define BORDERBITS_fixed_mask 0x00000002
78 #define BORDERBITS_fixed_shift 1
79 #define BORDERBITS_sizable_mask 0x00000004
80 #define BORDERBITS_sizable_shift 2
81 #define BORDERBITS_deep_mask 0x00000008
82 #define BORDERBITS_deep__shift 3
83 #define BORDERBITS_bevel_mask 0x00000010
84 #define BORDERBITS_bevel_shift 4
85 #define BORDERBITS_thin_mask 0x00000020
86 #define BORDERBITS_thin_shift 5
88 #define BORDERBITS_contour(x) ((((BorderBits)(x)) & BORDERBITS_contour_MASK) >> BORDERBITS_contours_SHIFT)
89 #define BORDERBITS_fixed(x) ((((BorderBits)(x)) & BORDERBITS_fixed_MASK) >> BORDERBITS_fixed_SHIFT)
90 #define BORDERBITS_sizable(x) ((((BorderBits)(x)) & BORDERBITS_sizable_MASK) >> BORDERBITS_sizable_SHIFT)
91 #define BORDERBITS_deep(x) ((((BorderBits)(x)) & BORDERBITS_deep_MASK) >> BORDERBITS_deep_SHIFT)
92 #define BORDERBITS_bevel(x) ((((BorderBits)(x)) & BORDERBITS_bevel_MASK) >> BORDERBITS_bevel_SHIFT)
93 #define BORDERBITS_thin(x) ((((BorderBits)(x)) & BORDERBITS_thin_MASK) >> BORDERBITS_thin_SHIFT)
96 struct Size { int w, h; };
97 struct Point { int x, y; };
100 typedef struct Size Size;
101 typedef struct Point Point;
103 /****************************************************************************
105 ****************************************************************************/
107 typedef uint32 Color;
111 typedef Color SystemColor;
119 formColor = COLOR(229, 234, 245)
122 ///////////// Surface Class /////////////////////////////////////////////////
124 typedef Instance Surface;
126 extern Class * class_Surface;
129 extern Method * method_Surface_writeTextf;
131 extern void (* Surface_writeTextf)(Surface s, int x, int y, const char * format, ...);
134 ///////////// FontResource Class /////////////////////////////////////////////////
135 extern Class * class_FontResource;
137 typedef Instance FontResource;
140 extern Property * property_FontResource_faceName;
141 extern Property * property_FontResource_size;
143 extern void (* FontResource_set_faceName)(FontResource f, constString v);
144 extern constString (* FontResource_get_faceName)(FontResource f);
146 extern void (* FontResource_set_size)(FontResource f, float v);
147 extern float (* FontResource_get_size)(FontResource f);
149 extern void (* FontResource_set_bold)(FontResource f, bool v);
150 extern bool (* FontResource_get_bold)(FontResource f);
152 extern void (* FontResource_set_italic)(FontResource f, bool v);
153 extern bool (* FontResource_get_italic)(FontResource f);
155 /****************************************************************************
157 ****************************************************************************/
159 // Bit Class Typedefs
160 typedef uint32 Modifiers;
161 typedef uint32 BorderBits;
165 typedef BorderBits BorderStyle;
169 typedef int64 DialogResult;
190 contour = BORDERBITS_contour_mask,
191 fixed = BORDERBITS_fixed_mask | contour,
192 sizable = BORDERBITS_sizable_mask | fixed,
193 thin = BORDERBITS_thin_mask | fixed,
194 sizableThin = BORDERBITS_sizable_mask | thin,
195 deep = BORDERBITS_deep_mask,
196 bevel = BORDERBITS_bevel_mask,
197 sizableDeep = sizable|deep,
198 sizableBevel = sizable|bevel,
199 fixedDeep = fixed|deep,
200 fixedBevel = fixed|bevel,
201 deepContour = deep|contour
204 ///////////// Window Class /////////////////////////////////////////////////
205 typedef Instance Window;
207 extern Class * class_Window;
210 extern Property * property_Window_caption;
211 extern Property * property_Window_caption;
212 extern Property * property_Window_size;
213 extern Property * property_Window_clientSize;
214 extern Property * property_Window_hasClose;
215 extern Property * property_Window_hasMinimize;
216 extern Property * property_Window_hasMaximize;
217 extern Property * property_Window_borderStyle;
218 extern Property * property_Window_background;
219 extern Property * property_Window_parent;
220 extern Property * property_Window_position;
221 extern Property * property_Window_font;
223 extern void (* Window_set_borderStyle)(Window w, BorderStyle v);
224 extern BorderStyle (* Window_get_borderStyle)(Window w);
226 extern void (* Window_set_size)(Window w, const Size * v);
227 extern void (* Window_get_size)(Window w, Size * v);
229 extern void (* Window_set_clientSize)(Window w, const Size * v);
230 extern void (* Window_get_clientSize)(Window w, Size * v);
232 extern void (* Window_set_hasClose)(Window w, bool v);
233 extern bool (* Window_get_hasClose)(Window w);
235 extern void (* Window_set_hasMaximize)(Window w, bool v);
236 extern bool (* Window_get_hasMaximize)(Window w);
238 extern void (* Window_set_hasMinimize)(Window w, bool v);
239 extern bool (* Window_get_hasMinimize)(Window w);
241 extern void (* Window_set_parent)(Window w, Window v);
242 extern Window (* Window_get_parent)(Window w);
244 extern void (* Window_set_background)(Window w, Color v);
245 extern Color (* Window_get_background)(Window w);
247 extern void (* Window_set_position)(Window w, const Point * v);
248 extern void (* Window_get_position)(Window w, Point * v);
250 extern void (* Window_set_font)(Window w, FontResource v);
251 extern FontResource (* Window_get_font)(Window w);
253 extern void (* Window_set_caption)(Window w, constString v);
254 extern constString (* Window_get_caption)(Window w);
257 extern DialogResult (* Window_modal)(Window);
259 extern Method * method_Window_modal;
260 extern Method * method_Window_onCreate;
262 extern int Window_onCreate_vTblID;
263 extern int Window_onRedraw_vTblID;
265 ///////////// Label Class /////////////////////////////////////////////////
266 extern Class * class_Label;
268 typedef Instance Label;
270 ///////////// MessageBox Class /////////////////////////////////////////////////
271 typedef Window MessageBox;
273 extern Class * class_MessageBox;
276 extern Property * property_MessageBox_contents;
278 extern void (* MessageBox_set_contents)(MessageBox m, constString v);
279 extern constString (* MessageBox_get_contents)(MessageBox m);
281 ///////////// Button Class /////////////////////////////////////////////////
282 typedef Window Button;
284 extern Class * class_Button;
287 extern int Button_notifyClicked_vTblID;
290 extern Class * class_ToolButton;
292 ///////////// DataBox Class /////////////////////////////////////////////////
293 typedef Window DataBox;
295 ///////////// GuiApplication Class /////////////////////////////////////////////////
296 extern Class * class_GuiApplication;
298 typedef Instance GuiApplication;
300 Module ecere_init(Module fromModule);
308 #undef GuiApplication