If several doc templates use the same document and view classes, they should
share their filters in Save As git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -276,6 +276,9 @@ public:
|
|||||||
|
|
||||||
bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); }
|
bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); }
|
||||||
|
|
||||||
|
wxClassInfo* GetDocClassInfo() const { return m_docClassInfo; }
|
||||||
|
wxClassInfo* GetViewClassInfo() const { return m_viewClassInfo; }
|
||||||
|
|
||||||
virtual bool FileMatchesTemplate(const wxString& path);
|
virtual bool FileMatchesTemplate(const wxString& path);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -253,11 +253,42 @@ bool wxDocument::SaveAs()
|
|||||||
if (!docTemplate)
|
if (!docTemplate)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#if defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXMAC__)
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
wxObjectListNode* node = wxDocManager::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.IsEmpty() )
|
||||||
|
filter << wxT('|');
|
||||||
|
|
||||||
|
filter << t->GetDescription() << wxT(" (") << t->GetFileFilter() << wxT(") |")
|
||||||
|
<< t->GetFileFilter();
|
||||||
|
}
|
||||||
|
|
||||||
|
node = node->GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
wxString filter = docTemplate->GetFileFilter() ;
|
||||||
|
#endif
|
||||||
wxString tmp = wxFileSelector(_("Save as"),
|
wxString tmp = wxFileSelector(_("Save as"),
|
||||||
docTemplate->GetDirectory(),
|
docTemplate->GetDirectory(),
|
||||||
wxFileNameFromPath(GetFilename()),
|
wxFileNameFromPath(GetFilename()),
|
||||||
docTemplate->GetDefaultExtension(),
|
docTemplate->GetDefaultExtension(),
|
||||||
docTemplate->GetFileFilter(),
|
filter,
|
||||||
wxSAVE | wxOVERWRITE_PROMPT,
|
wxSAVE | wxOVERWRITE_PROMPT,
|
||||||
GetDocumentWindow());
|
GetDocumentWindow());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user