comparison dwtestoo.cpp @ 2869:c873b6f862b9

C++: Add text widget and packing to the window. Also reformat both files using spaces instead of tabs.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 18 Dec 2022 12:13:46 +0000
parents 5ee1aaa48fc7
children 4b7c4cd7a11d
comparison
equal deleted inserted replaced
2868:5ee1aaa48fc7 2869:c873b6f862b9
1 /*
2 * Simple C++ Dynamic Windows Example
3 */
1 #include <dw.hpp> 4 #include <dw.hpp>
2 5
3 class MyWindow : public DW::Window 6 class MyWindow : public DW::Window
4 { 7 {
5 public: 8 public:
6 MyWindow() { 9 MyWindow() {
7 SetText("Basic application"); 10 SetText("Basic application");
8 SetSize(200, 200); 11 SetSize(200, 200);
9 } 12 }
10 virtual int OnDelete() override { DW::App *app = DW::App::Init(); app->MainQuit(); return FALSE; } 13 virtual int OnDelete() override { DW::App *app = DW::App::Init(); app->MainQuit(); return FALSE; }
11 virtual int OnConfigure(int width, int height) override { return FALSE; } 14 virtual int OnConfigure(int width, int height) override { return FALSE; }
12 }; 15 };
13 16
14 int dwmain(int argc, char* argv[]) 17 int dwmain(int argc, char* argv[])
15 { 18 {
16 DW::App *app = DW::App::Init(argc, argv, "org.dbsoft.dwindows.dwtestoo"); 19 DW::App *app = DW::App::Init(argc, argv, "org.dbsoft.dwindows.dwtestoo");
17 MyWindow *window = new MyWindow(); 20 MyWindow *window = new MyWindow();
21 DW::Text *text = new DW::Text("Test window");
22
23 window->PackStart(text, DW_SIZE_AUTO, DW_SIZE_AUTO, TRUE, TRUE, 0);
24 text->SetStyle(DW_DT_CENTER | DW_DT_VCENTER, DW_DT_CENTER | DW_DT_VCENTER);
25 window->Show();
18 26
19 window->Show(); 27 app->Main();
28 app->Exit(0);
20 29
21 app->Main(); 30 return 0;
22 app->Exit(0);
23
24 return 0;
25 } 31 }