TAPs 0.7.7.3
TAPsWXFrameSupportGLCanvas.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsWXFrameWithGLCanvas.hpp
00003 A main frame using wxWidgets Toolkit supporting OpenGL.
00004 
00005 SUKITTI PUNAK   (05/05/2006)
00006 UPDATE          (05/05/2006)
00007 ******************************************************************************/
00008 #include "TAPsWXFrameWithGLCanvas.hpp"
00009 // Using Inclusion Model (i.e. definitions are included in declarations)
00010 //                       (this name.cpp is included in name.hpp)
00011 // Each friend is defined directly inside its declaration.
00012 
00013 //=============================================================================
00014 // REMARK:  WXID is a namespace with defining enum for extra ids that that do 
00015 //          not included in wxID.
00016 //          See <TAPs/wxWidgets/TAPsWXEnumList.hpp>
00017 //=============================================================================
00018 
00019 BEGIN_NAMESPACE_TAPs
00020 //=============================================================================
00021 //-----------------------------------------------------------------------------
00022 BEGIN_EVENT_TABLE( WXFrameSupportGLCanvas, wxFrame )
00023     //---------------------------------------------------------------
00024     // Menu File
00025     EVT_MENU( wxID_OPEN,            WXFrameSupportGLCanvas::OnFileOpen )
00026     EVT_MENU( wxID_CLOSE,           WXFrameSupportGLCanvas::OnFileClose )
00027     EVT_MENU( WXID::MENU_EXPORT,    WXFrameSupportGLCanvas::OnFileExport )
00028     EVT_MENU( wxID_EXIT,            WXFrameSupportGLCanvas::OnFileExit )
00029     //---------------------------------------------------------------
00030     // Menu Edit
00031     EVT_MENU( wxID_UNDO,        WXFrameSupportGLCanvas::OnEditUndo )
00032     EVT_MENU( wxID_REDO,        WXFrameSupportGLCanvas::OnEditRedo )
00033     //---------------------------------------------------------------
00034     // Menu View
00035     EVT_MENU( wxID_RESET,       WXFrameSupportGLCanvas::OnViewReset )
00036     //---------------------------------------------------------------
00037     // Menu Window
00038     EVT_MENU( WXID::MENU_NEW_WINDOW,    WXFrameSupportGLCanvas::OnWindowNewWindow )
00039     //---------------------------------------------------------------
00040     // Menu Help
00041     EVT_MENU( wxID_ABOUT,       WXFrameSupportGLCanvas::OnHelpAbout )
00042     //---------------------------------------------------------------
00043 END_EVENT_TABLE()
00044 //-----------------------------------------------------------------------------
00045 //=============================================================================
00046 
00047 //=============================================================================
00048 // Static Fn for Creating WXFrameSupportGLCanvas
00049 //-----------------------------------------------------------------------------
00050 WXFrameSupportGLCanvas * WXFrameSupportGLCanvas::Create (
00051                 WXFrameSupportGLCanvas * parentFrame, 
00052                 bool isCloneWindow )
00053 {
00054     wxString str = wxT( "Another wxWidgets (w/ OpenGL) Application" );
00055     if ( isCloneWindow )    str += wxT( " - Clone" );
00056     WXFrameSupportGLCanvas * frame = 
00057         new WXFrameSupportGLCanvas( NULL, str, wxDefaultPosition, wxSize( 540, 560 ) );
00058     //---------------------------------------------------------------
00059     // Create Main Menu
00060     CreateMainMenu( frame );
00061     //---------------------------------------------------------------
00062     if ( parentFrame ) {
00063         frame->m_pWXOpenGLCanvas = new WXOpenGLCanvas( 
00064                     frame, parentFrame->m_pWXOpenGLCanvas,
00065                     wxID_ANY, wxDefaultPosition, wxDefaultSize );
00066     }
00067     else {
00068         frame->m_pWXOpenGLCanvas = new WXOpenGLCanvas( 
00069                     frame, 
00070                     wxID_ANY, wxDefaultPosition, wxDefaultSize );
00071     }
00072     //---------------------------------------------------------------
00073     // Show the frame
00074     frame->Show( true );
00075     //---------------------------------------------------------------
00076     return frame;
00077 }
00078 //-----------------------------------------------------------------------------
00079 //=============================================================================
00080 
00081 
00082 //=============================================================================
00083 // Constructor for Class WXFrameSupportGLCanvas
00084 //-----------------------------------------------------------------------------
00085 WXFrameSupportGLCanvas::WXFrameSupportGLCanvas ( 
00086             wxWindow * parent, 
00087             const wxString & title, 
00088             const wxPoint & pos,
00089             const wxSize & size, 
00090             long style )
00091     : wxFrame( parent, wxID_ANY, title, pos, size, style )
00092     , m_pWXOpenGLCanvas( NULL )
00093 {
00094     SetIcon( wxIcon( sample_xpm ) );
00095 }
00096 //-----------------------------------------------------------------------------
00097 //=============================================================================
00098 
00099 //=============================================================================
00100 // START MENU FILE
00101 //-----------------------------------------------------------------------------
00102 // Intercept Open File menu commands
00103 void WXFrameSupportGLCanvas::OnFileOpen ( wxCommandEvent & WXUNUSED(event) )
00104 {
00105     wxString caption = wxT("Choose a file");
00106     wxString wildcard 
00107         = wxT( "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif");
00108         //= wxT( " files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif");
00109     //wxString defaultDir = wxT( "d:\\" );
00110     wxString defaultDir = wxEmptyString;
00111     wxString defaultFilename = wxEmptyString;
00112     wxFileDialog fileDialog( this, wxT("Open A Model File Dialog"), 
00113                              defaultDir, 
00114                              defaultFilename, wxT(""), wxOPEN );
00115                              //defaultFilename, wildcard, wxOPEN );
00116     //---------------------------------------------------------------
00117     if ( fileDialog.ShowModal() == wxID_OK ) {
00118         wxString info;
00119         info.Printf( wxT("Full file name: %s\n")
00120                      wxT("Path: %s\n")
00121                      wxT("Name: %s\n"),
00122                      fileDialog.GetPath().c_str(),
00123                      fileDialog.GetDirectory().c_str(),
00124                      fileDialog.GetFilename().c_str() );
00125         wxMessageDialog dialog ( this, info, wxT("Selected File") );
00126         dialog.ShowModal();
00127         wxString path   = fileDialog.GetPath();
00128         int filterIndex = fileDialog.GetFilterIndex();
00129     }
00130     //---------------------------------------------------------------
00131     // Repaint the OpenGL window
00132     //this->RetGLCanvasPtr()->OnPaint( wxPaintEvent() );
00133     //---------------------------------------------------------------
00134 }
00135 //-----------------------------------------------------------------------------
00136 // Intercept Close File menu commands
00137 void WXFrameSupportGLCanvas::OnFileClose ( wxCommandEvent & WXUNUSED(event) )
00138 {
00139     WX::Debug::DisplayDialog( wxString( "On File Close" ) );
00140     //---------------------------------------------------------------
00141     // Repaint the OpenGL window
00142     //this->RetGLCanvasPtr()->OnPaint( wxPaintEvent() );
00143     //---------------------------------------------------------------
00144 }
00145 //-----------------------------------------------------------------------------
00146 // Intercept Export File menu commands
00147 void WXFrameSupportGLCanvas::OnFileExport ( wxCommandEvent & WXUNUSED(event) )
00148 {
00149     WX::Debug::DisplayDialog( wxString( "On File Export" ) );
00150     //---------------------------------------------------------------
00151     // Repaint the OpenGL window
00152     //this->RetGLCanvasPtr()->OnPaint( wxPaintEvent() );
00153     //---------------------------------------------------------------
00154 }
00155 //-----------------------------------------------------------------------------
00156 // Intercept Exit menu commands
00157 void WXFrameSupportGLCanvas::OnFileExit ( wxCommandEvent & WXUNUSED(event) )
00158 {
00159     //WX::Debug::DisplayDialog( wxString( "On File Exit" ) );
00160     //---------------------------------------------------------------
00161     // True is to force the frame to close
00162     Close( true );
00163     //ExitHandler();    // User defined function
00164     //---------------------------------------------------------------
00165 }
00166 //-----------------------------------------------------------------------------
00167 // END MENU FILE
00168 //=============================================================================
00169 
00170 //=============================================================================
00171 // START MENU EDIT
00172 //-----------------------------------------------------------------------------
00173 // Intercept Undo Edit menu commands
00174 void WXFrameSupportGLCanvas::OnEditUndo ( wxCommandEvent & WXUNUSED(event) )
00175 {
00176     WX::Debug::DisplayDialog( wxString( "On Edit Undo" ) );
00177     //---------------------------------------------------------------
00178     // Repaint the OpenGL window
00179     //this->RetGLCanvasPtr()->OnPaint( wxPaintEvent() );
00180     //---------------------------------------------------------------
00181 }
00182 //-----------------------------------------------------------------------------
00183 // Intercept Redo Edit menu commands
00184 void WXFrameSupportGLCanvas::OnEditRedo ( wxCommandEvent & WXUNUSED(event) )
00185 {
00186     WX::Debug::DisplayDialog( wxString( "On Edit Redo" ) );
00187     //---------------------------------------------------------------
00188     // Repaint the OpenGL window
00189     //this->RetGLCanvasPtr()->OnPaint( wxPaintEvent() );
00190     //---------------------------------------------------------------
00191 }
00192 //-----------------------------------------------------------------------------
00193 // END MENU EDIT
00194 //=============================================================================
00195 
00196 //=============================================================================
00197 // START MENU VIEW
00198 //-----------------------------------------------------------------------------
00199 // Intercept Reset View menu commands
00200 void WXFrameSupportGLCanvas::OnViewReset ( wxCommandEvent & WXUNUSED(event) )
00201 {
00202     WX::Debug::DisplayDialog( wxString( "On View Reset" ) );
00203     //---------------------------------------------------------------
00204     // Repaint the OpenGL window
00205     //this->RetGLCanvasPtr()->OnPaint( wxPaintEvent() );
00206     //---------------------------------------------------------------
00207 }
00208 //-----------------------------------------------------------------------------
00209 // END MENU VIEW
00210 //=============================================================================
00211 
00212 //=============================================================================
00213 // START MENU WINDOW
00214 //-----------------------------------------------------------------------------
00215 // Intercept New Window Window menu commands
00216 void WXFrameSupportGLCanvas::OnWindowNewWindow ( wxCommandEvent & WXUNUSED(event) )
00217 {
00218     WX::Debug::DisplayDialog( wxString( "On Window New Window" ) );
00219     //---------------------------------------------------------------
00220     // Repaint the OpenGL window
00221     //this->RetGLCanvasPtr()->OnPaint( wxPaintEvent() );
00222     //---------------------------------------------------------------
00223 }
00224 //-----------------------------------------------------------------------------
00225 // END MENU WINDOW
00226 //=============================================================================
00227 
00228 //=============================================================================
00229 // START MENU HELP
00230 //-----------------------------------------------------------------------------
00231 // Intercept About Help menu commands
00232 void WXFrameSupportGLCanvas::OnHelpAbout ( wxCommandEvent & WXUNUSED(event) )
00233 {
00234     WX::Debug::DisplayDialog( wxString( "On Help About" ) );
00235     //---------------------------------------------------------------
00236     // Repaint the OpenGL window
00237     //this->RetGLCanvasPtr()->OnPaint( wxPaintEvent() );
00238     //---------------------------------------------------------------
00239 }
00240 //-----------------------------------------------------------------------------
00241 // END MENU HELP
00242 //=============================================================================
00243 
00244 //=============================================================================
00245 // CREATE MENUS
00246 //-----------------------------------------------------------------------------
00247 void WXFrameSupportGLCanvas::CreateMainMenu ( WXFrameSupportGLCanvas * frame )
00248 {
00249     //---------------------------------------------------------------
00250     // Make MenuBar and Menus
00251     frame->CreateMenuBar();
00252     //-----------------------------------------------------
00253     // Set MenuBar
00254     frame->SetMenuBar( frame->m_menuBar );
00255     frame->CreateStatusBar();
00256     frame->SetStatusText( "Another wxWidgets (w/ OpenGL) Application" );
00257 }
00258 //-----------------------------------------------------------------------------
00259 void WXFrameSupportGLCanvas::CreateMenuBar ()
00260 {
00261     m_menuBar = new wxMenuBar;
00262     //---------------------------------------------------------------
00263     CreateMenuFile();
00264     CreateMenuEdit();
00265     CreateMenuView();
00266     CreateMenuWindow();
00267     CreateMenuHelp();
00268     //---------------------------------------------------------------
00269     m_menuBar->Append( m_menuFile, wxT( "&File" ) );
00270     m_menuBar->Append( m_menuEdit, wxT( "&Edit" ) );
00271     m_menuBar->Append( m_menuView, wxT( "&View" ) );
00272     m_menuBar->Append( m_menuWindow, wxT( "&Window" ) );
00273     m_menuBar->Append( m_menuHelp, wxT( "&Help" ) );
00274     //---------------------------------------------------------------
00275 }
00276 //-----------------------------------------------------------------------------
00277 void WXFrameSupportGLCanvas::CreateMenuFile ()
00278 {
00279     //-----------------------------------------------------
00280     // Menu File
00281     m_menuFile = new wxMenu;
00282     m_menuFile->Append( wxID_OPEN, wxT("&Open Model...\tCtrl+O"), wxT("Opens a file") );
00283     m_menuFile->Append( wxID_CLOSE, wxT("&Close Model\tCtrl+F4"), wxT("Closes the file") );
00284     m_menuFile->AppendSeparator();
00285     m_menuFile->Append( WXID::MENU_EXPORT, wxT("&Export..."), 
00286                   wxT("Export ...") );
00287     m_menuFile->AppendSeparator();
00288     m_menuFile->Append( wxID_EXIT, wxT("E&xit"), wxT("Quits the program") );
00289 }
00290 //-----------------------------------------------------------------------------
00291 void WXFrameSupportGLCanvas::CreateMenuEdit ()
00292 {
00293     //-----------------------------------------------------
00294     // Menu Edit
00295     m_menuEdit = new wxMenu;
00296     m_menuEdit->Append( wxID_UNDO, wxT("&Undo\tCtrl+Z"), wxT("Undo") );
00297     m_menuEdit->Append( wxID_REDO, wxT("&Redo\tCtrl+Y"), wxT("Redo") );
00298 }
00299 //-----------------------------------------------------------------------------
00300 void WXFrameSupportGLCanvas::CreateMenuView ()
00301 {
00302     //-----------------------------------------------------
00303     // Menu View
00304     m_menuView = new wxMenu;
00305     m_menuView->Append( wxID_RESET, wxT("&Reset\tCtrl+R"), wxT("Reset") );
00306 }
00307 //-----------------------------------------------------------------------------
00308 void WXFrameSupportGLCanvas::CreateMenuWindow ()
00309 {
00310     //-----------------------------------------------------
00311     // Menu View
00312     m_menuWindow = new wxMenu;
00313     m_menuWindow->Append( WXID::MENU_NEW_WINDOW, wxT("&New Window"), wxT("New Window") );
00314 }
00315 //-----------------------------------------------------------------------------
00316 void WXFrameSupportGLCanvas::CreateMenuHelp ()
00317 {
00318     //-----------------------------------------------------
00319     // Menu Help
00320     m_menuHelp = new wxMenu;
00321     m_menuHelp->Append( wxID_ABOUT, wxT("&About"), wxT("About this application") );
00322 }
00323 //-----------------------------------------------------------------------------
00324 //=============================================================================
00325 
00326 //=============================================================================
00327 // UPDATE MENUS
00328 //-----------------------------------------------------------------------------
00329 void WXFrameSupportGLCanvas::UpdateMenuFile ()
00330 {}
00331 //-----------------------------------------------------------------------------
00332 void WXFrameSupportGLCanvas::UpdateMenuEdit ()
00333 {}
00334 //-----------------------------------------------------------------------------
00335 void WXFrameSupportGLCanvas::UpdateMenuView ()
00336 {}
00337 //-----------------------------------------------------------------------------
00338 void WXFrameSupportGLCanvas::UpdateMenuWindow ()
00339 {}
00340 //-----------------------------------------------------------------------------
00341 void WXFrameSupportGLCanvas::UpdateMenuHelp ()
00342 {}
00343 //-----------------------------------------------------------------------------
00344 //=============================================================================
00345 
00346 //-----------------------------------------------------------------------------
00347 //=============================================================================
00348 END_NAMESPACE_TAPs
00349 //-----------------------------------------------------------------------------
00350 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00351 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines