]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/docview/docview.cpp
Support using GetTextExtent() with empty string to get descent in wxOSX.
[wxWidgets.git] / samples / docview / docview.cpp
index 57eeef7c520d9f073ac62083c4eb2f60a6603aeb..c8d4adcf7368e737efbdcbae27e2f1e24bc85836 100644 (file)
 #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 )
     {
@@ -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();
 }
@@ -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
     );
 }
-