]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/ogl/samples/ogledit/ogledit.cpp
1. typos corrected in ftp/protocol/url (Members is no longer a hyperlink
[wxWidgets.git] / utils / ogl / samples / ogledit / ogledit.cpp
index cc18d2d2c1226211741b8722b5b8a3db3f7f8769..87f19e6e857143d5bddb83195e3a7ffc79981860 100644 (file)
@@ -24,8 +24,8 @@
 #include <wx/wx.h>
 #endif
 
-#if !USE_DOC_VIEW_ARCHITECTURE
-#error You must set USE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
+#if !wxUSE_DOC_VIEW_ARCHITECTURE
+#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
 #endif
 
 #include "ogledit.h"
 #include "doc.h"
 #include "view.h"
 
+#if defined(__WXGTK__) || defined(__WXMOTIF__)
+#include "ogl.xpm"
+#endif
+
 // A macro needed for some compilers (AIX) that need 'main' to be defined
 // in the application itself.
 IMPLEMENT_APP(MyApp)
 
-// This statement initialises the whole application
-MyApp myApp;
-
 MyApp::MyApp(void)
 {
   frame = NULL;
+  myDocManager= NULL;
 }
 
 // The `main program' equivalent, creating the windows and returning the
@@ -52,7 +54,7 @@ bool MyApp::OnInit(void)
   wxOGLInitialize();
   
   //// Create a document manager
-  wxDocManager *myDocManager = new wxDocManager;
+  myDocManager = new wxDocManager;
 
   //// Create a template relating drawing documents to their views
   (void) new wxDocTemplate(myDocManager, "Diagram", "*.dia", "", "dia", "Diagram Doc", "Diagram View",
@@ -66,12 +68,7 @@ bool MyApp::OnInit(void)
   frame = new MyFrame(myDocManager, NULL, "OGLEdit Demo", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE);
 
   //// Give it an icon
-#ifdef __WXMSW__
-  frame->SetIcon(wxIcon("ogl_icn"));
-#endif
-#ifdef __X__
-  frame->SetIcon(wxIcon("ogl.xbm"));
-#endif
+  frame->SetIcon(wxICON(ogl));
 
   //// Make a menubar
   wxMenu *file_menu = new wxMenu;
@@ -116,7 +113,7 @@ bool MyApp::OnInit(void)
   menu_bar->Append(help_menu, "&Help");
 
   frame->canvas = frame->CreateCanvas(NULL, frame);
-  frame->palette = myApp.CreatePalette(frame);
+  frame->palette = wxGetApp().CreatePalette(frame);
   myDocManager->CreateDocument("", wxDOC_NEW);
 
   //// Associate the menu bar with the frame
@@ -130,6 +127,13 @@ bool MyApp::OnInit(void)
   return TRUE;
 }
 
+int MyApp::OnExit(void)
+{
+    wxOGLCleanUp();
+    delete myDocManager;
+    return 0;
+}
+
 /*
  * This is the top-level window of the application.
  */
@@ -139,6 +143,7 @@ IMPLEMENT_CLASS(MyFrame, wxDocParentFrame)
 BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame)
     EVT_MENU(OGLEDIT_ABOUT, MyFrame::OnAbout)
     EVT_SIZE(MyFrame::OnSize)
+    EVT_CLOSE(MyFrame::OnCloseWindow)
 END_EVENT_TABLE()
 
 MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title,
@@ -170,15 +175,13 @@ void MyFrame::OnSize(wxSizeEvent& event)
   }
 }
 
-bool MyFrame::OnClose(void)
+void MyFrame::OnCloseWindow(wxCloseEvent& event)
 {
-  if (wxDocParentFrame::OnClose())
+  wxDocParentFrame::OnCloseWindow(event);
+  if (!event.GetVeto())
   {
     wxOGLCleanUp();
-    return TRUE;
   }
-  else
-    return FALSE;
 }
 
 // Intercept menu commands
@@ -195,8 +198,7 @@ MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent)
 
   // Non-retained canvas
   MyCanvas *canvas = new MyCanvas(view, parent, -1, wxPoint(0, 0), wxSize(width, height), 0);
-  wxCursor *cursor = new wxCursor(wxCURSOR_HAND);
-  canvas->SetCursor(cursor);
+  canvas->SetCursor(wxCursor(wxCURSOR_HAND));
 
   // Give it scrollbars
   canvas->SetScrollbars(20, 20, 50, 50);
@@ -206,6 +208,6 @@ MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent)
 
 MyFrame *GetMainFrame(void)
 {
-  return myApp.frame;
+  return wxGetApp().frame;
 }