]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/docview.cpp
Do not use wxS in array of const wxChar*
[wxWidgets.git] / src / common / docview.cpp
index 5dae19b52bb071f1ee1d6f45c5d8f8d6e78d3863..4e7c5624d118637020261155272fa2d4f8503da9 100644 (file)
@@ -233,6 +233,18 @@ wxView *wxDocument::GetFirstView() const
     return static_cast<wxView *>(m_documentViews.GetFirst()->GetData());
 }
 
+void wxDocument::Modify(bool mod)
+{
+    if (mod != m_documentModified)
+    {
+        m_documentModified = mod;
+
+        // Allow views to append asterix to the title
+        wxView* view = GetFirstView();
+        if (view) view->OnChangeFilename();
+    }
+}
+
 wxDocManager *wxDocument::GetDocumentManager() const
 {
     return m_documentTemplate ? m_documentTemplate->GetDocumentManager() : NULL;
@@ -713,7 +725,12 @@ void wxView::OnChangeFilename()
     wxDocument *doc = GetDocument();
     if (!doc) return;
 
-    win->SetLabel(doc->GetUserReadableName());
+    wxString label = doc->GetUserReadableName();
+    if (doc->IsModified())
+    {
+       label += "*";
+    }
+    win->SetLabel(label);
 }
 
 void wxView::SetDocument(wxDocument *doc)
@@ -899,8 +916,6 @@ wxDocManager* wxDocManager::sm_docManager = NULL;
 
 wxDocManager::wxDocManager(long WXUNUSED(flags), bool initialize)
 {
-    wxASSERT_MSG( !sm_docManager, "multiple wxDocManagers not allowed" );
-
     sm_docManager = this;
 
     m_defaultDocumentNameCounter = 1;
@@ -991,9 +1006,9 @@ wxString wxDocManager::GetLastDirectory() const
         // this ensures that if the user opens a file, closes the program and
         // runs it again the "Open file" dialog will open in the directory of
         // the last file he used
-        wxString lastOpened = GetHistoryFile(0);
-        if ( !lastOpened.empty() )
+        if ( m_fileHistory && m_fileHistory->GetCount() )
         {
+            const wxString lastOpened = m_fileHistory->GetHistoryFile(0);
             const wxFileName fn(lastOpened);
             if ( fn.DirExists() )
             {
@@ -1001,6 +1016,7 @@ wxString wxDocManager::GetLastDirectory() const
             }
             //else: should we try the next one?
         }
+        //else: no history yet
 
         // if we don't have any files in the history (yet?), use the
         // system-dependent default location for the document files
@@ -1094,6 +1110,7 @@ void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
 void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
 {
 #if wxUSE_PRINTING_ARCHITECTURE
+    wxBusyCursor busy;
     wxView *view = GetActiveView();
     if (!view)
         return;