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 // FIXME: This method totally duplicates a method with the same name in
65 // wxScrollHelperEvtHandler, we really should merge them by reusing the
66 // common parts in wxAnyScrollHelperBase.
67 bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent
& event
)
69 wxEventType evType
= event
.GetEventType();
71 // Pass it on to the real handler: notice that we must not call
72 // ProcessEvent() on this object itself as it wouldn't pass it to the next
73 // handler (i.e. the real window) if we're called from a previous handler
74 // (as indicated by "process here only" flag being set) and we do want to
75 // execute the handler defined in the window we're associated with right
76 // now, without waiting until TryAfter() is called from wxEvtHandler.
77 bool processed
= m_nextHandler
->ProcessEvent(event
);
79 // always process the size events ourselves, even if the user code handles
80 // them as well, as we need to AdjustScrollbars()
82 // NB: it is important to do it after processing the event in the normal
83 // way as HandleOnSize() may generate a wxEVT_SIZE itself if the
84 // scrollbar[s] (dis)appear and it should be seen by the user code
86 if ( evType
== wxEVT_SIZE
)
88 m_scrollHelper
->HandleOnSize((wxSizeEvent
&)event
);
92 if ( processed
&& event
.IsCommandEvent())
95 // For wxEVT_PAINT the user code can either handle this event as usual or
96 // override virtual OnDraw(), so if the event hasn't been handled we need
97 // to call this virtual function ourselves.
99 #ifndef __WXUNIVERSAL__
100 // in wxUniversal "processed" will always be true, because
101 // all windows use the paint event to draw themselves.
102 // In this case we can't use this flag to determine if a custom
103 // paint event handler already drew our window and we just
104 // call OnDraw() anyway.
106 #endif // !__WXUNIVERSAL__
107 evType
== wxEVT_PAINT
)
109 m_scrollHelper
->HandleOnPaint((wxPaintEvent
&)event
);
113 // reset the skipped flag (which might have been set to true in
114 // ProcessEvent() above) to be able to test it below
115 bool wasSkipped
= event
.GetSkipped();
119 if ( evType
== wxEVT_SCROLLWIN_TOP
||
120 evType
== wxEVT_SCROLLWIN_BOTTOM
||
121 evType
== wxEVT_SCROLLWIN_LINEUP
||
122 evType
== wxEVT_SCROLLWIN_LINEDOWN
||
123 evType
== wxEVT_SCROLLWIN_PAGEUP
||
124 evType
== wxEVT_SCROLLWIN_PAGEDOWN
||
125 evType
== wxEVT_SCROLLWIN_THUMBTRACK
||
126 evType
== wxEVT_SCROLLWIN_THUMBRELEASE
)
128 m_scrollHelper
->HandleOnScroll((wxScrollWinEvent
&)event
);
129 if ( !event
.GetSkipped() )
131 // it makes sense to indicate that we processed the message as we
132 // did scroll the window (and also notice that wxAutoScrollTimer
133 // relies on our return value to stop scrolling when we are at top
134 // or bottom already)
140 else if ( evType
== wxEVT_MOUSEWHEEL
)
142 m_scrollHelper
->HandleOnMouseWheel((wxMouseEvent
&)event
);
144 #endif // wxUSE_MOUSEWHEEL
146 event
.Skip(wasSkipped
);
148 // We called ProcessEvent() on the next handler, meaning that we explicitly
149 // worked around the request to process the event in this handler only. As
150 // explained above, this is unfortunately really necessary but the trouble
151 // is that the event will continue to be post-processed by the previous
152 // handler resulting in duplicate calls to event handlers. Call the special
153 // function below to prevent this from happening, base class DoTryChain()
154 // will check for it and behave accordingly.
156 // And if we're not called from DoTryChain(), this won't do anything anyhow.
157 event
.DidntHonourProcessOnlyIn();
163 // ============================================================================
164 // wxVarScrollHelperBase implementation
165 // ============================================================================
167 // ----------------------------------------------------------------------------
168 // wxVarScrollHelperBase initialization
169 // ----------------------------------------------------------------------------
171 wxVarScrollHelperBase::wxVarScrollHelperBase(wxWindow
*win
)
172 : wxAnyScrollHelperBase(win
)
175 m_sumWheelRotation
= 0;
182 m_physicalScrolling
= true;
185 // by default, the associated window is also the target window
186 DoSetTargetWindow(win
);
189 wxVarScrollHelperBase::~wxVarScrollHelperBase()
194 // ----------------------------------------------------------------------------
195 // wxVarScrollHelperBase various helpers
196 // ----------------------------------------------------------------------------
199 wxVarScrollHelperBase::AssignOrient(wxCoord
& x
,
204 if ( GetOrientation() == wxVERTICAL
)
217 wxVarScrollHelperBase::IncOrient(wxCoord
& x
, wxCoord
& y
, wxCoord inc
)
219 if ( GetOrientation() == wxVERTICAL
)
225 wxCoord
wxVarScrollHelperBase::DoEstimateTotalSize() const
227 // estimate the total height: it is impossible to call
228 // OnGetUnitSize() for every unit because there may be too many of
229 // them, so we just make a guess using some units in the beginning,
230 // some in the end and some in the middle
231 static const size_t NUM_UNITS_TO_SAMPLE
= 10;
234 if ( m_unitMax
< 3*NUM_UNITS_TO_SAMPLE
)
236 // in this case, full calculations are faster and more correct than
238 sizeTotal
= GetUnitsSize(0, m_unitMax
);
240 else // too many units to calculate exactly
242 // look at some units in the beginning/middle/end
244 GetUnitsSize(0, NUM_UNITS_TO_SAMPLE
) +
245 GetUnitsSize(m_unitMax
- NUM_UNITS_TO_SAMPLE
,
247 GetUnitsSize(m_unitMax
/2 - NUM_UNITS_TO_SAMPLE
/2,
248 m_unitMax
/2 + NUM_UNITS_TO_SAMPLE
/2);
250 // use the height of the units we looked as the average
251 sizeTotal
= (wxCoord
)
252 (((float)sizeTotal
/ (3*NUM_UNITS_TO_SAMPLE
)) * m_unitMax
);
258 wxCoord
wxVarScrollHelperBase::GetUnitsSize(size_t unitMin
, size_t unitMax
) const
260 if ( unitMin
== unitMax
)
262 else if ( unitMin
> unitMax
)
263 return -GetUnitsSize(unitMax
, unitMin
);
264 //else: unitMin < unitMax
266 // let the user code know that we're going to need all these units
267 OnGetUnitsSizeHint(unitMin
, unitMax
);
269 // sum up their sizes
271 for ( size_t unit
= unitMin
; unit
< unitMax
; ++unit
)
273 size
+= OnGetUnitSize(unit
);
279 size_t wxVarScrollHelperBase::FindFirstVisibleFromLast(size_t unitLast
, bool full
) const
281 const wxCoord sWindow
= GetOrientationTargetSize();
283 // go upwards until we arrive at a unit such that unitLast is not visible
284 // any more when it is shown
285 size_t unitFirst
= unitLast
;
289 s
+= OnGetUnitSize(unitFirst
);
293 // for this unit to be fully visible we need to go one unit
294 // down, but if it is enough for it to be only partly visible then
295 // this unit will do as well
313 size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent
& event
) const
315 wxEventType evtType
= event
.GetEventType();
317 if ( evtType
== wxEVT_SCROLLWIN_TOP
)
321 else if ( evtType
== wxEVT_SCROLLWIN_BOTTOM
)
325 else if ( evtType
== wxEVT_SCROLLWIN_LINEUP
)
327 return m_unitFirst
? m_unitFirst
- 1 : 0;
329 else if ( evtType
== wxEVT_SCROLLWIN_LINEDOWN
)
331 return m_unitFirst
+ 1;
333 else if ( evtType
== wxEVT_SCROLLWIN_PAGEUP
)
335 // Page up should do at least as much as line up.
336 return wxMin(FindFirstVisibleFromLast(m_unitFirst
),
337 m_unitFirst
? m_unitFirst
- 1 : 0);
339 else if ( evtType
== wxEVT_SCROLLWIN_PAGEDOWN
)
341 // And page down should do at least as much as line down.
342 if ( GetVisibleEnd() )
343 return wxMax(GetVisibleEnd() - 1, m_unitFirst
+ 1);
345 return wxMax(GetVisibleEnd(), m_unitFirst
+ 1);
347 else if ( evtType
== wxEVT_SCROLLWIN_THUMBRELEASE
)
349 return event
.GetPosition();
351 else if ( evtType
== wxEVT_SCROLLWIN_THUMBTRACK
)
353 return event
.GetPosition();
356 // unknown scroll event?
357 wxFAIL_MSG( wxT("unknown scroll event type?") );
361 void wxVarScrollHelperBase::UpdateScrollbar()
363 // if there is nothing to scroll, remove the scrollbar
370 // see how many units can we fit on screen
371 const wxCoord sWindow
= GetOrientationTargetSize();
373 // do vertical calculations
376 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
381 s
+= OnGetUnitSize(unit
);
384 m_nUnitsVisible
= unit
- m_unitFirst
;
386 int unitsPageSize
= m_nUnitsVisible
;
389 // last unit is only partially visible, we still need the scrollbar and
390 // so we have to "fix" pageSize because if it is equal to m_unitMax
391 // the scrollbar is not shown at all under MSW
395 // set the scrollbar parameters to reflect this
396 m_win
->SetScrollbar(GetOrientation(), m_unitFirst
, unitsPageSize
, m_unitMax
);
399 void wxVarScrollHelperBase::RemoveScrollbar()
402 m_nUnitsVisible
= m_unitMax
;
403 m_win
->SetScrollbar(GetOrientation(), 0, 0, 0);
406 void wxVarScrollHelperBase::DeleteEvtHandler()
408 // search for m_handler in the handler list
409 if ( m_win
&& m_handler
)
411 if ( m_win
->RemoveEventHandler(m_handler
) )
415 //else: something is very wrong, so better [maybe] leak memory than
416 // risk a crash because of double deletion
422 void wxVarScrollHelperBase::DoSetTargetWindow(wxWindow
*target
)
424 m_targetWindow
= target
;
426 target
->MacSetClipChildren( true ) ;
429 // install the event handler which will intercept the events we're
430 // interested in (but only do it for our real window, not the target window
431 // which we scroll - we don't need to hijack its events)
432 if ( m_targetWindow
== m_win
)
434 // if we already have a handler, delete it first
437 m_handler
= new wxVarScrollHelperEvtHandler(this);
438 m_targetWindow
->PushEventHandler(m_handler
);
442 // ----------------------------------------------------------------------------
443 // wxVarScrollHelperBase operations
444 // ----------------------------------------------------------------------------
446 void wxVarScrollHelperBase::SetTargetWindow(wxWindow
*target
)
448 wxCHECK_RET( target
, wxT("target window must not be NULL") );
450 if ( target
== m_targetWindow
)
453 DoSetTargetWindow(target
);
456 void wxVarScrollHelperBase::SetUnitCount(size_t count
)
458 // save the number of units
461 // and our estimate for their total height
462 m_sizeTotal
= EstimateTotalSize();
464 // ScrollToUnit() will update the scrollbar itself if it changes the unit
465 // we pass to it because it's out of [new] range
466 size_t oldScrollPos
= m_unitFirst
;
467 DoScrollToUnit(m_unitFirst
);
468 if ( oldScrollPos
== m_unitFirst
)
470 // but if it didn't do it, we still need to update the scrollbar to
471 // reflect the changed number of units ourselves
476 void wxVarScrollHelperBase::RefreshUnit(size_t unit
)
478 // is this unit visible?
479 if ( !IsVisible(unit
) )
481 // no, it is useless to do anything
485 // calculate the rect occupied by this unit on screen
487 AssignOrient(rect
.width
, rect
.height
,
488 GetNonOrientationTargetSize(), OnGetUnitSize(unit
));
490 for ( size_t n
= GetVisibleBegin(); n
< unit
; ++n
)
492 IncOrient(rect
.x
, rect
.y
, OnGetUnitSize(n
));
496 m_targetWindow
->RefreshRect(rect
);
499 void wxVarScrollHelperBase::RefreshUnits(size_t from
, size_t to
)
501 wxASSERT_MSG( from
<= to
, wxT("RefreshUnits(): empty range") );
503 // clump the range to just the visible units -- it is useless to refresh
505 if ( from
< GetVisibleBegin() )
506 from
= GetVisibleBegin();
508 if ( to
> GetVisibleEnd() )
509 to
= GetVisibleEnd();
511 // calculate the rect occupied by these units on screen
515 int nonorient_size
= GetNonOrientationTargetSize();
517 for ( size_t nBefore
= GetVisibleBegin();
521 orient_pos
+= OnGetUnitSize(nBefore
);
524 for ( size_t nBetween
= from
; nBetween
<= to
; nBetween
++ )
526 orient_size
+= OnGetUnitSize(nBetween
);
530 AssignOrient(rect
.x
, rect
.y
, 0, orient_pos
);
531 AssignOrient(rect
.width
, rect
.height
, nonorient_size
, orient_size
);
534 m_targetWindow
->RefreshRect(rect
);
537 void wxVarScrollHelperBase::RefreshAll()
541 m_targetWindow
->Refresh();
544 bool wxVarScrollHelperBase::ScrollLayout()
546 if ( m_targetWindow
->GetSizer() && m_physicalScrolling
)
548 // adjust the sizer dimensions/position taking into account the
549 // virtual size and scrolled position of the window.
552 AssignOrient(x
, y
, 0, -GetScrollOffset());
555 m_targetWindow
->GetVirtualSize(&w
, &h
);
557 m_targetWindow
->GetSizer()->SetDimension(x
, y
, w
, h
);
561 // fall back to default for LayoutConstraints
562 return m_targetWindow
->wxWindow::Layout();
565 int wxVarScrollHelperBase::VirtualHitTest(wxCoord coord
) const
567 const size_t unitMax
= GetVisibleEnd();
568 for ( size_t unit
= GetVisibleBegin(); unit
< unitMax
; ++unit
)
570 coord
-= OnGetUnitSize(unit
);
578 // ----------------------------------------------------------------------------
579 // wxVarScrollHelperBase scrolling
580 // ----------------------------------------------------------------------------
582 bool wxVarScrollHelperBase::DoScrollToUnit(size_t unit
)
586 // we're empty, code below doesn't make sense in this case
590 // determine the real first unit to scroll to: we shouldn't scroll beyond
592 size_t unitFirstLast
= FindFirstVisibleFromLast(m_unitMax
- 1, true);
593 if ( unit
> unitFirstLast
)
594 unit
= unitFirstLast
;
597 if ( unit
== m_unitFirst
)
604 // remember the currently shown units for the refresh code below
605 size_t unitFirstOld
= GetVisibleBegin(),
606 unitLastOld
= GetVisibleEnd();
611 // the size of scrollbar thumb could have changed
614 // finally refresh the display -- but only redraw as few units as possible
615 // to avoid flicker. We can't do this if we have children because they
617 if ( m_targetWindow
->GetChildren().empty() &&
618 (GetVisibleBegin() >= unitLastOld
|| GetVisibleEnd() <= unitFirstOld
) )
620 // the simplest case: we don't have any old units left, just redraw
622 m_targetWindow
->Refresh();
624 else // scroll the window
626 // Avoid scrolling visible parts of the screen on Mac
628 if (m_physicalScrolling
&& m_targetWindow
->IsShownOnScreen())
630 if ( m_physicalScrolling
)
634 dy
= GetUnitsSize(GetVisibleBegin(), unitFirstOld
);
636 if ( GetOrientation() == wxHORIZONTAL
)
643 m_targetWindow
->ScrollWindow(dx
, dy
);
645 else // !m_physicalScrolling
647 // we still need to invalidate but we can't use ScrollWindow
648 // because physical scrolling is disabled (the user either didn't
649 // want children scrolled and/or doesn't want pixels to be
650 // physically scrolled).
651 m_targetWindow
->Refresh();
658 bool wxVarScrollHelperBase::DoScrollUnits(int units
)
660 units
+= m_unitFirst
;
664 return DoScrollToUnit(units
);
667 bool wxVarScrollHelperBase::DoScrollPages(int pages
)
669 bool didSomething
= false;
676 unit
= GetVisibleEnd();
683 unit
= FindFirstVisibleFromLast(GetVisibleEnd());
687 didSomething
= DoScrollToUnit(unit
);
693 // ----------------------------------------------------------------------------
695 // ----------------------------------------------------------------------------
697 void wxVarScrollHelperBase::HandleOnSize(wxSizeEvent
& event
)
701 // sometimes change in varscrollable window's size can result in
702 // unused empty space after the last item. Fix it by decrementing
703 // first visible item position according to the available space.
705 // determine free space
706 const wxCoord sWindow
= GetOrientationTargetSize();
709 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
714 s
+= OnGetUnitSize(unit
);
716 wxCoord freeSpace
= sWindow
- s
;
718 // decrement first visible item index as long as there is free space
719 size_t idealUnitFirst
;
720 for ( idealUnitFirst
= m_unitFirst
;
724 wxCoord us
= OnGetUnitSize(idealUnitFirst
-1);
725 if ( freeSpace
< us
)
729 m_unitFirst
= idealUnitFirst
;
737 void wxVarScrollHelperBase::HandleOnScroll(wxScrollWinEvent
& event
)
739 if (GetOrientation() != event
.GetOrientation())
745 DoScrollToUnit(GetNewScrollPosition(event
));
748 UpdateMacScrollWindow();
752 void wxVarScrollHelperBase::DoPrepareDC(wxDC
& dc
)
754 if ( m_physicalScrolling
)
756 wxPoint pt
= dc
.GetDeviceOrigin();
758 IncOrient(pt
.x
, pt
.y
, -GetScrollOffset());
760 dc
.SetDeviceOrigin(pt
.x
, pt
.y
);
764 int wxVarScrollHelperBase::DoCalcScrolledPosition(int coord
) const
766 return coord
- GetScrollOffset();
769 int wxVarScrollHelperBase::DoCalcUnscrolledPosition(int coord
) const
771 return coord
+ GetScrollOffset();
776 void wxVarScrollHelperBase::HandleOnMouseWheel(wxMouseEvent
& event
)
778 // we only want to process wheel events for vertical implementations.
779 // There is no way to determine wheel orientation (and on MSW horizontal
780 // wheel rotation just fakes scroll events, rather than sending a MOUSEWHEEL
782 if ( GetOrientation() != wxVERTICAL
)
785 m_sumWheelRotation
+= event
.GetWheelRotation();
786 int delta
= event
.GetWheelDelta();
788 // how much to scroll this time
789 int units_to_scroll
= -(m_sumWheelRotation
/delta
);
790 if ( !units_to_scroll
)
793 m_sumWheelRotation
+= units_to_scroll
*delta
;
795 if ( !event
.IsPageScroll() )
796 DoScrollUnits( units_to_scroll
*event
.GetLinesPerAction() );
797 else // scroll pages instead of units
798 DoScrollPages( units_to_scroll
);
801 #endif // wxUSE_MOUSEWHEEL
804 // ============================================================================
805 // wxVarHVScrollHelper implementation
806 // ============================================================================
808 // ----------------------------------------------------------------------------
809 // wxVarHVScrollHelper operations
810 // ----------------------------------------------------------------------------
812 void wxVarHVScrollHelper::SetRowColumnCount(size_t rowCount
, size_t columnCount
)
814 SetRowCount(rowCount
);
815 SetColumnCount(columnCount
);
818 bool wxVarHVScrollHelper::ScrollToRowColumn(size_t row
, size_t column
)
821 result
|= ScrollToRow(row
);
822 result
|= ScrollToColumn(column
);
826 void wxVarHVScrollHelper::RefreshRowColumn(size_t row
, size_t column
)
828 // is this unit visible?
829 if ( !IsRowVisible(row
) || !IsColumnVisible(column
) )
831 // no, it is useless to do anything
835 // calculate the rect occupied by this cell on screen
836 wxRect v_rect
, h_rect
;
837 v_rect
.height
= OnGetRowHeight(row
);
838 h_rect
.width
= OnGetColumnWidth(column
);
842 for ( n
= GetVisibleRowsBegin(); n
< row
; n
++ )
844 v_rect
.y
+= OnGetRowHeight(n
);
847 for ( n
= GetVisibleColumnsBegin(); n
< column
; n
++ )
849 h_rect
.x
+= OnGetColumnWidth(n
);
852 // refresh but specialize the behaviour if we have a single target window
853 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
856 v_rect
.width
= h_rect
.width
;
857 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
862 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
864 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
866 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
867 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
871 void wxVarHVScrollHelper::RefreshRowsColumns(size_t fromRow
, size_t toRow
,
872 size_t fromColumn
, size_t toColumn
)
874 wxASSERT_MSG( fromRow
<= toRow
|| fromColumn
<= toColumn
,
875 wxT("RefreshRowsColumns(): empty range") );
877 // clump the range to just the visible units -- it is useless to refresh
879 if ( fromRow
< GetVisibleRowsBegin() )
880 fromRow
= GetVisibleRowsBegin();
882 if ( toRow
> GetVisibleRowsEnd() )
883 toRow
= GetVisibleRowsEnd();
885 if ( fromColumn
< GetVisibleColumnsBegin() )
886 fromColumn
= GetVisibleColumnsBegin();
888 if ( toColumn
> GetVisibleColumnsEnd() )
889 toColumn
= GetVisibleColumnsEnd();
891 // calculate the rect occupied by these units on screen
892 wxRect v_rect
, h_rect
;
893 size_t nBefore
, nBetween
;
895 for ( nBefore
= GetVisibleRowsBegin();
899 v_rect
.y
+= OnGetRowHeight(nBefore
);
902 for ( nBetween
= fromRow
; nBetween
<= toRow
; nBetween
++ )
904 v_rect
.height
+= OnGetRowHeight(nBetween
);
907 for ( nBefore
= GetVisibleColumnsBegin();
908 nBefore
< fromColumn
;
911 h_rect
.x
+= OnGetColumnWidth(nBefore
);
914 for ( nBetween
= fromColumn
; nBetween
<= toColumn
; nBetween
++ )
916 h_rect
.width
+= OnGetColumnWidth(nBetween
);
919 // refresh but specialize the behaviour if we have a single target window
920 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
923 v_rect
.width
= h_rect
.width
;
924 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
929 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
931 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
933 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
934 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
938 wxPosition
wxVarHVScrollHelper::VirtualHitTest(wxCoord x
, wxCoord y
) const
940 return wxPosition(wxVarVScrollHelper::VirtualHitTest(y
),
941 wxVarHScrollHelper::VirtualHitTest(x
));
944 void wxVarHVScrollHelper::DoPrepareDC(wxDC
& dc
)
946 wxVarVScrollHelper::DoPrepareDC(dc
);
947 wxVarHScrollHelper::DoPrepareDC(dc
);
950 bool wxVarHVScrollHelper::ScrollLayout()
952 bool layout_result
= false;
953 layout_result
|= wxVarVScrollHelper::ScrollLayout();
954 layout_result
|= wxVarHScrollHelper::ScrollLayout();
955 return layout_result
;
958 wxSize
wxVarHVScrollHelper::GetRowColumnCount() const
960 return wxSize(GetColumnCount(), GetRowCount());
963 wxPosition
wxVarHVScrollHelper::GetVisibleBegin() const
965 return wxPosition(GetVisibleRowsBegin(), GetVisibleColumnsBegin());
968 wxPosition
wxVarHVScrollHelper::GetVisibleEnd() const
970 return wxPosition(GetVisibleRowsEnd(), GetVisibleColumnsEnd());
973 bool wxVarHVScrollHelper::IsVisible(size_t row
, size_t column
) const
975 return IsRowVisible(row
) && IsColumnVisible(column
);
979 // ============================================================================
980 // wx[V/H/HV]ScrolledWindow implementations
981 // ============================================================================
983 IMPLEMENT_ABSTRACT_CLASS(wxVScrolledWindow
, wxPanel
)
984 IMPLEMENT_ABSTRACT_CLASS(wxHScrolledWindow
, wxPanel
)
985 IMPLEMENT_ABSTRACT_CLASS(wxHVScrolledWindow
, wxPanel
)
988 #if WXWIN_COMPATIBILITY_2_8
990 // ===========================================================================
991 // wxVarVScrollLegacyAdaptor
992 // ===========================================================================
994 size_t wxVarVScrollLegacyAdaptor::GetFirstVisibleLine() const
995 { return GetVisibleRowsBegin(); }
997 size_t wxVarVScrollLegacyAdaptor::GetLastVisibleLine() const
998 { return GetVisibleRowsEnd() - 1; }
1000 size_t wxVarVScrollLegacyAdaptor::GetLineCount() const
1001 { return GetRowCount(); }
1003 void wxVarVScrollLegacyAdaptor::SetLineCount(size_t count
)
1004 { SetRowCount(count
); }
1006 void wxVarVScrollLegacyAdaptor::RefreshLine(size_t line
)
1007 { RefreshRow(line
); }
1009 void wxVarVScrollLegacyAdaptor::RefreshLines(size_t from
, size_t to
)
1010 { RefreshRows(from
, to
); }
1012 bool wxVarVScrollLegacyAdaptor::ScrollToLine(size_t line
)
1013 { return ScrollToRow(line
); }
1015 bool wxVarVScrollLegacyAdaptor::ScrollLines(int lines
)
1016 { return ScrollRows(lines
); }
1018 bool wxVarVScrollLegacyAdaptor::ScrollPages(int pages
)
1019 { return ScrollRowPages(pages
); }
1021 wxCoord
wxVarVScrollLegacyAdaptor::OnGetLineHeight(size_t WXUNUSED(n
)) const
1023 wxFAIL_MSG( wxT("OnGetLineHeight() must be overridden if OnGetRowHeight() isn't!") );
1027 void wxVarVScrollLegacyAdaptor::OnGetLinesHint(size_t WXUNUSED(lineMin
),
1028 size_t WXUNUSED(lineMax
)) const
1032 wxCoord
wxVarVScrollLegacyAdaptor::OnGetRowHeight(size_t n
) const
1034 return OnGetLineHeight(n
);
1037 void wxVarVScrollLegacyAdaptor::OnGetRowsHeightHint(size_t rowMin
,
1038 size_t rowMax
) const
1040 OnGetLinesHint(rowMin
, rowMax
);
1043 #endif // WXWIN_COMPATIBILITY_2_8