MyApp::MyApp(void)
{
frame = NULL;
+ myDocManager= NULL;
}
// The `main program' equivalent, creating the windows and returning the
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",
return TRUE;
}
+int MyApp::OnExit(void)
+{
+ wxOGLCleanUp();
+ delete myDocManager;
+ return 0;
+}
+
/*
* This is the top-level window of the application.
*/
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,
}
}
-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
// 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);