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
00028 #include "gui/wxgout.h"
00029
00030
00031
00032 class App : public wxApp
00033 {
00034 public:
00035 virtual bool OnInit();
00036 };
00037
00038
00039
00040 class Frame : public wxFrame
00041 {
00042 public:
00043
00044 Frame(wxString const & Title);
00045 ~Frame();
00046
00047 void OnQuit (wxCommandEvent & Event);
00048 void OnAbout (wxCommandEvent & Event);
00049 void OnRun (wxCommandEvent & Event);
00050 private:
00051
00052 DECLARE_EVENT_TABLE()
00053
00054 wxTextCtrl * _term;
00055 };
00056
00057
00059
00060
00061
00062
00063 inline bool App::OnInit()
00064 {
00065 Frame * frame = new Frame(_("Minimal wxWidgets GUI App"));
00066 frame->Show(true);
00067 return true;
00068 }
00069
00070 DECLARE_APP (App)
00071
00072
00073
00074
00075 enum
00076 {
00077 ID_RUN = 100,
00078 };
00079
00080 inline Frame::Frame(wxString const & Title)
00081 : wxFrame( NULL, wxID_ANY, Title)
00082 {
00083
00084 wxMenuBar * mnu_bar = new wxMenuBar;
00085 wxMenu * mnu_file = new wxMenu;
00086 wxMenu * mnu_run = new wxMenu;
00087 wxMenu * mnu_help = new wxMenu;
00088 mnu_file->Append(wxID_EXIT , _("&Quit\tCtrl-Q") , _("Quit this program"));
00089 mnu_run ->Append(ID_RUN , _("&Run\tCtrl-R") , _("Run simulation"));
00090 mnu_help->Append(wxID_ABOUT, _("&About\tF1") , _("Show about dialog"));
00091 mnu_bar ->Append(mnu_file , _("&File"));
00092 mnu_bar ->Append(mnu_run , _("&Run"));
00093 mnu_bar ->Append(mnu_help , _("&Help"));
00094 SetMenuBar(mnu_bar);
00095
00096
00097 CreateStatusBar(2);
00098 SetStatusText(_("Welcome !"));
00099
00100
00101 _term = new wxTextCtrl(this, wxID_ANY, _("\n"), wxPoint(0,0), wxSize(0,0), wxTE_MULTILINE);
00102 _term->SetBackgroundColour(wxT("wheat"));
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 inline void Frame::OnRun(wxCommandEvent & Event)
00122 {
00123 Gout gout(_term);
00124 WGout wgout(_term);
00125 std::basic_streambuf<char> * cout_sbuf = std::cout.rdbuf(&gout);
00126 std::cout << "cout << Hi from OnRun\n";
00127 std::cout.rdbuf( cout_sbuf);
00128 #ifndef __WXMSW__
00129 std::basic_streambuf<wchar_t> * wcout_sbuf = std::wcout.rdbuf(&wgout);
00130 std::wcout << "wcout << Hi from OnRun\n";
00131 std::wcout.rdbuf(wcout_sbuf);
00132 #endif
00133 }
00134
00135 BEGIN_EVENT_TABLE(Frame, wxFrame)
00136 EVT_MENU (wxID_EXIT , Frame::OnQuit )
00137 EVT_MENU (wxID_ABOUT, Frame::OnAbout)
00138 EVT_MENU (ID_RUN , Frame::OnRun )
00139 END_EVENT_TABLE()
00140
00141 #endif // MECHSYS_WXGUI_H
00142
00143