ac81a1178eb828c502843a024253e6c24943ee59
[sdk] / bindings / cpp / samples / sample1.cpp
1 #define MODULE_NAME  "HelloForm"
2
3 #include "ecere.hpp"
4
5 class HelloForm : public Window
6 {
7 public:
8    Button button;
9
10    CONSTRUCT(HelloForm, Window)
11    {
12       caption = $("Sample App using Ecere Toolkit/C++ Bindings");
13       borderStyle = sizable;
14       clientSize = { 640, 480 };
15       hasClose = true;
16       hasMaximize = true;
17       hasMinimize = true;
18       background = formColor;
19       font = { "Arial", 30 };
20
21       button.parent = this;
22       button.position = { 200, 200 };
23       button.caption = $("Yay!!");
24       button.notifyClicked = [](Window & owner, Button & btn, int x, int y, Modifiers mods)
25       {
26          HelloForm & self = (HelloForm &)owner;
27          MessageBox msgBox;
28          msgBox.caption = self.button.caption;
29          msgBox.contents = $("C++ Bindings!");
30          msgBox.modal();
31          return true;
32       };
33    }
34
35    static Class * class_registration(Class * _class)
36    {
37       Window::class_registration(_class);
38       register_onRedraw(_class, [](Window & w, Surface surface) { surface.writeTextf(100, 100, $("Class Method!")); });
39       HelloForm::_class.destructor = [](HelloForm & self) { printf("It's the end my friend!\n"); };
40       return _class;
41    }
42 };
43
44 GuiApplication app;
45
46 REGISTER_CLASS_DEF(HelloForm, Window, app);
47
48 HelloForm hello;
49
50 MAIN_DEFINITION;