wxaui-gui.h

00001 /*************************************************************************************
00002  * MechSys - A C++ library to simulate (Continuum) Mechanical Systems                *
00003  * Copyright (C) 2005 Dorival de Moraes Pedroso <dorival.pedroso at gmail.com>       *
00004  * Copyright (C) 2005 Raul Dario Durand Farfan  <raul.durand at gmail.com>           *
00005  *                                                                                   *
00006  * This file is part of MechSys.                                                     *
00007  *                                                                                   *
00008  * MechSys is free software; you can redistribute it and/or modify it under the      *
00009  * terms of the GNU General Public License as published by the Free Software         *
00010  * Foundation; either version 2 of the License, or (at your option) any later        *
00011  * version.                                                                          *
00012  *                                                                                   *
00013  * MechSys is distributed in the hope that it will be useful, but WITHOUT ANY        *
00014  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A   *
00015  * PARTICULAR PURPOSE. See the GNU General Public License for more details.          *
00016  *                                                                                   *
00017  * You should have received a copy of the GNU General Public License along with      *
00018  * MechSys; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
00019  * Fifth Floor, Boston, MA 02110-1301, USA                                           *
00020  *************************************************************************************/
00021 
00022 #ifndef MECHSYS_WXGUI_H
00023 #define MECHSYS_WXGUI_H
00024 
00025 // STL
00026 #include <iostream>
00027 
00028 // wxWidgets
00029 #include "wx/wx.h"
00030 #include "wx/aui/aui.h"
00031 
00032 // ------------------------------------- wxApp ------------------------------------
00033 
00034 class App : public wxApp
00035 {
00036 public:
00037     virtual bool OnInit();
00038 }; // class App
00039 
00040 // ------------------------------------ wxFrame -----------------------------------
00041 
00042 class Frame : public wxFrame
00043 {
00044 public:
00045     // Constructor & Destructor
00046     Frame(wxString const & Title);
00047     ~Frame();
00048     // Events
00049     void OnQuit  (wxCommandEvent & Event);
00050     void OnAbout (wxCommandEvent & Event);
00051 private:
00052     // wxAUI
00053     wxAuiManager _mgr;
00054     // Event table
00055     DECLARE_EVENT_TABLE()
00056     // Controls
00057     wxTextCtrl * _text1;
00058     wxTextCtrl * _text2;
00059 }; // class Frame
00060 
00061 
00063 
00064 
00065 // ------------------------------------- wxApp ------------------------------------
00066 
00067 inline bool App::OnInit() // {{{
00068 {
00069     Frame * frame = new Frame(_("Minimal wxWidgets GUI App"));
00070     frame->Show(true);
00071     return true;
00072 } // }}}
00073 
00074 DECLARE_APP (App) // Implements App & GetApp()
00075 
00076 
00077 // ------------------------------------ wxFrame -----------------------------------
00078 
00079 enum // {{{
00080 {
00081     ID_RUN    = 100,
00082 }; // }}}
00083 
00084 inline Frame::Frame(wxString const & Title) // {{{
00085     : wxFrame(/* parent */ NULL, wxID_ANY, Title)
00086 {
00087     // wxAUI
00088     _mgr.SetManagedWindow(this);
00089 
00090     // Menubar
00091     wxMenuBar * mnu_bar  = new wxMenuBar;
00092     wxMenu    * mnu_file = new wxMenu;
00093     wxMenu    * mnu_run  = new wxMenu;
00094     wxMenu    * mnu_help = new wxMenu;
00095     mnu_file->Append(wxID_EXIT , _("&Quit\tCtrl-Q")         , _("Quit this program"));
00096     mnu_run ->Append(ID_RUN    , _("&Run\tCtrl-R")          , _("Run simulation"));
00097     mnu_help->Append(wxID_ABOUT, _("&About\tF1")            , _("Show about dialog"));
00098     mnu_bar ->Append(mnu_file  , _("&File"));
00099     mnu_bar ->Append(mnu_run   , _("&Run"));
00100     mnu_bar ->Append(mnu_help  , _("&Help"));
00101     SetMenuBar(mnu_bar);
00102 
00103     // Statusbar
00104     CreateStatusBar(2);
00105     SetStatusText(_("Welcome !"));
00106 
00107     // Text controls
00108     _text1 = new wxTextCtrl(this, wxID_ANY, _("\n"), wxPoint(0,0), wxSize(0,0), wxTE_MULTILINE);
00109     _text2 = new wxTextCtrl(this, wxID_ANY, _("\n"), wxPoint(0,0), wxSize(0,0), wxTE_MULTILINE);
00110     _text2->SetBackgroundColour(wxT("wheat"));
00111 
00112     // Add Pane and Update
00113     _mgr.AddPane(_text1, wxAuiPaneInfo().Caption(wxString(_("Text box 1"))).DestroyOnClose(false).Centre());
00114     _mgr.AddPane(_text2, wxAuiPaneInfo().Caption(wxString(_("Text box 2"))).DestroyOnClose(false).Bottom().MinSize(300,300));
00115     _mgr.Update();
00116 
00117 } // }}}
00118 
00119 inline Frame::~Frame() // {{{
00120 {
00121     // Unitialize wxAUI
00122     _mgr.UnInit();
00123 } // }}}
00124 
00125 inline void Frame::OnQuit(wxCommandEvent & Event) // {{{
00126 {
00127     Close();
00128 } // }}}
00129 
00130 inline void Frame::OnAbout(wxCommandEvent & Event) // {{{
00131 {
00132     wxString msg;
00133     msg.Printf(_("Hello and welcome to %s"), wxVERSION_STRING);
00134     wxMessageBox(msg, _("About Minimal"), wxOK | wxICON_INFORMATION, this);
00135 } // }}}
00136 
00137 BEGIN_EVENT_TABLE(Frame, wxFrame) // {{{
00138     EVT_MENU (wxID_EXIT , Frame::OnQuit )
00139     EVT_MENU (wxID_ABOUT, Frame::OnAbout)
00140 END_EVENT_TABLE() // }}}
00141 
00142 #endif // MECHSYS_WXGUI_H
00143 
00144 // vim:fdm=marker

Generated on Wed Jan 24 15:56:26 2007 for MechSys by  doxygen 1.4.7