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