bool m_hasDrawnWindow;
- DECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler)
+ wxDECLARE_NO_COPY_CLASS(wxScrollHelperEvtHandler);
};
#if wxUSE_TIMER
int m_pos,
m_orient;
- DECLARE_NO_COPY_CLASS(wxAutoScrollTimer)
+ wxDECLARE_NO_COPY_CLASS(wxAutoScrollTimer);
};
// ============================================================================
{
// 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
if ( m_timerAutoScroll )
{
delete m_timerAutoScroll;
- m_timerAutoScroll = (wxTimer *)NULL;
+ m_timerAutoScroll = NULL;
}
#endif
}
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
{
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 )
}
}
- 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()
m_xScrollPixelsPerLine,
m_xScrollLines,
m_xScrollPosition,
+ m_xScrollLinesPerPage,
m_xVisibility);
DoAdjustScrollbar(wxVERTICAL,
m_yScrollPixelsPerLine,
m_yScrollLines,
m_yScrollPosition,
+ m_yScrollLinesPerPage,
m_yVisibility);