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 Button eC_Button
41 #define Label eC_Label
42 #define MessageBox eC_MessageBox
43 #define GuiApplication eC_GuiApplication
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; })
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); })
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; })
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
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)
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
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)
95 struct Size { int w, h; };
96 struct Point { int x, y; };
99 typedef struct Size Size;
100 typedef struct Point Point;
102 /****************************************************************************
104 ****************************************************************************/
106 typedef uint32 Color;
110 typedef Color SystemColor;
118 formColor = COLOR(229, 234, 245)
121 ///////////// Surface Class /////////////////////////////////////////////////
123 typedef Instance Surface;
125 extern Class * class_Surface;
128 extern Method * method_Surface_writeTextf;
130 extern void (* Surface_writeTextf)(Surface s, int x, int y, const char * format, ...);
133 ///////////// FontResource Class /////////////////////////////////////////////////
134 extern Class * class_FontResource;
136 typedef Instance FontResource;
139 extern Property * property_FontResource_faceName;
140 extern Property * property_FontResource_size;
142 extern void (* FontResource_set_faceName)(FontResource f, constString v);
143 extern constString (* FontResource_get_faceName)(FontResource f);
145 extern void (* FontResource_set_size)(FontResource f, float v);
146 extern float (* FontResource_get_size)(FontResource f);
148 extern void (* FontResource_set_bold)(FontResource f, bool v);
149 extern bool (* FontResource_get_bold)(FontResource f);
151 extern void (* FontResource_set_italic)(FontResource f, bool v);
152 extern bool (* FontResource_get_italic)(FontResource f);
154 /****************************************************************************
156 ****************************************************************************/
158 // Bit Class Typedefs
159 typedef uint32 Modifiers;
160 typedef uint32 BorderBits;
164 typedef BorderBits BorderStyle;
168 typedef int64 DialogResult;
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
203 ///////////// Window Class /////////////////////////////////////////////////
204 typedef Instance Window;
206 extern Class * class_Window;
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;
222 extern void (* Window_set_borderStyle)(Window w, BorderStyle v);
223 extern BorderStyle (* Window_get_borderStyle)(Window w);
225 extern void (* Window_set_size)(Window w, const Size * v);
226 extern void (* Window_get_size)(Window w, Size * v);
228 extern void (* Window_set_clientSize)(Window w, const Size * v);
229 extern void (* Window_get_clientSize)(Window w, Size * v);
231 extern void (* Window_set_hasClose)(Window w, bool v);
232 extern bool (* Window_get_hasClose)(Window w);
234 extern void (* Window_set_hasMaximize)(Window w, bool v);
235 extern bool (* Window_get_hasMaximize)(Window w);
237 extern void (* Window_set_hasMinimize)(Window w, bool v);
238 extern bool (* Window_get_hasMinimize)(Window w);
240 extern void (* Window_set_parent)(Window w, Window v);
241 extern Window (* Window_get_parent)(Window w);
243 extern void (* Window_set_background)(Window w, Color v);
244 extern Color (* Window_get_background)(Window w);
246 extern void (* Window_set_position)(Window w, const Point * v);
247 extern void (* Window_get_position)(Window w, Point * v);
249 extern void (* Window_set_font)(Window w, FontResource v);
250 extern FontResource (* Window_get_font)(Window w);
252 extern void (* Window_set_caption)(Window w, constString v);
253 extern constString (* Window_get_caption)(Window w);
256 extern DialogResult (* Window_modal)(Window);
258 extern Method * method_Window_modal;
259 extern Method * method_Window_onCreate;
261 extern int Window_onCreate_vTblID;
262 extern int Window_onRedraw_vTblID;
264 ///////////// Label Class /////////////////////////////////////////////////
265 extern Class * class_Label;
267 typedef Instance Label;
269 ///////////// MessageBox Class /////////////////////////////////////////////////
270 typedef Window MessageBox;
272 extern Class * class_MessageBox;
275 extern Property * property_MessageBox_contents;
277 extern void (* MessageBox_set_contents)(MessageBox m, constString v);
278 extern constString (* MessageBox_get_contents)(MessageBox m);
280 ///////////// Button Class /////////////////////////////////////////////////
281 typedef Window Button;
283 extern Class * class_Button;
286 extern int Button_notifyClicked_vTblID;
289 extern Class * class_ToolButton;
291 ///////////// GuiApplication Class /////////////////////////////////////////////////
292 extern Class * class_GuiApplication;
294 typedef Instance GuiApplication;
296 Module ecere_init(Module fromModule);
303 #undef GuiApplication