]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/docview.cpp
fixed wxStrrchr(s, '\0') bug, added const and non const versions of wxStrchr, wxStrrc...
[wxWidgets.git] / src / common / docview.cpp
index 1127ffe74038bffe9375a235acf2c7fb98aefad5..c0b5b82c9da9ff119f2cd449effb5ea31f31ef3b 100644 (file)
@@ -164,6 +164,8 @@ bool wxDocument::Close()
 
 bool wxDocument::OnCloseDocument()
 {
+    // Tell all views that we're about to close
+    NotifyClosing();    
     DeleteContents();
     Modify(FALSE);
     return TRUE;
@@ -508,6 +510,17 @@ void wxDocument::UpdateAllViews(wxView *sender, wxObject *hint)
     }
 }
 
+void wxDocument::NotifyClosing()
+{
+    wxNode *node = m_documentViews.First();
+    while (node)
+    {
+        wxView *view = (wxView *)node->Data();
+        view->OnClosingDocument();
+        node = node->Next();
+    }
+}
+
 void wxDocument::SetFilename(const wxString& filename, bool notifyViews)
 {
     m_documentFile = filename;
@@ -594,7 +607,7 @@ bool wxView::Close(bool deleteWindow)
 
 void wxView::Activate(bool activate)
 {
-    if (GetDocumentManager())
+    if (GetDocument() && GetDocumentManager())
     {
         OnActivateView(activate, this, GetDocumentManager()->GetCurrentView());
         GetDocumentManager()->ActivateView(this, activate);
@@ -974,12 +987,16 @@ void wxDocManager::OnUpdateUndo(wxUpdateUIEvent& event)
 {
     wxDocument *doc = GetCurrentDocument();
     event.Enable( (doc && doc->GetCommandProcessor() && doc->GetCommandProcessor()->CanUndo()) );
+    if (doc && doc->GetCommandProcessor())
+        doc->GetCommandProcessor()->SetMenuStrings();
 }
 
 void wxDocManager::OnUpdateRedo(wxUpdateUIEvent& event)
 {
     wxDocument *doc = GetCurrentDocument();
     event.Enable( (doc && doc->GetCommandProcessor() && doc->GetCommandProcessor()->CanRedo()) );
+    if (doc && doc->GetCommandProcessor())
+        doc->GetCommandProcessor()->SetMenuStrings();
 }
 
 void wxDocManager::OnUpdatePrint(wxUpdateUIEvent& event)
@@ -1458,13 +1475,26 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
     wxDocTemplate **data = new wxDocTemplate *[noTemplates];
     int i;
     int n = 0;
+        
        for (i = 0; i < noTemplates; i++)
        {
                if (templates[i]->IsVisible())
                {
-                       strings.Add(templates[i]->m_description);
-                       if (!sort)
+               int j;
+            bool want = TRUE;
+                       for (j = 0; j < n; j++)
+                       {
+                //filter out NOT unique documents + view combinations
+                               if ( templates[i]->m_docTypeName == data[j]->m_docTypeName &&
+                     templates[i]->m_viewTypeName == data[j]->m_viewTypeName
+                   )
+                    want = FALSE;
+                       }
+
+            if ( want )
                        {
+                       strings.Add(templates[i]->m_description);
+
                                data[n] = templates[i];
                                n ++;
                        }
@@ -1525,14 +1555,24 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates,
     wxDocTemplate **data = new wxDocTemplate *[noTemplates];
     int i;
     int n = 0;
+        
     for (i = 0; i < noTemplates; i++)
     {
         wxDocTemplate *templ = templates[i];
         if ( templ->IsVisible() && !templ->GetViewName().empty() )
         {
-            strings.Add(templ->m_viewTypeName);
-                       if (!sort)
+               int j;
+            bool want = TRUE;
+                       for (j = 0; j < n; j++)
                        {
+                //filter out NOT unique views
+                               if ( templates[i]->m_viewTypeName == data[j]->m_viewTypeName )
+                    want = FALSE;
+                       }
+
+            if ( want )
+            {
+                       strings.Add(templ->m_viewTypeName);
                                data[n] = templ;
                                n ++;
                        }