// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "genscrolwin.h"
#endif
#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 <windows.h> // for DLGC_WANTARROWS
IMPLEMENT_CLASS(wxScrolledWindow, wxGenericScrolledWindow)
+/*
+ TODO PROPERTIES
+ style wxHSCROLL | wxVSCROLL
+*/
+
// ----------------------------------------------------------------------------
// wxScrollHelperEvtHandler: intercept the events from the window and forward
// them to wxScrollHelper
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
}
}
}
+#endif
// ----------------------------------------------------------------------------
// wxScrollHelperEvtHandler
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
-#ifdef __WXMAC__
- m_targetWindow->MacUpdateImmediately() ;
-#endif
-#endif
+#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
+ }
+#endif // !__WXUNIVERSAL__
}
// ----------------------------------------------------------------------------
{
m_targetWindow->ScrollWindow(dx, dy, GetScrollRect());
}
-
-#ifdef __WXMAC__
- m_targetWindow->MacUpdateImmediately() ;
-#endif
}
int wxScrollHelper::CalcScrollInc(wxScrollWinEvent& event)
// Adjust the scrollbars - new version.
void wxScrollHelper::AdjustScrollbars()
{
-#ifdef __WXMAC__
- m_targetWindow->MacUpdateImmediately();
-#endif
+ 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;
+ }
int w = 0, h = 0;
int oldw, oldh;
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
else
m_targetWindow->Refresh(TRUE, GetScrollRect());
}
-
-#ifdef __WXMAC__
- m_targetWindow->MacUpdateImmediately();
-#endif
}
void wxScrollHelper::DoPrepareDC(wxDC& dc)
if (((x_pos == -1) || (x_pos == m_xScrollPosition)) &&
((y_pos == -1) || (y_pos == m_yScrollPosition))) return;
-#ifdef __WXMAC__
- m_targetWindow->MacUpdateImmediately();
-#endif
-
int w, h;
GetTargetSize(&w, &h);
GetScrollRect() );
}
}
-
-#ifdef __WXMAC__
- m_targetWindow->MacUpdateImmediately();
-#endif
-
}
void wxScrollHelper::EnableScrolling (bool x_scroll, bool y_scroll)
void wxScrollHelper::StopAutoScrolling()
{
+#if wxUSE_TIMER
if ( m_timerAutoScroll )
{
delete m_timerAutoScroll;
m_timerAutoScroll = (wxTimer *)NULL;
}
+#endif
}
void wxScrollHelper::HandleOnMouseEnter(wxMouseEvent& event)
if ( !m_targetWindow->HasScrollbar(orient) )
return;
+#if wxUSE_TIMER
delete m_timerAutoScroll;
m_timerAutoScroll = new wxAutoScrollTimer
(
orient
);
m_timerAutoScroll->Start(50); // FIXME: make configurable
+#endif
}
}
{
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