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;
if (fileName.empty())
return false; // cancelled by user
- wxString ext;
- wxFileName::SplitPath(fileName, NULL, NULL, &ext);
-
- if (ext.empty())
- {
- fileName += wxT(".");
- fileName += docTemplate->GetDefaultExtension();
- }
-
// Files that were not saved correctly are not added to the FileHistory.
if (!OnSaveDocument(fileName))
return false;
SetTitle(wxFileNameFromPath(fileName));
SetFilename(fileName, true); // will call OnChangeFileName automatically
- // A file that doesn't use the default extension of its document template
- // cannot be opened via the FileHistory, so we do not add it.
- if (docTemplate->FileMatchesTemplate(fileName))
- {
- GetDocumentManager()->AddFileToHistory(fileName);
- }
- //else: the user will probably not be able to open the file again, so we
- // could warn about the wrong file-extension here
+ // A file that doesn't use the default extension of its document template
+ // cannot be opened via the FileHistory, so we do not add it.
+ if (docTemplate->FileMatchesTemplate(fileName))
+ {
+ GetDocumentManager()->AddFileToHistory(fileName);
+ }
+ //else: the user will probably not be able to open the file again, so we
+ // could warn about the wrong file-extension here
- return true;
+ return true;
}
bool wxDocument::OnSaveDocument(const wxString& file)
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)
wxDocManager::wxDocManager(long WXUNUSED(flags), bool initialize)
{
- wxASSERT_MSG( !sm_docManager, "multiple wxDocManagers not allowed" );
-
sm_docManager = this;
m_defaultDocumentNameCounter = 1;
// 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() )
{
}
//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
void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_PRINTING_ARCHITECTURE
+ wxBusyCursor busy;
wxView *view = GetActiveView();
if (!view)
return;