Views
Gadgets Package API Reference Guide
Product Documentation:
Views Documentation Home
List of all members | Public Member Functions
IlvToggle Class Reference

Gadget class. More...

#include <ilviews/gadgets/toggle.h>

Inheritance diagram for IlvToggle:
IlvGadget IlvSimpleGraphic IlvGraphic IlvStylable IlvValueInterface IlvColoredToggle

Public Member Functions

 IlvToggle (IlvDisplay *display, const char *label, const IlvRect &rect, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvToggle (IlvDisplay *display, const IlvPoint &point, const char *label, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvToggle (IlvDisplay *display, const IlvPoint &point, IlvBitmap *bitmap, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvToggle (IlvDisplay *display, IlvBitmap *bitmap, const IlvRect &rect, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
virtual void activate ()
 Is called by the interactor when the state of the toggle button changes. More...
 
virtual void drawCheckBox (IlvPort *dst, const IlvRect &rect, const IlvRegion *clip=0) const
 Is called to draw the check box of the toggle button. More...
 
virtual void drawText (IlvPort *dst, const IlvRect &rect, const IlvRegion *clip=0) const
 Is called to draw the label and bitmap of the toggle button. More...
 
IlvBitmapgetBitmap () const
 Returns the bitmap displayed by the toggle button. More...
 
IlvDim getCheckSize () const
 Returns the size of the state marker of the toggle button. More...
 
const char * getLabel () const
 Returns the label displayed by the toggle button. More...
 
IlvPosition getPosition () const
 Returns the position of the label or the bitmap relative to the state marker of the toggle button. More...
 
IlBoolean getState () const
 Returns the state of the toggle button (on or off). More...
 
IlvPosition getTextAlignment () const
 Returns the alignment of the label or the bitmap relative to the bounding box of the toggle button. More...
 
IlBoolean isIndeterminateMode () const
 Indicates whether the toggle is in the indeterminate mode. More...
 
IlBoolean isIndeterminateState () const
 Indicates whether the state of the toggle button is indeterminate. More...
 
IlBoolean isRadio () const
 Indicates whether the state marker has the shape of a radio button. More...
 
void setBitmap (IlvBitmap *bitmap)
 Sets the bitmap displayed by the toggle button. More...
 
void setCheckSize (IlvDim size)
 Sets the size of the state marker. More...
 
void setIndeterminateMode (IlBoolean value)
 Sets the mode of the toggle button to indeterminate mode. More...
 
void setIndeterminateState (IlBoolean value)
 Specifies whether the state of the toggle button should be indeterminate. More...
 
void setLabel (const char *label)
 Sets the label displayed by the toggle button. More...
 
void setPosition (IlvPosition position)
 Sets the position of the label or the bitmap relative to the state marker of the toggle button. More...
 
void setRadio (IlBoolean value)
 Specifies whether the state marker should have the shape of a radio button. More...
 
void setState (IlBoolean value)
 Sets the state of the toggle button (on or off). More...
 
void setTextAlignment (IlvPosition alignment)
 Sets the alignment of the label or the bitmap relative to the bounding box of the toggle button. More...
 

Detailed Description

Gadget class.

Library: ilvgadgt

The IlvToggle class defines toggle and radio buttons. Toggle and radio buttons are composed of a label and a marker that shows a state. The state marker can be represented as a rectangle or a diamond.

- IlvToggle objects grouped in an IlvSelector, IlvToggle used as a check box

A toggle button can have three states: on, off, or indeterminate. The toggle button appears grayed when its state is indeterminate.

See also
IlvButton, IlvSelector.

Accessors\nAccessors provide a scriptable and uniform way to inspect and modify an object by using its base class methods <tt>IlvValueInterface::queryValue()</tt>, <tt>IlvValueInterface::queryValues()</tt>, <tt>IlvValueInterface::changeValue()</tt>, <tt>IlvValueInterface::changeValues()</tt>.\n\n\nThis class inherits the accessors of its superclass \c IlvGadget and adds the following ones:

Name Type Equivalent methods
alignment Direction getTextAlignment(), setLabel()
bitmap Bitmap getBitmap(), setBitmap()
checkSize UInt getCheckSize(), setCheckSize()
indeterminate Boolean isIndeterminateState(), setIndeterminateState()
indeterminateMode Boolean isIndeterminateMode(), setIndeterminateMode()
label String getLabel(), setLabel()
position Direction getPosition(), setPosition()
radioType Boolean isRadio(), setRadio()
state Boolean getState(), setState()

Styling\nThis class supports the following CSS properties:

Graphic property CSS property Type
Background color background-color Color
Text color color Color

Constructor & Destructor Documentation

◆ IlvToggle() [1/4]

IlvToggle::IlvToggle ( IlvDisplay display,
const char *  label,
const IlvRect rect,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the class IlvToggle with a label. The label is copied.

Parameters
displayThe connection to the display.
labelThe label of the toggle button.
rectThe size and position of the toggle button.
thicknessThe thickness of the toggle button.
paletteThe palette used by the toggle button.

◆ IlvToggle() [2/4]

IlvToggle::IlvToggle ( IlvDisplay display,
const IlvPoint point,
const char *  label,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the class IlvToggle with a label. The label is copied. The size of the toggle button is automatically computed from label. If you want to specify its size, use the constructor that takes a rectangle as parameter.

Parameters
displayThe connection to the display.
pointThe position of the toggle button.
labelThe label of the toggle button.
thicknessThe thickness of the toggle button.
paletteThe palette used by the toggle button.

◆ IlvToggle() [3/4]

IlvToggle::IlvToggle ( IlvDisplay display,
IlvBitmap bitmap,
const IlvRect rect,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the class IlvToggle with a bitmap. The bitmap is locked.

Parameters
displayThe connection to the display.
bitmapThe bitmap of the toggle button.
rectThe size and position of the toggle button.
thicknessThe thickness of the toggle button.
paletteThe palette used by the toggle button.

◆ IlvToggle() [4/4]

IlvToggle::IlvToggle ( IlvDisplay display,
const IlvPoint point,
IlvBitmap bitmap,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the class IlvToggle with a bitmap. The bitmap is locked. The size of the toggle button is automatically computed from the bitmap size. If you want to specify its size, use the constructor that takes a rectangle as parameter.

Parameters
displayThe connection to the display.
pointThe position of the toggle button.
bitmapThe bitmap of the toggle button.
thicknessThe thickness of the toggle button.
paletteThe palette used by the toggle button.

Member Function Documentation

◆ activate()

virtual void IlvToggle::activate ( )
virtual

Is called by the interactor when the state of the toggle button changes.

The default implementation calls the main callback attached to the toggle button.

See also
IlvGraphic::callCallback().

◆ drawCheckBox()

virtual void IlvToggle::drawCheckBox ( IlvPort dst,
const IlvRect rect,
const IlvRegion clip = 0 
) const
virtual

Is called to draw the check box of the toggle button.

Parameters
dstThe destination port.
rectThe rectangle where to draw the check box.
clipThe clipping region.

◆ drawText()

virtual void IlvToggle::drawText ( IlvPort dst,
const IlvRect rect,
const IlvRegion clip = 0 
) const
virtual

Is called to draw the label and bitmap of the toggle button.

Parameters
dstThe destination port.
rectThe rectangle where to draw the label and bitmap.
clipThe clipping region.

◆ getBitmap()

IlvBitmap* IlvToggle::getBitmap ( ) const

Returns the bitmap displayed by the toggle button.

Returns
The bitmap displayed by the toggle button, or 0 if there is no bitmap.
See also
setBitmap().

◆ getCheckSize()

IlvDim IlvToggle::getCheckSize ( ) const

Returns the size of the state marker of the toggle button.

Returns
The size of the bounding box of the state marker.
See also
setCheckSize().

◆ getLabel()

const char* IlvToggle::getLabel ( ) const

Returns the label displayed by the toggle button.

Returns
The label displayed by the toggle button.
See also
setLabel(), getBitmap().

◆ getPosition()

IlvPosition IlvToggle::getPosition ( ) const

Returns the position of the label or the bitmap relative to the state marker of the toggle button.

Returns
The position of the label or the bitmap, relative to the state marker of the toggle button.
See also
setPosition(), getTextAlignment().

◆ getState()

IlBoolean IlvToggle::getState ( ) const

Returns the state of the toggle button (on or off).

Returns
IlTrue if the toggle button is on and IlFalse otherwise.
See also
setState(), isIndeterminateMode().

◆ getTextAlignment()

IlvPosition IlvToggle::getTextAlignment ( ) const

Returns the alignment of the label or the bitmap relative to the bounding box of the toggle button.

Returns
The alignment of the label or the bitmap relative to the bounding box of the toggle button.
See also
setTextAlignment(), getPosition().

◆ isIndeterminateMode()

IlBoolean IlvToggle::isIndeterminateMode ( ) const

Indicates whether the toggle is in the indeterminate mode.

Returns
IlTrue if the toggle is in the indeterminate mode. Otherwise it returns IlFalse.
See also
setIndeterminateState(), isIndeterminateState().

◆ isIndeterminateState()

IlBoolean IlvToggle::isIndeterminateState ( ) const

Indicates whether the state of the toggle button is indeterminate.

Returns
IlTrue if the state of the toggle button is indeterminate and IlFalse otherwise. Use the method getState() to define its state.

◆ isRadio()

IlBoolean IlvToggle::isRadio ( ) const

Indicates whether the state marker has the shape of a radio button.

Returns
IlTrue if the state marker has the shape of a radio button or IlFalse if it has the shape of a check box.

◆ setBitmap()

void IlvToggle::setBitmap ( IlvBitmap bitmap)

Sets the bitmap displayed by the toggle button.

Parameters
bitmapThe new bitmap. The old bitmap, if any, is unlocked, and the new one is locked.
See also
getBitmap().

◆ setCheckSize()

void IlvToggle::setCheckSize ( IlvDim  size)

Sets the size of the state marker.

Parameters
sizeThe new size of the state marker.
See also
getCheckSize().

◆ setIndeterminateMode()

void IlvToggle::setIndeterminateMode ( IlBoolean  value)

Sets the mode of the toggle button to indeterminate mode.

When a toggle button is in the indeterminate mode, it can have three states: set/not set/indeterminate. The indeterminate mode does not apply to radio buttons (see isRadio().

Parameters
valueSpecifies whether the toggle button should be in the indeterminate mode (IlTrue) or not (IlFalse).
See also
isIndeterminateMode(), setIndeterminateState(), isRadio().

◆ setIndeterminateState()

void IlvToggle::setIndeterminateState ( IlBoolean  value)

Specifies whether the state of the toggle button should be indeterminate.

When isIndeterminateMode() returns IlTrue, the state of the toggle button is set to indeterminate if value is set to IlTrue.

If value is set to IlFalse, you must call setState() to specify its state.

If the toggle button is not in the indeterminate mode, this method does nothing.

Note
A toggle button with a radio look must be used inside an IlvSelector and therefore its state can never be indeterminate.
Parameters
valueSpecifies whether the state of the toggle button should be indeterminate (IlTrue) or not (IlFalse).
See also
isIndeterminateMode(), getState(), isIndeterminateState().

◆ setLabel()

void IlvToggle::setLabel ( const char *  label)

Sets the label displayed by the toggle button.

Parameters
labelThe new label. The old label is deleted and the new one is copied.
See also
getLabel(), setBitmap().

◆ setPosition()

void IlvToggle::setPosition ( IlvPosition  position)

Sets the position of the label or the bitmap relative to the state marker of the toggle button.

Parameters
positionThe new position. Valid values are: IlvRight, IlvLeft, or IlvCenter.
See also
getPosition(), setTextAlignment().

◆ setRadio()

void IlvToggle::setRadio ( IlBoolean  value)

Specifies whether the state marker should have the shape of a radio button.

Parameters
valueSpecifies whether the state marker should have the shape of a radio button (IlTrue) or of a check box (IlFalse).

◆ setState()

void IlvToggle::setState ( IlBoolean  value)

Sets the state of the toggle button (on or off).

The state of the toggle button can also be switched by calling the member function invert() (see IlvGraphic::invert()).

Parameters
valueSpecifies whether the toggle button should be on (IlTrue) or off (IlFalse).
See also
getState(), setIndeterminateMode().

◆ setTextAlignment()

void IlvToggle::setTextAlignment ( IlvPosition  alignment)

Sets the alignment of the label or the bitmap relative to the bounding box of the toggle button.

Parameters
alignmentThe new alignment. Valid values are: IlvRight, IlvLeft, or IlvCenter.
See also
getTextAlignment(), setPosition().