]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/samples/ogl/studio/studio.cpp
Renderer should only be used for GTK+ 2
[wxWidgets.git] / contrib / samples / ogl / studio / studio.cpp
index 492f1ad4908791ffe2921889923a9a7a43c057e7..4e45f3c01c8712e6ab464beb690b00c2a6179934 100644 (file)
 #include "wx/mdi.h"
 #endif
 
-#include <wx/deprecated/setup.h>
-#include <wx/deprecated/resource.h>
+#include "wx/ogl/ogl.h" // base header of OGL, includes and adjusts wx/deprecated/setup.h
+
 #include "wx/config.h"
 #include "wx/laywin.h"
+#include "wx/helpwin.h"
 
 #include "studio.h"
 #include "view.h"
@@ -92,111 +93,113 @@ csApp::~csApp()
 // Initialise this in OnInit, not statically
 bool csApp::OnInit(void)
 {
-  if (!wxResourceParseFile(_T("studio_resources.wxr")))
-  {
-    wxMessageBox(_T("Could not find or parse resource file: studio_resources.wxr"), _T("Studio"));
-    return false;
-  }
+#if wxUSE_WX_RESOURCES
+    if (!wxResourceParseFile(_T("studio_resources.wxr")))
+    {
+        wxMessageBox(_T("Could not find or parse resource file: studio_resources.wxr"), _T("Studio"));
+        return false;
+    }
+#endif
 
 #if wxUSE_MS_HTML_HELP && !defined(__WXUNIVERSAL__)
-  m_helpController = new wxWinHelpController;
+    m_helpController = new wxWinHelpController;
 #else
-  m_helpController = new wxHtmlHelpController;
+    m_helpController = new wxHtmlHelpController;
 #endif
 
-  m_helpController->Initialize(_T("studio.hlp"));
+    m_helpController->Initialize(_T("studio.hlp"));
 
-  ReadOptions();
+    ReadOptions();
 
-  wxOGLInitialize();
+    wxOGLInitialize();
 
-  InitSymbols();
+    InitSymbols();
 
-  //// Create a document manager
-  m_docManager = new wxDocManager;
+    //// Create a document manager
+    m_docManager = new wxDocManager;
 
-  //// Create a template relating drawing documents to their views
-  (void) new wxDocTemplate(m_docManager, _T("Diagram"), _T("*.dia"), wxEmptyString, _T("dia"), _T("Diagram Doc"), _T("Diagram View"),
-          CLASSINFO(csDiagramDocument), CLASSINFO(csDiagramView));
+    //// Create a template relating drawing documents to their views
+    (void) new wxDocTemplate(m_docManager, _T("Diagram"), _T("*.dia"), wxEmptyString, _T("dia"), _T("Diagram Doc"), _T("Diagram View"),
+            CLASSINFO(csDiagramDocument), CLASSINFO(csDiagramView));
 
-  // Create the main frame window.
-  // Note that we use a frame style that doesn't have wxCLIP_CHILDREN in it
-  // (the default frame style contains wxCLIP_CHILDREN), otherwise the client
-  // area doesn't refresh properly when we change its position, under Windows.
+    // Create the main frame window.
+    // Note that we use a frame style that doesn't have wxCLIP_CHILDREN in it
+    // (the default frame style contains wxCLIP_CHILDREN), otherwise the client
+    // area doesn't refresh properly when we change its position, under Windows.
 
 #define wxDEFAULT_FRAME_STYLE_NO_CLIP \
-  (wxDEFAULT_FRAME_STYLE & ~wxCLIP_CHILDREN)
+    (wxDEFAULT_FRAME_STYLE & ~wxCLIP_CHILDREN)
 
-  csFrame* frame = new csFrame(m_docManager, NULL, wxID_ANY, _T("OGL Studio"), m_mainFramePos, m_mainFrameSize,
-   wxDEFAULT_FRAME_STYLE_NO_CLIP | wxHSCROLL | wxVSCROLL);
+    csFrame* frame = new csFrame(m_docManager, NULL, wxID_ANY, _T("OGL Studio"), m_mainFramePos, m_mainFrameSize,
+                     wxDEFAULT_FRAME_STYLE_NO_CLIP | wxHSCROLL | wxVSCROLL);
 
-  // Give it an icon
-  frame->SetIcon(wxICON(studio));
+    // Give it an icon
+    frame->SetIcon(wxICON(studio));
 
-  // Make a menubar
-  wxMenu *fileMenu = new wxMenu;
+    // Make a menubar
+    wxMenu *fileMenu = new wxMenu;
 
-  fileMenu->Append(wxID_NEW, _T("&New...\tCtrl+N"));
-  fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O"));
+    fileMenu->Append(wxID_NEW, _T("&New...\tCtrl+N"));
+    fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O"));
 
-  fileMenu->AppendSeparator();
+    fileMenu->AppendSeparator();
 
-  fileMenu->Append(wxID_PRINT, _T("&Print...\tCtrl+P"));
-  fileMenu->Append(wxID_PRINT_SETUP, _T("Print &Setup..."));
-  fileMenu->Append(wxID_PREVIEW, _T("Print Pre&view"));
-  fileMenu->AppendSeparator();
-  fileMenu->Append(wxID_EXIT, _T("E&xit"));
+    fileMenu->Append(wxID_PRINT, _T("&Print...\tCtrl+P"));
+    fileMenu->Append(wxID_PRINT_SETUP, _T("Print &Setup..."));
+    fileMenu->Append(wxID_PREVIEW, _T("Print Pre&view"));
+    fileMenu->AppendSeparator();
+    fileMenu->Append(wxID_EXIT, _T("E&xit"));
 
-  // A history of files visited. Use this menu.
-  m_docManager->FileHistoryUseMenu(fileMenu);
+    // A history of files visited. Use this menu.
+    m_docManager->FileHistoryUseMenu(fileMenu);
 
-  wxMenu *viewMenu = new wxMenu;
-  viewMenu->Append(ID_CS_SETTINGS, _T("&Settings..."));
+    wxMenu *viewMenu = new wxMenu;
+    viewMenu->Append(ID_CS_SETTINGS, _T("&Settings..."));
 
-  wxMenu *helpMenu = new wxMenu;
-  helpMenu->Append(wxID_HELP, _T("&Help Contents\tF1"));
-  helpMenu->Append(ID_CS_ABOUT, _T("&About"));
+    wxMenu *helpMenu = new wxMenu;
+    helpMenu->Append(wxID_HELP, _T("&Help Contents\tF1"));
+    helpMenu->Append(ID_CS_ABOUT, _T("&About"));
 
-  wxMenuBar *menuBar = new wxMenuBar;
+    wxMenuBar *menuBar = new wxMenuBar;
 
-  menuBar->Append(fileMenu, _T("&File"));
-  menuBar->Append(viewMenu, _T("&View"));
-  menuBar->Append(helpMenu, _T("&Help"));
+    menuBar->Append(fileMenu, _T("&File"));
+    menuBar->Append(viewMenu, _T("&View"));
+    menuBar->Append(helpMenu, _T("&Help"));
 
-  // Associate the menu bar with the frame
-  frame->SetMenuBar(menuBar);
+    // Associate the menu bar with the frame
+    frame->SetMenuBar(menuBar);
 
-  // Load the file history
-  wxConfig config(_T("OGL Studio"), _T("wxWidgets"));
-  m_docManager->FileHistoryLoad(config);
+    // Load the file history
+    wxConfig config(_T("OGL Studio"), _T("wxWidgets"));
+    m_docManager->FileHistoryLoad(config);
 
 #if wxUSE_STATUSBAR
-  frame->CreateStatusBar();
+    frame->CreateStatusBar();
 #endif // wxUSE_STATUSBAR
 
-  // The ordering of these is important for layout purposes
-  CreateDiagramToolBar(frame);
-  CreatePalette(frame);
+    // The ordering of these is important for layout purposes
+    CreateDiagramToolBar(frame);
+    CreatePalette(frame);
 
-  /*
-  CreateProjectWindow(frame);
-  FillProjectTreeCtrl();
-  */
+    /*
+    CreateProjectWindow(frame);
+    FillProjectTreeCtrl();
+    */
 
-  // Create the shape editing menu
-  m_shapeEditMenu = new ShapeEditMenu;
-  m_shapeEditMenu->Append(ID_CS_EDIT_PROPERTIES, _T("Edit properties"));
-  m_shapeEditMenu->AppendSeparator();
-  m_shapeEditMenu->Append(ID_CS_ROTATE_CLOCKWISE, _T("Rotate clockwise"));
-  m_shapeEditMenu->Append(ID_CS_ROTATE_ANTICLOCKWISE, _T("Rotate anticlockwise"));
-  m_shapeEditMenu->AppendSeparator();
-  m_shapeEditMenu->Append(ID_CS_CUT, _T("Cut"));
+    // Create the shape editing menu
+    m_shapeEditMenu = new ShapeEditMenu;
+    m_shapeEditMenu->Append(ID_CS_EDIT_PROPERTIES, _T("Edit properties"));
+    m_shapeEditMenu->AppendSeparator();
+    m_shapeEditMenu->Append(ID_CS_ROTATE_CLOCKWISE, _T("Rotate clockwise"));
+    m_shapeEditMenu->Append(ID_CS_ROTATE_ANTICLOCKWISE, _T("Rotate anticlockwise"));
+    m_shapeEditMenu->AppendSeparator();
+    m_shapeEditMenu->Append(ID_CS_CUT, _T("Cut"));
 
-  frame->Show(true);
+    frame->Show(true);
 
-  SetTopWindow(frame);
+    SetTopWindow(frame);
 
-  return true;
+    return true;
 }
 
 int csApp::OnExit(void)
