1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% Name: varscrollhelperbase.tex
3 %% Purpose: wxVarScrollHelperBase Documentation
8 %% Copyright: (c) 2007 wxWidgets Team
9 %% License: wxWindows Licence
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxVarScrollHelperBase
}}\label{wxvarscrollhelperbase
}
14 This class provides all common base functionality for scroll calculations
15 shared among all variable scrolled window implementations as well as
16 automatic scrollbar functionality, saved scroll positions, controlling
17 target windows to be scrolled, as well as defining all required virtual
18 functions that need to be implemented for any orientation specific work.
20 Documentation of this class is provided specifically for referencing use
21 of the functions provided by this class for use with the variable scrolled
22 windows that derive from here. You will likely want to derive your window
23 from one of the already implemented variable scrolled windows rather than
24 from wxVarScrollHelperBase directly.
26 \wxheading{Include files
}
32 \helpref{wxCore
}{librarieslist
}
36 \helpref{wxHScrolledWindow
}{wxhscrolledwindow
},
37 \rtfsp\helpref{wxHVScrolledWindow
}{wxhvscrolledwindow
},
38 \rtfsp\helpref{wxVScrolledWindow
}{wxvscrolledwindow
}
40 \latexignore{\rtfignore{\wxheading{Members
}}}
43 \membersection{wxVarScrollHelperBase::wxVarScrollHelperBase
}\label{wxvarscrollhelperbasewxvarscrollhelperbase
}
45 \func{}{wxVarScrollHelperBase
}{\param{wxWindow*
}{winToScroll
}}
47 Constructor taking the target window to be scrolled by this helper class.
48 This will attach scroll event handlers to the target window to catch and
49 handle scroll events appropriately.
52 \membersection{wxVarScrollHelperBase::
\destruct{wxVarScrollHelperBase
}}\label{wxvarscrollhelperbasedtor
}
54 \func{virtual
}{\destruct{wxVarScrollHelperBase
}}{\void}
56 Virtual destructor for detaching scroll event handlers attached with this
60 \membersection{wxVarScrollHelperBase::CalcScrolledPosition
}\label{wxvarscrollhelperbasecalcscrolledposition
}
62 \constfunc{int
}{CalcScrolledPosition
}{\param{int
}{coord
}}
64 Translates the logical coordinate given to the current device coordinate.
65 For example, if the window is scrolled
10 units and each scroll unit
66 represents
10 device units (which may not be the case since this class allows
67 for variable scroll unit sizes), a call to this function with a coordinate of
72 \helpref{CalcUnscrolledPosition()
}{wxvarscrollhelperbasecalcunscrolledposition
}
75 \membersection{wxVarScrollHelperBase::CalcUnscrolledPosition
}\label{wxvarscrollhelperbasecalcunscrolledposition
}
77 \constfunc{int
}{CalcUnscrolledPosition
}{\param{int
}{coord
}}
79 Translates the device coordinate given to the corresponding logical
80 coordinate. For example, if the window is scrolled
10 units and each scroll
81 unit represents
10 device units (which may not be the case since this class
82 allows for variable scroll unit sizes), a call to this function with a
83 coordinate of
15 will return
115.
87 \helpref{CalcScrolledPosition()
}{wxvarscrollhelperbasecalcscrolledposition
}
90 \membersection{wxVarScrollHelperBase::EnablePhysicalScrolling
}\label{wxvarscrollhelperbaseenablephysicalscrolling
}
92 \func{void
}{EnablePhysicalScrolling
}{\param{bool
}{scrolling = true
}}
94 With physical scrolling on (when this is
{\tt true
}), the device origin is
95 changed properly when a
\rtfsp\helpref{wxPaintDC
}{wxpaintdc
} is prepared,
96 children are actually moved and laid out properly, and the contents of the
97 window (pixels) are actually moved. When this is
{\tt false
}, you are
98 responsible for repainting any invalidated areas of the window yourself to
99 account for the new scroll position.
102 \membersection{wxVarScrollHelperBase::EstimateTotalSize
}\label{wxvarscrollhelperbaseestimatetotalsize
}
104 \constfunc{virtual wxCoord
}{EstimateTotalSize
}{\void}
106 When the number of scroll units change, we try to estimate the total size of
107 all units when the full window size is needed (i.e. to calculate the scrollbar
108 thumb size). This is a rather expensive operation in terms of unit access, so
109 if the user code may estimate the average size better or faster than we do, it
110 should override this function to implement its own logic. This function should
111 return the best guess for the total virtual window size.
113 Note that although returning a totally wrong value would still work, it risks
114 resulting in very strange scrollbar behaviour so this function should really
115 try to make the best guess possible.
118 \membersection{wxVarScrollHelperBase::GetNonOrientationTargetSize
}\label{wxvarscrollhelperbasegetnonorientationtargetsize
}
120 \constfunc{virtual int
}{GetNonOrientationTargetSize
}{\void}
122 This function needs to be overridden in the in the derived class to return the
123 window size with respect to the opposing orientation. If this is a vertical
124 scrolled window, it should return the height.
128 \helpref{GetOrientationTargetSize()
}{wxvarscrollhelperbasegetorientationtargetsize
}
131 \membersection{wxVarScrollHelperBase::GetOrientation
}\label{wxvarscrollhelperbasegetorientation
}
133 \constfunc{virtual wxOrientation
}{GetOrientation
}{\void}
135 This function need to be overridden to return the orientation that this helper
136 is working with, either
{\tt wxHORIZONTAL
} or
{\tt wxVERTICAL
}.
139 \membersection{wxVarScrollHelperBase::GetOrientationTargetSize
}\label{wxvarscrollhelperbasegetorientationtargetsize
}
141 \constfunc{virtual int
}{GetOrientationTargetSize
}{\void}
143 This function needs to be overridden in the in the derived class to return the
144 window size with respect to the orientation this helper is working with. If
145 this is a vertical scrolled window, it should return the width.
149 \helpref{GetNonOrientationTargetSize()
}{wxvarscrollhelperbasegetnonorientationtargetsize
}
152 \membersection{wxVarScrollHelperBase::GetTargetWindow
}\label{wxvarscrollhelperbasegettargetwindow
}
154 \constfunc{wxWindow*
}{GetTargetWindow
}{\void}
156 This function will return the target window this helper class is currently
161 \helpref{SetTargetWindow()
}{wxvarscrollhelperbasesettargetwindow
}
164 \membersection{wxVarScrollHelperBase::GetVisibleBegin
}\label{wxvarscrollhelperbasegetvisiblebegin
}
166 \constfunc{size
\_t}{GetVisibleBegin
}{\void}
168 Returns the index of the first visible unit based on the scroll position.
171 \membersection{wxVarScrollHelperBase::GetVisibleEnd
}\label{wxvarscrollhelperbasegetvisibleend
}
173 \constfunc{size
\_t}{GetVisibleEnd
}{\void}
175 Returns the index of the last visible unit based on the scroll position. This
176 includes the last unit even if it is only partially visible.
179 \membersection{wxVarScrollHelperBase::VirtualHitTest
}\label{wxvarscrollhelperbasevirtualhittest
}
181 \constfunc{int
}{VirtualHitTest
}{\param{wxCoord
}{coord
}}
183 Returns the virtual scroll unit under the device unit given accounting for
184 scroll position or
{\tt wxNOT
\_FOUND} if none (i.e. if it is below the last
188 \membersection{wxVarScrollHelperBase::IsVisible
}\label{wxvarscrollhelperbaseisvisible
}
190 \constfunc{bool
}{IsVisible
}{\param{size
\_t }{unit
}}
192 Returns
{\tt true
} if the given scroll unit is currently visible (even if only
193 partially visible) or
{\tt false
} otherwise.
196 \membersection{wxVarScrollHelperBase::OnGetUnitSize
}\label{wxvarscrollhelperbaseongetunitsize
}
198 \constfunc{virtual wxCoord
}{OnGetUnitSize
}{\param{size
\_t }{unit
}}
200 This function must be overridden in the derived class, and should return the
201 size of the given unit in pixels.
204 \membersection{wxVarScrollHelperBase::OnGetUnitsSizeHint
}\label{wxvarscrollhelperbaseongetunitssizehint
}
206 \constfunc{virtual void
}{OnGetUnitsSizeHint
}{\param{size
\_t }{unitMin
},
\param{size
\_t }{unitMax
}}
208 This function doesn't have to be overridden but it may be useful to do so if
209 calculating the units' sizes is a relatively expensive operation as it gives
210 your code a chance to calculate several of them at once and cache the result
213 {\tt OnGetUnitsSizeHint()
} is normally called just before
214 \helpref{OnGetUnitSize()
}{wxvarscrollhelperbaseongetunitsize
} but you
215 shouldn't rely on the latter being called for all units in the interval
216 specified here. It is also possible that OnGetUnitSize() will be called for
217 units outside of this interval, so this is really just a hint, not a promise.
219 Finally, note that unitMin is inclusive, while unitMax is exclusive.
222 \membersection{wxVarScrollHelperBase::RefreshAll
}\label{wxvarscrollhelperbaserefreshall
}
224 \func{virtual void
}{RefreshAll
}{\void}
226 Recalculate all parameters and repaint all units.
229 \membersection{wxVarScrollHelperBase::SetTargetWindow
}\label{wxvarscrollhelperbasesettargetwindow
}
231 \func{void
}{SetTargetWindow
}{\param{wxWindow*
}{target
}}
233 Normally the window will scroll itself, but in some rare occasions you might
234 want it to scroll (part of) another window (e.g. a child of it in order to
235 scroll only a portion the area between the scrollbars like a spreadsheet where
236 only the cell area will move).
240 \helpref{GetTargetWindow()
}{wxvarscrollhelperbasegettargetwindow
}
243 \membersection{wxVarScrollHelperBase::UpdateScrollbar
}\label{wxvarscrollhelperbaseupdatescrollbar
}
245 \func{virtual void
}{UpdateScrollbar
}{\void}
247 Update the thumb size shown by the scrollbar.