fixed event processing for the target window

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12822 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2001-12-02 15:04:38 +00:00
parent f69fcd070b
commit af4088f1be
2 changed files with 15 additions and 15 deletions

View File

@ -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();

View File

@ -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);