]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/docview.cpp
Updated font dialog constructors to use a reference to the font data
[wxWidgets.git] / src / common / docview.cpp
index 0015cce6e0e5ba05d3f214e94780e95c07c8814b..c368a8ee522ce5b1a8c6f9226d818122ab010a97 100644 (file)
@@ -341,7 +341,8 @@ bool wxDocument::OnOpenDocument(const wxString& file)
         return FALSE;
     }
 #if wxUSE_STD_IOSTREAM
-    if (!LoadObject(store))
+    LoadObject(store);
+    if ( !store && !store.eof() )
 #else
     int res = LoadObject(store).LastError();
     if ((res != wxSTREAM_NOERROR) &&
@@ -593,7 +594,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);
@@ -960,7 +961,7 @@ void wxDocManager::OnUpdateFileNew(wxUpdateUIEvent& event)
 void wxDocManager::OnUpdateFileSave(wxUpdateUIEvent& event)
 {
     wxDocument *doc = GetCurrentDocument();
-    event.Enable( (doc != (wxDocument*) NULL) );
+    event.Enable( doc && doc->IsModified() );
 }
 
 void wxDocManager::OnUpdateFileSaveAs(wxUpdateUIEvent& event)
@@ -973,12 +974,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)
@@ -1191,8 +1196,9 @@ bool wxDocManager::FlushDoc(wxDocument *WXUNUSED(doc))
 
 wxDocument *wxDocManager::GetCurrentDocument() const
 {
-    if (m_currentView)
-        return m_currentView->GetDocument();
+    wxView *view = GetCurrentView();
+    if (view)
+        return view->GetDocument();
     else
         return (wxDocument *) NULL;
 }
@@ -1456,13 +1462,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 ++;
                        }
@@ -1523,14 +1542,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 ++;
                        }