X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d5d58a93c327198b8d1dd781c7d07626d2b2062a..1978421a6d8b81c1f8a961da4b8ddf544fec7b1b:/src/generic/scrlwing.cpp diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index ffff7d7509..8dab9a85f1 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -18,7 +18,7 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "genscrolwin.h" #endif @@ -40,8 +40,11 @@ #include "wx/scrolwin.h" #include "wx/panel.h" +#if wxUSE_TIMER #include "wx/timer.h" +#endif #include "wx/sizer.h" +#include "wx/recguard.h" #ifdef __WXMSW__ #include // for DLGC_WANTARROWS @@ -61,6 +64,11 @@ IMPLEMENT_CLASS(wxScrolledWindow, wxGenericScrolledWindow) +/* + TODO PROPERTIES + style wxHSCROLL | wxVSCROLL +*/ + // ---------------------------------------------------------------------------- // wxScrollHelperEvtHandler: intercept the events from the window and forward // them to wxScrollHelper @@ -86,6 +94,7 @@ private: DECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler) }; +#if wxUSE_TIMER // ---------------------------------------------------------------------------- // wxAutoScrollTimer: the timer used to generate a stream of scroll events when // a captured mouse is held outside the window @@ -170,6 +179,7 @@ void wxAutoScrollTimer::Notify() } } } +#endif // ---------------------------------------------------------------------------- // wxScrollHelperEvtHandler @@ -360,15 +370,24 @@ void wxScrollHelper::SetScrollbars(int pixelsPerUnitX, if (do_refresh && !noRefresh) m_targetWindow->Refresh(TRUE, GetScrollRect()); - // TODO: check if we can use AdjustScrollbars always. -#ifdef __WXUNIVERSAL__ - AdjustScrollbars(); -#else - // This is also done by AdjustScrollbars, above +#ifndef __WXUNIVERSAL__ + // If the target is not the same as the window with the scrollbars, + // then we need to update the scrollbars here, since they won't have + // been updated by SetVirtualSize(). + if ( m_targetWindow != m_win ) +#endif // !__WXUNIVERSAL__ + { + AdjustScrollbars(); + } +#ifndef __WXUNIVERSAL__ + else + { + // otherwise this has been done by AdjustScrollbars, above #ifdef __WXMAC__ - m_targetWindow->MacUpdateImmediately() ; -#endif + m_targetWindow->Update() ; #endif + } +#endif // !__WXUNIVERSAL__ } // ---------------------------------------------------------------------------- @@ -496,7 +515,7 @@ void wxScrollHelper::HandleOnScroll(wxScrollWinEvent& event) } #ifdef __WXMAC__ - m_targetWindow->MacUpdateImmediately() ; + m_targetWindow->Update() ; #endif } @@ -603,8 +622,21 @@ int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event) // Adjust the scrollbars - new version. void wxScrollHelper::AdjustScrollbars() { + static wxRecursionGuardFlag s_flagReentrancy; + wxRecursionGuard guard(s_flagReentrancy); + if ( guard.IsInside() ) + { + // don't reenter AdjustScrollbars() while another call to + // AdjustScrollbars() is in progress because this may lead to calling + // ScrollWindow() twice and this can really happen under MSW if + // SetScrollbar() call below adds or removes the scrollbar which + // changes the window size and hence results in another + // AdjustScrollbars() call + return; + } + #ifdef __WXMAC__ - m_targetWindow->MacUpdateImmediately(); + m_targetWindow->Update(); #endif int w = 0, h = 0; @@ -704,7 +736,7 @@ void wxScrollHelper::AdjustScrollbars() oldh = h; GetTargetSize( &w, &h ); - } while ( w != oldw && h != oldh ); + } while ( w != oldw || h != oldh ); #ifdef __WXMOTIF__ // Sorry, some Motif-specific code to implement a backing pixmap @@ -758,7 +790,7 @@ void wxScrollHelper::AdjustScrollbars() } #ifdef __WXMAC__ - m_targetWindow->MacUpdateImmediately(); + m_targetWindow->Update(); #endif } @@ -824,7 +856,7 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos ) ((y_pos == -1) || (y_pos == m_yScrollPosition))) return; #ifdef __WXMAC__ - m_targetWindow->MacUpdateImmediately(); + m_targetWindow->Update(); #endif int w, h; @@ -874,7 +906,7 @@ void wxScrollHelper::Scroll( int x_pos, int y_pos ) } #ifdef __WXMAC__ - m_targetWindow->MacUpdateImmediately(); + m_targetWindow->Update(); #endif } @@ -1058,11 +1090,13 @@ bool wxScrollHelper::SendAutoScrollEvents(wxScrollWinEvent& event) const void wxScrollHelper::StopAutoScrolling() { +#if wxUSE_TIMER if ( m_timerAutoScroll ) { delete m_timerAutoScroll; m_timerAutoScroll = (wxTimer *)NULL; } +#endif } void wxScrollHelper::HandleOnMouseEnter(wxMouseEvent& event) @@ -1124,6 +1158,7 @@ void wxScrollHelper::HandleOnMouseLeave(wxMouseEvent& event) if ( !m_targetWindow->HasScrollbar(orient) ) return; +#if wxUSE_TIMER delete m_timerAutoScroll; m_timerAutoScroll = new wxAutoScrollTimer ( @@ -1134,6 +1169,7 @@ void wxScrollHelper::HandleOnMouseLeave(wxMouseEvent& event) orient ); m_timerAutoScroll->Start(50); // FIXME: make configurable +#endif } } @@ -1254,35 +1290,19 @@ wxGenericScrolledWindow::MSWWindowProc(WXUINT nMsg, { long rc = wxPanel::MSWWindowProc(nMsg, wParam, lParam); +#ifndef __WXWINCE__ // we need to process arrows ourselves for scrolling if ( nMsg == WM_GETDLGCODE ) { rc |= DLGC_WANTARROWS; } +#endif return rc; } #endif // __WXMSW__ -#if WXWIN_COMPATIBILITY - -void wxGenericScrolledWindow::GetScrollUnitsPerPage (int *x_page, int *y_page) const -{ - *x_page = GetScrollPageSize(wxHORIZONTAL); - *y_page = GetScrollPageSize(wxVERTICAL); -} - -void wxGenericScrolledWindow::CalcUnscrolledPosition(int x, int y, float *xx, float *yy) const -{ - if ( xx ) - *xx = (float)(x + m_xScrollPosition * m_xScrollPixelsPerLine); - if ( yy ) - *yy = (float)(y + m_yScrollPosition * m_yScrollPixelsPerLine); -} - -#endif // WXWIN_COMPATIBILITY - #endif // !wxGTK // vi:sts=4:sw=4:et