Show TOC Welcome to the QLIB 1.0 Online Reference
QLIB 

QCounter


Extends:QControl
Requires:
<script language="JavaScript" src="js/qlib/control.js"></script>
<script language="JavaScript" src="js/qlib/imagelist.js"></script>
<script language="JavaScript" src="js/qlib/counter.js"></script>
Show Demo

Description

Creates an animated digital indicator that can display only positive integers. The control can be set by a negative value, in such case zero is displayed. An imagelist should be provided as a resource, it must include at least eleven elements, the first ten should be images of digits from 0 to 9, the last one is used to fill off segments.

See Also

QImageList, UI Controls

Constructor

QCounter(parent, name, res, sizeopt, effectopt)
Creates an animated digital indicator from the resource provided. If the counter is created as a child control, valid parent object must be specified. If the counter object is assigned to global variable, parent should be null. The name should be the same as the name of variable or property that has been assigned by newly created object.
Parameters
parent - Parent control (if any, null otherwise).
name - The object reference name.
res - Imagelist resource (see QImageList for details).
size - Optional. Defines number of segments. Default value is 4.
effect - Optional. Specifies animation effect used to scroll the counter. Default value is QCounter.FAST.

Properties

PropertyAccessDescription
resRRefers to the resource object used to create the counter.
valueRReturns value that is currently displayed by the indicator. This property is changing during animation.
setvalRReturns the value by which the indicator has been set. Doesn't depend on animation.
sizeRNumber of the digit segments.
effectR / WSets or retrieves animation effect that is used to scroll the indicator.
 
Properties inherited from QControl
nameRName of the control. Serves as a direct reference to this object when evaluated.
idRAlphanumerical unique identifier of the control.
parentRReference to the parent control (if any, null otherwise).
tagR / WCan refer any value or object, tag is always passed to all event handlers as the last parameter.
windowRThis property is a reference to JavaScript window object in which the control exists.
documentRRefers to document object in which the corresponding HTML elements exist. Normally all elements of a DOM2 compatible browser are children of the top document object. If the control creates new document scope (i.e. printing tags like <IFRAME>, <LAYER>), it should assign this document to this property.

Methods

set(value)
Sets new value to be displayed by the indicator. Regardless the value specified, only positive integers are displayed, zero otherwise.
Parameters
value - New value to display.
update()
Updates the component on the screen according to its current state.

Class Constants

ConstantDescription
QCounter.INSTANTSuppresses the indicator scrolling, new value gets displayed instantly.
QCounter.FASTAccording to fast scrolling, the indicator reaches new value in 10 steps regardless the increment (default effect).
QCounter.SLOWDue to slow scrolling, the indicator reaches new value increasing or decreasing current value by 1.

CSS Class Selectors

CSS ClassDescriptionExample (defined in a CSS file)
TABLE.qcounterDefines style properties of a counter's TABLE element.TABLE.qcounter { background-color: green } /* fills background using green color. */
TABLE.qcounter TDDefines style of a segment.TABLE.qcounter TD { padding: 2px } /* sets 2px spacing around each segment. */