X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2d4a03f8a7875fecc472ba2eaa566fd48afdcb22..cd15bcaf50ead53ccf9d50965312f0dc754affb4:/samples/docview/docview.cpp diff --git a/samples/docview/docview.cpp b/samples/docview/docview.cpp index f8f2a8f98b..c8d4adcf73 100644 --- a/samples/docview/docview.cpp +++ b/samples/docview/docview.cpp @@ -7,7 +7,7 @@ // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart // (c) 2008 Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// /* @@ -55,12 +55,13 @@ #include "view.h" #include "wx/cmdline.h" +#include "wx/config.h" #ifdef __WXMAC__ #include "wx/filename.h" #endif -#if !defined(__WXMSW__) && !defined(__WXPM__) +#ifndef wxHAS_IMAGES_IN_RESOURCES #include "doc.xpm" #include "chart.xpm" #include "notepad.xpm" @@ -150,7 +151,10 @@ bool MyApp::OnInit() ::wxInitAllImageHandlers(); - SetAppName("DocView Sample"); + // Fill in the application information fields before creating wxConfig. + SetVendorName("wxWidgets"); + SetAppName("wx_docview_sample"); + SetAppDisplayName("wxWidgets DocView Sample"); //// Create a document manager wxDocManager *docManager = new wxDocManager; @@ -217,6 +221,10 @@ bool MyApp::OnInit() // A nice touch: a history of files visited. Use this menu. docManager->FileHistoryUseMenu(menuFile); +#if wxUSE_CONFIG + docManager->FileHistoryLoad(*wxConfig::Get()); +#endif // wxUSE_CONFIG + if ( m_mode == Mode_Single ) { @@ -228,16 +236,19 @@ bool MyApp::OnInit() CreateMenuBarForFrame(frame, menuFile, m_menuEdit); frame->SetIcon(wxICON(doc)); - frame->Centre(wxBOTH); - frame->Show(true); + frame->Centre(); + frame->Show(); - SetTopWindow(frame); return true; } int MyApp::OnExit() { - delete wxDocManager::GetDocumentManager(); + wxDocManager * const manager = wxDocManager::GetDocumentManager(); +#if wxUSE_CONFIG + manager->FileHistorySave(*wxConfig::Get()); +#endif // wxUSE_CONFIG + delete manager; return wxApp::OnExit(); } @@ -285,10 +296,11 @@ void MyApp::CreateMenuBarForFrame(wxFrame *frame, wxMenu *file, wxMenu *edit) frame->SetMenuBar(menubar); } -wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas) +wxFrame *MyApp::CreateChildFrame(wxView *view, bool isCanvas) { // create a child frame of appropriate class for the current mode wxFrame *subframe; + wxDocument *doc = view->GetDocument(); #if wxUSE_MDI_ARCHITECTURE if ( GetMode() == Mode_MDI ) { @@ -317,7 +329,7 @@ wxFrame *MyApp::CreateChildFrame(wxDocument *doc, wxView *view, bool isCanvas) wxSize(300, 300) ); - subframe->Centre(wxBOTH); + subframe->Centre(); } wxMenu *menuFile = new wxMenu; @@ -374,15 +386,24 @@ void MyApp::OnAbout(wxCommandEvent& WXUNUSED(event)) wxFAIL_MSG( "unknown mode "); } +#ifdef __VISUALC6__ + const int docsCount = + wxDocManager::GetDocumentManager()->GetDocuments().GetCount(); +#else + const int docsCount = + wxDocManager::GetDocumentManager()->GetDocumentsVector().size(); +#endif + wxLogMessage ( "This is the wxWidgets Document/View Sample\n" "running in %s mode.\n" + "%d open documents.\n" "\n" "Authors: Julian Smart, Vadim Zeitlin\n" "\n" "Usage: docview [--{mdi,sdi,single}]", - modeName + modeName, + docsCount ); } -