| 1 |
#include"mainwin.h" |
| 2 |
|
| 3 |
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) |
| 4 |
EVT_MENU(ID_Hello, MyFrame::OnHello) |
| 5 |
EVT_MENU(wxID_EXIT, MyFrame::OnExit) |
| 6 |
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) |
| 7 |
wxEND_EVENT_TABLE() |
| 8 |
|
| 9 |
bool MyApp::OnInit() { |
| 10 |
MyFrame *frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340)); |
| 11 |
frame->Show( true ); |
| 12 |
return true; |
| 13 |
} |
| 14 |
|
| 15 |
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) |
| 16 |
: wxFrame(NULL, wxID_ANY, title, pos, size) { |
| 17 |
wxMenu *menuFile = new wxMenu; |
| 18 |
menuFile->Append(ID_Hello, "&Hello...\tCtrl-H", |
| 19 |
"Help string shown in status bar for this menu item"); |
| 20 |
menuFile->AppendSeparator(); |
| 21 |
menuFile->Append(wxID_EXIT); |
| 22 |
wxMenu *menuHelp = new wxMenu; |
| 23 |
menuHelp->Append(wxID_ABOUT); |
| 24 |
wxMenuBar *menuBar = new wxMenuBar; |
| 25 |
menuBar->Append(menuFile, "&File"); |
| 26 |
menuBar->Append(menuHelp, "&Help"); |
| 27 |
SetMenuBar(menuBar); |
| 28 |
CreateStatusBar(); |
| 29 |
SetStatusText("This is status." ); |
| 30 |
} |
| 31 |
|
| 32 |
void MyFrame::OnExit(wxCommandEvent& event) { |
| 33 |
Close( true ); |
| 34 |
} |
| 35 |
|
| 36 |
void MyFrame::OnAbout(wxCommandEvent& event) { |
| 37 |
//wxMessageBox("Some text", wxOK | wxICON_INFORMATION); |
| 38 |
} |
| 39 |
|
| 40 |
void MyFrame::OnHello(wxCommandEvent& event) { |
| 41 |
wxLogMessage("Some more text."); |
| 42 |
} |
| 43 |
|
| 44 |
#if 0 |
| 45 |
wxIMPLEMENT_APP(MyApp); |
| 46 |
#else |
| 47 |
// Don't open a window because this is an unit test and needs to |
| 48 |
// run headless. |
| 49 |
int main(int, char **) { |
| 50 |
wxString name("Some app"); |
| 51 |
wxPoint p(0, 0); |
| 52 |
wxSize s(100, 100); |
| 53 |
return 0; |
| 54 |
} |
| 55 |
|
| 56 |
#endif |