#include #include #include class MyApp: public wxApp { public: virtual bool OnInit(); }; class MyFrame: public wxFrame { public: MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); private: void OnStdPath(wxCommandEvent& event); void OnInstallPrefix(wxCommandEvent& event); void OnGetCWD(wxCommandEvent& event); void OnExit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); wxDECLARE_EVENT_TABLE(); }; enum { ID_StdPath = 1, ID_GetCWD, ID_InstallPrefix }; wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(ID_StdPath, MyFrame::OnStdPath) EVT_MENU(ID_InstallPrefix, MyFrame::OnInstallPrefix) EVT_MENU(ID_GetCWD, MyFrame::OnGetCWD) EVT_MENU(wxID_EXIT, MyFrame::OnExit) EVT_MENU(wxID_ABOUT, MyFrame::OnAbout) wxEND_EVENT_TABLE() wxIMPLEMENT_APP(MyApp); bool MyApp::OnInit() { MyFrame *frame = new MyFrame( "Get Exe Path", wxPoint(50, 50), wxSize(450, 340) ); frame->Show( true ); return true; } MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) : wxFrame(NULL, wxID_ANY, title, pos, size) { wxMenu *menuFile = new wxMenu; menuFile->Append(ID_StdPath, "Standard Paths...", "Test with wxStandardPaths"); menuFile->Append(ID_InstallPrefix, "Install Prefix...", "Test with Install Prefix"); menuFile->Append(ID_GetCWD, "Get CWD...", "Test with wxGetCwd"); menuFile->AppendSeparator(); menuFile->Append(wxID_EXIT); wxMenu *menuHelp = new wxMenu; menuHelp->Append(wxID_ABOUT); wxMenuBar *menuBar = new wxMenuBar; menuBar->Append( menuFile, "&File" ); menuBar->Append( menuHelp, "&Help" ); SetMenuBar( menuBar ); CreateStatusBar(); SetStatusText( "Welcome to wxWidgets!" ); } void MyFrame::OnExit(wxCommandEvent& event) { Close( true ); } void MyFrame::OnAbout(wxCommandEvent& event) { wxMessageBox( "This is a wxWidgets' Hello world sample", "About Hello World", wxOK | wxICON_INFORMATION ); } void MyFrame::OnStdPath(wxCommandEvent& event) { wxLogMessage(wxStandardPaths::Get().GetExecutablePath()); } void MyFrame::OnInstallPrefix(wxCommandEvent& event) { wxLogMessage(wxStandardPaths::Get().GetInstallPrefix()); /* wxString prefix(wxStandardPaths::Get().GetInstallPrefix()); prefix = prefix + wxT("/share/wxMaxima"); wxLogMessage(prefix); */ } void MyFrame::OnGetCWD(wxCommandEvent& event) { wxLogMessage(wxGetCwd()); }