File: scrolbar.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 (297 lines) | stat: -rw-r--r-- 9,465 bytes parent folder | download | duplicates (7)
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
\section{\class{wxScrollBar}}\label{wxscrollbar}

A wxScrollBar is a control that represents a horizontal or
vertical scrollbar. It is distinct from the two scrollbars that some windows
provide automatically, but the two types of scrollbar share the way
events are received.

\wxheading{Derived from}

\helpref{wxControl}{wxcontrol}\\
\helpref{wxWindow}{wxwindow}\\
\helpref{wxEvtHandler}{wxevthandler}\\
\helpref{wxObject}{wxobject}

\wxheading{Include files}

<wx/scrolbar.h>

\wxheading{Remarks}

A scrollbar has the following main attributes: {\it range}, {\it thumb size}, {\it page size}, and {\it position}.

The range is the total number of units associated with the view represented by the scrollbar.
For a table with 15 columns, the range would be 15.

The thumb size is the number of units that are currently visible. For the table example, the window
might be sized so that only 5 columns are currently visible, in which case the application would
set the thumb size to 5. When the thumb size becomes the same as or greater than the range,
the scrollbar will be automatically hidden on most platforms.

The page size is the number of units that the scrollbar should scroll by, when `paging' through
the data. This value is normally the same as the thumb size length, because
it is natural to assume that the visible window size defines a page.

The scrollbar position is the current thumb position.

Most applications will find it convenient to provide a function called {\bf AdjustScrollbars} which can
be called initially, from an {\bf OnSize} event handler, and whenever the application data
changes in size. It will adjust the view, object and page size according
to the size of the window and the size of the data.

\wxheading{Window styles}

\twocolwidtha{5cm}
\begin{twocollist}\itemsep=0pt
\twocolitem{\windowstyle{wxSB\_HORIZONTAL}}{Specifies a horizontal scrollbar.}
\twocolitem{\windowstyle{wxSB\_VERTICAL}}{Specifies a vertical scrollbar.}
\end{twocollist}

See also \helpref{window styles overview}{windowstyles}.

\input scrolevt.inc

\wxheading{See also}

\helpref{Scrolling overview}{scrollingoverview},\rtfsp
\helpref{Event handling overview}{eventhandlingoverview},\rtfsp
\helpref{wxScrolledWindow}{wxscrolledwindow}

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


\membersection{wxScrollBar::wxScrollBar}\label{wxscrollbarctor}

\func{}{wxScrollBar}{\void}

Default constructor.

\func{}{wxScrollBar}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id},\rtfsp
\param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
\param{long}{ style = wxSB\_HORIZONTAL}, \param{const wxValidator\& }{validator = wxDefaultValidator},\rtfsp
\param{const wxString\& }{name = ``scrollBar"}}

Constructor, creating and showing a scrollbar.

\wxheading{Parameters}

\docparam{parent}{Parent window. Must be non-NULL.}

\docparam{id}{Window identifier. A value of -1 indicates a default value.}

\docparam{pos}{Window position. If the position (-1, -1) is specified then a default position is chosen.}

\docparam{size}{Window size. If the default size (-1, -1) is specified then a default size is chosen.}

\docparam{style}{Window style. See \helpref{wxScrollBar}{wxscrollbar}.}

\docparam{validator}{Window validator.}

\docparam{name}{Window name.}

\wxheading{See also}

\helpref{wxScrollBar::Create}{wxscrollbarcreate}, \helpref{wxValidator}{wxvalidator}


\membersection{wxScrollBar::\destruct{wxScrollBar}}\label{wxscrollbardtor}

\func{void}{\destruct{wxScrollBar}}{\void}

Destructor, destroying the scrollbar.


\membersection{wxScrollBar::Create}\label{wxscrollbarcreate}

\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id},\rtfsp
\param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
\param{long}{ style = wxSB\_HORIZONTAL}, \param{const wxValidator\& }{validator = wxDefaultValidator},\rtfsp
\param{const wxString\& }{name = ``scrollBar"}}

Scrollbar creation function called by the scrollbar constructor.
See \helpref{wxScrollBar::wxScrollBar}{wxscrollbarctor} for details.


\membersection{wxScrollBar::GetRange}\label{wxscrollbargetrange}

\constfunc{int}{GetRange}{\void}

Returns the length of the scrollbar.

\wxheading{See also}

\helpref{wxScrollBar::SetScrollbar}{wxscrollbarsetscrollbar}


\membersection{wxScrollBar::GetPageSize}\label{wxscrollbargetpagesize}

\constfunc{int}{GetPageSize}{\void}

Returns the page size of the scrollbar. This is the number of scroll units
that will be scrolled when the user pages up or down. Often it is the
same as the thumb size.

\wxheading{See also}

\helpref{wxScrollBar::SetScrollbar}{wxscrollbarsetscrollbar}


\membersection{wxScrollBar::GetThumbPosition}\label{wxscrollbargetthumbposition}

\constfunc{int}{GetThumbPosition}{\void}

Returns the current position of the scrollbar thumb.

\wxheading{See also}

\helpref{wxScrollBar::SetThumbPosition}{wxscrollbarsetthumbposition}


\membersection{wxScrollBar::GetThumbSize}\label{wxscrollbargetthumbsize}

\constfunc{int}{GetThumbSize}{\void}

Returns the thumb or `view' size.

