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 // Use GTK's own scroll wheel handling in GtkScrolledWindow
142 else if ( evType
== wxEVT_MOUSEWHEEL
)
144 m_scrollHelper
->HandleOnMouseWheel((wxMouseEvent
&)event
);
147 #endif // wxUSE_MOUSEWHEEL
148 else if ( evType
== wxEVT_CHAR
&&
149 (m_scrollHelper
->GetOrientation() == wxVERTICAL
) )
151 m_scrollHelper
->HandleOnChar((wxKeyEvent
&)event
);
152 if ( !event
.GetSkipped() )
159 event
.Skip(wasSkipped
);
161 // We called ProcessEvent() on the next handler, meaning that we explicitly
162 // worked around the request to process the event in this handler only. As
163 // explained above, this is unfortunately really necessary but the trouble
164 // is that the event will continue to be post-processed by the previous
165 // handler resulting in duplicate calls to event handlers. Call the special
166 // function below to prevent this from happening, base class DoTryChain()
167 // will check for it and behave accordingly.
169 // And if we're not called from DoTryChain(), this won't do anything anyhow.
170 event
.DidntHonourProcessOnlyIn();
176 // ============================================================================
177 // wxVarScrollHelperBase implementation
178 // ============================================================================
180 // ----------------------------------------------------------------------------
181 // wxVarScrollHelperBase initialization
182 // ----------------------------------------------------------------------------
184 wxVarScrollHelperBase::wxVarScrollHelperBase(wxWindow
*win
)
185 : wxAnyScrollHelperBase(win
)
188 m_sumWheelRotation
= 0;
195 m_physicalScrolling
= true;
198 // by default, the associated window is also the target window
199 DoSetTargetWindow(win
);
202 wxVarScrollHelperBase::~wxVarScrollHelperBase()
207 // ----------------------------------------------------------------------------
208 // wxVarScrollHelperBase various helpers
209 // ----------------------------------------------------------------------------
212 wxVarScrollHelperBase::AssignOrient(wxCoord
& x
,
217 if ( GetOrientation() == wxVERTICAL
)
230 wxVarScrollHelperBase::IncOrient(wxCoord
& x
, wxCoord
& y
, wxCoord inc
)
232 if ( GetOrientation() == wxVERTICAL
)
238 wxCoord
wxVarScrollHelperBase::DoEstimateTotalSize() const
240 // estimate the total height: it is impossible to call
241 // OnGetUnitSize() for every unit because there may be too many of
242 // them, so we just make a guess using some units in the beginning,
243 // some in the end and some in the middle
244 static const size_t NUM_UNITS_TO_SAMPLE
= 10;
247 if ( m_unitMax
< 3*NUM_UNITS_TO_SAMPLE
)
249 // in this case, full calculations are faster and more correct than
251 sizeTotal
= GetUnitsSize(0, m_unitMax
);
253 else // too many units to calculate exactly
255 // look at some units in the beginning/middle/end
257 GetUnitsSize(0, NUM_UNITS_TO_SAMPLE
) +
258 GetUnitsSize(m_unitMax
- NUM_UNITS_TO_SAMPLE
,
260 GetUnitsSize(m_unitMax
/2 - NUM_UNITS_TO_SAMPLE
/2,
261 m_unitMax
/2 + NUM_UNITS_TO_SAMPLE
/2);
263 // use the height of the units we looked as the average
264 sizeTotal
= (wxCoord
)
265 (((float)sizeTotal
/ (3*NUM_UNITS_TO_SAMPLE
)) * m_unitMax
);
271 wxCoord
wxVarScrollHelperBase::GetUnitsSize(size_t unitMin
, size_t unitMax
) const
273 if ( unitMin
== unitMax
)
275 else if ( unitMin
> unitMax
)
276 return -GetUnitsSize(unitMax
, unitMin
);
277 //else: unitMin < unitMax
279 // let the user code know that we're going to need all these units
280 OnGetUnitsSizeHint(unitMin
, unitMax
);
282 // sum up their sizes
284 for ( size_t unit
= unitMin
; unit
< unitMax
; ++unit
)
286 size
+= OnGetUnitSize(unit
);
292 size_t wxVarScrollHelperBase::FindFirstVisibleFromLast(size_t unitLast
, bool full
) const
294 const wxCoord sWindow
= GetOrientationTargetSize();
296 // go upwards until we arrive at a unit such that unitLast is not visible
297 // any more when it is shown
298 size_t unitFirst
= unitLast
;
302 s
+= OnGetUnitSize(unitFirst
);
306 // for this unit to be fully visible we need to go one unit
307 // down, but if it is enough for it to be only partly visible then
308 // this unit will do as well
326 size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent
& event
) const
328 wxEventType evtType
= event
.GetEventType();
330 if ( evtType
== wxEVT_SCROLLWIN_TOP
)
334 else if ( evtType
== wxEVT_SCROLLWIN_BOTTOM
)
338 else if ( evtType
== wxEVT_SCROLLWIN_LINEUP
)
340 return m_unitFirst
? m_unitFirst
- 1 : 0;
342 else if ( evtType
== wxEVT_SCROLLWIN_LINEDOWN
)
344 return m_unitFirst
+ 1;
346 else if ( evtType
== wxEVT_SCROLLWIN_PAGEUP
)
348 // Page up should do at least as much as line up.
349 return wxMin(FindFirstVisibleFromLast(m_unitFirst
),
350 m_unitFirst
? m_unitFirst
- 1 : 0);
352 else if ( evtType
== wxEVT_SCROLLWIN_PAGEDOWN
)
354 // And page down should do at least as much as line down.
355 if ( GetVisibleEnd() )
356 return wxMax(GetVisibleEnd() - 1, m_unitFirst
+ 1);
358 return wxMax(GetVisibleEnd(), m_unitFirst
+ 1);
360 else if ( evtType
== wxEVT_SCROLLWIN_THUMBRELEASE
)
362 return event
.GetPosition();
364 else if ( evtType
== wxEVT_SCROLLWIN_THUMBTRACK
)
366 return event
.GetPosition();
369 // unknown scroll event?
370 wxFAIL_MSG( wxT("unknown scroll event type?") );
374 void wxVarScrollHelperBase::UpdateScrollbar()
376 // if there is nothing to scroll, remove the scrollbar
383 // see how many units can we fit on screen
384 const wxCoord sWindow
= GetOrientationTargetSize();
386 // do vertical calculations
389 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
394 s
+= OnGetUnitSize(unit
);
397 m_nUnitsVisible
= unit
- m_unitFirst
;
399 int unitsPageSize
= m_nUnitsVisible
;
402 // last unit is only partially visible, we still need the scrollbar and
403 // so we have to "fix" pageSize because if it is equal to m_unitMax
404 // the scrollbar is not shown at all under MSW
408 // set the scrollbar parameters to reflect this
409 m_win
->SetScrollbar(GetOrientation(), m_unitFirst
, unitsPageSize
, m_unitMax
);
412 void wxVarScrollHelperBase::RemoveScrollbar()
415 m_nUnitsVisible
= m_unitMax
;
416 m_win
->SetScrollbar(GetOrientation(), 0, 0, 0);
419 void wxVarScrollHelperBase::DeleteEvtHandler()
421 // search for m_handler in the handler list
422 if ( m_win
&& m_handler
)
424 if ( m_win
->RemoveEventHandler(m_handler
) )
428 //else: something is very wrong, so better [maybe] leak memory than
429 // risk a crash because of double deletion
435 void wxVarScrollHelperBase::DoSetTargetWindow(wxWindow
*target
)
437 m_targetWindow
= target
;
439 target
->MacSetClipChildren( true ) ;
442 // install the event handler which will intercept the events we're
443 // interested in (but only do it for our real window, not the target window
444 // which we scroll - we don't need to hijack its events)
445 if ( m_targetWindow
== m_win
)
447 // if we already have a handler, delete it first
450 m_handler
= new wxVarScrollHelperEvtHandler(this);
451 m_targetWindow
->PushEventHandler(m_handler
);
455 // ----------------------------------------------------------------------------
456 // wxVarScrollHelperBase operations
457 // ----------------------------------------------------------------------------
459 void wxVarScrollHelperBase::SetTargetWindow(wxWindow
*target
)
461 wxCHECK_RET( target
, wxT("target window must not be NULL") );
463 if ( target
== m_targetWindow
)
466 DoSetTargetWindow(target
);
469 void wxVarScrollHelperBase::SetUnitCount(size_t count
)
471 // save the number of units
474 // and our estimate for their total height
475 m_sizeTotal
= EstimateTotalSize();
477 // ScrollToUnit() will update the scrollbar itself if it changes the unit
478 // we pass to it because it's out of [new] range
479 size_t oldScrollPos
= m_unitFirst
;
480 DoScrollToUnit(m_unitFirst
);
481 if ( oldScrollPos
== m_unitFirst
)
483 // but if it didn't do it, we still need to update the scrollbar to
484 // reflect the changed number of units ourselves
489 void wxVarScrollHelperBase::RefreshUnit(size_t unit
)
491 // is this unit visible?
492 if ( !IsVisible(unit
) )
494 // no, it is useless to do anything
498 // calculate the rect occupied by this unit on screen
500 AssignOrient(rect
.width
, rect
.height
,
501 GetNonOrientationTargetSize(), OnGetUnitSize(unit
));
503 for ( size_t n
= GetVisibleBegin(); n
< unit
; ++n
)
505 IncOrient(rect
.x
, rect
.y
, OnGetUnitSize(n
));
509 m_targetWindow
->RefreshRect(rect
);
512 void wxVarScrollHelperBase::RefreshUnits(size_t from
, size_t to
)
514 wxASSERT_MSG( from
<= to
, wxT("RefreshUnits(): empty range") );
516 // clump the range to just the visible units -- it is useless to refresh
518 if ( from
< GetVisibleBegin() )
519 from
= GetVisibleBegin();
521 if ( to
> GetVisibleEnd() )
522 to
= GetVisibleEnd();
524 // calculate the rect occupied by these units on screen
528 int nonorient_size
= GetNonOrientationTargetSize();
530 for ( size_t nBefore
= GetVisibleBegin();
534 orient_pos
+= OnGetUnitSize(nBefore
);
537 for ( size_t nBetween
= from
; nBetween
<= to
; nBetween
++ )
539 orient_size
+= OnGetUnitSize(nBetween
);
543 AssignOrient(rect
.x
, rect
.y
, 0, orient_pos
);
544 AssignOrient(rect
.width
, rect
.height
, nonorient_size
, orient_size
);
547 m_targetWindow
->RefreshRect(rect
);
550 void wxVarScrollHelperBase::RefreshAll()
554 m_targetWindow
->Refresh();
557 bool wxVarScrollHelperBase::ScrollLayout()
559 if ( m_targetWindow
->GetSizer() && m_physicalScrolling
)
561 // adjust the sizer dimensions/position taking into account the
562 // virtual size and scrolled position of the window.
565 AssignOrient(x
, y
, 0, -GetScrollOffset());
568 m_targetWindow
->GetVirtualSize(&w
, &h
);
570 m_targetWindow
->GetSizer()->SetDimension(x
, y
, w
, h
);
574 // fall back to default for LayoutConstraints
575 return m_targetWindow
->wxWindow::Layout();
578 int wxVarScrollHelperBase::VirtualHitTest(wxCoord coord
) const
580 const size_t unitMax
= GetVisibleEnd();
581 for ( size_t unit
= GetVisibleBegin(); unit
< unitMax
; ++unit
)
583 coord
-= OnGetUnitSize(unit
);
591 // ----------------------------------------------------------------------------
592 // wxVarScrollHelperBase scrolling
593 // ----------------------------------------------------------------------------
595 bool wxVarScrollHelperBase::DoScrollToUnit(size_t unit
)
599 // we're empty, code below doesn't make sense in this case
603 // determine the real first unit to scroll to: we shouldn't scroll beyond
605 size_t unitFirstLast
= FindFirstVisibleFromLast(m_unitMax
- 1, true);
606 if ( unit
> unitFirstLast
)
607 unit
= unitFirstLast
;
610 if ( unit
== m_unitFirst
)
617 // remember the currently shown units for the refresh code below
618 size_t unitFirstOld
= GetVisibleBegin(),
619 unitLastOld
= GetVisibleEnd();
624 // the size of scrollbar thumb could have changed
627 // finally refresh the display -- but only redraw as few units as possible
628 // to avoid flicker. We can't do this if we have children because they
630 if ( m_targetWindow
->GetChildren().empty() &&
631 (GetVisibleBegin() >= unitLastOld
|| GetVisibleEnd() <= unitFirstOld
) )
633 // the simplest case: we don't have any old units left, just redraw
635 m_targetWindow
->Refresh();
637 else // scroll the window
639 // Avoid scrolling visible parts of the screen on Mac
641 if (m_physicalScrolling
&& m_targetWindow
->IsShownOnScreen())
643 if ( m_physicalScrolling
)
647 dy
= GetUnitsSize(GetVisibleBegin(), unitFirstOld
);
649 if ( GetOrientation() == wxHORIZONTAL
)
656 m_targetWindow
->ScrollWindow(dx
, dy
);
658 else // !m_physicalScrolling
660 // we still need to invalidate but we can't use ScrollWindow
661 // because physical scrolling is disabled (the user either didn't
662 // want children scrolled and/or doesn't want pixels to be
663 // physically scrolled).
664 m_targetWindow
->Refresh();
671 bool wxVarScrollHelperBase::DoScrollUnits(int units
)
673 units
+= m_unitFirst
;
677 return DoScrollToUnit(units
);
680 bool wxVarScrollHelperBase::DoScrollPages(int pages
)
682 bool didSomething
= false;
689 unit
= GetVisibleEnd();
696 unit
= FindFirstVisibleFromLast(GetVisibleEnd());
700 didSomething
= DoScrollToUnit(unit
);
706 // ----------------------------------------------------------------------------
708 // ----------------------------------------------------------------------------
710 void wxVarScrollHelperBase::HandleOnSize(wxSizeEvent
& event
)
714 // sometimes change in varscrollable window's size can result in
715 // unused empty space after the last item. Fix it by decrementing
716 // first visible item position according to the available space.
718 // determine free space
719 const wxCoord sWindow
= GetOrientationTargetSize();
722 for ( unit
= m_unitFirst
; unit
< m_unitMax
; ++unit
)
727 s
+= OnGetUnitSize(unit
);
729 wxCoord freeSpace
= sWindow
- s
;
731 // decrement first visible item index as long as there is free space
732 size_t idealUnitFirst
;
733 for ( idealUnitFirst
= m_unitFirst
;
737 wxCoord us
= OnGetUnitSize(idealUnitFirst
-1);
738 if ( freeSpace
< us
)
742 m_unitFirst
= idealUnitFirst
;
750 void wxVarScrollHelperBase::HandleOnScroll(wxScrollWinEvent
& event
)
752 if (GetOrientation() != event
.GetOrientation())
758 DoScrollToUnit(GetNewScrollPosition(event
));
761 UpdateMacScrollWindow();
765 void wxVarScrollHelperBase::DoPrepareDC(wxDC
& dc
)
767 if ( m_physicalScrolling
)
769 wxPoint pt
= dc
.GetDeviceOrigin();
771 IncOrient(pt
.x
, pt
.y
, -GetScrollOffset());
773 dc
.SetDeviceOrigin(pt
.x
, pt
.y
);
777 int wxVarScrollHelperBase::DoCalcScrolledPosition(int coord
) const
779 return coord
- GetScrollOffset();
782 int wxVarScrollHelperBase::DoCalcUnscrolledPosition(int coord
) const
784 return coord
+ GetScrollOffset();
789 void wxVarScrollHelperBase::HandleOnMouseWheel(wxMouseEvent
& event
)
791 // we only want to process wheel events for vertical implementations.
792 // There is no way to determine wheel orientation (and on MSW horizontal
793 // wheel rotation just fakes scroll events, rather than sending a MOUSEWHEEL
795 if ( GetOrientation() != wxVERTICAL
)
798 m_sumWheelRotation
+= event
.GetWheelRotation();
799 int delta
= event
.GetWheelDelta();
801 // how much to scroll this time
802 int units_to_scroll
= -(m_sumWheelRotation
/delta
);
803 if ( !units_to_scroll
)
806 m_sumWheelRotation
+= units_to_scroll
*delta
;
808 if ( !event
.IsPageScroll() )
809 DoScrollUnits( units_to_scroll
*event
.GetLinesPerAction() );
810 else // scroll pages instead of units
811 DoScrollPages( units_to_scroll
);
814 #endif // wxUSE_MOUSEWHEEL
817 // ============================================================================
818 // wxVarHVScrollHelper implementation
819 // ============================================================================
821 // ----------------------------------------------------------------------------
822 // wxVarHVScrollHelper operations
823 // ----------------------------------------------------------------------------
825 void wxVarHVScrollHelper::SetRowColumnCount(size_t rowCount
, size_t columnCount
)
827 SetRowCount(rowCount
);
828 SetColumnCount(columnCount
);
831 bool wxVarHVScrollHelper::ScrollToRowColumn(size_t row
, size_t column
)
834 result
|= ScrollToRow(row
);
835 result
|= ScrollToColumn(column
);
839 void wxVarHVScrollHelper::RefreshRowColumn(size_t row
, size_t column
)
841 // is this unit visible?
842 if ( !IsRowVisible(row
) || !IsColumnVisible(column
) )
844 // no, it is useless to do anything
848 // calculate the rect occupied by this cell on screen
849 wxRect v_rect
, h_rect
;
850 v_rect
.height
= OnGetRowHeight(row
);
851 h_rect
.width
= OnGetColumnWidth(column
);
855 for ( n
= GetVisibleRowsBegin(); n
< row
; n
++ )
857 v_rect
.y
+= OnGetRowHeight(n
);
860 for ( n
= GetVisibleColumnsBegin(); n
< column
; n
++ )
862 h_rect
.x
+= OnGetColumnWidth(n
);
865 // refresh but specialize the behaviour if we have a single target window
866 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
869 v_rect
.width
= h_rect
.width
;
870 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
875 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
877 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
879 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
880 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
884 void wxVarHVScrollHelper::RefreshRowsColumns(size_t fromRow
, size_t toRow
,
885 size_t fromColumn
, size_t toColumn
)
887 wxASSERT_MSG( fromRow
<= toRow
|| fromColumn
<= toColumn
,
888 wxT("RefreshRowsColumns(): empty range") );
890 // clump the range to just the visible units -- it is useless to refresh
892 if ( fromRow
< GetVisibleRowsBegin() )
893 fromRow
= GetVisibleRowsBegin();
895 if ( toRow
> GetVisibleRowsEnd() )
896 toRow
= GetVisibleRowsEnd();
898 if ( fromColumn
< GetVisibleColumnsBegin() )
899 fromColumn
= GetVisibleColumnsBegin();
901 if ( toColumn
> GetVisibleColumnsEnd() )
902 toColumn
= GetVisibleColumnsEnd();
904 // calculate the rect occupied by these units on screen
905 wxRect v_rect
, h_rect
;
906 size_t nBefore
, nBetween
;
908 for ( nBefore
= GetVisibleRowsBegin();
912 v_rect
.y
+= OnGetRowHeight(nBefore
);
915 for ( nBetween
= fromRow
; nBetween
<= toRow
; nBetween
++ )
917 v_rect
.height
+= OnGetRowHeight(nBetween
);
920 for ( nBefore
= GetVisibleColumnsBegin();
921 nBefore
< fromColumn
;
924 h_rect
.x
+= OnGetColumnWidth(nBefore
);
927 for ( nBetween
= fromColumn
; nBetween
<= toColumn
; nBetween
++ )
929 h_rect
.width
+= OnGetColumnWidth(nBetween
);
932 // refresh but specialize the behaviour if we have a single target window
933 if ( wxVarVScrollHelper::GetTargetWindow() == wxVarHScrollHelper::GetTargetWindow() )
936 v_rect
.width
= h_rect
.width
;
937 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
942 v_rect
.width
= wxVarVScrollHelper::GetNonOrientationTargetSize();
944 h_rect
.width
= wxVarHScrollHelper::GetNonOrientationTargetSize();
946 wxVarVScrollHelper::GetTargetWindow()->RefreshRect(v_rect
);
947 wxVarHScrollHelper::GetTargetWindow()->RefreshRect(h_rect
);
951 wxPosition
wxVarHVScrollHelper::VirtualHitTest(wxCoord x
, wxCoord y
) const
953 return wxPosition(wxVarVScrollHelper::VirtualHitTest(y
),
954 wxVarHScrollHelper::VirtualHitTest(x
));
957 void wxVarHVScrollHelper::DoPrepareDC(wxDC
& dc
)
959 wxVarVScrollHelper::DoPrepareDC(dc
);
960 wxVarHScrollHelper::DoPrepareDC(dc
);
963 bool wxVarHVScrollHelper::ScrollLayout()
965 bool layout_result
= false;
966 layout_result
|= wxVarVScrollHelper::ScrollLayout();
967 layout_result
|= wxVarHScrollHelper::ScrollLayout();
968 return layout_result
;
971 wxSize
wxVarHVScrollHelper::GetRowColumnCount() const
973 return wxSize(GetColumnCount(), GetRowCount());
976 wxPosition
wxVarHVScrollHelper::GetVisibleBegin() const
978 return wxPosition(GetVisibleRowsBegin(), GetVisibleColumnsBegin());
981 wxPosition
wxVarHVScrollHelper::GetVisibleEnd() const
983 return wxPosition(GetVisibleRowsEnd(), GetVisibleColumnsEnd());
986 bool wxVarHVScrollHelper::IsVisible(size_t row
, size_t column
) const
988 return IsRowVisible(row
) && IsColumnVisible(column
);
992 // ============================================================================
993 // wx[V/H/HV]ScrolledWindow implementations
994 // ============================================================================
996 IMPLEMENT_ABSTRACT_CLASS(wxVScrolledWindow
, wxPanel
)
997 IMPLEMENT_ABSTRACT_CLASS(wxHScrolledWindow
, wxPanel
)
998 IMPLEMENT_ABSTRACT_CLASS(wxHVScrolledWindow
, wxPanel
)
1001 #if WXWIN_COMPATIBILITY_2_8
1003 // ===========================================================================
1004 // wxVarVScrollLegacyAdaptor
1005 // ===========================================================================
1007 size_t wxVarVScrollLegacyAdaptor::GetFirstVisibleLine() const
1008 { return GetVisibleRowsBegin(); }
1010 size_t wxVarVScrollLegacyAdaptor::GetLastVisibleLine() const
1011 { return GetVisibleRowsEnd() - 1; }
1013 size_t wxVarVScrollLegacyAdaptor::GetLineCount() const
1014 { return GetRowCount(); }
1016 void wxVarVScrollLegacyAdaptor::SetLineCount(size_t count
)
1017 { SetRowCount(count
); }
1019 void wxVarVScrollLegacyAdaptor::RefreshLine(size_t line
)
1020 { RefreshRow(line
); }
1022 void wxVarVScrollLegacyAdaptor::RefreshLines(size_t from
, size_t to
)
1023 { RefreshRows(from
, to
); }
1025 bool wxVarVScrollLegacyAdaptor::ScrollToLine(size_t line
)
1026 { return ScrollToRow(line
); }
1028 bool wxVarVScrollLegacyAdaptor::ScrollLines(int lines
)
1029 { return ScrollRows(lines
); }
1031 bool wxVarVScrollLegacyAdaptor::ScrollPages(int pages
)
1032 { return ScrollRowPages(pages
); }
1034 wxCoord
wxVarVScrollLegacyAdaptor::OnGetLineHeight(size_t WXUNUSED(n
)) const
1036 wxFAIL_MSG( wxT("OnGetLineHeight() must be overridden if OnGetRowHeight() isn't!") );
1040 void wxVarVScrollLegacyAdaptor::OnGetLinesHint(size_t WXUNUSED(lineMin
),
1041 size_t WXUNUSED(lineMax
)) const
1045 wxCoord
wxVarVScrollLegacyAdaptor::OnGetRowHeight(size_t n
) const
1047 return OnGetLineHeight(n
);
1050 void wxVarVScrollLegacyAdaptor::OnGetRowsHeightHint(size_t rowMin
,
1051 size_t rowMax
) const
1053 OnGetLinesHint(rowMin
, rowMax
);
1056 #endif // WXWIN_COMPATIBILITY_2_8