X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/52212bcb4a89cd0b784c93b5bc860308bd91c457..7d6a4d96961eac84d05db8bb24c64d39003f6e54:/src/generic/scrlwing.cpp diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 0f1a4f57ef..81dedd9875 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -209,11 +209,6 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) // (as indicated by "process here only" flag being set) and we do want to // execute the handler defined in the window we're associated with right // now, without waiting until TryAfter() is called from wxEvtHandler. - // - // Note that this means that the handler in the window will be called twice - // if there is a preceding event handler in the chain because we do it from - // here now and the base class DoTryChain() will also call it itself when - // we return. But this unfortunately seems unavoidable. bool processed = m_nextHandler->ProcessEvent(event); // always process the size events ourselves, even if the user code handles @@ -310,6 +305,17 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) event.Skip(wasSkipped); + // We called ProcessEvent() on the next handler, meaning that we explicitly + // worked around the request to process the event in this handler only. As + // explained above, this is unfortunately really necessary but the trouble + // is that the event will continue to be post-processed by the previous + // handler resulting in duplicate calls to event handlers. Call the special + // function below to prevent this from happening, base class DoTryChain() + // will check for it and behave accordingly. + // + // And if we're not called from DoTryChain(), this won't do anything anyhow. + event.DidntHonourProcessOnlyIn(); + return processed; } @@ -337,6 +343,8 @@ wxScrollHelperBase::wxScrollHelperBase(wxWindow *win) m_xScrollingEnabled = m_yScrollingEnabled = true; + m_kbdScrollingEnabled = true; + m_scaleX = m_scaleY = 1.0; #if wxUSE_MOUSEWHEEL @@ -377,16 +385,17 @@ void wxScrollHelperBase::SetScrollbars(int pixelsPerUnitX, int yPos, bool noRefresh) { - int xpos, ypos; + // Convert positions expressed in scroll units to positions in pixels. + int xPosInPixels = (xPos + m_xScrollPosition)*m_xScrollPixelsPerLine, + yPosInPixels = (yPos + m_yScrollPosition)*m_yScrollPixelsPerLine; - CalcUnscrolledPosition(xPos, yPos, &xpos, &ypos); bool do_refresh = ( (noUnitsX != 0 && m_xScrollLines == 0) || - (noUnitsX < m_xScrollLines && xpos > pixelsPerUnitX * noUnitsX) || + (noUnitsX < m_xScrollLines && xPosInPixels > pixelsPerUnitX * noUnitsX) || (noUnitsY != 0 && m_yScrollLines == 0) || - (noUnitsY < m_yScrollLines && ypos > pixelsPerUnitY * noUnitsY) || + (noUnitsY < m_yScrollLines && yPosInPixels > pixelsPerUnitY * noUnitsY) || (xPos != m_xScrollPosition) || (yPos != m_yScrollPosition) ); @@ -838,6 +847,12 @@ void wxScrollHelperBase::HandleOnPaint(wxPaintEvent& WXUNUSED(event)) // this they always have the priority void wxScrollHelperBase::HandleOnChar(wxKeyEvent& event) { + if ( !m_kbdScrollingEnabled ) + { + event.Skip(); + return; + } + // prepare the event this key press maps to wxScrollWinEvent newEvent; @@ -920,11 +935,7 @@ bool wxScrollHelperBase::SendAutoScrollEvents(wxScrollWinEvent& event) const void wxScrollHelperBase::StopAutoScrolling() { #if wxUSE_TIMER - if ( m_timerAutoScroll ) - { - delete m_timerAutoScroll; - m_timerAutoScroll = NULL; - } + wxDELETE(m_timerAutoScroll); #endif } @@ -1101,7 +1112,7 @@ void wxScrollHelperBase::HandleOnChildFocus(wxChildFocusEvent& event) // part of a wxComboCtrl visible and the button would still be outside the // scrolled area. But do so only if the parent fits *entirely* inside the // scrolled window. In other situations, such as nested wxPanel or - // wxScrolledWindows, the parent might be way to big to fit inside the + // wxScrolledWindows, the parent might be way too big to fit inside the // scrolled window. If that is the case, then make only the focused window // visible if ( win->GetParent() != m_targetWindow)