File: vscroll.tex

package info (click to toggle)
wxwidgets2.8 2.8.10.1-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 239,052 kB
  • ctags: 289,550
  • sloc: cpp: 1,838,857; xml: 396,717; python: 282,506; ansic: 126,171; makefile: 51,406; sh: 14,581; asm: 299; sql: 258; lex: 194; perl: 139; yacc: 128; pascal: 95; php: 39; lisp: 38; tcl: 24; haskell: 20; java: 18; cs: 18; erlang: 17; ruby: 16; ada: 9; ml: 9; csh: 9
file content (302 lines) | stat: -rw-r--r-- 11,351 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name:        vscroll.tex
%% Purpose:     wxVScrolledWindow documentation
%% Author:      Vadim Zeitlin
%% Modified by:
%% Created:     30.05.03
%% RCS-ID:      $Id: vscroll.tex 41905 2006-10-10 17:46:49Z JS $
%% Copyright:   (c) 2003 Vadim Zeitlin <vadim@wxwindows.org>
%% License:     wxWindows license
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{\class{wxVScrolledWindow}}\label{wxvscrolledwindow}

In the name of this class, "V" may stand for "variable" because it can be
used for scrolling lines of variable heights; "virtual" because it is not
necessary to know the heights of all lines in advance -- only those which
are shown on the screen need to be measured; or, even, "vertical" because
this class only supports scrolling in one direction currently (this could
and probably will change in the future however).

In any case, this is a generalization of the
\helpref{wxScrolledWindow}{wxscrolledwindow} class which can be only used when
all lines have the same height. It lacks some other wxScrolledWindow features
however, notably there is currently no support for horizontal scrolling; it
can't scroll another window nor only a rectangle of the window and not its
entire client area.

To use this class, you need to derive from it and implement
\helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight} pure virtual
method. You also must call \helpref{SetLineCount}{wxvscrolledwindowsetlinecount}
to let the base class know how many lines it should display but from that
moment on the scrolling is handled entirely by wxVScrolledWindow, you only
need to draw the visible part of contents in your {\tt OnPaint()} method as
usual. You should use \helpref{GetFirstVisibleLine()}{wxvscrolledwindowgetfirstvisibleline}
and \helpref{GetLastVisibleLine()}{wxvscrolledwindowgetlastvisibleline} to
select the lines to display. Note that the device context origin is not shifted
so the first visible line always appears at the point $(0, 0)$ in physical as
well as logical coordinates.

\wxheading{Derived from}

\helpref{wxPanel}{wxpanel}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}

\wxheading{Include files}

<wx/vscroll.h>


\latexignore{\rtfignore{\wxheading{Members}}}


\membersection{wxVScrolledWindow::wxVScrolledWindow}\label{wxvscrolledwindowctor}

\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}}

This is the normal constructor, no need to call Create() after using this one.

Note that {\tt wxVSCROLL} is always automatically added to our style, there is
no need to specify it explicitly.

\func{}{wxVScrolledWindow}{\void}

Default constructor, you must call \helpref{Create()}{wxvscrolledwindowcreate}
later.

\wxheading{Parameters}

\docparam{parent}{The parent window, must not be {\tt NULL}}

\docparam{id}{The identifier of this window, {\tt wxID\_ANY} by default}

\docparam{pos}{The initial window position}

\docparam{size}{The initial window size}

\docparam{style}{The window style. There are no special style bits defined for
this class.}

\docparam{name}{The name for this window; usually not used}


\membersection{wxVScrolledWindow::Create}\label{wxvscrolledwindowcreate}

\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}}

Same as the \helpref{non default ctor}{wxvscrolledwindowctor} but returns
status code: {\tt true} if ok, {\tt false} if the window couldn't have been created.

Just as with the ctor above, {\tt wxVSCROLL} style is always used, there is no
need to specify it explicitly.


