]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/vscroll.tex
changed the catalogs lookup back to the old behaviour of searching LC_MESSAGES subdir...
[wxWidgets.git] / docs / latex / wx / vscroll.tex
CommitLineData
cf7d6329
VZ
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: vscroll.tex
3%% Purpose: wxVScrolledWindow documentation
4%% Author: Vadim Zeitlin
5%% Modified by:
6%% Created: 30.05.03
7%% RCS-ID: $Id$
8%% Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
8795498c 9%% License: wxWindows license
cf7d6329
VZ
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12\section{\class{wxVScrolledWindow}}\label{wxvscrolledwindow}
13
14In the name of this class, "V" may stand for "variable" because it can be
15used for scrolling lines of variable heights; "virtual" because it is not
16necessary to know the heights of all lines in advance -- only those which
17are shown on the screen need to be measured; or, even, "vertical" because
18this class only supports scrolling in one direction currently (this could
19and probably will change in the future however).
20
410bfc93 21In any case, this is a generalization of the
2a70e6eb 22\helpref{wxScrolledWindow}{wxscrolledwindow} class which can be only used when
cf7d6329
VZ
23all lines have the same height. It lacks some other wxScrolledWindow features
24however, notably there is currently no support for horizontal scrolling; it
25can't scroll another window nor only a rectangle of the window and not its
26entire client area.
410bfc93
WS
27
28To use this class, you need to derive from it and implement
cf7d6329 29\helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight} pure virtual
410bfc93 30method. You also must call \helpref{SetLineCount}{wxvscrolledwindowsetlinecount}
cf7d6329
VZ
31to let the base class know how many lines it should display but from that
32moment on the scrolling is handled entirely by wxVScrolledWindow, you only
33need to draw the visible part of contents in your {\tt OnPaint()} method as
410bfc93 34usual. You should use \helpref{GetFirstVisibleLine()}{wxvscrolledwindowgetfirstvisibleline}
cf7d6329 35and \helpref{GetLastVisibleLine()}{wxvscrolledwindowgetlastvisibleline} to
dbd94b75 36select the lines to display. Note that the device context origin is not shifted
cf7d6329
VZ
37so the first visible line always appears at the point $(0, 0)$ in physical as
38well as logical coordinates.
39
40\wxheading{Derived from}
41
410bfc93
WS
42\helpref{wxPanel}{wxpanel}\\
43\helpref{wxWindow}{wxwindow}\\
44\helpref{wxEvtHandler}{wxevthandler}\\
45\helpref{wxObject}{wxobject}
cf7d6329
VZ
46
47\wxheading{Include files}
48
49<wx/vscroll.h>
50
51
52\latexignore{\rtfignore{\wxheading{Members}}}
53
54
55\membersection{wxVScrolledWindow::wxVScrolledWindow}\label{wxvscrolledwindowctor}
56
57\func{}{wxVScrolledWindow}{\param{wxWindow* }{parent}, \param{wxWindowID }{id = wxID\_ANY}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = 0}, \param{const wxString\& }{name = wxPanelNameStr}}
58
59This is the normal constructor, no need to call Create() after using this one.
60
61Note that {\tt wxVSCROLL} is always automatically added to our style, there is
62no need to specify it explicitly.
63
64\func{}{wxVScrolledWindow}{\void}
65
410bfc93 66Default constructor, you must call \helpref{Create()}{wxvscrolledwindowcreate}
cf7d6329
VZ
67later.
68
69\wxheading{Parameters}
70
71\docparam{parent}{The parent window, must not be {\tt NULL}}
72
73\docparam{id}{The identifier of this window, {\tt wxID\_ANY} by default}
74
75\docparam{pos}{The initial window position}
76
77\docparam{size}{The initial window size}
78
79\docparam{style}{The window style. There are no special style bits defined for
80this class.}
81
82\docparam{name}{The name for this window; usually not used}
83
84
85\membersection{wxVScrolledWindow::Create}\label{wxvscrolledwindowcreate}
86
87\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id = wxID\_ANY}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = 0}, \param{const wxString\& }{name = wxPanelNameStr}}
88
89Same as the \helpref{non default ctor}{wxvscrolledwindowctor} but returns
90status code: {\tt true} if ok, {\tt false} if the window couldn't have been created.
91
c9bf76f7 92Just as with the ctor above, {\tt wxVSCROLL} style is always used, there is no
cf7d6329
VZ
93need to specify it explicitly.
94
95
1e0af0bc
VZ
96\membersection{wxVScrolledWindow::EstimateTotalHeight}\label{wxvscrolledwindowestimatetotalheight}
97
98\constfunc{virtual wxCoord}{EstimateTotalHeight}{\void}
99
100This protected function is used internally by wxVScrolledWindow to estimate the
410bfc93 101total height of the window when \helpref{SetLineCount}{wxvscrolledwindowsetlinecount}
1e0af0bc
VZ
102is called. The default implementation uses the brute force approach if the
103number of the items in the control is small enough. Otherwise, it tries to find
104the average line height using some lines in the beginning, middle and the end.
105
106If it is undesirable to access all these lines (some of which might be never
107shown) just for the total height calculation, you may override the function and
108provide your own guess better and/or faster.
109
110Note that although returning a totally wrong value would still work, it risks
111to result in very strange scrollbar behaviour so this function should really
112try to make the best guess possible.
113
114
cf7d6329
VZ
115\membersection{wxVScrolledWindow::GetFirstVisibleLine}\label{wxvscrolledwindowgetfirstvisibleline}
116
117\constfunc{size\_t}{GetFirstVisibleLine}{\void}
118
119Returns the index of the first currently visible line.
120
dd932cbe
VZ
121This is same as \helpref{GetVisibleBegin}{wxvscrolledwindowgetvisiblebegin} and
122exists only for symmetry with \helpref{GetLastVisibleLine}{wxvscrolledwindowgetlastvisibleline}.
123
cf7d6329
VZ
124
125\membersection{wxVScrolledWindow::GetLastVisibleLine}\label{wxvscrolledwindowgetlastvisibleline}
126
127\constfunc{size\_t}{GetLastVisibleLine}{\void}
128
dd932cbe
VZ
129Returns the index of the last currently visible line. Note that this method
130returns \texttt{(size\_t)-1} (i.e. a huge positive number) if the control is
410bfc93 131empty so if this is possible you should use \helpref{GetVisibleEnd}{wxvscrolledwindowgetvisibleend}
dd932cbe
VZ
132instead.
133
134\wxheading{See also}
135
136\helpref{GetFirstVisibleLine}{wxvscrolledwindowgetfirstvisibleline}
cf7d6329
VZ
137
138
139\membersection{wxVScrolledWindow::GetLineCount}\label{wxvscrolledwindowgetlinecount}
140
141\constfunc{size\_t}{GetLineCount}{\void}
142
410bfc93 143Get the number of lines this window contains (previously set by
cf7d6329
VZ
144\helpref{SetLineCount()}{wxvscrolledwindowsetlinecount})
145
146
dd932cbe
VZ
147\membersection{wxVScrolledWindow::GetVisibleBegin}\label{wxvscrolledwindowgetvisiblebegin}
148
149\constfunc{size\_t}{GetVisibleBegin}{\void}
150
151Returns the index of the first currently visible line.
152
153\wxheading{See also}
154
155\helpref{GetVisibleEnd}{wxvscrolledwindowgetvisibleend}
156
157
158\membersection{wxVScrolledWindow::GetVisibleEnd}\label{wxvscrolledwindowgetvisibleend}
159
160\constfunc{size\_t}{GetVisibleEnd}{\void}
161
162Returns the index of the first line after the currently visible one. If the
163return value is $0$ it means that no lines are currently shown (which only
164happens if the control is empty). Note that the index returned by this method
d77836e4 165is not always a valid index as it may be equal to \helpref{GetLineCount}{wxvscrolledwindowgetlinecount}.
dd932cbe
VZ
166
167\wxheading{See also}
168
169\helpref{GetVisibleBegin}{wxvscrolledwindowgetvisiblebegin}
170
171
5d6dcfb3
VZ
172\membersection{wxVScrolledWindow::HitTest}\label{wxvscrolledwindowhittest}
173
174\constfunc{int}{HitTest}{\param{wxCoord }{x}, \param{wxCoord }{y}}
175
176\constfunc{int}{HitTest}{\param{const wxPoint\& }{pt}}
177
178Return the item at the specified (in physical coordinates) position or
179{\tt wxNOT\_FOUND} if none, i.e. if it is below the last item.
180
181
182\membersection{wxVScrolledWindow::IsVisible}\label{wxvscrolledwindowisvisible}
183
184\constfunc{bool}{IsVisible}{\param{size\_t }{line}}
185
410bfc93 186Returns {\tt true} if the given line is (at least partially) visible or
5d6dcfb3
VZ
187{\tt false} otherwise.
188
189
cf7d6329
VZ
190\membersection{wxVScrolledWindow::OnGetLineHeight}\label{wxvscrolledwindowongetlineheight}
191
41e95792 192\constfunc{virtual wxCoord}{OnGetLineHeight}{\param{size\_t }{n}}
cf7d6329
VZ
193
194This protected virtual function must be overridden in the derived class and it
195should return the height of the given line in pixels.
196
197\wxheading{See also}
198
199\helpref{OnGetLinesHint}{wxvscrolledwindowongetlineshint}
200
201
202\membersection{wxVScrolledWindow::OnGetLinesHint}\label{wxvscrolledwindowongetlineshint}
203
41e95792 204\constfunc{virtual void}{OnGetLinesHint}{\param{size\_t }{lineMin}, \param{size\_t }{lineMax}}
cf7d6329
VZ
205
206This function doesn't have to be overridden but it may be useful to do
207it if calculating the lines heights is a relatively expensive operation
208as it gives the user code a possibility to calculate several of them at
209once.
210
410bfc93 211{\tt OnGetLinesHint()} is normally called just before
cf7d6329
VZ
212\helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight} but you
213shouldn't rely on the latter being called for all lines in the interval
214specified here. It is also possible that OnGetLineHeight() will be
215called for the lines outside of this interval, so this is really just a
216hint, not a promise.
217
218Finally note that {\it lineMin} is inclusive, while {\it lineMax} is exclusive,
219as usual.
220
221
5d6dcfb3
VZ
222\membersection{wxVScrolledWindow::RefreshLine}\label{wxvscrolledwindowrefreshline}
223
224\func{void}{RefreshLine}{\param{size\_t }{line}}
225
226Refreshes the specified line -- it will be redrawn during the next main loop
227iteration.
228
229\wxheading{See also}
230
231\helpref{RefreshLines}{wxvscrolledwindowrefreshlines}
232
233
234\membersection{wxVScrolledWindow::RefreshLines}\label{wxvscrolledwindowrefreshlines}
235
236\func{void}{RefreshLines}{\param{size\_t }{from}, \param{size\_t }{to}}
237
238Refreshes all lines between {\it from} and {\it to}, inclusive. {\it from}
239should be less than or equal to {\it to}.
240
241\wxheading{See also}
242
243\helpref{RefreshLine}{wxvscrolledwindowrefreshline}
244
245
5de24291
VZ
246\membersection{wxVScrolledWindow::RefreshAll}\label{wxvscrolledwindowrefreshall}
247
248\func{void}{RefreshAll}{\void}
249
250This function completely refreshes the control, recalculating the number of
dbd94b75 251items shown on screen and repainting them. It should be called when the values
5de24291
VZ
252returned by \helpref{OnGetLineHeight}{wxvscrolledwindowongetlineheight} change
253for some reason and the window must be updated to reflect this.
254
255
cf7d6329
VZ
256\membersection{wxVScrolledWindow::ScrollLines}\label{wxvscrolledwindowscrolllines}
257
258\func{bool}{ScrollLines}{\param{int }{lines}}
259
260Scroll by the specified number of lines which may be positive (to scroll down)
261or negative (to scroll up).
262
263Returns {\tt true} if the window was scrolled, {\tt false} otherwise (for
264example if we're trying to scroll down but we are already showing the last
265line).
266
267\wxheading{See also}
268
269\helpref{LineUp}{wxwindowlineup}, \helpref{LineDown}{wxwindowlinedown}
270
271
272\membersection{wxVScrolledWindow::ScrollPages}\label{wxvscrolledwindowscrollpages}
273
274\func{bool}{ScrollPages}{\param{int }{pages}}
275
276Scroll by the specified number of pages which may be positive (to scroll down)
277or negative (to scroll up).
278
279\wxheading{See also}
280
281\helpref{ScrollLines}{wxvscrolledwindowscrolllines},\\
282\helpref{PageUp}{wxwindowpageup}, \helpref{PageDown}{wxwindowpagedown}
283
284
285\membersection{wxVScrolledWindow::ScrollToLine}\label{wxvscrolledwindowscrolltoline}
286
287\func{bool}{ScrollToLine}{\param{size\_t }{line}}
288
289Scroll to the specified line: it will become the first visible line in
290the window.
291
292Return {\tt true} if we scrolled the window, {\tt false} if nothing was done.
293
294
295\membersection{wxVScrolledWindow::SetLineCount}\label{wxvscrolledwindowsetlinecount}
296
297\func{void}{SetLineCount}{\param{size\_t }{count}}
298
299Set the number of lines the window contains: the derived class must
300provide the heights for all lines with indices up to the one given here
301in its \helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight}.