X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/29e1398fa035b277569c4514deb622e9f1ddcf40..cf25a599cd5ec86b3e054efb799dfbafe26a0d50:/src/generic/scrlwing.cpp?ds=sidebyside diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 278ae610c0..300f0a1463 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -86,7 +86,7 @@ private: bool m_hasDrawnWindow; - DECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler) + wxDECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler); }; #if wxUSE_TIMER @@ -112,7 +112,7 @@ private: int m_pos, m_orient; - DECLARE_NO_COPY_CLASS(wxAutoScrollTimer) + wxDECLARE_NO_COPY_CLASS(wxAutoScrollTimer); }; // ============================================================================ @@ -152,7 +152,7 @@ void wxAutoScrollTimer::Notify() { // and then send a pseudo mouse-move event to refresh the selection wxMouseEvent event2(wxEVT_MOTION); - wxGetMousePosition(&event2.m_x, &event2.m_y); + event2.SetPosition(wxGetMousePosition()); // the mouse event coordinates should be client, not screen as // returned by wxGetMousePosition @@ -937,7 +937,7 @@ void wxScrollHelperBase::StopAutoScrolling() if ( m_timerAutoScroll ) { delete m_timerAutoScroll; - m_timerAutoScroll = (wxTimer *)NULL; + m_timerAutoScroll = NULL; } #endif } @@ -1232,28 +1232,20 @@ void wxScrollHelper::DoAdjustScrollbar(int orient, int clientSize, int virtSize, - int& pixelsPerUnit, + int pixelsPerUnit, int& scrollUnits, int& scrollPosition, + int& scrollLinesPerPage, wxScrollbarVisibility visibility) { - if ( visibility == wxSHOW_SB_NEVER ) - { - m_win->SetScrollbar(orient, 0, 0, 0); - return; - } - // scroll lines per page: if 0, no scrolling is needed - int unitsPerPage; - // check if we need scrollbar in this direction at all - if ( pixelsPerUnit == 0 || - (clientSize >= virtSize && visibility != wxSHOW_SB_ALWAYS) ) + if ( pixelsPerUnit == 0 || clientSize >= virtSize ) { // scrolling is disabled or unnecessary scrollUnits = scrollPosition = 0; - unitsPerPage = 0; + scrollLinesPerPage = 0; } else // might need scrolling { @@ -1261,23 +1253,23 @@ wxScrollHelper::DoAdjustScrollbar(int orient, scrollUnits = (virtSize + pixelsPerUnit - 1) / pixelsPerUnit; // Calculate the number of fully scroll units - unitsPerPage = clientSize / pixelsPerUnit; + scrollLinesPerPage = clientSize / pixelsPerUnit; - if (unitsPerPage >= scrollUnits) + if ( scrollLinesPerPage >= scrollUnits ) { // we're big enough to not need scrolling scrollUnits = scrollPosition = 0; - unitsPerPage = 0; + scrollLinesPerPage = 0; } else // we do need a scrollbar { - if ( unitsPerPage < 1 ) - unitsPerPage = 1; + if ( scrollLinesPerPage < 1 ) + scrollLinesPerPage = 1; // Correct position if greater than extent of canvas minus // the visible portion of it or if below zero - const int posMax = scrollUnits - unitsPerPage; + const int posMax = scrollUnits - scrollLinesPerPage; if ( scrollPosition > posMax ) scrollPosition = posMax; else if ( scrollPosition < 0 ) @@ -1285,10 +1277,31 @@ wxScrollHelper::DoAdjustScrollbar(int orient, } } - m_win->SetScrollbar(orient, scrollPosition, unitsPerPage, scrollUnits); + // in wxSHOW_SB_NEVER case don't show the scrollbar even if it's needed, in + // wxSHOW_SB_ALWAYS case show the scrollbar even if it's not needed by + // passing a special range value to SetScrollbar() + int range; + switch ( visibility ) + { + case wxSHOW_SB_NEVER: + range = 0; + break; + + case wxSHOW_SB_ALWAYS: + range = scrollUnits ? scrollUnits : -1; + break; + + default: + wxFAIL_MSG( wxS("unknown scrollbar visibility") ); + // fall through + + case wxSHOW_SB_DEFAULT: + range = scrollUnits; + break; + + } - // The amount by which we scroll when paging - SetScrollPageSize(orient, unitsPerPage); + m_win->SetScrollbar(orient, scrollPosition, scrollLinesPerPage, range); } void wxScrollHelper::AdjustScrollbars() @@ -1348,6 +1361,7 @@ void wxScrollHelper::AdjustScrollbars() m_xScrollPixelsPerLine, m_xScrollLines, m_xScrollPosition, + m_xScrollLinesPerPage, m_xVisibility); DoAdjustScrollbar(wxVERTICAL, @@ -1356,6 +1370,7 @@ void wxScrollHelper::AdjustScrollbars() m_yScrollPixelsPerLine, m_yScrollLines, m_yScrollPosition, + m_yScrollLinesPerPage, m_yVisibility);