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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qrangecontrol.cpp:46 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQRangeControl Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQRangeControl Class Reference</h1>
<p>The TQRangeControl class provides an integer value within a range.
<a href="#details">More...</a>
<p><tt>#include <<a href="qrangecontrol-h.html">ntqrangecontrol.h</a>></tt>
<p>Inherited by <a href="ntqdial.html">TQDial</a>, <a href="ntqscrollbar.html">TQScrollBar</a>, <a href="ntqslider.html">TQSlider</a>, and <a href="ntqspinbox.html">TQSpinBox</a>.
<p><a href="qrangecontrol-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQRangeControl"><b>TQRangeControl</b></a> ()</li>
<li class=fn><a href="#TQRangeControl-2"><b>TQRangeControl</b></a> ( int minValue, int maxValue, int lineStep, int pageStep, int value )</li>
<li class=fn>virtual <a href="#~TQRangeControl"><b>~TQRangeControl</b></a> ()</li>
<li class=fn>int <a href="#value"><b>value</b></a> () const</li>
<li class=fn>void <a href="#setValue"><b>setValue</b></a> ( int value )</li>
<li class=fn>void <a href="#addPage"><b>addPage</b></a> ()</li>
<li class=fn>void <a href="#subtractPage"><b>subtractPage</b></a> ()</li>
<li class=fn>void <a href="#addLine"><b>addLine</b></a> ()</li>
<li class=fn>void <a href="#subtractLine"><b>subtractLine</b></a> ()</li>
<li class=fn>int <a href="#minValue"><b>minValue</b></a> () const</li>
<li class=fn>int <a href="#maxValue"><b>maxValue</b></a> () const</li>
<li class=fn>void <a href="#setRange"><b>setRange</b></a> ( int minValue, int maxValue )</li>
<li class=fn>void <a href="#setMinValue"><b>setMinValue</b></a> ( int minVal )</li>
<li class=fn>void <a href="#setMaxValue"><b>setMaxValue</b></a> ( int maxVal )</li>
<li class=fn>int <a href="#lineStep"><b>lineStep</b></a> () const</li>
<li class=fn>int <a href="#pageStep"><b>pageStep</b></a> () const</li>
<li class=fn>void <a href="#setSteps"><b>setSteps</b></a> ( int lineStep, int pageStep )</li>
<li class=fn>int <a href="#bound"><b>bound</b></a> ( int v ) const</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>int <a href="#positionFromValue"><b>positionFromValue</b></a> ( int logical_val, int span ) const</li>
<li class=fn>int <a href="#valueFromPosition"><b>valueFromPosition</b></a> ( int pos, int span ) const</li>
<li class=fn>void <a href="#directSetValue"><b>directSetValue</b></a> ( int value )</li>
<li class=fn>int <a href="#prevValue"><b>prevValue</b></a> () const</li>
<li class=fn>virtual void <a href="#valueChange"><b>valueChange</b></a> ()</li>
<li class=fn>virtual void <a href="#rangeChange"><b>rangeChange</b></a> ()</li>
<li class=fn>virtual void <a href="#stepChange"><b>stepChange</b></a> ()</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQRangeControl class provides an integer value within a range.
<p>
<p> Although originally designed for the <a href="ntqscrollbar.html">TQScrollBar</a> widget, the
TQRangeControl can also be used in conjunction with other widgets
such as <a href="ntqslider.html">TQSlider</a> and <a href="ntqspinbox.html">TQSpinBox</a>. Here are the five main concepts in
the class:
<p> <ol type=1>
<p> <li> <em>Current value</em> The bounded integer that
TQRangeControl maintains. <a href="#value">value</a>() returns it, and several
functions, including <a href="#setValue">setValue</a>(), set it.
<p> <li> <em>Minimum</em> The lowest value that value() can ever
return. Returned by <a href="#minValue">minValue</a>() and set by <a href="#setRange">setRange</a>() or one of the
constructors.
<p> <li> <em>Maximum</em> The highest value that value() can ever
return. Returned by <a href="#maxValue">maxValue</a>() and set by setRange() or one of the
constructors.
<p> <li> <em>Line step</em> The smaller of two natural steps that
TQRangeControl provides and typically corresponds to the user
pressing an arrow key. The line step is returned by <a href="#lineStep">lineStep</a>()
and set using <a href="#setSteps">setSteps</a>(). The functions <a href="#addLine">addLine</a>() and
<a href="#subtractLine">subtractLine</a>() respectively increment and decrement the current
value by lineStep().
<p> <li> <em>Page step</em> The larger of two natural steps that
TQRangeControl provides and typically corresponds to the user
pressing PageUp or PageDown. The page step is returned by
<a href="#pageStep">pageStep</a>() and set using setSteps(). The functions <a href="#addPage">addPage</a>() and
substractPage() respectively increment and decrement the current
value by pageStep().
<p> </ol>
<p> Unity (1) may be viewed as a third step size. <a href="#setValue">setValue</a>() lets you
set the current value to any integer in the allowed range, not
just <a href="#minValue">minValue</a>() + <em>n</em> * lineStep() for integer values of <em>n</em>.
Some widgets may allow the user to set any value at all; others
may just provide multiples of lineStep() or pageStep().
<p> TQRangeControl provides three virtual functions that are well
suited for updating the on-screen representation of range controls
and emitting signals: <a href="#valueChange">valueChange</a>(), <a href="#rangeChange">rangeChange</a>() and
<a href="#stepChange">stepChange</a>().
<p> TQRangeControl also provides a function called <a href="#bound">bound</a>() which lets
you force arbitrary integers to be within the allowed range of the
range control.
<p> We recommend that all widgets that inherit TQRangeControl provide
at least a signal called valueChanged(); many widgets will want to
provide addStep(), <a href="#addPage">addPage</a>(), substractStep() and substractPage()
as slots.
<p> Note that you must use multiple inheritance if you plan to
implement a widget using TQRangeControl because TQRangeControl is
not derived from <a href="tqwidget.html">TQWidget</a>.
<p>See also <a href="misc.html">Miscellaneous Classes</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQRangeControl"></a>TQRangeControl::TQRangeControl ()
</h3>
Constructs a range control with a minimum value of 0, maximum
value of 99, line step of 1, page step of 10 and initial value 0.
<h3 class=fn><a name="TQRangeControl-2"></a>TQRangeControl::TQRangeControl ( int minValue, int maxValue, int lineStep, int pageStep, int value )
</h3>
Constructs a range control whose value can never be smaller than
<em>minValue</em> or greater than <em>maxValue</em>, whose line step size is
<em>lineStep</em> and page step size is <em>pageStep</em> and whose value is
initially <em>value</em> (which is guaranteed to be in range using
<a href="#bound">bound</a>()).
<h3 class=fn><a name="~TQRangeControl"></a>TQRangeControl::~TQRangeControl ()<tt> [virtual]</tt>
</h3>
Destroys the range control
<h3 class=fn>void <a name="addLine"></a>TQRangeControl::addLine ()
</h3>
Equivalent to <tt>setValue( value() + lineStep() )</tt>.
<p> If the value is changed, then <a href="#valueChange">valueChange</a>() is called.
<p> <p>See also <a href="#subtractLine">subtractLine</a>(), <a href="#addPage">addPage</a>(), and <a href="#setValue">setValue</a>().
<h3 class=fn>void <a name="addPage"></a>TQRangeControl::addPage ()
</h3>
Equivalent to <tt>setValue( value() + pageStep() )</tt>.
<p> If the value is changed, then <a href="#valueChange">valueChange</a>() is called.
<p> <p>See also <a href="#subtractPage">subtractPage</a>(), <a href="#addLine">addLine</a>(), and <a href="#setValue">setValue</a>().
<h3 class=fn>int <a name="bound"></a>TQRangeControl::bound ( int v ) const
</h3>
Forces the value <em>v</em> to be within the range from <a href="#minValue">minValue</a>() to
<a href="#maxValue">maxValue</a>() inclusive, and returns the result.
<p> This function is provided so that you can easily force other
numbers than <a href="#value">value</a>() into the allowed range. You do not need to
call it in order to use TQRangeControl itself.
<p> <p>See also <a href="#setValue">setValue</a>(), <a href="#value">value</a>(), <a href="#minValue">minValue</a>(), and <a href="#maxValue">maxValue</a>().
<h3 class=fn>void <a name="directSetValue"></a>TQRangeControl::directSetValue ( int value )<tt> [protected]</tt>
</h3>
Sets the range control <em>value</em> directly without calling
<a href="#valueChange">valueChange</a>().
<p> Forces the new <em>value</em> to be within the legal range.
<p> You will rarely have to call this function. However, if you want
to change the range control's value inside the overloaded method
valueChange(), <a href="#setValue">setValue</a>() would call the function valueChange()
again. To avoid this recursion you must use <a href="#directSetValue">directSetValue</a>()
instead.
<p> <p>See also <a href="#setValue">setValue</a>().
<h3 class=fn>int <a name="lineStep"></a>TQRangeControl::lineStep () const
</h3>
<p> Returns the line step.
<p> <p>See also <a href="#setSteps">setSteps</a>() and <a href="#pageStep">pageStep</a>().
<h3 class=fn>int <a name="maxValue"></a>TQRangeControl::maxValue () const
</h3>
<p> Returns the maximum value of the range.
<p> <p>See also <a href="#setMaxValue">setMaxValue</a>(), <a href="#setRange">setRange</a>(), and <a href="#minValue">minValue</a>().
<h3 class=fn>int <a name="minValue"></a>TQRangeControl::minValue () const
</h3>
<p> Returns the minimum value of the range.
<p> <p>See also <a href="#setMinValue">setMinValue</a>(), <a href="#setRange">setRange</a>(), and <a href="#maxValue">maxValue</a>().
<h3 class=fn>int <a name="pageStep"></a>TQRangeControl::pageStep () const
</h3>
<p> Returns the page step.
<p> <p>See also <a href="#setSteps">setSteps</a>() and <a href="#lineStep">lineStep</a>().
<h3 class=fn>int <a name="positionFromValue"></a>TQRangeControl::positionFromValue ( int logical_val, int span ) const<tt> [protected]</tt>
</h3>
Converts <em>logical_val</em> to a pixel position. <a href="#minValue">minValue</a>() maps to 0,
<a href="#maxValue">maxValue</a>() maps to <em>span</em> and other values are distributed evenly
in-between.
<p> This function can handle the entire integer range without
overflow, providing <em>span</em> is <= 4096.
<p> Calling this method is useful when actually drawing a range
control such as a <a href="ntqscrollbar.html">TQScrollBar</a> on-screen.
<p> <p>See also <a href="#valueFromPosition">valueFromPosition</a>().
<h3 class=fn>int <a name="prevValue"></a>TQRangeControl::prevValue () const<tt> [protected]</tt>
</h3>
<p> Returns the previous value of the range control. "Previous value"
means the value before the last change occurred. Setting a new
range may affect the value, too, because the value is forced to be
inside the specified range. When the range control is initially
created, this is the same as <a href="#value">value</a>().
<p> <a href="#prevValue">prevValue</a>() can be outside the current legal range if a call to
<a href="#setRange">setRange</a>() causes the current value to change. For example, if the
range was [0, 1000] and the current value is 500, setRange(0, 400)
makes value() return 400 and prevValue() return 500.
<p> <p>See also <a href="#value">value</a>() and <a href="#setRange">setRange</a>().
<h3 class=fn>void <a name="rangeChange"></a>TQRangeControl::rangeChange ()<tt> [virtual protected]</tt>
</h3>
This virtual function is called whenever the range control's range
changes. You can reimplement it if you want to be notified when
the range changes. The default implementation does nothing.
<p> Note that this method is called after the range has changed.
<p> <p>See also <a href="#setRange">setRange</a>(), <a href="#valueChange">valueChange</a>(), and <a href="#stepChange">stepChange</a>().
<p>Reimplemented in <a href="ntqdial.html#rangeChange">TQDial</a>, <a href="ntqslider.html#rangeChange">TQSlider</a>, and <a href="ntqspinbox.html#rangeChange">TQSpinBox</a>.
<h3 class=fn>void <a name="setMaxValue"></a>TQRangeControl::setMaxValue ( int maxVal )
</h3>
Sets the minimum value of the range to <em>maxVal</em>.
<p> If necessary, the <a href="#minValue">minValue</a>() is adjusted so that the range remains
valid.
<p> <p>See also <a href="#maxValue">maxValue</a>() and <a href="#setMinValue">setMinValue</a>().
<h3 class=fn>void <a name="setMinValue"></a>TQRangeControl::setMinValue ( int minVal )
</h3>
Sets the minimum value of the range to <em>minVal</em>.
<p> If necessary, the <a href="#maxValue">maxValue</a>() is adjusted so that the range remains
valid.
<p> <p>See also <a href="#minValue">minValue</a>() and <a href="#setMaxValue">setMaxValue</a>().
<h3 class=fn>void <a name="setRange"></a>TQRangeControl::setRange ( int minValue, int maxValue )
</h3>
Sets the range control's minimum value to <em>minValue</em> and its
maximum value to <em>maxValue</em>.
<p> Calls the virtual <a href="#rangeChange">rangeChange</a>() function if one or both of the new
minimum and maximum values are different from the previous
setting. Calls the virtual <a href="#valueChange">valueChange</a>() function if the current
value is adjusted because it was outside the new range.
<p> If <em>maxValue</em> is smaller than <em>minValue</em>, <em>minValue</em> becomes
the only legal value.
<p> <p>See also <a href="#minValue">minValue</a>() and <a href="#maxValue">maxValue</a>().
<p>Examples: <a href="listbox-example.html#x1441">listbox/listbox.cpp</a>, <a href="tutorial1-12.html#x2387">t12/lcdrange.cpp</a>, <a href="tutorial1-05.html#x2315">t5/main.cpp</a>, <a href="tutorial1-06.html#x2325">t6/main.cpp</a>, <a href="tutorial1-08.html#x2334">t8/lcdrange.cpp</a>, and <a href="xform-example.html#x1250">xform/xform.cpp</a>.
<h3 class=fn>void <a name="setSteps"></a>TQRangeControl::setSteps ( int lineStep, int pageStep )
</h3>
Sets the range's line step to <em>lineStep</em> and page step to <em>pageStep</em>.
<p> Calls the virtual <a href="#stepChange">stepChange</a>() function if the new line step
or page step are different from the previous settings.
<p> <p>See also <a href="#lineStep">lineStep</a>(), <a href="#pageStep">pageStep</a>(), and <a href="#setRange">setRange</a>().
<h3 class=fn>void <a name="setValue"></a>TQRangeControl::setValue ( int value )
</h3>
Sets the range control's value to <em>value</em> and forces it to be
within the legal range.
<p> Calls the virtual <a href="#valueChange">valueChange</a>() function if the new value is
different from the previous value. The old value can still be
retrieved using <a href="#prevValue">prevValue</a>().
<p> <p>See also <a href="#value">value</a>().
<h3 class=fn>void <a name="stepChange"></a>TQRangeControl::stepChange ()<tt> [virtual protected]</tt>
</h3>
This virtual function is called whenever the range control's
line or page step settings change. You can reimplement it if you
want to be notified when the step changes. The default
implementation does nothing.
<p> Note that this method is called after a step setting has changed.
<p> <p>See also <a href="#setSteps">setSteps</a>(), <a href="#rangeChange">rangeChange</a>(), and <a href="#valueChange">valueChange</a>().
<h3 class=fn>void <a name="subtractLine"></a>TQRangeControl::subtractLine ()
</h3>
Equivalent to <tt>setValue( value() - lineStep() )</tt>.
<p> If the value is changed, then <a href="#valueChange">valueChange</a>() is called.
<p> <p>See also <a href="#addLine">addLine</a>(), <a href="#subtractPage">subtractPage</a>(), and <a href="#setValue">setValue</a>().
<h3 class=fn>void <a name="subtractPage"></a>TQRangeControl::subtractPage ()
</h3>
Equivalent to <tt>setValue( value() - pageStep() )</tt>.
<p> If the value is changed, then <a href="#valueChange">valueChange</a>() is called.
<p> <p>See also <a href="#addPage">addPage</a>(), <a href="#subtractLine">subtractLine</a>(), and <a href="#setValue">setValue</a>().
<h3 class=fn>int <a name="value"></a>TQRangeControl::value () const
</h3>
<p> Returns the current range control value. This is guaranteed to be
within the range [minValue(), <a href="#maxValue">maxValue</a>()].
<p> <p>See also <a href="#setValue">setValue</a>() and <a href="#prevValue">prevValue</a>().
<h3 class=fn>void <a name="valueChange"></a>TQRangeControl::valueChange ()<tt> [virtual protected]</tt>
</h3>
This virtual function is called whenever the range control value
changes. You can reimplement it if you want to be notified when
the value changes. The default implementation does nothing.
<p> Note that this method is called after the value has changed. The
previous value can be retrieved using <a href="#prevValue">prevValue</a>().
<p> <p>See also <a href="#setValue">setValue</a>(), <a href="#addPage">addPage</a>(), <a href="#subtractPage">subtractPage</a>(), <a href="#addLine">addLine</a>(), <a href="#subtractLine">subtractLine</a>(), <a href="#rangeChange">rangeChange</a>(), and <a href="#stepChange">stepChange</a>().
<p>Reimplemented in <a href="ntqdial.html#valueChange">TQDial</a>, <a href="ntqslider.html#valueChange">TQSlider</a>, and <a href="ntqspinbox.html#valueChange">TQSpinBox</a>.
<h3 class=fn>int <a name="valueFromPosition"></a>TQRangeControl::valueFromPosition ( int pos, int span ) const<tt> [protected]</tt>
</h3>
Converts the pixel position <em>pos</em> to a value. 0 maps to
<a href="#minValue">minValue</a>(), <em>span</em> maps to <a href="#maxValue">maxValue</a>() and other values are
distributed evenly in-between.
<p> This function can handle the entire integer range without
overflow.
<p> Calling this method is useful if you actually implemented a range
control widget such as <a href="ntqscrollbar.html">TQScrollBar</a> and want to handle mouse press
events. This function then maps screen coordinates to the logical
values.
<p> <p>See also <a href="#positionFromValue">positionFromValue</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright © 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>
|