blob: 4b43fe6e33912ce4e841e08dd6be741e6b131b78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
|