@@ -224,7 +227,7 @@ int csApp::OnExit(void)
  * Centralised code for creating a document frame.
  * Called from view.cpp, when a view is created.
  */
+
 wxMDIChildFrame *csApp::CreateChildFrame(wxDocument *doc, wxView *view, wxMenu** editMenuRet)
 {
   //// Make a child frame
@@ -347,20 +350,20 @@ void csApp::InitToolBar(wxToolBar* toolBar)
 #error "Not implemented for this platform."
 #endif
 
-  toolBar->AddTool(wxID_NEW, *bitmaps[0], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("New file"));
-  toolBar->AddTool(wxID_OPEN, *bitmaps[1], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Open file"));
-  toolBar->AddTool(wxID_SAVE, *bitmaps[2], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Save file"));
+  toolBar->AddTool(wxID_NEW, *bitmaps[0], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("New file"));
+  toolBar->AddTool(wxID_OPEN, *bitmaps[1], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Open file"));
+  toolBar->AddTool(wxID_SAVE, *bitmaps[2], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Save file"));
   toolBar->AddSeparator();
-  toolBar->AddTool(wxID_PRINT, *bitmaps[6], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Print"));
+  toolBar->AddTool(wxID_PRINT, *bitmaps[6], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Print"));
   toolBar->AddSeparator();
-  toolBar->AddTool(wxID_COPY, *bitmaps[3], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Copy"));
-  toolBar->AddTool(wxID_CUT, *bitmaps[4], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Cut"));
-  toolBar->AddTool(wxID_PASTE, *bitmaps[5], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Paste"));
+  toolBar->AddTool(wxID_COPY, *bitmaps[3], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Copy"));
+  toolBar->AddTool(wxID_CUT, *bitmaps[4], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Cut"));
+  toolBar->AddTool(wxID_PASTE, *bitmaps[5], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Paste"));
   toolBar->AddSeparator();
-  toolBar->AddTool(wxID_UNDO, *bitmaps[8], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Undo"));
-  toolBar->AddTool(wxID_REDO, *bitmaps[9], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Redo"));
+  toolBar->AddTool(wxID_UNDO, *bitmaps[8], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Undo"));
+  toolBar->AddTool(wxID_REDO, *bitmaps[9], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Redo"));
   toolBar->AddSeparator();
-  toolBar->AddTool(wxID_HELP, *bitmaps[7], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Help"));
+  toolBar->AddTool(wxID_HELP, *bitmaps[7], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Help"));
 
   toolBar->Realize();
 
@@ -421,18 +424,18 @@ void csApp::CreateDiagramToolBar(wxFrame* parent)
 #error "Not implemented for this platform."
 #endif
 
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNL, *bitmaps[0], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Align left"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNR, *bitmaps[1], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Align right"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNT, *bitmaps[2], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Align top"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNB, *bitmaps[3], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Align bottom"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGN_HORIZ, *bitmaps[4], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Align horizontally"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGN_VERT, *bitmaps[5], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Align vertically"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_COPY_SIZE, *bitmaps[6], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Copy size"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNL, *bitmaps[0], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Align left"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNR, *bitmaps[1], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Align right"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNT, *bitmaps[2], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Align top"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGNB, *bitmaps[3], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Align bottom"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGN_HORIZ, *bitmaps[4], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Align horizontally"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_ALIGN_VERT, *bitmaps[5], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Align vertically"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_COPY_SIZE, *bitmaps[6], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Copy size"));
     m_diagramToolBar->AddSeparator();
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_LINE_ARROW, *bitmaps[7], wxNullBitmap, true, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Toggle arrow"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_NEW_POINT, *bitmaps[8], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("New line point"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_CUT_POINT, *bitmaps[9], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Cut line point"));
-    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_STRAIGHTEN, *bitmaps[10], wxNullBitmap, false, wxDefaultPosition.x, wxDefaultPosition.y, NULL, _T("Straighten lines"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_LINE_ARROW, *bitmaps[7], wxNullBitmap, true, wxDefaultCoord, wxDefaultCoord, NULL, _T("Toggle arrow"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_NEW_POINT, *bitmaps[8], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("New line point"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_CUT_POINT, *bitmaps[9], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Cut line point"));
+    m_diagramToolBar->AddTool(DIAGRAM_TOOLBAR_STRAIGHTEN, *bitmaps[10], wxNullBitmap, false, wxDefaultCoord, wxDefaultCoord, NULL, _T("Straighten lines"));
 
     m_diagramToolBar->Realize();