X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b97dc9c8bcfbc22e007474427289c7d5fbd9746e..9859d369b49e35a1cad0f760173e165f974fb6cb:/src/generic/scrlwing.cpp diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 99e9a43640..d46d0a017c 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -41,6 +41,10 @@ #include "wx/sizer.h" #endif +#ifdef __WXMAC__ +#include "wx/scrolbar.h" +#endif + #include "wx/recguard.h" #ifdef __WXMSW__ @@ -231,16 +235,18 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) } } - // reset the skipped flag to false as it might have been set to true in - // ProcessEvent() above - event.Skip(false); - if ( evType == wxEVT_PAINT ) { m_scrollHelper->HandleOnPaint((wxPaintEvent &)event); return true; } + // reset the skipped flag (which might have been set to true in + // ProcessEvent() above) to be able to test it below + bool wasSkipped = event.GetSkipped(); + if ( wasSkipped ) + event.Skip(false); + if ( evType == wxEVT_SCROLLWIN_TOP || evType == wxEVT_SCROLLWIN_BOTTOM || evType == wxEVT_SCROLLWIN_LINEUP || @@ -250,8 +256,16 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) evType == wxEVT_SCROLLWIN_THUMBTRACK || evType == wxEVT_SCROLLWIN_THUMBRELEASE ) { - m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event); - return !event.GetSkipped(); + m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event); + if ( !event.GetSkipped() ) + { + // it makes sense to indicate that we processed the message as we + // did scroll the window (and also notice that wxAutoScrollTimer + // relies on our return value to stop scrolling when we are at top + // or bottom already) + processed = true; + wasSkipped = false; + } } if ( evType == wxEVT_ENTER_WINDOW ) @@ -271,10 +285,17 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) else if ( evType == wxEVT_CHAR ) { m_scrollHelper->HandleOnChar((wxKeyEvent &)event); - return !event.GetSkipped(); + if ( !event.GetSkipped() ) + { + processed = true; + wasSkipped = false; + } } - return false; + if ( processed ) + event.Skip(wasSkipped); + + return processed; } // ---------------------------------------------------------------------------- @@ -447,6 +468,22 @@ wxWindow *wxScrollHelper::GetTargetWindow() const return m_targetWindow; } +#ifdef __WXMAC__ +static bool wxScrolledWindowHasChildren(wxWindow* win) +{ + wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst(); + while ( node ) + { + wxWindow* child = node->GetData(); + if ( !child->IsKindOf(CLASSINFO(wxScrollBar)) ) + return true; + + node = node->GetNext(); + } + return false; +} +#endif + // ---------------------------------------------------------------------------- // scrolling implementation itself // ---------------------------------------------------------------------------- @@ -463,6 +500,11 @@ void wxScrollHelper::HandleOnScroll(wxScrollWinEvent& event) } bool needsRefresh = false; +#ifdef __WXMAC__ + // OS X blocks on immediate redraws, so make this a refresh + if (!wxScrolledWindowHasChildren(m_targetWindow)) + needsRefresh = true; +#endif int dx = 0, dy = 0; int orient = event.GetOrientation(); @@ -1299,7 +1341,7 @@ void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event) wxScrollWinEvent newEvent; newEvent.SetPosition(0); - newEvent.SetOrientation(wxVERTICAL); + newEvent.SetOrientation( event.GetWheelAxis() == 0 ? wxVERTICAL : wxHORIZONTAL); newEvent.SetEventObject(m_win); if (event.IsPageScroll()) @@ -1350,7 +1392,13 @@ bool wxScrolledWindow::Create(wxWindow *parent, MacSetClipChildren( true ) ; #endif - bool ok = wxPanel::Create(parent, id, pos, size, style|wxHSCROLL|wxVSCROLL, name); + // by default, we're scrollable in both directions (but if one of the + // styles is specified explicitly, we shouldn't add the other one + // automatically) + if ( !(style & (wxHSCROLL | wxVSCROLL)) ) + style |= wxHSCROLL | wxVSCROLL; + + bool ok = wxPanel::Create(parent, id, pos, size, style, name); return ok; }