wxprog.cpp 1.4 KB

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