#include #include #include #include #include #include int wxID_EDIT1 = wxNewId(); int wxID_EDIT2 = wxNewId(); int wxID_GRID = wxNewId(); int wxID_SHOWHIDE = wxNewId(); class MyApp : public wxApp { virtual bool OnInit(); }; DECLARE_APP(MyApp) IMPLEMENT_APP(MyApp) class MyFrame : public wxFrame { wxPanel* mpPanel; wxButton* mpButton ; wxBoxSizer* mpSizer; wxTextCtrl* mpText; public: MyFrame(const wxString& title); ~MyFrame(); void OnQuit(wxCommandEvent &event); void OnButtonPressed(wxCommandEvent &event); void OnShowHide(wxCommandEvent &event); DECLARE_EVENT_TABLE() }; bool MyApp::OnInit() { MyFrame *frame = new MyFrame(wxT("test")); frame->Show(); return true; } //-------------------------------------------------- BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(wxID_EXIT, MyFrame::OnQuit) EVT_BUTTON(wxID_ABOUT, MyFrame::OnButtonPressed) EVT_BUTTON(wxID_OK, MyFrame::OnButtonPressed) EVT_BUTTON(wxID_CANCEL, MyFrame::OnButtonPressed) EVT_BUTTON(wxID_SHOWHIDE, MyFrame::OnShowHide) END_EVENT_TABLE() MyFrame::MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600,400), wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxRESIZE_BORDER) { wxMenu *filemenu = new wxMenu; filemenu->Append(wxID_EXIT, wxT("Exit\tAlt-X"), wxT("Quit this program")); wxMenuBar *bar = new wxMenuBar(); bar->Append(filemenu, wxT("File") ); SetMenuBar(bar); CreateStatusBar(2,0); //no sizegripper SetStatusText(wxT("Welcome to wxWidgets")); mpPanel = new wxPanel(this); mpButton = new wxButton(mpPanel, wxID_OK,wxT("Button"), wxDefaultPosition, wxDefaultSize); mpText = new wxTextCtrl(mpPanel, wxID_ANY); mpSizer = new wxBoxSizer(wxVERTICAL); mpSizer->Add(mpButton,0, wxALIGN_CENTER_HORIZONTAL); mpSizer->Add(mpText, 1, wxEXPAND); mpPanel->SetSizer(mpSizer); mpPanel->Layout(); } MyFrame::~MyFrame() { } void MyFrame::OnQuit(wxCommandEvent& event) { this->Close(); } void MyFrame::OnButtonPressed(wxCommandEvent& event) { } void MyFrame::OnShowHide(wxCommandEvent& event) { }