// 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; }
// 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();
}
// ----------------------------------------------------------------------------
-// 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*/);
}
}
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
// 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);