git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57950
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// modified to false)
virtual bool OnSaveModified();
// modified to false)
virtual bool OnSaveModified();
+ // if you override, remember to call the default
+ // implementation (wxDocument::OnChangeFilename)
+ virtual void OnChangeFilename(bool notifyViews);
+
// Called by framework if created automatically by the default document
// manager: gives document a chance to initialise and (usually) create a
// view
// Called by framework if created automatically by the default document
// manager: gives document a chance to initialise and (usually) create a
// view
/**
Called when the filename has changed. The default implementation
/**
Called when the filename has changed. The default implementation
- constructs a suitable title and sets the title of the view frame (if
- any).
+ constructs a suitable title and sets the title of the view frame (if any).
*/
virtual void OnChangeFilename();
*/
virtual void OnChangeFilename();
/**
Sets the filename for this document. Usually called by the framework.
/**
Sets the filename for this document. Usually called by the framework.
+ Calls OnChangeFilename() which in turn calls wxView::OnChangeFilename() for
+ all views if @a notifyViews is @true,
+ */
+ void SetFilename(const wxString& filename, bool notifyViews = false);
+
+ /**
If @a notifyViews is @true, wxView::OnChangeFilename() is called for
all views.
If @a notifyViews is @true, wxView::OnChangeFilename() is called for
all views.
- void SetFilename(const wxString& filename, bool notifyViews = false);
+ virtual void OnChangeFilename(bool notifyViews);
/**
Sets the title for this document. The document title is used for an
/**
Sets the title for this document. The document title is used for an
if (defaultDir.IsEmpty())
defaultDir = wxPathOnly(GetFilename());
if (defaultDir.IsEmpty())
defaultDir = wxPathOnly(GetFilename());
- wxString tmp = wxFileSelector(_("Save As"),
+ wxString fileName = wxFileSelector(_("Save As"),
defaultDir,
wxFileNameFromPath(GetFilename()),
docTemplate->GetDefaultExtension(),
defaultDir,
wxFileNameFromPath(GetFilename()),
docTemplate->GetDefaultExtension(),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
GetDocumentWindow());
wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
GetDocumentWindow());
- wxString fileName(tmp);
- wxString path, name, ext;
- wxFileName::SplitPath(fileName, & path, & name, & ext);
+ wxString ext;
+ wxFileName::SplitPath(fileName, NULL, NULL, &ext);
fileName += docTemplate->GetDefaultExtension();
}
fileName += docTemplate->GetDefaultExtension();
}
- SetFilename(fileName);
- SetTitle(wxFileNameFromPath(fileName));
-
- // Notify the views that the filename has changed
- wxList::compatibility_iterator node = m_documentViews.GetFirst();
- while (node)
- {
- wxView *view = (wxView *)node->GetData();
- view->OnChangeFilename();
- node = node->GetNext();
- }
-
// Files that were not saved correctly are not added to the FileHistory.
// Files that were not saved correctly are not added to the FileHistory.
- if (!OnSaveDocument(m_documentFile))
+ if (!OnSaveDocument(fileName))
+ 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))
// 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))
GetUserReadableName()
),
wxTheApp->GetAppDisplayName(),
GetUserReadableName()
),
wxTheApp->GetAppDisplayName(),
- wxYES_NO | wxCANCEL | wxICON_QUESTION,
- GetDocumentWindow()
+ wxYES_NO | wxCANCEL | wxICON_QUESTION | wxCENTRE,
+ wxFindSuitableParent()
void wxDocument::SetFilename(const wxString& filename, bool notifyViews)
{
m_documentFile = filename;
void wxDocument::SetFilename(const wxString& filename, bool notifyViews)
{
m_documentFile = filename;
+ OnChangeFilename(notifyViews);
+}
+
+void wxDocument::OnChangeFilename(bool notifyViews)
+{
if ( notifyViews )
{
// Notify the views that the filename has changed
if ( notifyViews )
{
// Notify the views that the filename has changed
else
msgTitle = wxString(_("File error"));
else
msgTitle = wxString(_("File error"));
- (void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK | wxICON_EXCLAMATION,
+ (void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK | wxICON_EXCLAMATION | wxCENTRE,
parent);
path = wxEmptyString;
parent);
path = wxEmptyString;
// can only happen if the application changes the allowed templates in runtime.
(void)wxMessageBox(_("Sorry, the format for this file is unknown."),
_("Open File"),
// can only happen if the application changes the allowed templates in runtime.
(void)wxMessageBox(_("Sorry, the format for this file is unknown."),
_("Open File"),
- wxOK | wxICON_EXCLAMATION, wxFindSuitableParent());
+ wxOK | wxICON_EXCLAMATION | wxCENTRE, wxFindSuitableParent());