From: Julian Smart Date: Sat, 18 Jul 1998 22:04:25 +0000 (+0000) Subject: wxDocManager gets the only view if none other specified as the current view; X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/637f467a0639bf942ebeb466d056fa339bfdbdee wxDocManager gets the only view if none other specified as the current view; 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 --- diff --git a/include/wx/docview.h b/include/wx/docview.h index a60bfa4536..63b3441488 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -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; } diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 9671a5cf2c..80ad3550d6 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -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()];