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
)
143 wxASSERT_MSG( win
, wxT("associated window can't be NULL in wxVarScrollHelperBase") );
146 m_sumWheelRotation
= 0;
154 m_targetWindow
= NULL
;
156 m_physicalScrolling
= true;
161 // by default, the associated window is also the target window
162 DoSetTargetWindow(win
);
166 wxVarScrollHelperBase::~wxVarScrollHelperBase()
171 // ----------------------------------------------------------------------------
172 // wxVarScrollHelperBase various helpers
173 // ----------------------------------------------------------------------------
176 wxVarScrollHelperBase::AssignOrient(wxCoord
& x
,
181 if ( GetOrientation() == wxVERTICAL
)
194 wxVarScrollHelperBase::IncOrient(wxCoord
& x
, wxCoord
& y
, wxCoord inc
)
196 if ( GetOrientation() == wxVERTICAL
)
202 wxCoord
wxVarScrollHelperBase::DoEstimateTotalSize() const
204 // estimate the total height: it is impossible to call
205 // OnGetUnitSize() for every unit because there may be too many of
206 // them, so we just make a guess using some units in the beginning,
207 // some in the end and some in the middle
208 static const size_t NUM_UNITS_TO_SAMPLE
= 10;
211 if ( m_unitMax
< 3*NUM_UNITS_TO_SAMPLE
)
213 // in this case, full calculations are faster and more correct than
215 sizeTotal
= GetUnitsSize(0, m_unitMax
);
217 else // too many units to calculate exactly
219 // look at some units in the beginning/middle/end
221 GetUnitsSize(0, NUM_UNITS_TO_SAMPLE
) +
222 GetUnitsSize(m_unitMax
- NUM_UNITS_TO_SAMPLE
,
224 GetUnitsSize(m_unitMax
/2 - NUM_UNITS_TO_SAMPLE
/2,
225 m_unitMax
/2 + NUM_UNITS_TO_SAMPLE
/2);
227 // use the height of the units we looked as the average
228 sizeTotal
= (wxCoord
)
229 (((float)sizeTotal
/ (3*NUM_UNITS_TO_SAMPLE
)) * m_unitMax
);
235 wxCoord
wxVarScrollHelperBase::GetUnitsSize(size_t unitMin
, size_t unitMax
) const
237 if ( unitMin
== unitMax
)
239 else if ( unitMin
> unitMax
)
240 return -GetUnitsSize(unitMax
, unitMin
);
241 //else: unitMin < unitMax
243 // let the user code know that we're going to need all these units
244 OnGetUnitsSizeHint(unitMin
, unitMax
);
246 // sum up their sizes
248 for ( size_t unit
= unitMin
; unit
< unitMax
; ++unit
)
250 size
+= OnGetUnitSize(unit
);
256 size_t wxVarScrollHelperBase::FindFirstVisibleFromLast(size_t unitLast
, bool full
) const
258 const wxCoord sWindow
= GetOrientationTargetSize();
260 // go upwards until we arrive at a unit such that unitLast is not visible
261 // any more when it is shown
262 size_t unitFirst
= unitLast
;
266 s
+= OnGetUnitSize(unitFirst
);
270 // for this unit to be fully visible we need to go one unit
271 // down, but if it is enough for it to be only partly visible then
272 // this unit will do as well
290 size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent
& event
) const
292 wxEventType evtType
= event
.GetEventType();
294 if ( evtType
== wxEVT_SCROLLWIN_TOP
)
298 else if ( evtType
== wxEVT_SCROLLWIN_BOTTOM
)
302 else if ( evtType
== wxEVT_SCROLLWIN_LINEUP
)
304 return m_unitFirst
? m_unitFirst
- 1 : 0;
306 else if ( evtType
== wxEVT_SCROLLWIN_LINEDOWN
)
308 return m_unitFirst
+ 1;
310 else if ( evtType
== wxEVT_SCROLLWIN_PAGEUP
)
312 // Page up should do at least as much as line up.
313 return wxMin(FindFirstVisibleFromLast(m_unitFirst
),
314 m_unitFirst
? m_unitFirst
- 1 : 0);
316 else if ( evtType
== wxEVT_SCROLLWIN_PAGEDOWN
)
318 // And page down should do at least as much as line down.
319 if ( GetVisibleEnd() )
320 return wxMax(GetVisibleEnd() - 1, m_unitFirst
+ 1);
322 return wxMax(GetVisibleEnd(), m_unitFirst
+ 1);
324 else if ( evtType
== wxEVT_SCROLLWIN_THUMBRELEASE
)
326 return event
.GetPosition();
328 else if ( evtType
== wxEVT_SCROLLWIN_THUMBTRACK
)
330 return event
.GetPosition();
333 // unknown scroll event?
334 wxFAIL_MSG( wxT("unknown scroll event type?") );
338 void wxVarScrollHelperBase::UpdateScrollbar()
340 // if there is nothing to scroll, remove the scrollbar
347 // see how many units can we fit on screen
348 const wxCoord sWindow
= GetOrientationTargetSize();
350 // do vertical calculations
353 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
358 s
+= OnGetUnitSize(unit
);
361 m_nUnitsVisible
= unit
- m_unitFirst
;
363 int unitsPageSize
= m_nUnitsVisible
;
366 // last unit is only partially visible, we still need the scrollbar and
367 // so we have to "fix" pageSize because if it is equal to m_unitMax
368 // the scrollbar is not shown at all under MSW
372 // set the scrollbar parameters to reflect this
373 m_win
->SetScrollbar(GetOrientation(), m_unitFirst
, unitsPageSize
, m_unitMax
);
376 void wxVarScrollHelperBase::RemoveScrollbar()
379 m_nUnitsVisible
= m_unitMax
;
380 m_win
->SetScrollbar(GetOrientation(), 0, 0, 0);
383 void wxVarScrollHelperBase::DeleteEvtHandler()
385 // search for m_handler in the handler list
386 if ( m_win
&& m_handler
)
388 if ( m_win
->RemoveEventHandler(m_handler
) )
392 //else: something is very wrong, so better [maybe] leak memory than
393 // risk a crash because of double deletion
399 void wxVarScrollHelperBase::DoSetTargetWindow(wxWindow
*target
)
401 m_targetWindow
= target
;
403 target
->MacSetClipChildren( true ) ;
406 // install the event handler which will intercept the events we're
407 // interested in (but only do it for our real window, not the target window
408 // which we scroll - we don't need to hijack its events)
409 if ( m_targetWindow
== m_win
)
411 // if we already have a handler, delete it first
414 m_handler
= new wxVarScrollHelperEvtHandler(this);
415 m_targetWindow
->PushEventHandler(m_handler
);
419 // ----------------------------------------------------------------------------
420 // wxVarScrollHelperBase operations
421 // ----------------------------------------------------------------------------
423 void wxVarScrollHelperBase::SetTargetWindow(wxWindow
*target
)
425 wxCHECK_RET( target
, wxT("target window must not be NULL") );
427 if ( target
== m_targetWindow
)
430 DoSetTargetWindow(target
);
433 void wxVarScrollHelperBase::SetUnitCount(size_t count
)
435 // save the number of units
438 // and our estimate for their total height
439 m_sizeTotal
= EstimateTotalSize();
441 // ScrollToUnit() will update the scrollbar itself if it changes the unit
442 // we pass to it because it's out of [new] range
443 size_t oldScrollPos
= m_unitFirst
;
444 DoScrollToUnit(m_unitFirst
);
445 if ( oldScrollPos
== m_unitFirst
)
447 // but if it didn't do it, we still need to update the scrollbar to
448 // reflect the changed number of units ourselves
453 void wxVarScrollHelperBase::RefreshUnit(size_t unit
)
455 // is this unit visible?
456 if ( !IsVisible(unit
) )
458 // no, it is useless to do anything
462 // calculate the rect occupied by this unit on screen
464 AssignOrient(rect
.width
, rect
.height
,
465 GetNonOrientationTargetSize(), OnGetUnitSize(unit
));
467 for ( size_t n
= GetVisibleBegin(); n
< unit
; ++n
)
469 IncOrient(rect
.x
, rect
.y
, OnGetUnitSize(n
));
473 m_targetWindow
->RefreshRect(rect
);
476 void wxVarScrollHelperBase::RefreshUnits(size_t from
, size_t to
)
478 wxASSERT_MSG( from
<= to
, wxT("RefreshUnits(): empty range") );
480 // clump the range to just the visible units -- it is useless to refresh
482 if ( from
< GetVisibleBegin() )
483 from
= GetVisibleBegin();
485 if ( to
> GetVisibleEnd() )
486 to
= GetVisibleEnd();
488 // calculate the rect occupied by these units on screen
492 int nonorient_size
= GetNonOrientationTargetSize();
494 for ( size_t nBefore
= GetVisibleBegin();
498 orient_pos
+= OnGetUnitSize(nBefore
);
501 for ( size_t nBetween
= from
; nBetween
<= to
; nBetween
++ )
503 orient_size
+= OnGetUnitSize(nBetween
);
507 AssignOrient(rect
.x
, rect
.y
, 0, orient_pos
);
508 AssignOrient(rect
.width
, rect
.height
, nonorient_size
, orient_size
);
511 m_targetWindow
->RefreshRect(rect
);
514 void wxVarScrollHelperBase::RefreshAll()
518 m_targetWindow
->Refresh();
521 bool wxVarScrollHelperBase::ScrollLayout()
523 if ( m_targetWindow
->GetSizer() && m_physicalScrolling
)
525 // adjust the sizer dimensions/position taking into account the
526 // virtual size and scrolled position of the window.
529 AssignOrient(x
, y
, 0, -GetScrollOffset());
532 m_targetWindow
->GetVirtualSize(&w
, &h
);
534 m_targetWindow
->GetSizer()->SetDimension(x
, y
, w
, h
);
538 // fall back to default for LayoutConstraints
539 return m_targetWindow
->wxWindow::Layout();
542 int wxVarScrollHelperBase::VirtualHitTest(wxCoord coord
) const
544 const size_t unitMax
= GetVisibleEnd();
545 for ( size_t unit
= GetVisibleBegin(); unit
< unitMax
; ++unit
)
547 coord
-= OnGetUnitSize(unit
);
555 // ----------------------------------------------------------------------------
556 // wxVarScrollHelperBase scrolling
557 // ----------------------------------------------------------------------------
559 bool wxVarScrollHelperBase::DoScrollToUnit(size_t unit
)
563 // we're empty, code below doesn't make sense in this case
567 // determine the real first unit to scroll to: we shouldn't scroll beyond
569 size_t unitFirstLast
= FindFirstVisibleFromLast(m_unitMax
- 1, true);
570 if ( unit
> unitFirstLast
)
571 unit
= unitFirstLast
;
574 if ( unit
== m_unitFirst
)
581 // remember the currently shown units for the refresh code below
582 size_t unitFirstOld
= GetVisibleBegin(),
583 unitLastOld
= GetVisibleEnd();
588 // the size of scrollbar thumb could have changed
591 // finally refresh the display -- but only redraw as few units as possible
592 // to avoid flicker. We can't do this if we have children because they
594 if ( m_targetWindow
->GetChildren().empty() &&
595 (GetVisibleBegin() >= unitLastOld
|| GetVisibleEnd() <= unitFirstOld
) )
597 // the simplest case: we don't have any old units left, just redraw
599 m_targetWindow
->Refresh();
601 else // scroll the window
603 // Avoid scrolling visible parts of the screen on Mac
605 if (m_physicalScrolling
&& m_targetWindow
->IsShownOnScreen())
607 if ( m_physicalScrolling
)
611 dy
= GetUnitsSize(GetVisibleBegin(), unitFirstOld
);
613 if ( GetOrientation() == wxHORIZONTAL
)
620 m_targetWindow
->ScrollWindow(dx
, dy
);
622 else // !m_physicalScrolling
624 // we still need to invalidate but we can't use ScrollWindow
625 // because physical scrolling is disabled (the user either didn't
626 // want children scrolled and/or doesn't want pixels to be
627 // physically scrolled).
628 m_targetWindow
->Refresh();
635 bool wxVarScrollHelperBase::DoScrollUnits(int units
)
637 units
+= m_unitFirst
;
641 return DoScrollToUnit(units
);
644 bool wxVarScrollHelperBase::DoScrollPages(int pages
)
646 bool didSomething
= false;
653 unit
= GetVisibleEnd();
660 unit
= FindFirstVisibleFromLast(GetVisibleEnd());
664 didSomething
= DoScrollToUnit(unit
);
670 // ----------------------------------------------------------------------------
672 // ----------------------------------------------------------------------------
674 void wxVarScrollHelperBase::HandleOnSize(wxSizeEvent
& event
)
678 // sometimes change in varscrollable window's size can result in
679 // unused empty space after the last item. Fix it by decrementing
680 // first visible item position according to the available space.
682 // determine free space
683 const wxCoord sWindow
= GetOrientationTargetSize();
686 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
691 s
+= OnGetUnitSize(unit
);
693 wxCoord freeSpace
= sWindow
- s
;
695 // decrement first visible item index as long as there is free space
696 size_t idealUnitFirst
;
697 for ( idealUnitFirst
= m_unitFirst
;
701 wxCoord us
= OnGetUnitSize(idealUnitFirst
-1);
702 if ( freeSpace
< us
)
706 m_unitFirst
= idealUnitFirst
;
714 void wxVarScrollHelperBase::HandleOnScroll(wxScrollWinEvent
& event
)
716 if (GetOrientation() != event
.GetOrientation())
722 DoScrollToUnit(GetNewScrollPosition(event
));
725 UpdateMacScrollWindow();
729 void wxVarScrollHelperBase::DoPrepareDC(wxDC
& dc
)
731 if ( m_physicalScrolling
)
733 wxPoint pt
= dc
.GetDeviceOrigin();
735 IncOrient(pt
.x
, pt
.y
, -GetScrollOffset());
737 dc
.SetDeviceOrigin(pt
.x
, pt
.y
);
741 int wxVarScrollHelperBase::DoCalcScrolledPosition(int coord
) const
743 return coord
- GetScrollOffset();
746 int wxVarScrollHelperBase::DoCalcUnscrolledPosition(int coord
) const
748 return coord
+ GetScrollOffset();
753 void wxVarScrollHelperBase::HandleOnMouseWheel(wxMouseEvent
& event
)
755 // we only want to process wheel events for vertical implementations.
756 // There is no way to determine wheel orientation (and on MSW horizontal
757 // wheel rotation just fakes scroll events, rather than sending a MOUSEWHEEL
759 if ( GetOrientation() != wxVERTICAL
)
762 m_sumWheelRotation
+= event
.GetWheelRotation();
763 int delta
= event
.GetWheelDelta();
765 // how much to scroll this time
766 int units_to_scroll
= -(m_sumWheelRotation
/delta
);
767 if ( !units_to_scroll
)
770 m_sumWheelRotation
+= units_to_scroll
*delta
;
772 if ( !event
.IsPageScroll() )
773 DoScrollUnits( units_to_scroll
*event
.GetLinesPerAction() );
774 else // scroll pages instead of units
775 DoScrollPages( units_to_scroll
);
778 #endif // wxUSE_MOUSEWHEEL
781 // ============================================================================
782 // wxVarHVScrollHelper implementation
783 // ============================================================================
785 // ----------------------------------------------------------------------------
786 // wxVarHVScrollHelper operations
787 // ----------------------------------------------------------------------------
789 void wxVarHVScrollHelper::SetRowColumnCount(size_t rowCount
, size_t columnCount
)
791 SetRowCount(rowCount
);
792 SetColumnCount(columnCount
);
795 bool wxVarHVScrollHelper::ScrollToRowColumn(size_t row
, size_t column
)
798 result
|= ScrollToRow(row
);
799 result
|= ScrollToColumn(column
);
803 void wxVarHVScrollHelper::RefreshRowColumn(size_t row
, size_t column
)
805 // is this unit visible?
806 if ( !IsRowVisible(row
) || !IsColumnVisible(column
) )
808 // no, it is useless to do anything
812 // calculate the rect occupied by this cell on screen
813 wxRect v_rect
, h_rect
;
814 v_rect
.height
= OnGetRowHeight(row
);
815 h_rect
.width
= OnGetColumnWidth(column
);
819 for ( n
= GetVisibleRowsBegin(); n
< row
; n
++ )
821 v_rect
.y
+= OnGetRowHeight(n
);
824 for ( n
= GetVisibleColumnsBegin(); n
< column
; n
++ )
826 h_rect
.x
+= OnGetColumnWidth(n
);
829 // refresh but specialize the behaviour if we have a single target window
830 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
833 v_rect
.width
= h_rect
.width
;
834 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
839 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
841 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
843 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
844 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
848 void wxVarHVScrollHelper::RefreshRowsColumns(size_t fromRow
, size_t toRow
,
849 size_t fromColumn
, size_t toColumn
)
851 wxASSERT_MSG( fromRow
<= toRow
|| fromColumn
<= toColumn
,
852 wxT("RefreshRowsColumns(): empty range") );
854 // clump the range to just the visible units -- it is useless to refresh
856 if ( fromRow
< GetVisibleRowsBegin() )
857 fromRow
= GetVisibleRowsBegin();
859 if ( toRow
> GetVisibleRowsEnd() )
860 toRow
= GetVisibleRowsEnd();
862 if ( fromColumn
< GetVisibleColumnsBegin() )
863 fromColumn
= GetVisibleColumnsBegin();
865 if ( toColumn
> GetVisibleColumnsEnd() )
866 toColumn
= GetVisibleColumnsEnd();
868 // calculate the rect occupied by these units on screen
869 wxRect v_rect
, h_rect
;
870 size_t nBefore
, nBetween
;
872 for ( nBefore
= GetVisibleRowsBegin();
876 v_rect
.y
+= OnGetRowHeight(nBefore
);
879 for ( nBetween
= fromRow
; nBetween
<= toRow
; nBetween
++ )
881 v_rect
.height
+= OnGetRowHeight(nBetween
);
884 for ( nBefore
= GetVisibleColumnsBegin();
885 nBefore
< fromColumn
;
888 h_rect
.x
+= OnGetColumnWidth(nBefore
);
891 for ( nBetween
= fromColumn
; nBetween
<= toColumn
; nBetween
++ )
893 h_rect
.width
+= OnGetColumnWidth(nBetween
);
896 // refresh but specialize the behaviour if we have a single target window
897 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
900 v_rect
.width
= h_rect
.width
;
901 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
906 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
908 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
910 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
911 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
915 wxPosition
wxVarHVScrollHelper::VirtualHitTest(wxCoord x
, wxCoord y
) const
917 return wxPosition(wxVarVScrollHelper::VirtualHitTest(y
),
918 wxVarHScrollHelper::VirtualHitTest(x
));
921 void wxVarHVScrollHelper::DoPrepareDC(wxDC
& dc
)
923 wxVarVScrollHelper::DoPrepareDC(dc
);
924 wxVarHScrollHelper::DoPrepareDC(dc
);
927 bool wxVarHVScrollHelper::ScrollLayout()
929 bool layout_result
= false;
930 layout_result
|= wxVarVScrollHelper::ScrollLayout();
931 layout_result
|= wxVarHScrollHelper::ScrollLayout();
932 return layout_result
;
935 wxSize
wxVarHVScrollHelper::GetRowColumnCount() const
937 return wxSize(GetColumnCount(), GetRowCount());
940 wxPosition
wxVarHVScrollHelper::GetVisibleBegin() const
942 return wxPosition(GetVisibleRowsBegin(), GetVisibleColumnsBegin());
945 wxPosition
wxVarHVScrollHelper::GetVisibleEnd() const
947 return wxPosition(GetVisibleRowsEnd(), GetVisibleColumnsEnd());
950 bool wxVarHVScrollHelper::IsVisible(size_t row
, size_t column
) const
952 return IsRowVisible(row
) && IsColumnVisible(column
);
956 // ============================================================================
957 // wx[V/H/HV]ScrolledWindow implementations
958 // ============================================================================
960 IMPLEMENT_ABSTRACT_CLASS(wxVScrolledWindow
, wxPanel
)
961 IMPLEMENT_ABSTRACT_CLASS(wxHScrolledWindow
, wxPanel
)
962 IMPLEMENT_ABSTRACT_CLASS(wxHVScrolledWindow
, wxPanel
)
965 #if WXWIN_COMPATIBILITY_2_8
967 // ===========================================================================
968 // wxVarVScrollLegacyAdaptor
969 // ===========================================================================
971 size_t wxVarVScrollLegacyAdaptor::GetFirstVisibleLine() const
972 { return GetVisibleRowsBegin(); }
974 size_t wxVarVScrollLegacyAdaptor::GetLastVisibleLine() const
975 { return GetVisibleRowsEnd() - 1; }
977 size_t wxVarVScrollLegacyAdaptor::GetLineCount() const
978 { return GetRowCount(); }
980 void wxVarVScrollLegacyAdaptor::SetLineCount(size_t count
)
981 { SetRowCount(count
); }
983 void wxVarVScrollLegacyAdaptor::RefreshLine(size_t line
)
984 { RefreshRow(line
); }
986 void wxVarVScrollLegacyAdaptor::RefreshLines(size_t from
, size_t to
)
987 { RefreshRows(from
, to
); }
989 bool wxVarVScrollLegacyAdaptor::ScrollToLine(size_t line
)
990 { return ScrollToRow(line
); }
992 bool wxVarVScrollLegacyAdaptor::ScrollLines(int lines
)
993 { return ScrollRows(lines
); }
995 bool wxVarVScrollLegacyAdaptor::ScrollPages(int pages
)
996 { return ScrollRowPages(pages
); }
998 wxCoord
wxVarVScrollLegacyAdaptor::OnGetLineHeight(size_t WXUNUSED(n
)) const
1000 wxFAIL_MSG( wxT("OnGetLineHeight() must be overridden if OnGetRowHeight() isn't!") );
1004 void wxVarVScrollLegacyAdaptor::OnGetLinesHint(size_t WXUNUSED(lineMin
),
1005 size_t WXUNUSED(lineMax
)) const
1009 wxCoord
wxVarVScrollLegacyAdaptor::OnGetRowHeight(size_t n
) const
1011 return OnGetLineHeight(n
);
1014 void wxVarVScrollLegacyAdaptor::OnGetRowsHeightHint(size_t rowMin
,
1015 size_t rowMax
) const
1017 OnGetLinesHint(rowMin
, rowMax
);
1020 #endif // WXWIN_COMPATIBILITY_2_8