00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MECHSYS_WXGUI_H
00023 #define MECHSYS_WXGUI_H
00024
00025 #include <iostream>
00026 #include "wx/wx.h"
00027 #include "wx/grid.h"
00028
00029
00030
00031 class App : public wxApp
00032 {
00033 public:
00034 virtual bool OnInit();
00035 };
00036
00037
00038
00039 class Frame : public wxFrame
00040 {
00041 public:
00042
00043 Frame(wxString const & Title);
00044 ~Frame();
00045
00046 void OnQuit (wxCommandEvent & Event);
00047 void OnAbout (wxCommandEvent & Event);
00048 private:
00049
00050 DECLARE_EVENT_TABLE()
00051 };
00052
00053
00055
00056
00057
00058
00059 inline bool App::OnInit()
00060 {
00061 Frame * frame = new Frame(_("Minimal wxWidgets GUI App"));
00062 frame->Show(true);
00063 return true;
00064 }
00065
00066 DECLARE_APP (App)
00067
00068
00069
00070
00071 enum
00072 {
00073 ID_RUN = 100,
00074 };
00075
00076 inline Frame::Frame(wxString const & Title)
00077 : wxFrame( NULL, wxID_ANY, Title)
00078 {
00079
00080 wxMenuBar * mnu_bar = new wxMenuBar;
00081 wxMenu * mnu_file = new wxMenu;
00082 wxMenu * mnu_run = new wxMenu;
00083 wxMenu * mnu_help = new wxMenu;
00084 mnu_file->Append(wxID_EXIT , _("&Quit\tCtrl-Q") , _("Quit this program"));
00085 mnu_run ->Append(ID_RUN , _("&Run\tCtrl-R") , _("Run simulation"));
00086 mnu_help->Append(wxID_ABOUT, _("&About\tF1") , _("Show about dialog"));
00087 mnu_bar ->Append(mnu_file , _("&File"));
00088 mnu_bar ->Append(mnu_run , _("&Run"));
00089 mnu_bar ->Append(mnu_help , _("&Help"));
00090 SetMenuBar(mnu_bar);
00091
00092
00093 CreateStatusBar(2);
00094 SetStatusText(_("Welcome !"));
00095
00096
00097 const int n_choices = 5;
00098 wxString choices[n_choices] = {_("one"), _("two"), _("three"), _("four"), _("five")};
00099 wxGrid * grid = new wxGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
00100 grid -> CreateGrid (10,10);
00101 grid -> SetCellEditor (1,1,new wxGridCellChoiceEditor(n_choices, choices, true));
00102
00103 }
00104
00105 inline Frame::~Frame()
00106 {
00107 }
00108
00109 inline void Frame::OnQuit(wxCommandEvent & Event)
00110 {
00111 Close();
00112 }
00113
00114 inline void Frame::OnAbout(wxCommandEvent & Event)
00115 {
00116 wxString msg;
00117 msg.Printf(_("Hello and welcome to %s"), wxVERSION_STRING);
00118 wxMessageBox(msg, _("About Minimal"), wxOK | wxICON_INFORMATION, this);
00119 }
00120
00121 BEGIN_EVENT_TABLE(Frame, wxFrame)
00122 EVT_MENU (wxID_EXIT , Frame::OnQuit )
00123 EVT_MENU (wxID_ABOUT, Frame::OnAbout)
00124 END_EVENT_TABLE()
00125
00126 #endif // MECHSYS_WXGUI_H
00127
00128