twxiconbox-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 #include <iostream>
00026 #include "wx/wx.h"
00027 #include "wx/grid.h"
00028 
00029 #include "gui/wxiconbox.h"
00030 
00031 #define ICONS_PHI26_USE32
00032 #include "gui/icons.phi26.h"
00033 
00034 // ------------------------------------- wxApp ------------------------------------
00035 
00036 class App : public wxApp
00037 {
00038 public:
00039     virtual bool OnInit();
00040 }; // class App
00041 
00042 // ------------------------------------ wxFrame -----------------------------------
00043 
00044 class Frame : public wxFrame
00045 {
00046 public:
00047     // Constructor & Destructor
00048     Frame(wxString const & Title);
00049     ~Frame();
00050     // Events
00051     void OnQuit        (wxCommandEvent       & Event);
00052     void OnAbout       (wxCommandEvent       & Event);
00053 private:
00054     // Event table
00055     DECLARE_EVENT_TABLE()
00056     // Controls
00057     WxIconBox * _icon_box;
00058 }; // class Frame
00059 
00060 
00062 
00063 
00064 // ------------------------------------- wxApp ------------------------------------
00065 
00066 inline bool App::OnInit() // {{{
00067 {
00068     Frame * frame = new Frame(_("Minimal wxWidgets GUI App"));
00069     frame->Show(true);
00070     return true;
00071 } // }}}
00072 
00073 DECLARE_APP (App) // Implements App & GetApp()
00074 
00075 
00076 // ------------------------------------ wxFrame -----------------------------------
00077 
00078 enum // {{{
00079 {
00080     ID_RUN   = 100,
00081     ID_INP_1 = 110,
00082     ID_INP_2 = 120,
00083     ID_INP_3 = 130
00084 }; // }}}
00085 
00086 inline Frame::Frame(wxString const & Title) // {{{
00087     : wxFrame(/* parent */ NULL, wxID_ANY, Title)
00088 {
00089     // Menubar
00090     wxMenuBar * mnu_bar  = new wxMenuBar;
00091     wxMenu    * mnu_file = new wxMenu;
00092     wxMenu    * mnu_run  = new wxMenu;
00093     wxMenu    * mnu_help = new wxMenu;
00094     mnu_file->Append(wxID_EXIT , _("&Quit\tCtrl-Q")         , _("Quit this program"));
00095     mnu_run ->Append(ID_RUN    , _("&Run\tCtrl-R")          , _("Run simulation"));
00096     mnu_help->Append(wxID_ABOUT, _("&About\tF1")            , _("Show about dialog"));
00097     mnu_bar ->Append(mnu_file  , _("&File"));
00098     mnu_bar ->Append(mnu_run   , _("&Run"));
00099     mnu_bar ->Append(mnu_help  , _("&Help"));
00100     SetMenuBar(mnu_bar);
00101 
00102     // Statusbar
00103     CreateStatusBar(2);
00104     SetStatusText(_("Welcome !"));
00105 
00106     // Incon box
00107     _icon_box = new WxIconBox(this, wxID_ANY, wxDefaultPosition, /*Width*/ 300, /*nLines*/ 6);
00108     _icon_box->Add(wxIcon(s32_crit_TR_phi_26),_(" (TR) Tresca               ")); 
00109     _icon_box->Add(wxIcon(s32_crit_VM_phi_26),_(" (VM) von Mises            ")); 
00110     _icon_box->Add(wxIcon(s32_crit_MC_phi_26),_(" (MC) Mohr-Coulomb         ")); 
00111     _icon_box->Add(wxIcon(s32_crit_LD_phi_26),_(" (LD) Lade-Duncan          ")); 
00112     _icon_box->Add(wxIcon(s32_crit_DP_phi_26),_(" (DP) Drucker-Prager       ")); 
00113     _icon_box->Add(wxIcon(s32_crit_MN_phi_26),_(" (MN) Matsuoka-Nakai       ")); 
00114     _icon_box->Add(wxIcon(s32_crit_SM_phi_26),_(" (SM) SMP (Novo)           ")); 
00115     _icon_box->Add(wxIcon(s32_crit_AR_phi_26),_(" (AR) Argyris-Sheng et al. ")); 
00116 
00117     // Sizers
00118     wxBoxSizer * bsz0 = new wxBoxSizer (wxVERTICAL);
00119     bsz0 -> Add          (_icon_box, 0, wxALIGN_LEFT|wxALL, 5);
00120     this -> SetSizer     (bsz0);
00121     bsz0 -> Fit          (this);
00122     bsz0 -> SetSizeHints (this);
00123 
00124 } // }}}
00125 
00126 inline Frame::~Frame() // {{{
00127 {
00128 } // }}}
00129 
00130 inline void Frame::OnQuit(wxCommandEvent & Event) // {{{
00131 {
00132     Close();
00133 } // }}}
00134 
00135 inline void Frame::OnAbout(wxCommandEvent & Event) // {{{
00136 {
00137     wxString msg;
00138     msg.Printf(_("Hello and welcome to %s"), wxVERSION_STRING);
00139     wxMessageBox(msg, _("About Minimal"), wxOK | wxICON_INFORMATION, this);
00140 } // }}}
00141 
00142 BEGIN_EVENT_TABLE(Frame, wxFrame) // {{{
00143     EVT_MENU            (wxID_EXIT , Frame::OnQuit       )
00144     EVT_MENU            (wxID_ABOUT, Frame::OnAbout      )
00145 END_EVENT_TABLE() // }}}
00146 
00147 #endif // MECHSYS_WXGUI_H
00148 
00149 // vim:fdm=marker

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