Advertisement
Guest User

Untitled

a guest
Oct 7th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #include "wx/wx.h"
  2. #include "wx/frame.h"
  3.  
  4.  
  5. class MyApp : public wxApp
  6. {
  7. public:
  8. // Called on application start-up
  9. bool OnInit();
  10. };
  11.  
  12. class MyFrame : wxFrame
  13. {
  14. public :
  15. //Constructor
  16. MyFrame (const wxString& title);
  17.  
  18. // Event handlers
  19. void OnQuit(wxCommandEvent& event);
  20. void OnAbout(wxCommandEvent& event);
  21. private :
  22. // This class handlers events
  23. DECLARE_EVENT_TABLE();
  24. };
  25.  
  26. IMPLEMENT_APP(MyApp)
  27.  
  28. DECLARE_APP(MyApp)
  29.  
  30. bool MyApp::OnInit()
  31. {
  32. // Create the main application window
  33. MyFrame *frame = new MyFrame(wxT("Minimal wxWidgets App"));
  34.  
  35. // Show it
  36. frame->Show(true);
  37.  
  38. // Start the event loop
  39. return true;
  40. };
  41.  
  42. // Event table for MyFrame
  43. BEGIN_EVENT_TABLE(MyFrame, wxFrame)
  44. EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
  45. EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
  46. END_EVENT_TABLE()
  47.  
  48.  
  49. void MyFrame::OnAbout(wxCommandEvent& event)
  50. {
  51. wxString msg;
  52. msg.Printf(wxT("Hello and we welcome to %s"), wxVERSION_STRING);
  53.  
  54. wxMessageBox(msg, wxT("About Minimal"), wxOK | wxICON_INFORMATION, this);
  55. }
  56.  
  57. void MyFrame::OnQuit(wxCommandEvent& event)
  58. {
  59. // Destroy the Frame
  60. Close();
  61. }
  62. #include "mondrian.xpm"
  63.  
  64. MyFrame::MyFrame(const wxString& title)
  65. : wxFrame(NULL, wxID_ANY, title)
  66. {
  67. // Set the frame icon
  68. SetIcon(wxIcon(mondrian_xpm));
  69.  
  70. // Create a menu bar
  71. wxMenu *fileMenu = new wxMenu;
  72.  
  73. // The "About" item should be in the help menu
  74. wxMenu *helpMenu = new wxMenu;
  75. helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"),
  76. wxT("Show about dialog"));
  77.  
  78. fileMenu->Append(wxID_EXIT, wxT("E&xit\tAlt-X"),
  79. wxT("Quit this program"));
  80.  
  81. // Now append the freshly created menu to the menu bar...
  82. wxMenuBar *menuBar = new wxMenuBar();
  83. menuBar->Append(fileMenu, wxT("&File"));
  84. menuBar->Append(helpMenu, wxT("&Help"));
  85.  
  86. // ... and attach this menu bar to the frame
  87. SetMenuBar(menuBar);
  88.  
  89. // Create a status bar just for fun
  90. CreateStatusBar(2);
  91. SetStatusText(wxT("Welcome to wxWidgets!"));
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement