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:
@@ -80,7 +80,7 @@ public:
|
|||||||
// occasions you might want it to scroll [part of] another window (e.g. a
|
// 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
|
// child of it in order to scroll only a portion the area between the
|
||||||
// scrollbars (spreadsheet: only cell area will move).
|
// scrollbars (spreadsheet: only cell area will move).
|
||||||
virtual void SetTargetWindow(wxWindow *target, bool pushEventHandler = FALSE);
|
virtual void SetTargetWindow(wxWindow *target);
|
||||||
virtual wxWindow *GetTargetWindow() const;
|
virtual wxWindow *GetTargetWindow() const;
|
||||||
|
|
||||||
void SetTargetRect(const wxRect& rect) { m_rectToScroll = rect; }
|
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
|
// change just the target window (unlike SetWindow which changes m_win as
|
||||||
// well)
|
// well)
|
||||||
void DoSetTargetWindow(wxWindow *target, bool pushEventHandler = FALSE);
|
void DoSetTargetWindow(wxWindow *target);
|
||||||
|
|
||||||
// delete the event handler we installed
|
// delete the event handler we installed
|
||||||
void DeleteEvtHandler();
|
void DeleteEvtHandler();
|
||||||
|
@@ -384,15 +384,15 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// target window handling
|
// [target] window handling
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxScrollHelper::DeleteEvtHandler()
|
void wxScrollHelper::DeleteEvtHandler()
|
||||||
{
|
{
|
||||||
// FIXME: we should search for m_handler in the handler list
|
// 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;
|
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;
|
m_targetWindow = target;
|
||||||
|
|
||||||
// install the event handler which will intercept the events we're
|
// install the event handler which will intercept the events we're
|
||||||
// interested in
|
// interested in (but only do it for our real window, not the target window
|
||||||
if (pushEventHandler)
|
// which we scroll - we don't need to hijack its events)
|
||||||
|
if ( m_targetWindow == m_win )
|
||||||
{
|
{
|
||||||
m_handler = new wxScrollHelperEvtHandler(this);
|
m_handler = new wxScrollHelperEvtHandler(this);
|
||||||
m_targetWindow->PushEventHandler(m_handler);
|
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") );
|
wxCHECK_RET( target, wxT("target window must not be NULL") );
|
||||||
|
|
||||||
if ( target == m_targetWindow )
|
if ( target == m_targetWindow )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pushEventHandler)
|
DoSetTargetWindow(target);
|
||||||
DeleteEvtHandler();
|
|
||||||
|
|
||||||
DoSetTargetWindow(target, pushEventHandler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow *wxScrollHelper::GetTargetWindow() const
|
wxWindow *wxScrollHelper::GetTargetWindow() const
|
||||||
@@ -839,7 +838,8 @@ void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event))
|
|||||||
// scroll position
|
// scroll position
|
||||||
void wxScrollHelper::HandleOnPaint(wxPaintEvent& WXUNUSED(event))
|
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);
|
DoPrepareDC(dc);
|
||||||
|
|
||||||
OnDraw(dc);
|
OnDraw(dc);
|
||||||
|
Reference in New Issue
Block a user