Mercurial > dwindows
annotate dwtestoo.cpp @ 2871:4b7c4cd7a11d
OS2: Fix building the C++ bindings on OS/2 with GCC.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 18 Dec 2022 21:59:12 +0000 |
parents | c873b6f862b9 |
children | 0bbfb19022e7 |
rev | line source |
---|---|
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
1 /* |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
2 * Simple C++ Dynamic Windows Example |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
3 */ |
2871
4b7c4cd7a11d
OS2: Fix building the C++ bindings on OS/2 with GCC.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2869
diff
changeset
|
4 #include "dw.hpp" |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
5 |
2868
5ee1aaa48fc7
C++: The last signal handler change only worked with Clang/LLVM.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2867
diff
changeset
|
6 class MyWindow : public DW::Window |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
7 { |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
8 public: |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
9 MyWindow() { |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
10 SetText("Basic application"); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
11 SetSize(200, 200); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
12 } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
13 virtual int OnDelete() override { DW::App *app = DW::App::Init(); app->MainQuit(); return FALSE; } |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
14 virtual int OnConfigure(int width, int height) override { return FALSE; } |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
15 }; |
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
16 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
17 int dwmain(int argc, char* argv[]) |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
18 { |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
19 DW::App *app = DW::App::Init(argc, argv, "org.dbsoft.dwindows.dwtestoo"); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
20 MyWindow *window = new MyWindow(); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
21 DW::Text *text = new DW::Text("Test window"); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
22 |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
23 window->PackStart(text, DW_SIZE_AUTO, DW_SIZE_AUTO, TRUE, TRUE, 0); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
24 text->SetStyle(DW_DT_CENTER | DW_DT_VCENTER, DW_DT_CENTER | DW_DT_VCENTER); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
25 window->Show(); |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
26 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
27 app->Main(); |
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
28 app->Exit(0); |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
29 |
2869
c873b6f862b9
C++: Add text widget and packing to the window.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2868
diff
changeset
|
30 return 0; |
2861
ef7a414f9b71
Add initial C++ binding header and example program.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
31 } |