1 | #include <wx/wx.h> |
---|
2 | |
---|
3 | class MyApp : public wxApp |
---|
4 | { |
---|
5 | virtual bool OnInit(); |
---|
6 | }; |
---|
7 | |
---|
8 | IMPLEMENT_APP(MyApp) |
---|
9 | |
---|
10 | class MyFrame : public wxFrame |
---|
11 | { |
---|
12 | public: |
---|
13 | MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); |
---|
14 | void OnQuit(wxCommandEvent& event); |
---|
15 | }; |
---|
16 | |
---|
17 | enum |
---|
18 | { |
---|
19 | ID_Quit=1 |
---|
20 | }; |
---|
21 | |
---|
22 | |
---|
23 | bool MyApp::OnInit() |
---|
24 | { |
---|
25 | MyFrame *frame = new MyFrame( _("Hello World"), wxPoint(50, 50), |
---|
26 | wxSize(450, 350)); |
---|
27 | |
---|
28 | frame->Connect( ID_Quit, wxEVT_COMMAND_MENU_SELECTED, |
---|
29 | (wxObjectEventFunction) &MyFrame::OnQuit ); |
---|
30 | |
---|
31 | frame->Show(true); |
---|
32 | SetTopWindow(frame); |
---|
33 | return true; |
---|
34 | } |
---|
35 | |
---|
36 | MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) |
---|
37 | : wxFrame( NULL, -1, title, pos, size ) |
---|
38 | { |
---|
39 | wxMenuBar *menuBar = new wxMenuBar; |
---|
40 | wxMenu *menuFile = new wxMenu; |
---|
41 | |
---|
42 | menuFile->Append( ID_Quit, _("E&xit") ); |
---|
43 | menuBar->Append(menuFile, _("&File") ); |
---|
44 | SetMenuBar(menuBar); |
---|
45 | |
---|
46 | CreateStatusBar(); |
---|
47 | SetStatusText( _("Welcome to wxWidgets!") ); |
---|
48 | } |
---|
49 | |
---|
50 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) |
---|
51 | { |
---|
52 | Close(true); |
---|
53 | } |
---|