- bool do_refresh =
- (
- (noUnitsX != 0 && m_xScrollLines == 0) ||
- (noUnitsX < m_xScrollPosition) ||
- (noUnitsY != 0 && m_yScrollLines == 0) ||
- (noUnitsY < m_yScrollPosition) ||
- (xPos != m_xScrollPosition) ||
- (yPos != m_yScrollPosition) ||
- (pixelsPerUnitX != m_xScrollPixelsPerLine) ||
- (pixelsPerUnitY != m_yScrollPixelsPerLine)
- );
-
- m_xScrollPixelsPerLine = pixelsPerUnitX;
- m_yScrollPixelsPerLine = pixelsPerUnitY;
- m_xScrollPosition = xPos;
- m_yScrollPosition = yPos;
- m_xScrollLines = noUnitsX;
- m_yScrollLines = noUnitsY;
-
- AdjustScrollbars();
-
- if (do_refresh && !noRefresh) Refresh();
-
-#ifdef __WXMSW__
- UpdateWindow ((HWND) GetHWND());
+ // only do all this as long as the window is capturing the mouse
+ if ( wxWindow::GetCapture() != m_win )
+ {
+ Stop();
+ }
+ else // we still capture the mouse, continue generating events
+ {
+ // first scroll the window if we are allowed to do it
+ wxScrollWinEvent event1(m_eventType, m_pos, m_orient);
+ event1.SetEventObject(m_win);
+ if ( m_scrollHelper->SendAutoScrollEvents(event1) &&
+ m_win->GetEventHandler()->ProcessEvent(event1) )
+ {
+ // and then send a pseudo mouse-move event to refresh the selection
+ wxMouseEvent event2(wxEVT_MOTION);
+ wxGetMousePosition(&event2.m_x, &event2.m_y);
+
+ // the mouse event coordinates should be client, not screen as
+ // returned by wxGetMousePosition
+ wxWindow *parentTop = m_win;
+ while ( parentTop->GetParent() )
+ parentTop = parentTop->GetParent();
+ wxPoint ptOrig = parentTop->GetPosition();
+ event2.m_x -= ptOrig.x;
+ event2.m_y -= ptOrig.y;
+
+ event2.SetEventObject(m_win);
+
+ // FIXME: we don't fill in the other members - ok?
+
+ m_win->GetEventHandler()->ProcessEvent(event2);
+ }
+ else // can't scroll further, stop
+ {
+ Stop();
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+// wxScrollHelperEvtHandler
+// ----------------------------------------------------------------------------
+
+bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
+{
+ if ( wxEvtHandler::ProcessEvent(event) )
+ return TRUE;
+
+ // reset the skipped flag to FALSE as it might have been set to TRUE in
+ // ProcessEvent() above
+ event.Skip(FALSE);
+
+ wxEventType evType = event.GetEventType();
+
+ if ( evType == wxEVT_PAINT )
+ {
+ m_scrollHelper->HandleOnPaint((wxPaintEvent &)event);
+ return TRUE;
+ }
+
+ if ( evType == wxEVT_SCROLLWIN_TOP ||
+ evType == wxEVT_SCROLLWIN_BOTTOM ||
+ evType == wxEVT_SCROLLWIN_LINEUP ||
+ evType == wxEVT_SCROLLWIN_LINEDOWN ||
+ evType == wxEVT_SCROLLWIN_PAGEUP ||
+ evType == wxEVT_SCROLLWIN_PAGEDOWN ||
+ evType == wxEVT_SCROLLWIN_THUMBTRACK ||
+ evType == wxEVT_SCROLLWIN_THUMBRELEASE )
+ {
+ m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event);
+ return !event.GetSkipped();
+ }
+
+ if ( evType == wxEVT_ENTER_WINDOW )
+ {
+ m_scrollHelper->HandleOnMouseEnter((wxMouseEvent &)event);
+ }
+ else if ( evType == wxEVT_LEAVE_WINDOW )
+ {
+ m_scrollHelper->HandleOnMouseLeave((wxMouseEvent &)event);
+ }
+#if wxUSE_MOUSEWHEEL
+ else if ( evType == wxEVT_MOUSEWHEEL )
+ {
+ m_scrollHelper->HandleOnMouseWheel((wxMouseEvent &)event);
+ }
+#endif // wxUSE_MOUSEWHEEL
+ else if ( evType == wxEVT_SIZE )
+ {
+ m_scrollHelper->HandleOnSize((wxSizeEvent &)event);
+ }
+ else if ( evType == wxEVT_CHAR )
+ {
+ m_scrollHelper->HandleOnChar((wxKeyEvent &)event);
+ return !event.GetSkipped();
+ }
+
+ return FALSE;
+}
+
+// ----------------------------------------------------------------------------
+// wxScrollHelper construction
+// ----------------------------------------------------------------------------
+
+wxScrollHelper::wxScrollHelper(wxWindow *win)
+{
+ m_xScrollPixelsPerLine =
+ m_yScrollPixelsPerLine =
+ m_xScrollPosition =
+ m_yScrollPosition =
+ m_xScrollLines =
+ m_yScrollLines =
+ m_xScrollLinesPerPage =
+ m_yScrollLinesPerPage = 0;
+
+ m_xScrollingEnabled =
+ m_yScrollingEnabled = TRUE;
+
+ m_scaleX =
+ m_scaleY = 1.0;
+#if wxUSE_MOUSEWHEEL
+ m_wheelRotation = 0;