From a6b7e90b5d31baa6cd04e0f65ccba4901368e021 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 22 Jul 2011 16:16:03 +0000 Subject: [PATCH] Save and restore file history in docview sample. Show how the file history can be saved to and restored from wxConfig. This makes it much easier to test file history related stuff as the history doesn't need to be recreated during every sample run. It is also closer to what real applications using docview framework do as the file history is relatively useless if it's not saved. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68332 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/docview/docview.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/samples/docview/docview.cpp b/samples/docview/docview.cpp index 57eeef7c52..287f7876dc 100644 --- a/samples/docview/docview.cpp +++ b/samples/docview/docview.cpp @@ -55,6 +55,7 @@ #include "view.h" #include "wx/cmdline.h" +#include "wx/config.h" #ifdef __WXMAC__ #include "wx/filename.h" @@ -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 ) { @@ -236,7 +244,11 @@ bool MyApp::OnInit() 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(); } -- 2.45.2