diff options
| author | ruki <[email protected]> | 2026-08-09 18:25:05 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-08-09 18:25:05 +0800 |
| commit | ced7f2ae519bc9eca92bcf4f177fe177ddd0e747 (patch) | |
| tree | af4d584b3c7badc1df56038cdb29099b4f3e99fd /xmake/templates/c++/wxwidgets/src/main.cpp | |
| parent | 6ac4ea833193a4319a1eb6e5f588d1877fd48064 (diff) | |
| parent | 5f5daf64c504e1103a355f45bf925a5149b03e24 (diff) | |
Merge pull request #7699 from xmake-io/templates
move templates dir
Diffstat (limited to 'xmake/templates/c++/wxwidgets/src/main.cpp')
| -rw-r--r-- | xmake/templates/c++/wxwidgets/src/main.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/xmake/templates/c++/wxwidgets/src/main.cpp b/xmake/templates/c++/wxwidgets/src/main.cpp new file mode 100644 index 000000000..4b43fe6e3 --- /dev/null +++ b/xmake/templates/c++/wxwidgets/src/main.cpp @@ -0,0 +1,48 @@ +#include <wx/wx.h> + +namespace Examples { +class Frame : public wxFrame { + enum wxOwnedID { + ID_Hello = 2 + }; + + public: + Frame() : wxFrame(nullptr, wxID_ANY, "Hello World") { + auto menuFile = new wxMenu(); + menuFile->Append(ID_Hello, "&Hello...\tCtrl-H", "Help string shown in status bar for this menu item"); + menuFile->AppendSeparator(); + menuFile->Append(wxID_EXIT); + + auto menuHelp = new wxMenu(); + menuHelp->Append(wxID_ABOUT); + auto menuBar = new wxMenuBar(); + + menuBar->Append(menuFile, "&File"); + menuBar->Append(menuHelp, "&Help"); + SetMenuBar(menuBar); + + CreateStatusBar(); + SetStatusText("Welcome to wxWidgets!"); + + menuBar->Bind(wxEVT_MENU, [&](wxCommandEvent &event) { + if (event.GetId() == ID_Hello) + wxLogMessage("Hello world from wxWidgets!"); + else if (event.GetId() == wxID_ABOUT) + wxMessageBox("This is a wxWidgets Hello World example", "About Hello World", wxOK | wxICON_INFORMATION); + else if (event.GetId() == wxID_EXIT) + Close(true); + else + event.Skip(); + }); + } +}; + +class Application : public wxApp { + bool OnInit() override { + (new Frame())->Show(); + return true; + } +}; +} // namespace Examples + +wxIMPLEMENT_APP(Examples::Application);
\ No newline at end of file |
