Mercurial > dwindows
diff dwtestoo.cpp @ 2882:99311a9091af
C++: Add lambda support via Connect functions on C++11, on older compilers
use traditional function pointers instead. Also added inital menu support
although it is incomplete as of this commit.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 22 Dec 2022 13:59:46 +0000 |
parents | 0bbfb19022e7 |
children | d301fed4bc23 |
line wrap: on
line diff
--- a/dwtestoo.cpp Thu Dec 22 13:57:38 2022 +0000 +++ b/dwtestoo.cpp Thu Dec 22 13:59:46 2022 +0000 @@ -14,14 +14,30 @@ int OnConfigure(int width, int height) override { return FALSE; } }; +#ifndef DW_CPP11 +int button_clicked() +{ + app->MessageBox("Button", DW_MB_OK | DW_MB_WARNING, "Clicked!"); + return TRUE; +} +#endif + int dwmain(int argc, char* argv[]) { DW::App *app = DW::App::Init(argc, argv, "org.dbsoft.dwindows.dwtestoo"); MyWindow *window = new MyWindow(); - DW::Text *text = new DW::Text("Test window"); + DW::Button *button = new DW::Button("Test window"); - window->PackStart(text, DW_SIZE_AUTO, DW_SIZE_AUTO, TRUE, TRUE, 0); - text->SetStyle(DW_DT_CENTER | DW_DT_VCENTER, DW_DT_CENTER | DW_DT_VCENTER); + window->PackStart(button, DW_SIZE_AUTO, DW_SIZE_AUTO, TRUE, TRUE, 0); +#ifdef DW_CPP11 + button->ConnectClicked([app] () -> int + { + app->MessageBox("Button", DW_MB_OK | DW_MB_WARNING, "Clicked!"); + return TRUE; + }); +#else + button ->ConnectClicked(&button_clicked); +#endif window->Show(); app->Main();