From af4088f1bebd177c33a085f892062fd1d5c64d88 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 2 Dec 2001 15:04:38 +0000 Subject: [PATCH] fixed event processing for the target window git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12822 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/scrolwin.h | 4 ++-- src/generic/scrlwing.cpp | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/wx/scrolwin.h b/include/wx/scrolwin.h index 8bf0404a25..0894cd920b 100644 --- a/include/wx/scrolwin.h +++ b/include/wx/scrolwin.h @@ -80,7 +80,7 @@ public: // occasions you might want it to scroll [part of] another window (e.g. a // child of it in order to scroll only a portion the area between the // scrollbars (spreadsheet: only cell area will move). - virtual void SetTargetWindow(wxWindow *target, bool pushEventHandler = FALSE); + virtual void SetTargetWindow(wxWindow *target); virtual wxWindow *GetTargetWindow() const; void SetTargetRect(const wxRect& rect) { m_rectToScroll = rect; } @@ -146,7 +146,7 @@ protected: // change just the target window (unlike SetWindow which changes m_win as // well) - void DoSetTargetWindow(wxWindow *target, bool pushEventHandler = FALSE); + void DoSetTargetWindow(wxWindow *target); // delete the event handler we installed void DeleteEvtHandler(); diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index b1849b2589..8aec5d087e 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -384,15 +384,15 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX, } // ---------------------------------------------------------------------------- -// target window handling +// [target] window handling // ---------------------------------------------------------------------------- void wxScrollHelper::DeleteEvtHandler() { // FIXME: we should search for m_handler in the handler list - if ( m_targetWindow ) + if ( m_win ) { - m_targetWindow->PopEventHandler(TRUE /* Delete old event handler*/); + m_win->PopEventHandler(TRUE /* Delete old event handler*/); } } @@ -402,33 +402,32 @@ void wxScrollHelper::SetWindow(wxWindow *win) m_win = win; - DoSetTargetWindow(win, TRUE); + // by default, the associated window is also the target window + DoSetTargetWindow(win); } -void wxScrollHelper::DoSetTargetWindow(wxWindow *target, bool pushEventHandler) +void wxScrollHelper::DoSetTargetWindow(wxWindow *target) { m_targetWindow = target; // install the event handler which will intercept the events we're - // interested in - if (pushEventHandler) + // interested in (but only do it for our real window, not the target window + // which we scroll - we don't need to hijack its events) + if ( m_targetWindow == m_win ) { m_handler = new wxScrollHelperEvtHandler(this); m_targetWindow->PushEventHandler(m_handler); } } -void wxScrollHelper::SetTargetWindow( wxWindow *target, bool pushEventHandler ) +void wxScrollHelper::SetTargetWindow(wxWindow *target) { wxCHECK_RET( target, wxT("target window must not be NULL") ); if ( target == m_targetWindow ) return; - if (pushEventHandler) - DeleteEvtHandler(); - - DoSetTargetWindow(target, pushEventHandler); + DoSetTargetWindow(target); } wxWindow *wxScrollHelper::GetTargetWindow() const @@ -839,7 +838,8 @@ void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event)) // scroll position void wxScrollHelper::HandleOnPaint(wxPaintEvent& WXUNUSED(event)) { - wxPaintDC dc(m_targetWindow); + // don't use m_targetWindow here, this is always called for ourselves + wxPaintDC dc(m_win); DoPrepareDC(dc); OnDraw(dc); -- 2.45.2