X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a83f860948059b0273b5cc6d9e43fadad3ebfca..a1d5aa9361ecbbe6715ef29d8c69ddaa8a00d4ba:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 8936703547..4e7c5624d1 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -233,6 +233,18 @@ wxView *wxDocument::GetFirstView() const return static_cast(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; @@ -2235,7 +2252,11 @@ void wxFileHistory::AddFilesToMenu(wxMenu* menu) bool wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream) { +#if wxUSE_FFILE wxFFile file(filename, wxT("rb")); +#elif wxUSE_FILE + wxFile file(filename, wxFile::read); +#endif if ( !file.IsOpened() ) return false; @@ -2259,7 +2280,11 @@ bool wxTransferFileToStream(const wxString& filename, wxSTD ostream& stream) bool wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename) { +#if wxUSE_FFILE wxFFile file(filename, wxT("wb")); +#elif wxUSE_FILE + wxFile file(filename, wxFile::write); +#endif if ( !file.IsOpened() ) return false; @@ -2282,7 +2307,11 @@ bool wxTransferStreamToFile(wxSTD istream& stream, const wxString& filename) bool wxTransferFileToStream(const wxString& filename, wxOutputStream& stream) { +#if wxUSE_FFILE wxFFile file(filename, wxT("rb")); +#elif wxUSE_FILE + wxFile file(filename, wxFile::read); +#endif if ( !file.IsOpened() ) return false; @@ -2306,7 +2335,11 @@ bool wxTransferFileToStream(const wxString& filename, wxOutputStream& stream) bool wxTransferStreamToFile(wxInputStream& stream, const wxString& filename) { +#if wxUSE_FFILE wxFFile file(filename, wxT("wb")); +#elif wxUSE_FILE + wxFile file(filename, wxFile::write); +#endif if ( !file.IsOpened() ) return false;