- return FALSE;
-
- wxString tmp = wxFileSelector(_("Save as"),
- docTemplate->GetDirectory(),
- GetFilename(),
- docTemplate->GetDefaultExtension(),
- docTemplate->GetFileFilter(),
- wxSAVE | wxOVERWRITE_PROMPT,
- GetDocumentWindow());
-
- if (tmp.IsEmpty())
- return FALSE;
-
- wxString fileName(tmp);
- wxString path("");
- wxString name("");
- wxString ext("");
- wxSplitPath(fileName, & path, & name, & ext);
-
- if (ext.IsEmpty() || ext == "")
- {
- fileName += ".";
- fileName += docTemplate->GetDefaultExtension();
- }
-
- SetFilename(fileName);
+ return false;
+
+#ifdef wxHAS_MULTIPLE_FILEDLG_FILTERS
+ wxString filter = docTemplate->GetDescription() + wxT(" (") +
+ docTemplate->GetFileFilter() + wxT(")|") +
+ docTemplate->GetFileFilter();
+
+ // Now see if there are some other template with identical view and document
+ // classes, whose filters may also be used.
+ if (docTemplate->GetViewClassInfo() && docTemplate->GetDocClassInfo())
+ {
+ wxList::compatibility_iterator
+ node = docTemplate->GetDocumentManager()->GetTemplates().GetFirst();
+ while (node)
+ {
+ wxDocTemplate *t = (wxDocTemplate*) node->GetData();
+
+ if (t->IsVisible() && t != docTemplate &&
+ t->GetViewClassInfo() == docTemplate->GetViewClassInfo() &&
+ t->GetDocClassInfo() == docTemplate->GetDocClassInfo())
+ {
+ // add a '|' to separate this filter from the previous one
+ if ( !filter.empty() )
+ filter << wxT('|');
+
+ filter << t->GetDescription()
+ << wxT(" (") << t->GetFileFilter() << wxT(") |")
+ << t->GetFileFilter();
+ }
+
+ node = node->GetNext();
+ }
+ }
+#else
+ wxString filter = docTemplate->GetFileFilter() ;
+#endif
+
+ wxString defaultDir = docTemplate->GetDirectory();
+ if ( defaultDir.empty() )
+ {
+ defaultDir = wxPathOnly(GetFilename());
+ if ( defaultDir.empty() )
+ defaultDir = GetDocumentManager()->GetLastDirectory();
+ }
+
+ wxString fileName = wxFileSelector(_("Save As"),
+ defaultDir,
+ wxFileNameFromPath(GetFilename()),
+ docTemplate->GetDefaultExtension(),
+ filter,
+ wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
+ GetDocumentWindow());
+
+ if (fileName.empty())
+ return false; // cancelled by user
+
+ // Files that were not saved correctly are not added to the FileHistory.
+ if (!OnSaveDocument(fileName))
+ return false;
+