1 #define MODULE_NAME "HelloForm"
3 // #define __CONSOLE_APP__
11 class Foo : public Instance
15 Foo(int a, int b) : Foo() { this->a = a, this->b = b; };
17 CONSTRUCT(Foo, Instance)
19 onCopy = [](Foo & self, Foo & other)
21 printf("%d, %d\n", other.a, other.b);
22 printf("self: %p\n", &self);
27 onCompare = [](Foo & self, Foo & other)
29 if(self.a > other.a) return 1;
30 if(self.a < other.a) return -1;
31 if(self.b > other.b) return 1;
32 if(self.b < other.b) return -1;
36 /*onDisplay = [](Foo & self, Surface & s, int x , int y , int w, void * fd, Alignment a, DataDisplayFlags f)
45 //Instance::class_registration(_class);
46 register_onDisplay(_class, [](Foo & _self, Surface & s, int x , int y , int w, void * fd, Alignment a, DataDisplayFlags f) { printf("Meh\n"); });
49 REGISTER_CLASS_DEF(Foo, Instance, app);
53 class HelloForm2 : public Window
58 CONSTRUCT(HelloForm2, Window)
60 caption = $("My Second Ecere/C++ Bindings App");
61 borderStyle = sizable;
62 clientSize = { 640, 480 };
66 background = formColor;
67 font = { "Arial", 30 };
70 button.position = { 200, 200 };
71 button.caption = $("Yay!!");
72 // button.onRedraw = [](Window & w, Surface s){ };
73 button.notifyClicked = [](Window & owner, Button & btn, int x, int y, Modifiers mods)
75 double i = 3.14159265;
77 constString s = _onGetString(class_double, &i, tmp, null, null);
78 //PrintLn(class_String, "Hello! -- ", class_String, s, null); // Need to terminate with a null!
79 //HelloForm2 & self = (HelloForm2 &)owner;
80 //MessageBox($("C++ Bindings!"), self.button.caption).modal();
82 /*FontResource a("Arial", 20, true);
83 FontResource b("Comic Sans MS", 20, true);
84 FontResource c("Arial", 20, true);
86 int ab = ((FontResource *)null)->onCompare(b);
87 //bool ab = ((FontResource *)null)->onCompare(*(FontResource *)null);
88 //bool ac = a.onCompare(c);
89 int ac = a.onCompare(*(FontResource *)null);
90 printf("a compare b = %d\n", ab);
91 printf("a compare c = %d\n", ac);*/
97 /*Foo obj4; obj4.onCopy(obj1);
100 printf("result: face = %s, size = %f, bold = %d\n",
101 (constString)fr.faceName, (float)fr.size, (int)fr.bold);
105 Foo * o = (Foo *)null; o->onDisplay(s, 0,0,0, null, 0, 0);
106 //((Foo *)&obj3)->onDisplay(Surface { }, 0,0,0, null, 0, 0);
109 r = obj1.onCompare(obj2); printf("result: %d\n", r);
110 //r = obj2.onCompare(obj1); printf("result: %d\n", r);
111 //r = obj1.onCompare(obj3); printf("result: %d\n", r);
112 //printf("result: a = %d, b = %d\n", obj4.a, obj4.b);
119 /*onCreate = [](Window & w)
121 MessageBox($("Cool"), $("Creation!")).modal();
125 //onRedraw(Surface());
129 /*static void myOnRedraw(Window & w, Surface & surface)
131 surface.writeTextf(100, 100, $("Testing stuff!"));
132 //surface.writeTextf(100, 100, "%d + %d = %d", 2, 3, 2+3);
137 Window::class_registration(_class);
138 register_onRedraw(_class, [](Window & w, Surface & surface)
140 surface.writeTextf(100, 100, $("Class Method!"));
141 //surface.writeTextf(100, 100, "%d + %d = %d", 2, 3, 2+3);
145 REGISTER_CLASS_DEF(HelloForm2, Window, app);
149 //eC_Class * c = eC_findClass(app.impl, "HelloForm2");
150 eC_Class * c = HelloForm2::_class.impl;
151 ((HelloForm2 *)_INSTANCE(newi(c), c))->modal();
154 class HelloForm3 : public HelloForm2
157 CONSTRUCT(HelloForm3, HelloForm2)
159 background = 0x50B0F0;
161 font = { "Monaco", 30, true };
163 onRedraw = [](Window & w, Surface & surface)
165 surface.writeTextf(100, 100, $("Instance Method!"));
166 //surface.writeTextf(100, 100, "%d + %d = %d", 2, 3, 2+3);
170 REGISTER_CLASS_DEF(HelloForm3, HelloForm2, app);