439edea6845595ce5815e39084d34d6e45fba387
[sdk] / bindings / c / ecere.c
1 #include "ecere.h"
2
3 Class * class_Surface;
4
5 Method * method_Surface_writeTextf;
6
7 void (* Surface_writeTextf)(Surface s, int x, int y, const char * format, ...);
8
9 Class * class_FontResource;
10
11 Property * property_FontResource_faceName;
12 Property * property_FontResource_size;
13 Property * property_FontResource_bold;
14 Property * property_FontResource_italic;
15 Property * property_FontResource_outlineSize;
16 Property * property_FontResource_outlineFade;
17
18 void (* FontResource_set_faceName)(FontResource f, constString v);
19 constString (* FontResource_get_faceName)(FontResource f);
20
21 void (* FontResource_set_size)(FontResource f, float v);
22 float (* FontResource_get_size)(FontResource f);
23
24 void (* FontResource_set_outlineSize)(FontResource f, float v);
25 float (* FontResource_get_outlineSize)(FontResource f);
26
27 void (* FontResource_set_outlineFade)(FontResource f, float v);
28 float (* FontResource_get_outlineFade)(FontResource f);
29
30 void (* FontResource_set_bold)(FontResource f, bool v);
31 bool (* FontResource_get_bold)(FontResource f);
32
33 void (* FontResource_set_italic)(FontResource f, bool v);
34 bool (* FontResource_get_italic)(FontResource f);
35
36 Class * class_Window;
37
38 int Window_onCreate_vTblID;
39 int Window_onRedraw_vTblID;
40
41 Property * property_Window_caption;
42 Property * property_Window_size;
43 Property * property_Window_clientSize;
44 Property * property_Window_hasClose;
45 Property * property_Window_hasMinimize;
46 Property * property_Window_hasMaximize;
47 Property * property_Window_borderStyle;
48 Property * property_Window_background;
49 Property * property_Window_foreground;
50 Property * property_Window_parent;
51 Property * property_Window_position;
52 Property * property_Window_font;
53 Property * property_Window_displayDriver;
54
55 Method * method_Window_modal;
56 Method * method_Window_create;
57
58 Method * method_Window_onCreate;
59 Method * method_Window_onRedraw;
60
61 void (* Window_set_borderStyle)(Window w, BorderStyle v);
62 BorderStyle (* Window_get_borderStyle)(Window w);
63
64 void (* Window_set_size)(Window w, const Size * v);
65 void (* Window_get_size)(Window w, Size * v);
66
67 void (* Window_set_clientSize)(Window w, const Size * v);
68 void (* Window_get_clientSize)(Window w, Size * v);
69
70 void (* Window_set_hasClose)(Window w, bool v);
71 bool (* Window_get_hasClose)(Window w);
72
73 void (* Window_set_hasMaximize)(Window w, bool v);
74 bool (* Window_get_hasMaximize)(Window w);
75
76 void (* Window_set_hasMinimize)(Window w, bool v);
77 bool (* Window_get_hasMinimize)(Window w);
78
79 void (* Window_set_parent)(Window w, Window v);
80 Window (* Window_get_parent)(Window w);
81
82 void (* Window_set_background)(Window w, Color v);
83 Color (* Window_get_background)(Window w);
84
85 void (* Window_set_foreground)(Window w, Color v);
86 Color (* Window_get_foreground)(Window w);
87
88 void (* Window_set_position)(Window w, const Point * v);
89 void (* Window_get_position)(Window w, Point * v);
90
91 void (* Window_set_font)(Window w, Instance v);
92 FontResource (* Window_get_font)(Window w);
93
94 void (* Window_set_caption)(Window w, constString v);
95 constString (* Window_get_caption)(Window w);
96
97 void (* Window_set_displayDriver)(Window w, constString v);
98 constString (* Window_get_displayDriver)(Window w);
99
100 DialogResult (* Window_modal)(Window);
101
102 bool (* Window_create)(Window);
103
104 Class * class_Button;
105
106 Method * method_Button_notifyClicked;
107
108 int Button_notifyClicked_vTblID;
109
110 Class * class_ToolButton;
111
112 Class * class_Label;
113
114 Class * class_GuiApplication;
115
116 Class * class_MessageBox;
117
118 Property * property_MessageBox_contents;
119
120 void (* MessageBox_set_contents)(MessageBox m, constString v);
121 constString (* MessageBox_get_contents)(MessageBox m);
122
123 Module ecere_init(Module fromModule)
124 {
125    Module module = Module_load(fromModule, "ecere", publicAccess);
126    if(module)
127    {
128       // Set up all the class_*, property, method, function pointers ...
129       class_Surface = eC_findClass(module, "Surface");
130       if(class_Surface)
131       {
132          method_Surface_writeTextf = Class_findMethod(class_Surface, "WriteTextf", module);
133          if(method_Surface_writeTextf)
134             Surface_writeTextf = (void *)method_Surface_writeTextf->function;
135       }
136
137       class_FontResource = eC_findClass(module, "FontResource");
138       if(class_FontResource)
139       {
140          property_FontResource_faceName = Class_findProperty(class_FontResource, "faceName", module);
141          if(property_FontResource_faceName)
142          {
143             FontResource_set_faceName = (void *)property_FontResource_faceName->Set;
144             FontResource_get_faceName = (void *)property_FontResource_faceName->Get;
145          }
146
147          property_FontResource_size = Class_findProperty(class_FontResource, "size", module);
148          if(property_FontResource_size)
149          {
150             FontResource_set_size = (void *)property_FontResource_size->Set;
151             FontResource_get_size = (void *)property_FontResource_size->Get;
152          }
153
154          property_FontResource_bold = Class_findProperty(class_FontResource, "bold", module);
155          if(property_FontResource_bold)
156          {
157             FontResource_set_bold = (void *)property_FontResource_bold->Set;
158             FontResource_get_bold = (void *)property_FontResource_bold->Get;
159          }
160
161          property_FontResource_italic = Class_findProperty(class_FontResource, "italic", module);
162          if(property_FontResource_italic)
163          {
164             FontResource_set_italic = (void *)property_FontResource_italic->Set;
165             FontResource_get_italic = (void *)property_FontResource_italic->Get;
166          }
167
168          property_FontResource_outlineSize = Class_findProperty(class_FontResource, "outlineSize", module);
169          if(property_FontResource_outlineSize)
170          {
171             FontResource_set_outlineSize = (void *)property_FontResource_outlineSize->Set;
172             FontResource_get_outlineSize = (void *)property_FontResource_outlineSize->Get;
173          }
174
175          property_FontResource_outlineFade = Class_findProperty(class_FontResource, "outlineFade", module);
176          if(property_FontResource_outlineFade)
177          {
178             FontResource_set_outlineFade = (void *)property_FontResource_outlineFade->Set;
179             FontResource_get_outlineFade = (void *)property_FontResource_outlineFade->Get;
180          }
181       }
182
183       class_Window = eC_findClass(module, "Window");
184       if(class_Window)
185       {
186          method_Window_modal = Class_findMethod(class_Window, "Modal", module);
187          if(method_Window_modal)
188             Window_modal = (void *)method_Window_modal->function;
189
190          method_Window_create = Class_findMethod(class_Window, "Create", module);
191          if(method_Window_create)
192             Window_create = (void *)method_Window_create->function;
193
194          method_Window_onCreate = Class_findMethod(class_Window, "OnCreate", module);
195          if(method_Window_onCreate)
196             Window_onCreate_vTblID = method_Window_onCreate->vid;
197          method_Window_onRedraw = Class_findMethod(class_Window, "OnRedraw", module);
198          if(method_Window_onRedraw)
199             Window_onRedraw_vTblID = method_Window_onRedraw->vid;
200
201          property_Window_displayDriver = Class_findProperty(class_Window, "displayDriver", module);
202          if(property_Window_displayDriver)
203          {
204             Window_set_displayDriver = (void *)property_Window_displayDriver->Set;
205             Window_get_displayDriver = (void *)property_Window_displayDriver->Get;
206          }
207
208          property_Window_caption = Class_findProperty(class_Window, "caption", module);
209          if(property_Window_caption)
210          {
211             Window_set_caption = (void *)property_Window_caption->Set;
212             Window_get_caption = (void *)property_Window_caption->Get;
213          }
214
215          property_Window_size = Class_findProperty(class_Window, "size", module);
216          if(property_Window_size)
217          {
218             Window_set_size = (void *)property_Window_size->Set;
219             Window_get_size = (void *)property_Window_size->Get;
220          }
221
222          property_Window_clientSize = Class_findProperty(class_Window, "clientSize", module);
223          if(property_Window_clientSize)
224          {
225             Window_set_clientSize = (void *)property_Window_clientSize->Set;
226             Window_get_clientSize = (void *)property_Window_clientSize->Get;
227          }
228
229          property_Window_borderStyle = Class_findProperty(class_Window, "borderStyle", module);
230          if(property_Window_borderStyle)
231          {
232             Window_set_borderStyle = (void *)property_Window_borderStyle->Set;
233             Window_get_borderStyle = (void *)property_Window_borderStyle->Get;
234          }
235
236          property_Window_background = Class_findProperty(class_Window, "background", module);
237          if(property_Window_background)
238          {
239             Window_set_background = (void *)property_Window_background->Set;
240             Window_get_background = (void *)property_Window_background->Get;
241          }
242
243          property_Window_foreground = Class_findProperty(class_Window, "foreground", module);
244          if(property_Window_foreground)
245          {
246             Window_set_foreground = (void *)property_Window_foreground->Set;
247             Window_get_foreground = (void *)property_Window_foreground->Get;
248          }
249
250          property_Window_hasClose = Class_findProperty(class_Window, "hasClose", module);
251          if(property_Window_hasClose)
252          {
253             Window_set_hasClose = (void *)property_Window_hasClose->Set;
254             Window_get_hasClose = (void *)property_Window_hasClose->Get;
255          }
256
257          property_Window_hasMinimize = Class_findProperty(class_Window, "hasMinimize", module);
258          if(property_Window_hasMinimize)
259          {
260             Window_set_hasMinimize = (void *)property_Window_hasMinimize->Set;
261             Window_get_hasMinimize = (void *)property_Window_hasMinimize->Get;
262          }
263
264          property_Window_hasMaximize = Class_findProperty(class_Window, "hasMaximize", module);
265          if(property_Window_hasMaximize)
266          {
267             Window_set_hasMaximize = (void *)property_Window_hasMaximize->Set;
268             Window_get_hasMaximize = (void *)property_Window_hasMaximize->Get;
269          }
270
271          property_Window_parent = Class_findProperty(class_Window, "parent", module);
272          if(property_Window_parent)
273          {
274             Window_set_parent = (void *)property_Window_parent->Set;
275             Window_get_parent = (void *)property_Window_parent->Get;
276          }
277
278          property_Window_position = Class_findProperty(class_Window, "position", module);
279          if(property_Window_position)
280          {
281             Window_set_position = (void *)property_Window_position->Set;
282             Window_get_position = (void *)property_Window_position->Get;
283          }
284
285          property_Window_font = Class_findProperty(class_Window, "font", module);
286          if(property_Window_font)
287          {
288             Window_set_font = (void *)property_Window_font->Set;
289             Window_get_font = (void *)property_Window_font->Get;
290          }
291       }
292
293       class_Label = eC_findClass(module, "Label");
294
295       class_Button = eC_findClass(module, "Button");
296       if(class_Button)
297       {
298          method_Button_notifyClicked = Class_findMethod(class_Button, "NotifyClicked", module);
299          if(method_Button_notifyClicked)
300             Button_notifyClicked_vTblID = method_Button_notifyClicked->vid;
301       }
302
303       class_MessageBox = eC_findClass(module, "MessageBox");
304       if(class_MessageBox)
305       {
306          property_MessageBox_contents = Class_findProperty(class_MessageBox, "contents", module);
307          if(property_MessageBox_contents)
308          {
309             MessageBox_set_contents = (void *)property_MessageBox_contents->Set;
310             MessageBox_get_contents = (void *)property_MessageBox_contents->Get;
311          }
312       }
313
314       class_GuiApplication = eC_findClass(module, "GuiApplication");
315    }
316    return module;
317 }