comparison dwtestoo.cpp @ 2895:5a6bf6bd3001

C++: Divide up C++11 and Lambda support since some compilers can support lambdas without full C++11 support. For instance MSVC 2010 supports lambdas but only MSVC 2017 supports C++11 or higher. GCC 4.5 supports lambdas but GCC 4.8.1 supports C++11.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 23 Dec 2022 04:13:51 +0000
parents 4b075e64536c
children 8af64b6d75a9
comparison
equal deleted inserted replaced
2894:5bbd275369cd 2895:5a6bf6bd3001
12 } 12 }
13 int OnDelete() override { DW::App *app = DW::App::Init(); app->MainQuit(); return FALSE; } 13 int OnDelete() override { DW::App *app = DW::App::Init(); app->MainQuit(); return FALSE; }
14 int OnConfigure(int width, int height) override { return FALSE; } 14 int OnConfigure(int width, int height) override { return FALSE; }
15 }; 15 };
16 16
17 #ifndef DW_CPP11 17 #ifndef DW_LAMBDA
18 int button_clicked() 18 int button_clicked()
19 { 19 {
20 DW::App *app = DW::App::Init(); 20 DW::App *app = DW::App::Init();
21 app->MessageBox("Button", DW_MB_OK | DW_MB_INFORMATION, "Clicked!"); 21 app->MessageBox("Button", DW_MB_OK | DW_MB_INFORMATION, "Clicked!");
22 return TRUE; 22 return TRUE;
37 DW::App *app = DW::App::Init(argc, argv, "org.dbsoft.dwindows.dwtestoo"); 37 DW::App *app = DW::App::Init(argc, argv, "org.dbsoft.dwindows.dwtestoo");
38 MyWindow *window = new MyWindow(); 38 MyWindow *window = new MyWindow();
39 DW::Button *button = new DW::Button("Test window"); 39 DW::Button *button = new DW::Button("Test window");
40 40
41 window->PackStart(button, DW_SIZE_AUTO, DW_SIZE_AUTO, TRUE, TRUE, 0); 41 window->PackStart(button, DW_SIZE_AUTO, DW_SIZE_AUTO, TRUE, TRUE, 0);
42 #ifdef DW_CPP11 42 #ifdef DW_LAMBDA
43 button->ConnectClicked([app] () -> int 43 button->ConnectClicked([app] () -> int
44 { 44 {
45 app->MessageBox("Button", DW_MB_OK | DW_MB_WARNING, "Clicked!"); 45 app->MessageBox("Button", DW_MB_OK | DW_MB_WARNING, "Clicked!");
46 return TRUE; 46 return TRUE;
47 }); 47 });
52 DW::MenuBar *mainmenubar = window->MenuBarNew(); 52 DW::MenuBar *mainmenubar = window->MenuBarNew();
53 53
54 // add menus to the menubar 54 // add menus to the menubar
55 DW::Menu *menu = new DW::Menu(); 55 DW::Menu *menu = new DW::Menu();
56 DW::MenuItem *menuitem = menu->AppendItem("~Quit"); 56 DW::MenuItem *menuitem = menu->AppendItem("~Quit");
57 #ifdef DW_CPP11 57 #ifdef DW_LAMBDA
58 menuitem->ConnectClicked([app] () -> int 58 menuitem->ConnectClicked([app] () -> int
59 { 59 {
60 if(app->MessageBox("dwtest", DW_MB_YESNO | DW_MB_QUESTION, "Are you sure you want to exit?") != 0) { 60 if(app->MessageBox("dwtest", DW_MB_YESNO | DW_MB_QUESTION, "Are you sure you want to exit?") != 0) {
61 app->MainQuit(); 61 app->MainQuit();
62 } 62 }