]> git.saurik.com Git - wxWidgets.git/commitdiff
wxDocManager gets the only view if none other specified as the current view;
authorJulian Smart <julian@anthemion.co.uk>
Sat, 18 Jul 1998 22:04:25 +0000 (22:04 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sat, 18 Jul 1998 22:04:25 +0000 (22:04 +0000)
added ProcessEvent so views get their events processed properly.

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

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

index a60bfa45360a7c523b8d823c2699ea4623ba0944..63b344148816ab40ccc240268d0c9b2add981691 100644 (file)
@@ -283,6 +283,9 @@ class WXDLLEXPORT wxDocManager: public wxEvtHandler
   void OnUndo(wxCommandEvent& event);
   void OnRedo(wxCommandEvent& event);
 
+  // Extend event processing to search the view's event table
+  virtual bool ProcessEvent(wxEvent& event);
+
   virtual wxDocument *CreateDocument(const wxString& path, long flags = 0);
   virtual wxView *CreateView(wxDocument *doc, long flags = 0);
   virtual void DeleteTemplate(wxDocTemplate *temp, long flags = 0);
@@ -314,7 +317,7 @@ class WXDLLEXPORT wxDocManager: public wxEvtHandler
   // Views or windows should inform the document manager
   // when a view is going in or out of focus
   virtual void ActivateView(wxView *view, bool activate = TRUE, bool deleting = FALSE);
-  virtual inline wxView *GetCurrentView(void) const { return m_currentView; }
+  virtual wxView *GetCurrentView(void) const;
 
   virtual inline wxList& GetDocuments(void) const { return (wxList&) m_docs; }
 
index 9671a5cf2ca46cf5607d17e2e8eb96c1ae02f952..80ad3550d6ed0cb05a4cca0f65f00797e45b6065 100644 (file)
@@ -839,6 +839,30 @@ void wxDocManager::OnRedo(wxCommandEvent& WXUNUSED(event))
     doc->GetCommandProcessor()->Redo();
 }
 
+wxView *wxDocManager::GetCurrentView(void) const
+{
+    if (m_currentView)
+        return m_currentView;
+    if (m_docs.Number() == 1)
+    {
+        wxDocument* doc = (wxDocument*) m_docs.First()->Data();
+        return doc->GetFirstView();
+    }
+    return NULL;
+}
+
+// Extend event processing to search the view's event table
+bool wxDocManager::ProcessEvent(wxEvent& event)
+{
+    wxView* view = GetCurrentView();
+    if (view)
+    {
+        if (view->ProcessEvent(event))
+            return TRUE;
+    }
+    return wxEvtHandler::ProcessEvent(event);
+}
+
 wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags)
 {
   wxDocTemplate **templates = new wxDocTemplate *[m_templates.Number()];