\wxheading{See also}

\helpref{wxScrollBar::SetScrollbar}{wxscrollbarsetscrollbar}

\begin{comment}

\membersection{wxScrollBar::SetObjectLength}\label{wxscrollbarsetobjectlength}

\func{void}{SetObjectLength}{\param{int}{ objectLength}}

Sets the object length for the scrollbar. This is the total object size (virtual size). You must
call \helpref{SetViewLength}{wxscrollbarsetviewlength} {\it before} calling SetObjectLength.

\wxheading{Parameters}

\docparam{objectLength}{The object length of the scrollbar.}

\wxheading{Remarks}

Example: you are implementing scrollbars on a text window, where text lines have a maximum width
of 100 characters. Your text window has a current width of 60 characters. So the view length is 60,
and the object length is 100. The scrollbar will then enable you to scroll to see the other 40 characters.

You will need to call {\bf SetViewLength} and {\bf SetObjectLength} whenever there
is a change in the size of the window (the view size) or the size of the
contents (the object length).

\wxheading{See also}

\helpref{wxScrollBar::GetObjectLength}{wxscrollbargetobjectlength}


\membersection{wxScrollBar::SetPageSize}\label{wxscrollbarsetpagesize}

\func{void}{SetPageSize}{\param{int}{ pageSize}}

Sets the page size for the scrollbar. This is the number of scroll units which are scrolled when the
user pages down (clicks on the scrollbar outside the thumbtrack area).

\wxheading{Parameters}

\docparam{pageSize}{The page size in scroll units.}

\wxheading{Remarks}

At present, this needs to be called {\it before} other set functions.

\wxheading{See also}

\helpref{wxScrollBar::GetPageSize}{wxscrollbargetpagesize}
\end{comment}


\membersection{wxScrollBar::SetThumbPosition}\label{wxscrollbarsetthumbposition}

\func{void}{SetThumbPosition}{\param{int}{ viewStart}}

Sets the position of the scrollbar.

\wxheading{Parameters}

\docparam{viewStart}{The position of the scrollbar thumb.}

\wxheading{See also}

\helpref{wxScrollBar::GetThumbPosition}{wxscrollbargetthumbposition}


\membersection{wxScrollBar::SetScrollbar}\label{wxscrollbarsetscrollbar}

\func{virtual void}{SetScrollbar}{\param{int }{position},\rtfsp
\param{int }{thumbSize}, \param{int }{range},\rtfsp
\param{int }{pageSize},\rtfsp
\param{const bool }{refresh = true}}

Sets the scrollbar properties.

\wxheading{Parameters}

\docparam{position}{The position of the scrollbar in scroll units.}

\docparam{thumbSize}{The size of the thumb, or visible portion of the scrollbar, in scroll units.}

\docparam{range}{The maximum position of the scrollbar.}

\docparam{pageSize}{The size of the page size in scroll units. This is the number of units
the scrollbar will scroll when it is paged up or down. Often it is the same as
the thumb size.}

\docparam{refresh}{true to redraw the scrollbar, false otherwise.}

\wxheading{Remarks}

Let's say you wish to display 50 lines of text, using the same font.
The window is sized so that you can only see 16 lines at a time.

You would use:

{\small%
\begin{verbatim}
  scrollbar->SetScrollbar(0, 16, 50, 15);
\end{verbatim}
}

The page size is 1 less than the thumb size so that the last line of the previous
page will be visible on the next page, to help orient the user.

Note that with the window at this size, the thumb position can never go
above 50 minus 16, or 34.

You can determine how many lines are currently visible by dividing the current view
size by the character height in pixels.

When defining your own scrollbar behaviour, you will always need to recalculate
the scrollbar settings when the window size changes. You could therefore put your
scrollbar calculations and SetScrollbar
call into a function named AdjustScrollbars, which can be called initially and also
from a \helpref{wxSizeEvent}{wxsizeevent} event handler function.

\wxheading{See also}

\helpref{Scrolling overview}{scrollingoverview},\rtfsp
\helpref{wxWindow::SetScrollbar}{wxwindowsetscrollbar}, \helpref{wxScrolledWindow}{wxscrolledwindow}


\begin{comment}

\membersection{wxScrollBar::SetViewLength}\label{wxscrollbarsetviewlength}

\func{void}{SetViewLength}{\param{int}{ viewLength}}

Sets the view length for the scrollbar.

\wxheading{Parameters}

\docparam{viewLength}{View length.}

\wxheading{See also}

\helpref{wxScrollBar::GetViewLength}{wxscrollbargetviewlength}
\end{comment}