1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/vscroll.cpp
3 // Purpose: wxVScrolledWindow implementation
4 // Author: Vadim Zeitlin
5 // Modified by: Brad Anderson, David Warkentin
7 // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
31 #include "wx/vscroll.h"
33 #include "wx/utils.h" // For wxMin/wxMax().
35 // ============================================================================
36 // wxVarScrollHelperEvtHandler declaration
37 // ============================================================================
39 // ----------------------------------------------------------------------------
40 // wxScrollHelperEvtHandler: intercept the events from the window and forward
41 // them to wxVarScrollHelperBase
42 // ----------------------------------------------------------------------------
44 class WXDLLEXPORT wxVarScrollHelperEvtHandler
: public wxEvtHandler
47 wxVarScrollHelperEvtHandler(wxVarScrollHelperBase
*scrollHelper
)
49 m_scrollHelper
= scrollHelper
;
52 virtual bool ProcessEvent(wxEvent
& event
);
55 wxVarScrollHelperBase
*m_scrollHelper
;
57 wxDECLARE_NO_COPY_CLASS(wxVarScrollHelperEvtHandler
);
60 // ============================================================================
61 // wxVarScrollHelperEvtHandler implementation
62 // ============================================================================
64 bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent
& event
)
66 wxEventType evType
= event
.GetEventType();
68 // pass it on to the real handler
69 bool processed
= wxEvtHandler::ProcessEvent(event
);
71 // always process the size events ourselves, even if the user code handles
72 // them as well, as we need to AdjustScrollbars()
74 // NB: it is important to do it after processing the event in the normal
75 // way as HandleOnSize() may generate a wxEVT_SIZE itself if the
76 // scrollbar[s] (dis)appear and it should be seen by the user code
78 if ( evType
== wxEVT_SIZE
)
80 m_scrollHelper
->HandleOnSize((wxSizeEvent
&)event
);
82 return !event
.GetSkipped();
87 // normally, nothing more to do here - except if we have a command
89 if ( event
.IsCommandEvent() )
95 // reset the skipped flag (which might have been set to true in
96 // ProcessEvent() above) to be able to test it below
97 bool wasSkipped
= event
.GetSkipped();
101 if ( evType
== wxEVT_SCROLLWIN_TOP
||
102 evType
== wxEVT_SCROLLWIN_BOTTOM
||
103 evType
== wxEVT_SCROLLWIN_LINEUP
||
104 evType
== wxEVT_SCROLLWIN_LINEDOWN
||
105 evType
== wxEVT_SCROLLWIN_PAGEUP
||
106 evType
== wxEVT_SCROLLWIN_PAGEDOWN
||
107 evType
== wxEVT_SCROLLWIN_THUMBTRACK
||
108 evType
== wxEVT_SCROLLWIN_THUMBRELEASE
)
110 m_scrollHelper
->HandleOnScroll((wxScrollWinEvent
&)event
);
111 if ( !event
.GetSkipped() )
113 // it makes sense to indicate that we processed the message as we
114 // did scroll the window (and also notice that wxAutoScrollTimer
115 // relies on our return value for continuous scrolling)
121 else if ( evType
== wxEVT_MOUSEWHEEL
)
123 m_scrollHelper
->HandleOnMouseWheel((wxMouseEvent
&)event
);
125 #endif // wxUSE_MOUSEWHEEL
127 event
.Skip(wasSkipped
);
133 // ============================================================================
134 // wxVarScrollHelperBase implementation
135 // ============================================================================
137 // ----------------------------------------------------------------------------
138 // wxVarScrollHelperBase initialization
139 // ----------------------------------------------------------------------------
141 wxVarScrollHelperBase::wxVarScrollHelperBase(wxWindow
*win
)
142 : wxAnyScrollHelperBase(win
)
145 m_sumWheelRotation
= 0;
152 m_physicalScrolling
= true;
155 // by default, the associated window is also the target window
156 DoSetTargetWindow(win
);
159 wxVarScrollHelperBase::~wxVarScrollHelperBase()
164 // ----------------------------------------------------------------------------
165 // wxVarScrollHelperBase various helpers
166 // ----------------------------------------------------------------------------
169 wxVarScrollHelperBase::AssignOrient(wxCoord
& x
,
174 if ( GetOrientation() == wxVERTICAL
)
187 wxVarScrollHelperBase::IncOrient(wxCoord
& x
, wxCoord
& y
, wxCoord inc
)
189 if ( GetOrientation() == wxVERTICAL
)
195 wxCoord
wxVarScrollHelperBase::DoEstimateTotalSize() const
197 // estimate the total height: it is impossible to call
198 // OnGetUnitSize() for every unit because there may be too many of
199 // them, so we just make a guess using some units in the beginning,
200 // some in the end and some in the middle
201 static const size_t NUM_UNITS_TO_SAMPLE
= 10;
204 if ( m_unitMax
< 3*NUM_UNITS_TO_SAMPLE
)
206 // in this case, full calculations are faster and more correct than
208 sizeTotal
= GetUnitsSize(0, m_unitMax
);
210 else // too many units to calculate exactly
212 // look at some units in the beginning/middle/end
214 GetUnitsSize(0, NUM_UNITS_TO_SAMPLE
) +
215 GetUnitsSize(m_unitMax
- NUM_UNITS_TO_SAMPLE
,
217 GetUnitsSize(m_unitMax
/2 - NUM_UNITS_TO_SAMPLE
/2,
218 m_unitMax
/2 + NUM_UNITS_TO_SAMPLE
/2);
220 // use the height of the units we looked as the average
221 sizeTotal
= (wxCoord
)
222 (((float)sizeTotal
/ (3*NUM_UNITS_TO_SAMPLE
)) * m_unitMax
);
228 wxCoord
wxVarScrollHelperBase::GetUnitsSize(size_t unitMin
, size_t unitMax
) const
230 if ( unitMin
== unitMax
)
232 else if ( unitMin
> unitMax
)
233 return -GetUnitsSize(unitMax
, unitMin
);
234 //else: unitMin < unitMax
236 // let the user code know that we're going to need all these units
237 OnGetUnitsSizeHint(unitMin
, unitMax
);
239 // sum up their sizes
241 for ( size_t unit
= unitMin
; unit
< unitMax
; ++unit
)
243 size
+= OnGetUnitSize(unit
);
249 size_t wxVarScrollHelperBase::FindFirstVisibleFromLast(size_t unitLast
, bool full
) const
251 const wxCoord sWindow
= GetOrientationTargetSize();
253 // go upwards until we arrive at a unit such that unitLast is not visible
254 // any more when it is shown
255 size_t unitFirst
= unitLast
;
259 s
+= OnGetUnitSize(unitFirst
);
263 // for this unit to be fully visible we need to go one unit
264 // down, but if it is enough for it to be only partly visible then
265 // this unit will do as well
283 size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent
& event
) const
285 wxEventType evtType
= event
.GetEventType();
287 if ( evtType
== wxEVT_SCROLLWIN_TOP
)
291 else if ( evtType
== wxEVT_SCROLLWIN_BOTTOM
)
295 else if ( evtType
== wxEVT_SCROLLWIN_LINEUP
)
297 return m_unitFirst
? m_unitFirst
- 1 : 0;
299 else if ( evtType
== wxEVT_SCROLLWIN_LINEDOWN
)
301 return m_unitFirst
+ 1;
303 else if ( evtType
== wxEVT_SCROLLWIN_PAGEUP
)
305 // Page up should do at least as much as line up.
306 return wxMin(FindFirstVisibleFromLast(m_unitFirst
),
307 m_unitFirst
? m_unitFirst
- 1 : 0);
309 else if ( evtType
== wxEVT_SCROLLWIN_PAGEDOWN
)
311 // And page down should do at least as much as line down.
312 if ( GetVisibleEnd() )
313 return wxMax(GetVisibleEnd() - 1, m_unitFirst
+ 1);
315 return wxMax(GetVisibleEnd(), m_unitFirst
+ 1);
317 else if ( evtType
== wxEVT_SCROLLWIN_THUMBRELEASE
)
319 return event
.GetPosition();
321 else if ( evtType
== wxEVT_SCROLLWIN_THUMBTRACK
)
323 return event
.GetPosition();
326 // unknown scroll event?
327 wxFAIL_MSG( wxT("unknown scroll event type?") );
331 void wxVarScrollHelperBase::UpdateScrollbar()
333 // if there is nothing to scroll, remove the scrollbar
340 // see how many units can we fit on screen
341 const wxCoord sWindow
= GetOrientationTargetSize();
343 // do vertical calculations
346 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
351 s
+= OnGetUnitSize(unit
);
354 m_nUnitsVisible
= unit
- m_unitFirst
;
356 int unitsPageSize
= m_nUnitsVisible
;
359 // last unit is only partially visible, we still need the scrollbar and
360 // so we have to "fix" pageSize because if it is equal to m_unitMax
361 // the scrollbar is not shown at all under MSW
365 // set the scrollbar parameters to reflect this
366 m_win
->SetScrollbar(GetOrientation(), m_unitFirst
, unitsPageSize
, m_unitMax
);
369 void wxVarScrollHelperBase::RemoveScrollbar()
372 m_nUnitsVisible
= m_unitMax
;
373 m_win
->SetScrollbar(GetOrientation(), 0, 0, 0);
376 void wxVarScrollHelperBase::DeleteEvtHandler()
378 // search for m_handler in the handler list
379 if ( m_win
&& m_handler
)
381 if ( m_win
->RemoveEventHandler(m_handler
) )
385 //else: something is very wrong, so better [maybe] leak memory than
386 // risk a crash because of double deletion
392 void wxVarScrollHelperBase::DoSetTargetWindow(wxWindow
*target
)
394 m_targetWindow
= target
;
396 target
->MacSetClipChildren( true ) ;
399 // install the event handler which will intercept the events we're
400 // interested in (but only do it for our real window, not the target window
401 // which we scroll - we don't need to hijack its events)
402 if ( m_targetWindow
== m_win
)
404 // if we already have a handler, delete it first
407 m_handler
= new wxVarScrollHelperEvtHandler(this);
408 m_targetWindow
->PushEventHandler(m_handler
);
412 // ----------------------------------------------------------------------------
413 // wxVarScrollHelperBase operations
414 // ----------------------------------------------------------------------------
416 void wxVarScrollHelperBase::SetTargetWindow(wxWindow
*target
)
418 wxCHECK_RET( target
, wxT("target window must not be NULL") );
420 if ( target
== m_targetWindow
)
423 DoSetTargetWindow(target
);
426 void wxVarScrollHelperBase::SetUnitCount(size_t count
)
428 // save the number of units
431 // and our estimate for their total height
432 m_sizeTotal
= EstimateTotalSize();
434 // ScrollToUnit() will update the scrollbar itself if it changes the unit
435 // we pass to it because it's out of [new] range
436 size_t oldScrollPos
= m_unitFirst
;
437 DoScrollToUnit(m_unitFirst
);
438 if ( oldScrollPos
== m_unitFirst
)
440 // but if it didn't do it, we still need to update the scrollbar to
441 // reflect the changed number of units ourselves
446 void wxVarScrollHelperBase::RefreshUnit(size_t unit
)
448 // is this unit visible?
449 if ( !IsVisible(unit
) )
451 // no, it is useless to do anything
455 // calculate the rect occupied by this unit on screen
457 AssignOrient(rect
.width
, rect
.height
,
458 GetNonOrientationTargetSize(), OnGetUnitSize(unit
));
460 for ( size_t n
= GetVisibleBegin(); n
< unit
; ++n
)
462 IncOrient(rect
.x
, rect
.y
, OnGetUnitSize(n
));
466 m_targetWindow
->RefreshRect(rect
);
469 void wxVarScrollHelperBase::RefreshUnits(size_t from
, size_t to
)
471 wxASSERT_MSG( from
<= to
, wxT("RefreshUnits(): empty range") );
473 // clump the range to just the visible units -- it is useless to refresh
475 if ( from
< GetVisibleBegin() )
476 from
= GetVisibleBegin();
478 if ( to
> GetVisibleEnd() )
479 to
= GetVisibleEnd();
481 // calculate the rect occupied by these units on screen
485 int nonorient_size
= GetNonOrientationTargetSize();
487 for ( size_t nBefore
= GetVisibleBegin();
491 orient_pos
+= OnGetUnitSize(nBefore
);
494 for ( size_t nBetween
= from
; nBetween
<= to
; nBetween
++ )
496 orient_size
+= OnGetUnitSize(nBetween
);
500 AssignOrient(rect
.x
, rect
.y
, 0, orient_pos
);
501 AssignOrient(rect
.width
, rect
.height
, nonorient_size
, orient_size
);
504 m_targetWindow
->RefreshRect(rect
);
507 void wxVarScrollHelperBase::RefreshAll()
511 m_targetWindow
->Refresh();
514 bool wxVarScrollHelperBase::ScrollLayout()
516 if ( m_targetWindow
->GetSizer() && m_physicalScrolling
)
518 // adjust the sizer dimensions/position taking into account the
519 // virtual size and scrolled position of the window.
522 AssignOrient(x
, y
, 0, -GetScrollOffset());
525 m_targetWindow
->GetVirtualSize(&w
, &h
);
527 m_targetWindow
->GetSizer()->SetDimension(x
, y
, w
, h
);
531 // fall back to default for LayoutConstraints
532 return m_targetWindow
->wxWindow::Layout();
535 int wxVarScrollHelperBase::VirtualHitTest(wxCoord coord
) const
537 const size_t unitMax
= GetVisibleEnd();
538 for ( size_t unit
= GetVisibleBegin(); unit
< unitMax
; ++unit
)
540 coord
-= OnGetUnitSize(unit
);
548 // ----------------------------------------------------------------------------
549 // wxVarScrollHelperBase scrolling
550 // ----------------------------------------------------------------------------
552 bool wxVarScrollHelperBase::DoScrollToUnit(size_t unit
)
556 // we're empty, code below doesn't make sense in this case
560 // determine the real first unit to scroll to: we shouldn't scroll beyond
562 size_t unitFirstLast
= FindFirstVisibleFromLast(m_unitMax
- 1, true);
563 if ( unit
> unitFirstLast
)
564 unit
= unitFirstLast
;
567 if ( unit
== m_unitFirst
)
574 // remember the currently shown units for the refresh code below
575 size_t unitFirstOld
= GetVisibleBegin(),
576 unitLastOld
= GetVisibleEnd();
581 // the size of scrollbar thumb could have changed
584 // finally refresh the display -- but only redraw as few units as possible
585 // to avoid flicker. We can't do this if we have children because they
587 if ( m_targetWindow
->GetChildren().empty() &&
588 (GetVisibleBegin() >= unitLastOld
|| GetVisibleEnd() <= unitFirstOld
) )
590 // the simplest case: we don't have any old units left, just redraw
592 m_targetWindow
->Refresh();
594 else // scroll the window
596 // Avoid scrolling visible parts of the screen on Mac
598 if (m_physicalScrolling
&& m_targetWindow
->IsShownOnScreen())
600 if ( m_physicalScrolling
)
604 dy
= GetUnitsSize(GetVisibleBegin(), unitFirstOld
);
606 if ( GetOrientation() == wxHORIZONTAL
)
613 m_targetWindow
->ScrollWindow(dx
, dy
);
615 else // !m_physicalScrolling
617 // we still need to invalidate but we can't use ScrollWindow
618 // because physical scrolling is disabled (the user either didn't
619 // want children scrolled and/or doesn't want pixels to be
620 // physically scrolled).
621 m_targetWindow
->Refresh();
628 bool wxVarScrollHelperBase::DoScrollUnits(int units
)
630 units
+= m_unitFirst
;
634 return DoScrollToUnit(units
);
637 bool wxVarScrollHelperBase::DoScrollPages(int pages
)
639 bool didSomething
= false;
646 unit
= GetVisibleEnd();
653 unit
= FindFirstVisibleFromLast(GetVisibleEnd());
657 didSomething
= DoScrollToUnit(unit
);
663 // ----------------------------------------------------------------------------
665 // ----------------------------------------------------------------------------
667 void wxVarScrollHelperBase::HandleOnSize(wxSizeEvent
& event
)
671 // sometimes change in varscrollable window's size can result in
672 // unused empty space after the last item. Fix it by decrementing
673 // first visible item position according to the available space.
675 // determine free space
676 const wxCoord sWindow
= GetOrientationTargetSize();
679 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
684 s
+= OnGetUnitSize(unit
);
686 wxCoord freeSpace
= sWindow
- s
;
688 // decrement first visible item index as long as there is free space
689 size_t idealUnitFirst
;
690 for ( idealUnitFirst
= m_unitFirst
;
694 wxCoord us
= OnGetUnitSize(idealUnitFirst
-1);
695 if ( freeSpace
< us
)
699 m_unitFirst
= idealUnitFirst
;
707 void wxVarScrollHelperBase::HandleOnScroll(wxScrollWinEvent
& event
)
709 if (GetOrientation() != event
.GetOrientation())
715 DoScrollToUnit(GetNewScrollPosition(event
));
718 UpdateMacScrollWindow();
722 void wxVarScrollHelperBase::DoPrepareDC(wxDC
& dc
)
724 if ( m_physicalScrolling
)
726 wxPoint pt
= dc
.GetDeviceOrigin();
728 IncOrient(pt
.x
, pt
.y
, -GetScrollOffset());
730 dc
.SetDeviceOrigin(pt
.x
, pt
.y
);
734 int wxVarScrollHelperBase::DoCalcScrolledPosition(int coord
) const
736 return coord
- GetScrollOffset();
739 int wxVarScrollHelperBase::DoCalcUnscrolledPosition(int coord
) const
741 return coord
+ GetScrollOffset();
746 void wxVarScrollHelperBase::HandleOnMouseWheel(wxMouseEvent
& event
)
748 // we only want to process wheel events for vertical implementations.
749 // There is no way to determine wheel orientation (and on MSW horizontal
750 // wheel rotation just fakes scroll events, rather than sending a MOUSEWHEEL
752 if ( GetOrientation() != wxVERTICAL
)
755 m_sumWheelRotation
+= event
.GetWheelRotation();
756 int delta
= event
.GetWheelDelta();
758 // how much to scroll this time
759 int units_to_scroll
= -(m_sumWheelRotation
/delta
);
760 if ( !units_to_scroll
)
763 m_sumWheelRotation
+= units_to_scroll
*delta
;
765 if ( !event
.IsPageScroll() )
766 DoScrollUnits( units_to_scroll
*event
.GetLinesPerAction() );
767 else // scroll pages instead of units
768 DoScrollPages( units_to_scroll
);
771 #endif // wxUSE_MOUSEWHEEL
774 // ============================================================================
775 // wxVarHVScrollHelper implementation
776 // ============================================================================
778 // ----------------------------------------------------------------------------
779 // wxVarHVScrollHelper operations
780 // ----------------------------------------------------------------------------
782 void wxVarHVScrollHelper::SetRowColumnCount(size_t rowCount
, size_t columnCount
)
784 SetRowCount(rowCount
);
785 SetColumnCount(columnCount
);
788 bool wxVarHVScrollHelper::ScrollToRowColumn(size_t row
, size_t column
)
791 result
|= ScrollToRow(row
);
792 result
|= ScrollToColumn(column
);
796 void wxVarHVScrollHelper::RefreshRowColumn(size_t row
, size_t column
)
798 // is this unit visible?
799 if ( !IsRowVisible(row
) || !IsColumnVisible(column
) )
801 // no, it is useless to do anything
805 // calculate the rect occupied by this cell on screen
806 wxRect v_rect
, h_rect
;
807 v_rect
.height
= OnGetRowHeight(row
);
808 h_rect
.width
= OnGetColumnWidth(column
);
812 for ( n
= GetVisibleRowsBegin(); n
< row
; n
++ )
814 v_rect
.y
+= OnGetRowHeight(n
);
817 for ( n
= GetVisibleColumnsBegin(); n
< column
; n
++ )
819 h_rect
.x
+= OnGetColumnWidth(n
);
822 // refresh but specialize the behaviour if we have a single target window
823 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
826 v_rect
.width
= h_rect
.width
;
827 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
832 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
834 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
836 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
837 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
841 void wxVarHVScrollHelper::RefreshRowsColumns(size_t fromRow
, size_t toRow
,
842 size_t fromColumn
, size_t toColumn
)
844 wxASSERT_MSG( fromRow
<= toRow
|| fromColumn
<= toColumn
,
845 wxT("RefreshRowsColumns(): empty range") );
847 // clump the range to just the visible units -- it is useless to refresh
849 if ( fromRow
< GetVisibleRowsBegin() )
850 fromRow
= GetVisibleRowsBegin();
852 if ( toRow
> GetVisibleRowsEnd() )
853 toRow
= GetVisibleRowsEnd();
855 if ( fromColumn
< GetVisibleColumnsBegin() )
856 fromColumn
= GetVisibleColumnsBegin();
858 if ( toColumn
> GetVisibleColumnsEnd() )
859 toColumn
= GetVisibleColumnsEnd();
861 // calculate the rect occupied by these units on screen
862 wxRect v_rect
, h_rect
;
863 size_t nBefore
, nBetween
;
865 for ( nBefore
= GetVisibleRowsBegin();
869 v_rect
.y
+= OnGetRowHeight(nBefore
);
872 for ( nBetween
= fromRow
; nBetween
<= toRow
; nBetween
++ )
874 v_rect
.height
+= OnGetRowHeight(nBetween
);
877 for ( nBefore
= GetVisibleColumnsBegin();
878 nBefore
< fromColumn
;
881 h_rect
.x
+= OnGetColumnWidth(nBefore
);
884 for ( nBetween
= fromColumn
; nBetween
<= toColumn
; nBetween
++ )
886 h_rect
.width
+= OnGetColumnWidth(nBetween
);
889 // refresh but specialize the behaviour if we have a single target window
890 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
893 v_rect
.width
= h_rect
.width
;
894 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
899 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
901 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
903 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
904 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
908 wxPosition
wxVarHVScrollHelper::VirtualHitTest(wxCoord x
, wxCoord y
) const
910 return wxPosition(wxVarVScrollHelper::VirtualHitTest(y
),
911 wxVarHScrollHelper::VirtualHitTest(x
));
914 void wxVarHVScrollHelper::DoPrepareDC(wxDC
& dc
)
916 wxVarVScrollHelper::DoPrepareDC(dc
);
917 wxVarHScrollHelper::DoPrepareDC(dc
);
920 bool wxVarHVScrollHelper::ScrollLayout()
922 bool layout_result
= false;
923 layout_result
|= wxVarVScrollHelper::ScrollLayout();
924 layout_result
|= wxVarHScrollHelper::ScrollLayout();
925 return layout_result
;
928 wxSize
wxVarHVScrollHelper::GetRowColumnCount() const
930 return wxSize(GetColumnCount(), GetRowCount());
933 wxPosition
wxVarHVScrollHelper::GetVisibleBegin() const
935 return wxPosition(GetVisibleRowsBegin(), GetVisibleColumnsBegin());
938 wxPosition
wxVarHVScrollHelper::GetVisibleEnd() const
940 return wxPosition(GetVisibleRowsEnd(), GetVisibleColumnsEnd());
943 bool wxVarHVScrollHelper::IsVisible(size_t row
, size_t column
) const
945 return IsRowVisible(row
) && IsColumnVisible(column
);
949 // ============================================================================
950 // wx[V/H/HV]ScrolledWindow implementations
951 // ============================================================================
953 IMPLEMENT_ABSTRACT_CLASS(wxVScrolledWindow
, wxPanel
)
954 IMPLEMENT_ABSTRACT_CLASS(wxHScrolledWindow
, wxPanel
)
955 IMPLEMENT_ABSTRACT_CLASS(wxHVScrolledWindow
, wxPanel
)
958 #if WXWIN_COMPATIBILITY_2_8
960 // ===========================================================================
961 // wxVarVScrollLegacyAdaptor
962 // ===========================================================================
964 size_t wxVarVScrollLegacyAdaptor::GetFirstVisibleLine() const
965 { return GetVisibleRowsBegin(); }
967 size_t wxVarVScrollLegacyAdaptor::GetLastVisibleLine() const
968 { return GetVisibleRowsEnd() - 1; }
970 size_t wxVarVScrollLegacyAdaptor::GetLineCount() const
971 { return GetRowCount(); }
973 void wxVarVScrollLegacyAdaptor::SetLineCount(size_t count
)
974 { SetRowCount(count
); }
976 void wxVarVScrollLegacyAdaptor::RefreshLine(size_t line
)
977 { RefreshRow(line
); }
979 void wxVarVScrollLegacyAdaptor::RefreshLines(size_t from
, size_t to
)
980 { RefreshRows(from
, to
); }
982 bool wxVarVScrollLegacyAdaptor::ScrollToLine(size_t line
)
983 { return ScrollToRow(line
); }
985 bool wxVarVScrollLegacyAdaptor::ScrollLines(int lines
)
986 { return ScrollRows(lines
); }
988 bool wxVarVScrollLegacyAdaptor::ScrollPages(int pages
)
989 { return ScrollRowPages(pages
); }
991 wxCoord
wxVarVScrollLegacyAdaptor::OnGetLineHeight(size_t WXUNUSED(n
)) const
993 wxFAIL_MSG( wxT("OnGetLineHeight() must be overridden if OnGetRowHeight() isn't!") );
997 void wxVarVScrollLegacyAdaptor::OnGetLinesHint(size_t WXUNUSED(lineMin
),
998 size_t WXUNUSED(lineMax
)) const
1002 wxCoord
wxVarVScrollLegacyAdaptor::OnGetRowHeight(size_t n
) const
1004 return OnGetLineHeight(n
);
1007 void wxVarVScrollLegacyAdaptor::OnGetRowsHeightHint(size_t rowMin
,
1008 size_t rowMax
) const
1010 OnGetLinesHint(rowMin
, rowMax
);
1013 #endif // WXWIN_COMPATIBILITY_2_8