]> git.saurik.com Git - wxWidgets.git/commitdiff
If several doc templates use the same document and view classes, they should
authorJulian Smart <julian@anthemion.co.uk>
Thu, 3 Jun 2004 19:04:16 +0000 (19:04 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 3 Jun 2004 19:04:16 +0000 (19:04 +0000)
share their filters in Save As

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/docview.h
src/common/docview.cpp

index 08a9a3ce4440ee977a0c85c792a4e444d8a46cf8..0d005d04b6c4717117bc9d05df7b27c2575f2d20 100644 (file)
@@ -276,6 +276,9 @@ public:
 
     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);
 
 protected:
index f77b00cdbda2f97f9c81506006b9d3f4e679ed7a..d881e212d1fa55954bfefde97d133d6515d08851 100644 (file)
@@ -253,11 +253,42 @@ bool wxDocument::SaveAs()
     if (!docTemplate)
         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"),
             docTemplate->GetDirectory(),
             wxFileNameFromPath(GetFilename()),
             docTemplate->GetDefaultExtension(),
-            docTemplate->GetFileFilter(),
+            filter,
             wxSAVE | wxOVERWRITE_PROMPT,
             GetDocumentWindow());