1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/vscroll.cpp
3 // Purpose: wxVScrolledWindow implementation
4 // Author: Vadim Zeitlin
5 // Modified by: Brad Anderson, David Warkentin
8 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
32 #include "wx/vscroll.h"
34 // ============================================================================
35 // wxVarScrollHelperEvtHandler declaration
36 // ============================================================================
38 // ----------------------------------------------------------------------------
39 // wxScrollHelperEvtHandler: intercept the events from the window and forward
40 // them to wxVarScrollHelperBase
41 // ----------------------------------------------------------------------------
43 class WXDLLEXPORT wxVarScrollHelperEvtHandler
: public wxEvtHandler
46 wxVarScrollHelperEvtHandler(wxVarScrollHelperBase
*scrollHelper
)
48 m_scrollHelper
= scrollHelper
;
51 virtual bool ProcessEvent(wxEvent
& event
);
54 wxVarScrollHelperBase
*m_scrollHelper
;
56 wxDECLARE_NO_COPY_CLASS(wxVarScrollHelperEvtHandler
);
59 // ============================================================================
60 // wxVarScrollHelperEvtHandler implementation
61 // ============================================================================
63 bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent
& event
)
65 wxEventType evType
= event
.GetEventType();
67 // pass it on to the real handler
68 bool processed
= wxEvtHandler::ProcessEvent(event
);
70 // always process the size events ourselves, even if the user code handles
71 // them as well, as we need to AdjustScrollbars()
73 // NB: it is important to do it after processing the event in the normal
74 // way as HandleOnSize() may generate a wxEVT_SIZE itself if the
75 // scrollbar[s] (dis)appear and it should be seen by the user code
77 if ( evType
== wxEVT_SIZE
)
79 m_scrollHelper
->HandleOnSize((wxSizeEvent
&)event
);
81 return !event
.GetSkipped();
86 // normally, nothing more to do here - except if we have a command
88 if ( event
.IsCommandEvent() )
94 // reset the skipped flag (which might have been set to true in
95 // ProcessEvent() above) to be able to test it below
96 bool wasSkipped
= event
.GetSkipped();
100 // reset the skipped flag to false as it might have been set to true in
101 // ProcessEvent() above
104 if ( evType
== wxEVT_SCROLLWIN_TOP
||
105 evType
== wxEVT_SCROLLWIN_BOTTOM
||
106 evType
== wxEVT_SCROLLWIN_LINEUP
||
107 evType
== wxEVT_SCROLLWIN_LINEDOWN
||
108 evType
== wxEVT_SCROLLWIN_PAGEUP
||
109 evType
== wxEVT_SCROLLWIN_PAGEDOWN
||
110 evType
== wxEVT_SCROLLWIN_THUMBTRACK
||
111 evType
== wxEVT_SCROLLWIN_THUMBRELEASE
)
113 m_scrollHelper
->HandleOnScroll((wxScrollWinEvent
&)event
);
114 if ( !event
.GetSkipped() )
116 // it makes sense to indicate that we processed the message as we
117 // did scroll the window (and also notice that wxAutoScrollTimer
118 // relies on our return value for continuous scrolling)
124 else if ( evType
== wxEVT_MOUSEWHEEL
)
126 m_scrollHelper
->HandleOnMouseWheel((wxMouseEvent
&)event
);
128 #endif // wxUSE_MOUSEWHEEL
131 event
.Skip(wasSkipped
);
137 // ============================================================================
138 // wxVarScrollHelperBase implementation
139 // ============================================================================
141 // ----------------------------------------------------------------------------
142 // wxVarScrollHelperBase initialization
143 // ----------------------------------------------------------------------------
145 wxVarScrollHelperBase::wxVarScrollHelperBase(wxWindow
*win
)
147 wxASSERT_MSG( win
, wxT("associated window can't be NULL in wxVarScrollHelperBase") );
150 m_sumWheelRotation
= 0;
158 m_targetWindow
= NULL
;
160 m_physicalScrolling
= true;
165 // by default, the associated window is also the target window
166 DoSetTargetWindow(win
);
170 wxVarScrollHelperBase::~wxVarScrollHelperBase()
175 // ----------------------------------------------------------------------------
176 // wxVarScrollHelperBase various helpers
177 // ----------------------------------------------------------------------------
180 wxVarScrollHelperBase::AssignOrient(wxCoord
& x
,
185 if ( GetOrientation() == wxVERTICAL
)
198 wxVarScrollHelperBase::IncOrient(wxCoord
& x
, wxCoord
& y
, wxCoord inc
)
200 if ( GetOrientation() == wxVERTICAL
)
206 wxCoord
wxVarScrollHelperBase::DoEstimateTotalSize() const
208 // estimate the total height: it is impossible to call
209 // OnGetUnitSize() for every unit because there may be too many of
210 // them, so we just make a guess using some units in the beginning,
211 // some in the end and some in the middle
212 static const size_t NUM_UNITS_TO_SAMPLE
= 10;
215 if ( m_unitMax
< 3*NUM_UNITS_TO_SAMPLE
)
217 // in this case, full calculations are faster and more correct than
219 sizeTotal
= GetUnitsSize(0, m_unitMax
);
221 else // too many units to calculate exactly
223 // look at some units in the beginning/middle/end
225 GetUnitsSize(0, NUM_UNITS_TO_SAMPLE
) +
226 GetUnitsSize(m_unitMax
- NUM_UNITS_TO_SAMPLE
,
228 GetUnitsSize(m_unitMax
/2 - NUM_UNITS_TO_SAMPLE
/2,
229 m_unitMax
/2 + NUM_UNITS_TO_SAMPLE
/2);
231 // use the height of the units we looked as the average
232 sizeTotal
= (wxCoord
)
233 (((float)sizeTotal
/ (3*NUM_UNITS_TO_SAMPLE
)) * m_unitMax
);
239 wxCoord
wxVarScrollHelperBase::GetUnitsSize(size_t unitMin
, size_t unitMax
) const
241 if ( unitMin
== unitMax
)
243 else if ( unitMin
> unitMax
)
244 return -GetUnitsSize(unitMax
, unitMin
);
245 //else: unitMin < unitMax
247 // let the user code know that we're going to need all these units
248 OnGetUnitsSizeHint(unitMin
, unitMax
);
250 // sum up their sizes
252 for ( size_t unit
= unitMin
; unit
< unitMax
; ++unit
)
254 size
+= OnGetUnitSize(unit
);
260 size_t wxVarScrollHelperBase::FindFirstVisibleFromLast(size_t unitLast
, bool full
) const
262 const wxCoord sWindow
= GetOrientationTargetSize();
264 // go upwards until we arrive at a unit such that unitLast is not visible
265 // any more when it is shown
266 size_t unitFirst
= unitLast
;
270 s
+= OnGetUnitSize(unitFirst
);
274 // for this unit to be fully visible we need to go one unit
275 // down, but if it is enough for it to be only partly visible then
276 // this unit will do as well
294 size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent
& event
) const
296 wxEventType evtType
= event
.GetEventType();
298 if ( evtType
== wxEVT_SCROLLWIN_TOP
)
302 else if ( evtType
== wxEVT_SCROLLWIN_BOTTOM
)
306 else if ( evtType
== wxEVT_SCROLLWIN_LINEUP
)
308 return m_unitFirst
? m_unitFirst
- 1 : 0;
310 else if ( evtType
== wxEVT_SCROLLWIN_LINEDOWN
)
312 return m_unitFirst
+ 1;
314 else if ( evtType
== wxEVT_SCROLLWIN_PAGEUP
)
316 return FindFirstVisibleFromLast(m_unitFirst
);
318 else if ( evtType
== wxEVT_SCROLLWIN_PAGEDOWN
)
320 if ( GetVisibleEnd() )
321 return GetVisibleEnd() - 1;
323 return GetVisibleEnd();
325 else if ( evtType
== wxEVT_SCROLLWIN_THUMBRELEASE
)
327 return event
.GetPosition();
329 else if ( evtType
== wxEVT_SCROLLWIN_THUMBTRACK
)
331 return event
.GetPosition();
334 // unknown scroll event?
335 wxFAIL_MSG( wxT("unknown scroll event type?") );
339 void wxVarScrollHelperBase::UpdateScrollbar()
341 // if there is nothing to scroll, remove the scrollbar
348 // see how many units can we fit on screen
349 const wxCoord sWindow
= GetOrientationTargetSize();
351 // do vertical calculations
354 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
359 s
+= OnGetUnitSize(unit
);
362 m_nUnitsVisible
= unit
- m_unitFirst
;
364 int unitsPageSize
= m_nUnitsVisible
;
367 // last unit is only partially visible, we still need the scrollbar and
368 // so we have to "fix" pageSize because if it is equal to m_unitMax
369 // the scrollbar is not shown at all under MSW
373 // set the scrollbar parameters to reflect this
374 m_win
->SetScrollbar(GetOrientation(), m_unitFirst
, unitsPageSize
, m_unitMax
);
377 void wxVarScrollHelperBase::RemoveScrollbar()
380 m_nUnitsVisible
= m_unitMax
;
381 m_win
->SetScrollbar(GetOrientation(), 0, 0, 0);
384 void wxVarScrollHelperBase::DeleteEvtHandler()
386 // search for m_handler in the handler list
387 if ( m_win
&& m_handler
)
389 if ( m_win
->RemoveEventHandler(m_handler
) )
393 //else: something is very wrong, so better [maybe] leak memory than
394 // risk a crash because of double deletion
400 void wxVarScrollHelperBase::DoSetTargetWindow(wxWindow
*target
)
402 m_targetWindow
= target
;
404 target
->MacSetClipChildren( true ) ;
407 // install the event handler which will intercept the events we're
408 // interested in (but only do it for our real window, not the target window
409 // which we scroll - we don't need to hijack its events)
410 if ( m_targetWindow
== m_win
)
412 // if we already have a handler, delete it first
415 m_handler
= new wxVarScrollHelperEvtHandler(this);
416 m_targetWindow
->PushEventHandler(m_handler
);
420 // ----------------------------------------------------------------------------
421 // wxVarScrollHelperBase operations
422 // ----------------------------------------------------------------------------
424 void wxVarScrollHelperBase::SetTargetWindow(wxWindow
*target
)
426 wxCHECK_RET( target
, wxT("target window must not be NULL") );
428 if ( target
== m_targetWindow
)
431 DoSetTargetWindow(target
);
434 void wxVarScrollHelperBase::SetUnitCount(size_t count
)
436 // save the number of units
439 // and our estimate for their total height
440 m_sizeTotal
= EstimateTotalSize();
442 // ScrollToUnit() will update the scrollbar itself if it changes the unit
443 // we pass to it because it's out of [new] range
444 size_t oldScrollPos
= m_unitFirst
;
445 DoScrollToUnit(m_unitFirst
);
446 if ( oldScrollPos
== m_unitFirst
)
448 // but if it didn't do it, we still need to update the scrollbar to
449 // reflect the changed number of units ourselves
454 void wxVarScrollHelperBase::RefreshUnit(size_t unit
)
456 // is this unit visible?
457 if ( !IsVisible(unit
) )
459 // no, it is useless to do anything
463 // calculate the rect occupied by this unit on screen
465 AssignOrient(rect
.width
, rect
.height
,
466 GetNonOrientationTargetSize(), OnGetUnitSize(unit
));
468 for ( size_t n
= GetVisibleBegin(); n
< unit
; ++n
)
470 IncOrient(rect
.x
, rect
.y
, OnGetUnitSize(n
));
474 m_targetWindow
->RefreshRect(rect
);
477 void wxVarScrollHelperBase::RefreshUnits(size_t from
, size_t to
)
479 wxASSERT_MSG( from
<= to
, wxT("RefreshUnits(): empty range") );
481 // clump the range to just the visible units -- it is useless to refresh
483 if ( from
< GetVisibleBegin() )
484 from
= GetVisibleBegin();
486 if ( to
> GetVisibleEnd() )
487 to
= GetVisibleEnd();
489 // calculate the rect occupied by these units on screen
490 int orient_size
, nonorient_size
, orient_pos
;
491 orient_size
= nonorient_size
= orient_pos
= 0;
493 nonorient_size
= GetNonOrientationTargetSize();
495 for ( size_t nBefore
= GetVisibleBegin();
499 orient_pos
+= OnGetUnitSize(nBefore
);
502 for ( size_t nBetween
= from
; nBetween
<= to
; nBetween
++ )
504 orient_size
+= OnGetUnitSize(nBetween
);
508 AssignOrient(rect
.x
, rect
.y
, 0, orient_pos
);
509 AssignOrient(rect
.width
, rect
.height
, nonorient_size
, orient_size
);
512 m_targetWindow
->RefreshRect(rect
);
515 void wxVarScrollHelperBase::RefreshAll()
519 m_targetWindow
->Refresh();
522 bool wxVarScrollHelperBase::ScrollLayout()
524 if ( m_targetWindow
->GetSizer() && m_physicalScrolling
)
526 // adjust the sizer dimensions/position taking into account the
527 // virtual size and scrolled position of the window.
530 AssignOrient(x
, y
, 0, -GetScrollOffset());
533 m_targetWindow
->GetVirtualSize(&w
, &h
);
535 m_targetWindow
->GetSizer()->SetDimension(x
, y
, w
, h
);
539 // fall back to default for LayoutConstraints
540 return m_targetWindow
->wxWindow::Layout();
543 int wxVarScrollHelperBase::VirtualHitTest(wxCoord coord
) const
545 const size_t unitMax
= GetVisibleEnd();
546 for ( size_t unit
= GetVisibleBegin(); unit
< unitMax
; ++unit
)
548 coord
-= OnGetUnitSize(unit
);
556 // ----------------------------------------------------------------------------
557 // wxVarScrollHelperBase scrolling
558 // ----------------------------------------------------------------------------
560 bool wxVarScrollHelperBase::DoScrollToUnit(size_t unit
)
564 // we're empty, code below doesn't make sense in this case
568 // determine the real first unit to scroll to: we shouldn't scroll beyond
570 size_t unitFirstLast
= FindFirstVisibleFromLast(m_unitMax
- 1, true);
571 if ( unit
> unitFirstLast
)
572 unit
= unitFirstLast
;
575 if ( unit
== m_unitFirst
)
582 // remember the currently shown units for the refresh code below
583 size_t unitFirstOld
= GetVisibleBegin(),
584 unitLastOld
= GetVisibleEnd();
589 // the size of scrollbar thumb could have changed
592 // finally refresh the display -- but only redraw as few units as possible
593 // to avoid flicker. We can't do this if we have children because they
595 if ( m_targetWindow
->GetChildren().empty() &&
596 (GetVisibleBegin() >= unitLastOld
|| GetVisibleEnd() <= unitFirstOld
) )
598 // the simplest case: we don't have any old units left, just redraw
600 m_targetWindow
->Refresh();
602 else // scroll the window
604 // Avoid scrolling visible parts of the screen on Mac
606 if (m_physicalScrolling
&& m_targetWindow
->IsShownOnScreen())
608 if ( m_physicalScrolling
)
612 dy
= GetUnitsSize(GetVisibleBegin(), unitFirstOld
);
614 if ( GetOrientation() == wxHORIZONTAL
)
621 m_targetWindow
->ScrollWindow(dx
, dy
);
623 else // !m_physicalScrolling
625 // we still need to invalidate but we can't use ScrollWindow
626 // because physical scrolling is disabled (the user either didn't
627 // want children scrolled and/or doesn't want pixels to be
628 // physically scrolled).
629 m_targetWindow
->Refresh();
636 bool wxVarScrollHelperBase::DoScrollUnits(int units
)
638 units
+= m_unitFirst
;
642 return DoScrollToUnit(units
);
645 bool wxVarScrollHelperBase::DoScrollPages(int pages
)
647 bool didSomething
= false;
654 unit
= GetVisibleEnd();
661 unit
= FindFirstVisibleFromLast(GetVisibleEnd());
665 didSomething
= DoScrollToUnit(unit
);
671 // ----------------------------------------------------------------------------
673 // ----------------------------------------------------------------------------
675 void wxVarScrollHelperBase::HandleOnSize(wxSizeEvent
& event
)
679 // sometimes change in varscrollable window's size can result in
680 // unused empty space after the last item. Fix it by decrementing
681 // first visible item position according to the available space.
683 // determine free space
684 const wxCoord sWindow
= GetOrientationTargetSize();
687 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
692 s
+= OnGetUnitSize(unit
);
694 wxCoord freeSpace
= sWindow
- s
;
696 // decrement first visible item index as long as there is free space
697 size_t idealUnitFirst
;
698 for ( idealUnitFirst
= m_unitFirst
;
702 wxCoord us
= OnGetUnitSize(idealUnitFirst
-1);
703 if ( freeSpace
< us
)
707 m_unitFirst
= idealUnitFirst
;
715 void wxVarScrollHelperBase::HandleOnScroll(wxScrollWinEvent
& event
)
717 if (GetOrientation() != event
.GetOrientation())
723 DoScrollToUnit(GetNewScrollPosition(event
));
726 UpdateMacScrollWindow();
730 void wxVarScrollHelperBase::DoPrepareDC(wxDC
& dc
)
732 if ( m_physicalScrolling
)
734 wxPoint pt
= dc
.GetDeviceOrigin();
736 IncOrient(pt
.x
, pt
.y
, -GetScrollOffset());
738 dc
.SetDeviceOrigin(pt
.x
, pt
.y
);
742 int wxVarScrollHelperBase::DoCalcScrolledPosition(int coord
) const
744 return coord
- GetScrollOffset();
747 int wxVarScrollHelperBase::DoCalcUnscrolledPosition(int coord
) const
749 return coord
+ GetScrollOffset();
754 void wxVarScrollHelperBase::HandleOnMouseWheel(wxMouseEvent
& event
)
756 // we only want to process wheel events for vertical implementations.
757 // There is no way to determine wheel orientation (and on MSW horizontal
758 // wheel rotation just fakes scroll events, rather than sending a MOUSEWHEEL
760 if ( GetOrientation() != wxVERTICAL
)
763 m_sumWheelRotation
+= event
.GetWheelRotation();
764 int delta
= event
.GetWheelDelta();
766 // how much to scroll this time
767 int units_to_scroll
= -(m_sumWheelRotation
/delta
);
768 if ( !units_to_scroll
)
771 m_sumWheelRotation
+= units_to_scroll
*delta
;
773 if ( !event
.IsPageScroll() )
774 DoScrollUnits( units_to_scroll
*event
.GetLinesPerAction() );
775 else // scroll pages instead of units
776 DoScrollPages( units_to_scroll
);
779 #endif // wxUSE_MOUSEWHEEL
782 // ============================================================================
783 // wxVarHVScrollHelper implementation
784 // ============================================================================
786 // ----------------------------------------------------------------------------
787 // wxVarHVScrollHelper operations
788 // ----------------------------------------------------------------------------
790 void wxVarHVScrollHelper::SetRowColumnCount(size_t rowCount
, size_t columnCount
)
792 SetRowCount(rowCount
);
793 SetColumnCount(columnCount
);
796 bool wxVarHVScrollHelper::ScrollToRowColumn(size_t row
, size_t column
)
799 result
|= ScrollToRow(row
);
800 result
|= ScrollToColumn(column
);
804 void wxVarHVScrollHelper::RefreshRowColumn(size_t row
, size_t column
)
806 // is this unit visible?
807 if ( !IsRowVisible(row
) || !IsColumnVisible(column
) )
809 // no, it is useless to do anything
813 // calculate the rect occupied by this cell on screen
814 wxRect v_rect
, h_rect
;
815 v_rect
.height
= OnGetRowHeight(row
);
816 h_rect
.width
= OnGetColumnWidth(column
);
820 for ( n
= GetVisibleRowsBegin(); n
< row
; n
++ )
822 v_rect
.y
+= OnGetRowHeight(n
);
825 for ( n
= GetVisibleColumnsBegin(); n
< column
; n
++ )
827 h_rect
.x
+= OnGetColumnWidth(n
);
830 // refresh but specialize the behavior if we have a single target window
831 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
834 v_rect
.width
= h_rect
.width
;
835 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
840 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
842 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
844 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
845 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
849 void wxVarHVScrollHelper::RefreshRowsColumns(size_t fromRow
, size_t toRow
,
850 size_t fromColumn
, size_t toColumn
)
852 wxASSERT_MSG( fromRow
<= toRow
|| fromColumn
<= toColumn
,
853 wxT("RefreshRowsColumns(): empty range") );
855 // clump the range to just the visible units -- it is useless to refresh
857 if ( fromRow
< GetVisibleRowsBegin() )
858 fromRow
= GetVisibleRowsBegin();
860 if ( toRow
> GetVisibleRowsEnd() )
861 toRow
= GetVisibleRowsEnd();
863 if ( fromColumn
< GetVisibleColumnsBegin() )
864 fromColumn
= GetVisibleColumnsBegin();
866 if ( toColumn
> GetVisibleColumnsEnd() )
867 toColumn
= GetVisibleColumnsEnd();
869 // calculate the rect occupied by these units on screen
870 wxRect v_rect
, h_rect
;
871 size_t nBefore
, nBetween
;
873 for ( nBefore
= GetVisibleRowsBegin();
877 v_rect
.y
+= OnGetRowHeight(nBefore
);
880 for ( nBetween
= fromRow
; nBetween
<= toRow
; nBetween
++ )
882 v_rect
.height
+= OnGetRowHeight(nBetween
);
885 for ( nBefore
= GetVisibleColumnsBegin();
886 nBefore
< fromColumn
;
889 h_rect
.x
+= OnGetColumnWidth(nBefore
);
892 for ( nBetween
= fromColumn
; nBetween
<= toColumn
; nBetween
++ )
894 h_rect
.width
+= OnGetColumnWidth(nBetween
);
897 // refresh but specialize the behavior if we have a single target window
898 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
901 v_rect
.width
= h_rect
.width
;
902 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
907 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
909 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
911 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
912 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
916 wxPosition
wxVarHVScrollHelper::VirtualHitTest(wxCoord x
, wxCoord y
) const
918 return wxPosition(wxVarVScrollHelper::VirtualHitTest(y
),
919 wxVarHScrollHelper::VirtualHitTest(x
));
922 void wxVarHVScrollHelper::DoPrepareDC(wxDC
& dc
)
924 wxVarVScrollHelper::DoPrepareDC(dc
);
925 wxVarHScrollHelper::DoPrepareDC(dc
);
928 bool wxVarHVScrollHelper::ScrollLayout()
930 bool layout_result
= false;
931 layout_result
|= wxVarVScrollHelper::ScrollLayout();
932 layout_result
|= wxVarHScrollHelper::ScrollLayout();
933 return layout_result
;
936 wxSize
wxVarHVScrollHelper::GetRowColumnCount() const
938 return wxSize(GetColumnCount(), GetRowCount());
941 wxPosition
wxVarHVScrollHelper::GetVisibleBegin() const
943 return wxPosition(GetVisibleRowsBegin(), GetVisibleColumnsBegin());
946 wxPosition
wxVarHVScrollHelper::GetVisibleEnd() const
948 return wxPosition(GetVisibleRowsEnd(), GetVisibleColumnsEnd());
951 bool wxVarHVScrollHelper::IsVisible(size_t row
, size_t column
) const
953 return IsRowVisible(row
) && IsColumnVisible(column
);
957 // ============================================================================
958 // wx[V/H/HV]ScrolledWindow implementations
959 // ============================================================================
961 IMPLEMENT_ABSTRACT_CLASS(wxVScrolledWindow
, wxPanel
)
962 IMPLEMENT_ABSTRACT_CLASS(wxHScrolledWindow
, wxPanel
)
963 IMPLEMENT_ABSTRACT_CLASS(wxHVScrolledWindow
, wxPanel
)
966 #if WXWIN_COMPATIBILITY_2_8
968 // ===========================================================================
969 // wxVarVScrollLegacyAdaptor
970 // ===========================================================================
972 size_t wxVarVScrollLegacyAdaptor::GetFirstVisibleLine() const
973 { return GetVisibleRowsBegin(); }
975 size_t wxVarVScrollLegacyAdaptor::GetLastVisibleLine() const
976 { return GetVisibleRowsEnd() - 1; }
978 size_t wxVarVScrollLegacyAdaptor::GetLineCount() const
979 { return GetRowCount(); }
981 void wxVarVScrollLegacyAdaptor::SetLineCount(size_t count
)
982 { SetRowCount(count
); }
984 void wxVarVScrollLegacyAdaptor::RefreshLine(size_t line
)
985 { RefreshRow(line
); }
987 void wxVarVScrollLegacyAdaptor::RefreshLines(size_t from
, size_t to
)
988 { RefreshRows(from
, to
); }
990 bool wxVarVScrollLegacyAdaptor::ScrollToLine(size_t line
)
991 { return ScrollToRow(line
); }
993 bool wxVarVScrollLegacyAdaptor::ScrollLines(int lines
)
994 { return ScrollRows(lines
); }
996 bool wxVarVScrollLegacyAdaptor::ScrollPages(int pages
)
997 { return ScrollRowPages(pages
); }
999 wxCoord
wxVarVScrollLegacyAdaptor::OnGetLineHeight(size_t WXUNUSED(n
)) const
1001 wxFAIL_MSG( wxT("OnGetLineHeight() must be overridden if OnGetRowHeight() isn't!") );
1005 void wxVarVScrollLegacyAdaptor::OnGetLinesHint(size_t WXUNUSED(lineMin
),
1006 size_t WXUNUSED(lineMax
)) const
1010 wxCoord
wxVarVScrollLegacyAdaptor::OnGetRowHeight(size_t n
) const
1012 return OnGetLineHeight(n
);
1015 void wxVarVScrollLegacyAdaptor::OnGetRowsHeightHint(size_t rowMin
,
1016 size_t rowMax
) const
1018 OnGetLinesHint(rowMin
, rowMax
);
1021 #endif // WXWIN_COMPATIBILITY_2_8