\membersection{wxVScrolledWindow::EstimateTotalHeight}\label{wxvscrolledwindowestimatetotalheight}

\constfunc{virtual wxCoord}{EstimateTotalHeight}{\void}

This protected function is used internally by wxVScrolledWindow to estimate the
total height of the window when \helpref{SetLineCount}{wxvscrolledwindowsetlinecount}
is called. The default implementation uses the brute force approach if the
number of the items in the control is small enough. Otherwise, it tries to find
the average line height using some lines in the beginning, middle and the end.

If it is undesirable to access all these lines (some of which might be never
shown) just for the total height calculation, you may override the function and
provide your own guess better and/or faster.

Note that although returning a totally wrong value would still work, it risks
to result in very strange scrollbar behaviour so this function should really
try to make the best guess possible.


\membersection{wxVScrolledWindow::GetFirstVisibleLine}\label{wxvscrolledwindowgetfirstvisibleline}

\constfunc{size\_t}{GetFirstVisibleLine}{\void}

Returns the index of the first currently visible line.

This is same as \helpref{GetVisibleBegin}{wxvscrolledwindowgetvisiblebegin} and
exists only for symmetry with \helpref{GetLastVisibleLine}{wxvscrolledwindowgetlastvisibleline}.


\membersection{wxVScrolledWindow::GetLastVisibleLine}\label{wxvscrolledwindowgetlastvisibleline}

\constfunc{size\_t}{GetLastVisibleLine}{\void}

Returns the index of the last currently visible line. Note that this method
returns \texttt{(size\_t)-1} (i.e. a huge positive number) if the control is
empty so if this is possible you should use \helpref{GetVisibleEnd}{wxvscrolledwindowgetvisibleend}
instead.

\wxheading{See also}

\helpref{GetFirstVisibleLine}{wxvscrolledwindowgetfirstvisibleline}


\membersection{wxVScrolledWindow::GetLineCount}\label{wxvscrolledwindowgetlinecount}

\constfunc{size\_t}{GetLineCount}{\void}

Get the number of lines this window contains (previously set by
\helpref{SetLineCount()}{wxvscrolledwindowsetlinecount})


\membersection{wxVScrolledWindow::GetVisibleBegin}\label{wxvscrolledwindowgetvisiblebegin}

\constfunc{size\_t}{GetVisibleBegin}{\void}

Returns the index of the first currently visible line.

\wxheading{See also}

\helpref{GetVisibleEnd}{wxvscrolledwindowgetvisibleend}


\membersection{wxVScrolledWindow::GetVisibleEnd}\label{wxvscrolledwindowgetvisibleend}

\constfunc{size\_t}{GetVisibleEnd}{\void}

Returns the index of the first line after the currently visible one. If the
return value is $0$ it means that no lines are currently shown (which only
happens if the control is empty). Note that the index returned by this method
is not always a valid index as it may be equal to \helpref{GetLineCount}{wxvscrolledwindowgetlinecount}.

\wxheading{See also}

\helpref{GetVisibleBegin}{wxvscrolledwindowgetvisiblebegin}


\membersection{wxVScrolledWindow::HitTest}\label{wxvscrolledwindowhittest}

\constfunc{int}{HitTest}{\param{wxCoord }{x}, \param{wxCoord }{y}}

\constfunc{int}{HitTest}{\param{const wxPoint\& }{pt}}

Return the item at the specified (in physical coordinates) position or
{\tt wxNOT\_FOUND} if none, i.e. if it is below the last item.


\membersection{wxVScrolledWindow::IsVisible}\label{wxvscrolledwindowisvisible}

\constfunc{bool}{IsVisible}{\param{size\_t }{line}}

Returns {\tt true} if the given line is (at least partially) visible or
{\tt false} otherwise.


\membersection{wxVScrolledWindow::OnGetLineHeight}\label{wxvscrolledwindowongetlineheight}

\constfunc{virtual wxCoord}{OnGetLineHeight}{\param{size\_t }{n}}

