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 #include "gui/wxrealnuminput.h"
00030
00031
00032
00033 class App : public wxApp
00034 {
00035 public:
00036 virtual bool OnInit();
00037 };
00038
00039
00040
00041 class Frame : public wxFrame
00042 {
00043 public:
00044
00045 Frame(wxString const & Title);
00046 ~Frame();
00047
00048 void OnQuit (wxCommandEvent & Event);
00049 void OnAbout (wxCommandEvent & Event);
00050 void OnInp1Changed (WxRealNumInput_Event & Event);
00051 void OnInp2Changed (WxRealNumInput_Event & Event);
00052 void OnInp3Changed (WxRealNumInput_Event & Event);
00053 private:
00054
00055 DECLARE_EVENT_TABLE()
00056
00057 WxRealNumInput * _inp_1;
00058 WxRealNumInput * _inp_2;
00059 WxRealNumInput * _inp_3;
00060 };
00061
00062
00064
00065
00066
00067
00068 inline bool App::OnInit()
00069 {
00070 Frame * frame = new Frame(_("Minimal wxWidgets GUI App"));
00071 frame->Show(true);
00072 return true;
00073 }
00074
00075 DECLARE_APP (App)
00076
00077
00078
00079
00080 enum
00081 {
00082 ID_RUN = 100,
00083 ID_INP_1 = 110,
00084 ID_INP_2 = 120,
00085 ID_INP_3 = 130
00086 };
00087
00088 inline Frame::Frame(wxString const & Title)
00089 : wxFrame( NULL, wxID_ANY, Title)
00090 {
00091
00092 wxMenuBar * mnu_bar = new wxMenuBar;
00093 wxMenu * mnu_file = new wxMenu;
00094 wxMenu * mnu_run = new wxMenu;
00095 wxMenu * mnu_help = new wxMenu;
00096 mnu_file->Append(wxID_EXIT , _("&Quit\tCtrl-Q") , _("Quit this program"));
00097 mnu_run ->Append(ID_RUN , _("&Run\tCtrl-R") , _("Run simulation"));
00098 mnu_help->Append(wxID_ABOUT, _("&About\tF1") , _("Show about dialog"));
00099 mnu_bar ->Append(mnu_file , _("&File"));
00100 mnu_bar ->Append(mnu_run , _("&Run"));
00101 mnu_bar ->Append(mnu_help , _("&Help"));
00102 SetMenuBar(mnu_bar);
00103
00104
00105 CreateStatusBar(2);
00106 SetStatusText(_("Welcome !"));
00107
00108
00109 _inp_1 = new WxRealNumInput(this, ID_INP_1, _T("123.456"), wxDefaultPosition, wxDefaultSize);
00110 _inp_2 = new WxRealNumInput(this, ID_INP_2, _T("223.456"), wxDefaultPosition, wxDefaultSize);
00111 _inp_3 = new WxRealNumInput(this, ID_INP_3, _T("323.456"), wxDefaultPosition, wxDefaultSize);
00112
00113
00114 wxBoxSizer * bsz0 = new wxBoxSizer (wxVERTICAL);
00115 bsz0 -> Add (_inp_1, 0, wxALIGN_LEFT|wxALL, 5);
00116 bsz0 -> Add (_inp_2, 0, wxALIGN_LEFT|wxALL, 5);
00117 bsz0 -> Add (_inp_3, 0, wxALIGN_LEFT|wxALL, 5);
00118 this -> SetSizer (bsz0);
00119 bsz0 -> Fit (this);
00120 bsz0 -> SetSizeHints (this);
00121
00122 }
00123
00124 inline Frame::~Frame()
00125 {
00126 }
00127
00128 inline void Frame::OnQuit(wxCommandEvent & Event)
00129 {
00130 Close();
00131 }
00132
00133 inline void Frame::OnAbout(wxCommandEvent & Event)
00134 {
00135 wxString msg;
00136 msg.Printf(_("Hello and welcome to %s"), wxVERSION_STRING);
00137 wxMessageBox(msg, _("About Minimal"), wxOK | wxICON_INFORMATION, this);
00138 }
00139
00140 inline void Frame::OnInp1Changed(WxRealNumInput_Event & Event)
00141 {
00142 wxString msg;
00143 msg.Printf(_("Got number %f"), Event.GetValue());
00144 wxMessageBox(msg, _("OnInp1Changed"), wxOK | wxICON_INFORMATION, this);
00145 }
00146
00147 inline void Frame::OnInp2Changed(WxRealNumInput_Event & Event)
00148 {
00149 wxString msg;
00150 msg.Printf(_("Got number %f"), Event.GetValue());
00151 wxMessageBox(msg, _("OnInp2Changed"), wxOK | wxICON_INFORMATION, this);
00152 }
00153
00154 inline void Frame::OnInp3Changed(WxRealNumInput_Event & Event)
00155 {
00156 wxString msg;
00157 msg.Printf(_("Got number %f"), Event.GetValue());
00158 wxMessageBox(msg, _("OnInp3Changed"), wxOK | wxICON_INFORMATION, this);
00159 }
00160
00161 BEGIN_EVENT_TABLE(Frame, wxFrame)
00162 EVT_MENU (wxID_EXIT , Frame::OnQuit )
00163 EVT_MENU (wxID_ABOUT, Frame::OnAbout )
00164 EVT_REALNUM_CHANGED (ID_INP_1 , Frame::OnInp1Changed)
00165 EVT_REALNUM_CHANGED (ID_INP_2 , Frame::OnInp2Changed)
00166 EVT_REALNUM_CHANGED (ID_INP_3 , Frame::OnInp3Changed)
00167 END_EVENT_TABLE()
00168
00169 #endif // MECHSYS_WXGUI_H
00170
00171