1 /****************************************************************************
2 ===========================================================================
4 ===========================================================================
5 ****************************************************************************/
6 #if !defined(__ECERE_HPP__)
12 /****************************************************************************
14 ****************************************************************************/
15 ///////////// Surface Class /////////////////////////////////////////////////
16 class Surface : public Instance
19 CONSTRUCT(Surface, Instance) { }
21 inline void writeTextf(int x, int y, const char * format, ...)
23 Surface_writeTextf(impl, x, y, format); // var args are a pain to pass...
27 ///////////// FontResource Class /////////////////////////////////////////////////
28 class FontResource : public Instance
31 CONSTRUCT(FontResource, Instance) { }
33 inline FontResource(constString faceName, float size = 10, eC_bool bold = false, eC_bool italic = false) : FontResource()
35 this->faceName = faceName;
38 this->italic = italic;
42 #define PSELF SELF(FontResource, bold)
45 set(eC_bool, bold, FontResource_set_bold(self ? self->impl : null, v))
46 get(eC_bool, bold, return FontResource_get_bold(self ? self->impl : null))
49 set(eC_bool, italic, FontResource_set_italic(self ? self->impl : null, v))
50 get(eC_bool, italic, return FontResource_get_italic(self ? self->impl : null))
53 set(constString, faceName, FontResource_set_faceName(self ? self->impl : null, v))
54 get(constString, faceName, return FontResource_get_faceName(self ? self->impl : null))
57 set(float, size, FontResource_set_size(self ? self->impl : null, v))
58 get(float, size, return FontResource_get_size(self ? self->impl : null))
62 /****************************************************************************
64 ****************************************************************************/
65 ///////////// Window Class /////////////////////////////////////////////////
66 #define Window_class_registration(d) \
67 REGISTER_METHOD("OnRedraw", onRedraw, Window, d, void, (eC_Window o, eC_Surface s), o, (*i, Surface { s }), (o, s), ); \
68 REGISTER_METHOD("OnCreate", onCreate, Window, d, bool, (eC_Window o), o, (*i), (o), true);
70 bool foo(eC_Instance o);
72 class Window : public Instance
75 CONSTRUCT(Window, Instance) { }
77 REGISTER() { Window_class_registration(Window); }
79 VIRTUAL_METHOD(onCreate, Window, Window, bool, (Window &), (),
80 return Window_onCreate(self->impl));
81 VIRTUAL_METHOD(onRedraw, Window, Window, void, (Window &, Surface), (Surface surface),
82 return Window_onRedraw(self->impl, surface.impl));
84 DialogResult modal() { return Window_modal(impl); }
86 // TOCHECK: See if we'll need set/get methods in addition to 'properties' for SWIG
87 //void set_size(const Size & v) { Window_set_size(impl, &v); }
88 //void set_hasClose(eC_bool v) { Window_set_hasClose(impl, v); }
91 #define PSELF SELF(Window, parent)
94 set(const Window &, parent, Window_set_parent(self ? self->impl : null, v.impl))
96 eC_Instance i = Window_get_parent(self ? self->impl : null);
97 return *(Window *)_INSTANCE(i, Window::_class.impl))
99 _set(const Window *, parent, Window_set_parent(self ? self->impl : null, v ? v->impl : null))
100 get(Window *, parent,
101 eC_Instance i = Window_get_parent(self ? self->impl : null);
102 return i ? (Window *)_INSTANCE(i, Window::_class.impl) : null)
104 get(Window, parent, return Window(Window_get_parent(self ? self->impl : null)));
107 set(const Size &, size, Window_set_size(self ? self->impl : null, &v))
108 get(Size, size, { Size v; Window_get_size(self ? self->impl : null, &v); return v; })
111 set(const Size &, clientSize, Window_set_clientSize(self ? self->impl : null, &v))
112 get(Size, clientSize, { Size v; Window_get_clientSize(self ? self->impl : null, &v); return v; })
115 set(const Point &, position, Window_set_position(self ? self->impl : null, &v))
116 get(Point, position, { Point v; Window_get_position(self ? self->impl : null, &v); return v; })
119 set(eC_bool, hasClose, Window_set_hasClose(self ? self->impl : null, v))
120 get(eC_bool, hasClose, return Window_get_hasClose(self ? self->impl : null))
122 property(hasMinimize,
123 set(eC_bool, hasMinimize, Window_set_hasMinimize(self ? self->impl : null, v))
124 get(eC_bool, hasMinimize, return Window_get_hasMinimize(self ? self->impl : null))
126 property(hasMaximize,
127 set(eC_bool, hasMaximize, Window_set_hasMaximize(self ? self->impl : null, v))
128 get(eC_bool, hasMaximize, return Window_get_hasMaximize(self ? self->impl : null))
131 set(constString, caption, Window_set_caption(self ? self->impl : null, v))
132 get(constString, caption, return Window_get_caption(self ? self->impl : null))
135 set(const FontResource &, font, Window_set_font(self ? self->impl : null, v.impl))
136 get(FontResource &, font,
137 eC_Instance i = Window_get_font(self ? self->impl : null);
138 return *(FontResource *)_INSTANCE(i, FontResource::_class.impl))
140 _set(const FontResource *, font, Window_set_font(self ? self->impl : null, v->impl))
141 get(FontResource *, font,
142 eC_Instance i = Window_get_font(self ? self->impl : null);
143 return i ? (FontResource *)_INSTANCE(i, FontResource::_class.impl) : null)
145 get(FontResource, font, return FontResource(Window_get_font(self ? self->impl : null)))
147 property(borderStyle,
148 set(BorderStyle, borderStyle, Window_set_borderStyle(self ? self->impl : null, v))
149 get(BorderStyle, borderStyle, return Window_get_borderStyle(self ? self->impl : null))
152 set(Color, background, Window_set_background(self ? self->impl : null, v))
153 get(Color, background, return Window_get_background(self ? self->impl : null))
157 ///////////// Label Class /////////////////////////////////////////////////
158 class Label : public Window
161 CONSTRUCT(Label, Window) { }
163 REGISTER() { Window_class_registration(Label); }
166 ///////////// MessageBox Class /////////////////////////////////////////////////
167 class MessageBox : public Window
170 CONSTRUCT(MessageBox, Window) { }
172 MessageBox(constString contents, constString caption = ""/*, MessageBoxType type = ok*/) : MessageBox()
174 this->contents = contents;
175 this->caption = caption;
177 REGISTER() { Window_class_registration(MessageBox); }
180 #define PSELF SELF(MessageBox, contents)
183 set(constString, contents, MessageBox_set_contents(self ? self->impl : null, v))
184 get(constString, contents, return MessageBox_get_contents(self ? self->impl : null))
188 ///////////// Button Class /////////////////////////////////////////////////
189 #define Button_class_registration(d) \
190 Window_class_registration(d); \
191 REGISTER_METHOD("NotifyClicked", notifyClicked, Button, d, \
192 bool, (eC_Window m, eC_Button b, int x, int y, Modifiers mods), \
193 b, (*(Window *)INSTANCEL(m, m->_class), *(Button *)INSTANCEL(b, b->_class), x, y, mods), \
194 (m, b, x, y, mods), true);
196 class Button : public Window
199 CONSTRUCT(Button, Window) { }
201 REGISTER() { Button_class_registration(Button); }
203 VIRTUAL_METHOD(notifyClicked, Button, Button, bool, (Window &, Button &, int, int, Modifiers), (Window & window, Button & button, int x, int y, Modifiers mods),
204 return Button_notifyClicked(self->impl, window.impl, button.impl, x, y, mods));
207 ///////////// ToolButton Class /////////////////////////////////////////////////////
208 class ToolButton : public Button
211 CONSTRUCT(ToolButton, Button) { }
212 REGISTER() { Button_class_registration(ToolButton); }
215 #define PSELF SELF(ToolButton, Foo)
218 ///////////// GuiApplication Class /////////////////////////////////////////////////
219 class GuiApplication : public Application
222 APP_CONSTRUCT(GuiApplication, Application)
224 Instance_evolve(&impl, GuiApplication::_class.impl);
225 _INSTANCE(impl, impl->_class) = this;
229 REGISTER() { Application_class_registration(GuiApplication); }