tgrid-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 // ------------------------------------- wxApp ------------------------------------
00030 
00031 class App : public wxApp
00032 {
00033 public:
00034     virtual bool OnInit();
00035 }; // class App
00036 
00037 // ------------------------------------ wxFrame -----------------------------------
00038 
00039 class Frame : public wxFrame
00040 {
00041 public:
00042     // Constructor & Destructor
00043     Frame(wxString const & Title);
00044     ~Frame();
00045     // Events
00046     void OnQuit  (wxCommandEvent & Event);
00047     void OnAbout (wxCommandEvent & Event);
00048 private:
00049     // Event table
00050     DECLARE_EVENT_TABLE()
00051 }; // class Frame
00052 
00053 
00055 
00056 
00057 // ------------------------------------- wxApp ------------------------------------
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) // Implements App & GetApp()
00067 
00068 
00069 // ------------------------------------ wxFrame -----------------------------------
00070 
00071 enum // {{{
00072 {
00073     ID_RUN    = 100,
00074 }; // }}}
00075 
00076 inline Frame::Frame(wxString const & Title) // {{{
00077     : wxFrame(/* parent */ NULL, wxID_ANY, Title)
00078 {
00079     // Menubar
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     // Statusbar
00093     CreateStatusBar(2);
00094     SetStatusText(_("Welcome !"));
00095 
00096     // Grid
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,/*allow others*/ 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 // vim:fdm=marker

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