X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dc429f89a68f4e45c11dd8638d10a270b2d82505..cfcc39321282c5877cbb45248bb8004ced24516b:/src/generic/scrlwing.cpp diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index b36eace80e..f516a8552d 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -82,6 +82,8 @@ private: wxScrollHelper *m_scrollHelper; bool m_hasDrawnWindow; + + DECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler) }; // ---------------------------------------------------------------------------- @@ -104,6 +106,8 @@ private: wxEventType m_eventType; int m_pos, m_orient; + + DECLARE_NO_COPY_CLASS(wxAutoScrollTimer) }; // ============================================================================ @@ -340,16 +344,36 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX, m_xScrollPosition = xPos; m_yScrollPosition = yPos; - m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY ); + // For better backward compatibility we set persisting limits + // here not just the size. It makes SetScrollbars 'sticky' + // emulating the old non-autoscroll behaviour. - AdjustScrollbars(); + wxSize sz = m_targetWindow->GetClientSize(); +#if 1 + int x = wxMax(noUnitsX * pixelsPerUnitX, sz.x); + int y = wxMax(noUnitsY * pixelsPerUnitY, sz.y); +#else + int x = noUnitsX * pixelsPerUnitX; + int y = noUnitsY * pixelsPerUnitY; +#endif + m_targetWindow->SetVirtualSizeHints( x, y ); + + // The above should arguably be deprecated, this however we still need. + + m_targetWindow->SetVirtualSize( x, y ); if (do_refresh && !noRefresh) m_targetWindow->Refresh(TRUE, GetRect()); + // TODO: check if we can use AdjustScrollbars always. +#ifdef __WXUNIVERSAL__ + AdjustScrollbars(); +#else + // This is also done by AdjustScrollbars, above #ifdef __WXMAC__ m_targetWindow->MacUpdateImmediately() ; #endif +#endif } // ---------------------------------------------------------------------------- @@ -867,17 +891,19 @@ void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) co // Default OnSize resets scrollbars, if any void wxScrollHelper::HandleOnSize(wxSizeEvent& WXUNUSED(event)) { - if ( m_targetWindow != m_win ) - m_targetWindow->SetVirtualSize( m_targetWindow->GetClientSize() ); - - m_win->SetVirtualSize( m_win->GetClientSize() ); + if( m_win->GetAutoLayout() ) + { + if ( m_targetWindow != m_win ) + m_targetWindow->FitInside(); - AdjustScrollbars(); + m_win->FitInside(); #if wxUSE_CONSTRAINTS - if (m_win->GetAutoLayout()) m_win->Layout(); #endif + } + else + AdjustScrollbars(); } // This calls OnDraw, having adjusted the origin according to the current @@ -930,7 +956,7 @@ void wxScrollHelper::HandleOnChar(wxKeyEvent& event) yScrollOld = m_yScrollPosition; int dsty; - switch ( event.KeyCode() ) + switch ( event.GetKeyCode() ) { case WXK_PAGEUP: case WXK_PRIOR: @@ -1092,26 +1118,34 @@ void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event) if (lines != 0) { - lines *= event.GetLinesPerAction(); wxScrollWinEvent newEvent; newEvent.SetPosition(0); newEvent.SetOrientation(wxVERTICAL); newEvent.m_eventObject = m_win; - if (lines > 0) - newEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP; - else - newEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; - int times = abs(lines); - for (; times > 0; times --) + if (event.IsPageScroll()) + { + if (lines > 0) + newEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP; + else + newEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN; + m_win->GetEventHandler()->ProcessEvent(newEvent); + } + else + { + lines *= event.GetLinesPerAction(); + if (lines > 0) + newEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP; + else + newEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN; - /* Old Way */ - // int vsx, vsy; - // GetViewStart(&vsx, &vsy); - // Scroll(-1, vsy - lines); + int times = abs(lines); + for (; times > 0; times--) + m_win->GetEventHandler()->ProcessEvent(newEvent); + } } } @@ -1163,6 +1197,17 @@ bool wxGenericScrolledWindow::Layout() return wxPanel::Layout(); } +void wxGenericScrolledWindow::DoSetVirtualSize(int x, int y) +{ + wxPanel::DoSetVirtualSize( x, y ); + AdjustScrollbars(); + +#if wxUSE_CONSTRAINTS + if (GetAutoLayout()) + Layout(); +#endif +} + void wxGenericScrolledWindow::OnPaint(wxPaintEvent& event) { // the user code didn't really draw the window if we got here, so set this