You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
337 lines
19 KiB
337 lines
19 KiB
<!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="tqdial.html">TQDial</a>, <a href="tqscrollbar.html">TQScrollBar</a>, <a href="tqslider.html">TQSlider</a>, and <a href="tqspinbox.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="tqscrollbar.html">TQScrollBar</a> widget, the
|
|
TQRangeControl can also be used in conjunction with other widgets
|
|
such as <a href="tqslider.html">TQSlider</a> and <a href="tqspinbox.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="tqscrollbar.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="tqdial.html#rangeChange">TQDial</a>, <a href="tqslider.html#rangeChange">TQSlider</a>, and <a href="tqspinbox.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="tqdial.html#valueChange">TQDial</a>, <a href="tqslider.html#valueChange">TQSlider</a>, and <a href="tqspinbox.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="tqscrollbar.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>
|