This protected virtual function must be overridden in the derived class and it
should return the height of the given line in pixels.

\wxheading{See also}

\helpref{OnGetLinesHint}{wxvscrolledwindowongetlineshint}


\membersection{wxVScrolledWindow::OnGetLinesHint}\label{wxvscrolledwindowongetlineshint}

\constfunc{virtual void}{OnGetLinesHint}{\param{size\_t }{lineMin}, \param{size\_t }{lineMax}}

This function doesn't have to be overridden but it may be useful to do
it if calculating the lines heights is a relatively expensive operation
as it gives the user code a possibility to calculate several of them at
once.

{\tt OnGetLinesHint()} is normally called just before
\helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight} but you
shouldn't rely on the latter being called for all lines in the interval
specified here. It is also possible that OnGetLineHeight() will be
called for the lines outside of this interval, so this is really just a
hint, not a promise.

Finally note that {\it lineMin} is inclusive, while {\it lineMax} is exclusive,
as usual.


\membersection{wxVScrolledWindow::RefreshLine}\label{wxvscrolledwindowrefreshline}

\func{void}{RefreshLine}{\param{size\_t }{line}}

Refreshes the specified line -- it will be redrawn during the next main loop
iteration.

\wxheading{See also}

\helpref{RefreshLines}{wxvscrolledwindowrefreshlines}


\membersection{wxVScrolledWindow::RefreshLines}\label{wxvscrolledwindowrefreshlines}

\func{void}{RefreshLines}{\param{size\_t }{from}, \param{size\_t }{to}}

Refreshes all lines between {\it from} and {\it to}, inclusive. {\it from}
should be less than or equal to {\it to}.

\wxheading{See also}

\helpref{RefreshLine}{wxvscrolledwindowrefreshline}


\membersection{wxVScrolledWindow::RefreshAll}\label{wxvscrolledwindowrefreshall}

\func{void}{RefreshAll}{\void}

This function completely refreshes the control, recalculating the number of
items shown on screen and repainting them. It should be called when the values
returned by \helpref{OnGetLineHeight}{wxvscrolledwindowongetlineheight} change
for some reason and the window must be updated to reflect this.


\membersection{wxVScrolledWindow::ScrollLines}\label{wxvscrolledwindowscrolllines}

\func{bool}{ScrollLines}{\param{int }{lines}}

Scroll by the specified number of lines which may be positive (to scroll down)
or negative (to scroll up).

Returns {\tt true} if the window was scrolled, {\tt false} otherwise (for
example if we're trying to scroll down but we are already showing the last
line).

\wxheading{See also}

\helpref{LineUp}{wxwindowlineup}, \helpref{LineDown}{wxwindowlinedown}


\membersection{wxVScrolledWindow::ScrollPages}\label{wxvscrolledwindowscrollpages}

\func{bool}{ScrollPages}{\param{int }{pages}}

Scroll by the specified number of pages which may be positive (to scroll down)
or negative (to scroll up).

\wxheading{See also}

\helpref{ScrollLines}{wxvscrolledwindowscrolllines},\\
\helpref{PageUp}{wxwindowpageup}, \helpref{PageDown}{wxwindowpagedown}


\membersection{wxVScrolledWindow::ScrollToLine}\label{wxvscrolledwindowscrolltoline}

\func{bool}{ScrollToLine}{\param{size\_t }{line}}

Scroll to the specified line: it will become the first visible line in
the window.

Return {\tt true} if we scrolled the window, {\tt false} if nothing was done.


\membersection{wxVScrolledWindow::SetLineCount}\label{wxvscrolledwindowsetlinecount}

\func{void}{SetLineCount}{\param{size\_t }{count}}

Set the number of lines the window contains: the derived class must
provide the heights for all lines with indices up to the one given here
in its \helpref{OnGetLineHeight()}{wxvscrolledwindowongetlineheight}.