Rogue Wave Views
Gadgets Package API Reference Guide
Product Documentation:

Rogue Wave Views
Documentation Home
List of all members | Public Types | Public Member Functions
IlvNumberField Class Reference

Gadget class. More...

#include <ilviews/gadgets/numfield.h>

Inheritance diagram for IlvNumberField:
IlvTextField IlvGadget IlvSimpleGraphic IlvStylable IlvGraphic IlvValueInterface

Public Types

enum  IlvNumberFieldFormat {
  thousands, scientific, padright, showpoint,
  floatmode
}
 This enumeration defines the possible values for the mode of an IlvNumberField object. More...
 

Public Member Functions

 IlvNumberField (IlvDisplay *display, IlInt value, const IlvRect &rect, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvNumberField (IlvDisplay *display, IlDouble value, const IlvRect &rect, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvNumberField (IlvDisplay *display, const IlvPoint &point, IlInt value, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvNumberField (IlvDisplay *display, const IlvPoint &point, IlDouble value, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
virtual const char * check (IlUShort ch)
 Is called by the interactor for each key down event that corresponds to a regular character. More...
 
char getDecimalPointChar () const
 Returns the character used as the decimal separator. More...
 
IlBoolean getFloatMode () const
 Indicates if the floatmode is set. More...
 
IlDouble getFloatValue (IlBoolean &error) const
 Converts the number field value to a double value and returns this value. More...
 
IlUInt getFormat () const
 Returns the format of the number field. More...
 
IlInt getIntValue (IlBoolean &error) const
 Converts the number field value to an integer and returns this value. More...
 
IlDouble getMaxFloat () const
 Returns the maximum double value set for the number field. More...
 
IlInt getMaxInt () const
 Returns the maximum integer value defined for the number field. More...
 
IlDouble getMinFloat () const
 Returns the minimum double value set for the number field. More...
 
IlInt getMinInt () const
 Returns the minimum integer value set for the number field. More...
 
IlBoolean getPadRightMode () const
 Indicates if the padright mode is set. More...
 
IlUShort getPrecision () const
 Returns the precision defined for the number field when the float mode is set. More...
 
IlBoolean getScientificMode () const
 Indicates if the scientific mode is set. More...
 
IlBoolean getShowPointMode () const
 Indicates if the showpoint mode is set. More...
 
IlBoolean getShowThousandMode () const
 Indicates if the thousands mode is set. More...
 
char getThousandSeparator () const
 Returns the character used as the thousand separator. More...
 
void setDecimalPointChar (char separator)
 Sets the character used as the decimal separator. More...
 
void setFloatMode (IlBoolean val)
 Sets the floatmode on or off. More...
 
void setFormat (IlUInt format)
 Sets the format of the number field. More...
 
void setMaxFloat (IlDouble value)
 Sets the maximum double value of the number field. More...
 
void setMaxInt (IlInt value)
 Sets the maximum integer value of the number field. More...
 
void setMinFloat (IlDouble value)
 Sets the minimum double value of the number field. More...
 
void setMinInt (IlInt value)
 Sets the minimum integer value of the number field. More...
 
void setPadRightMode (IlBoolean val)
 Sets the padright mode on or off. More...
 
void setPrecision (IlUShort precision)
 Sets the precision defined for the number field when the float mode is set. More...
 
void setScientificMode (IlBoolean val)
 Sets the scientific mode on or off. More...
 
void setShowPointMode (IlBoolean val)
 Sets the showpoint mode on or off. More...
 
void setShowThousandMode (IlBoolean val)
 Sets the thousands mode on or off. More...
 
void setThousandSeparator (char separator)
 Sets the character used as the thousand separator. More...
 
IlBoolean setValue (IlInt value, IlBoolean redraw=IlFalse)
 Sets the value of the number field to the specified integer. More...
 
IlBoolean setValue (IlDouble value, IlBoolean redraw=IlFalse)
 Sets the value of the number field to a double value. More...
 
virtual void validate ()
 Is called by the interactor when the user presses the Return or the Enter key. More...
 
- Public Member Functions inherited from IlvTextField
 IlvTextField (IlvDisplay *display, const char *label, const IlvRect &rect, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
 IlvTextField (IlvDisplay *display, const IlvPoint &point, const char *label, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0)
 Constructor. More...
 
void addChangeCallback (IlvGraphicCallback callback)
 Adds a Label Changed callback. More...
 
void addChangeCallback (IlSymbol *callbackName)
 Adds a named Label Changed callback. More...
 
void addChangeCallback (IlvGraphicCallback callback, IlAny arg)
 Adds a Label Changed callback. More...
 
void addChangeCallback (IlSymbol *callbackName, IlAny arg)
 Adds a named Label Changed callback. More...
 
void ensureVisible (IlShort position, const IlvTransformer *t=0)
 Ensures that the character located at the specified position is visible. More...
 
IlvPosition getAlignment () const
 Returns the alignment of the text field. More...
 
IlvGraphicCallback getChangeCallback () const
 Returns a pointer to the first unnamed callback in the Label Changed callback list. More...
 
IlSymbolgetChangeCallbackName () const
 Returns the name of the first named callback in the Label Changed callback list. More...
 
IlBoolean getChangeFocusOnValidation () const
 Indicates whether the text field moves the keyboard focus to the next gadget once validated. More...
 
IlShort getCursorPosition () const
 Returns the cursor position. More...
 
IlShort getEndSelection () const
 Returns the index of the last selected character. More...
 
IlFloat getFloatValue () const
 Converts the text field contents to a floating point value and returns the result of the conversion. More...
 
IlInt getIntValue () const
 Converts the text field contents to an integer and returns the result of the conversion. More...
 
const char * getLabel () const
 Returns the label displayed by the text field. More...
 
IlShort getMaxChar () const
 Returns the maximum number of characters that the user can type in the text field. More...
 
virtual const char * getMessage () const
 Returns the message displayed by this text field. More...
 
IlShort getStartSelection () const
 Returns the index of the first selected character. More...
 
IlShort getTextPosition () const
 Returns the index of the first visible character of the text field. More...
 
virtual IlBoolean handleControl (IlUShort character)
 Is called by the interactor to handle control keys. More...
 
IlBoolean isCursorShown () const
 Indicates whether the cursor is visible. More...
 
IlBoolean isEditable () const
 Indicates whether the text field can be edited. More...
 
virtual void labelChanged ()
 Is called by the interactor whenever the label of the text field changes. More...
 
IlShort pointToPosition (const IlvPoint &point, const IlvTransformer *t=0) const
 Returns the index of the character located at the specified point. More...
 
virtual void removeSelection ()
 Removes the selected label from the text field. More...
 
void setAlignment (IlvPosition alignment)
 Sets the alignment of the text field. More...
 
void setChangeCallback (IlvGraphicCallback callback)
 Sets a Label Changed callback. More...
 
void setChangeCallback (IlSymbol *callbackName)
 Sets a named Label Changed callback. More...
 
void setChangeCallback (IlvGraphicCallback callback, IlAny arg)
 Sets a Label Changed callback. More...
 
void setChangeCallback (IlSymbol *callbackName, IlAny arg)
 Sets a named Label Changed callback. More...
 
void setChangeFocusOnValidation (IlBoolean value)
 Specifies whether the text field should move the keyboard focus to the next gadget once validated. More...
 
void setCursorPosition (IlShort position)
 Sets the cursor position. More...
 
void setEditable (IlBoolean value)
 Specifies whether the text field can be edited. More...
 
void setEndSelection (IlShort position)
 Sets the index of the last selected character. More...
 
virtual void setLabel (const char *label, IlBoolean redraw=IlFalse)
 Sets the label of the text field. More...
 
void setMaxChar (IlShort count)
 Sets the maximum number of characters that the user can type in the text field. More...
 
void setSelection (IlShort start, IlShort end)
 Selects a portion of the text field content. More...
 
void setStartSelection (IlShort position)
 Sets the index of the first selected character. More...
 
void setTextPosition (IlShort position)
 Sets the index of the first visible character of the text field. More...
 
void setValue (IlInt value, IlBoolean redraw=IlFalse)
 Sets the text field label to an integer value. More...
 
void setValue (IlFloat value, const char *format=0, IlBoolean redraw=IlFalse)
 Sets the text field label to a floating-point value. More...
 
void showCursor (IlBoolean value, IlBoolean redraw=IlFalse)
 Specifies whether the cursor should be visible. More...
 

Detailed Description

Gadget class.

Library: ilvgadgt

The IlvNumberField class is a subclass of IlvTextField defining a specialized text field that accommodates numeric values with various formats. It lets you specify the minimum and maximum values allowed in the number field. The validate callback is invoked only if the field contains a numeric value and this number is between the specified limits.

See also
IlvPasswordTextField, IlvDateField.

Accessors

Accessors provide a scriptable and uniform way to inspect and modify an object by using its base class methods IlvValueInterface::queryValue(), IlvValueInterface::queryValues(), IlvValueInterface::changeValue(), IlvValueInterface::changeValues(). This class inherits the accessors of its superclass IlvTextField and adds the following ones:

Name Type Equivalent methods
floatMode Boolean getFloatMode(), setFloatMode()
scientificMode Boolean getScientificMode(), setScientificMode()
padright Boolean getPadRightMode(), setPadRightMode()
showPoint Boolean getShowPointMode(), setShowPointMode()
showThousand Boolean getShowThousandMode(), setShowThousandMode()
thousandSeparator String getThousandSeparator(), setThousandSeparator()
decimalPoint String getDecimalPointChar(), setDecimalPointChar()
precision UInt getPrecision(), setPrecision()
intValue Int getIntValue(), setValue(IlInt, IlBoolean)
minInt Int getMinInt(), setMinInt()
maxInt Int getMaxInt(), setMaxInt()
floatValue Double getFloatValue(), setValue(IlDouble, IlBoolean)
minFloat Double getMinFloat(), setMinFloat()
maxFloat Double getMaxFloat(), setMaxFloat()

Styling

This class supports the following CSS properties:

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

Member Enumeration Documentation

§ IlvNumberFieldFormat

This enumeration defines the possible values for the mode of an IlvNumberField object.

See also
IlvNumberField::setFormat().
Enumerator
thousands 

Displays thousand separators.

scientific 

Displays double values with an exponent notation. This mode only works when the floatmode is set.

padright 

Adds trailing zeros after the decimal point. This mode only works when the floatmode is set.

showpoint 

Always shows the decimal separator. This mode only works when the floatmode is set.

floatmode 

Displays the field as a decimal value.

Constructor & Destructor Documentation

§ IlvNumberField() [1/4]

IlvNumberField::IlvNumberField ( IlvDisplay display,
IlInt  value,
const IlvRect rect,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the IlvNumberField class that accommodates an integer value.

Parameters
displayThe connection to the display.
valueThe integer value.
rectThe size and position of the number field.
thicknessThe thickness of the number field.
paletteThe palette used to draw the number field.

§ IlvNumberField() [2/4]

IlvNumberField::IlvNumberField ( IlvDisplay display,
IlDouble  value,
const IlvRect rect,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the IlvNumberField class that accommodates a double value.

Parameters
displayThe connection to the display.
valueThe double value.
rectThe size and position of the number field.
thicknessThe thickness of the number field.
paletteThe palette used to draw the number field.

§ IlvNumberField() [3/4]

IlvNumberField::IlvNumberField ( IlvDisplay display,
const IlvPoint point,
IlInt  value,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the IlvNumberField class that accommodates an integer value. The size of the number field is computed with the value parameter. If you want to give the number field a specific size, use a constructor that takes an IlvRect reference instead of an IlvPoint object as parameter.

Parameters
displayThe connection to the display.
pointThe position of the number field.
valueThe integer value.
thicknessThe thickness of the number field.
paletteThe palette used to draw the number field.

§ IlvNumberField() [4/4]

IlvNumberField::IlvNumberField ( IlvDisplay display,
const IlvPoint point,
IlDouble  value,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the IlvNumberfield class that accommodates a double value. The size of the number field is computed with the value parameter. If you want the number field to have a specific size, use a constructor that takes an IlvRect reference instead of an IlvPoint object as parameter.

Parameters
displayThe connection to the display.
pointThe position of the number field.
valueThe double value.
thicknessThe thickness of the number field.
paletteThe palette used to draw the number field.

Member Function Documentation

§ check()

virtual const char* IlvNumberField::check ( IlUShort  character)
virtual

Is called by the interactor for each key down event that corresponds to a regular character.

The default implementation inserts character in the text field (erasing the selection if there is one).

Parameters
characterThe ASCII code of the character.
Returns
The new label of the text field.
See also
setLabel().

Reimplemented from IlvTextField.

§ getDecimalPointChar()

char IlvNumberField::getDecimalPointChar ( ) const

Returns the character used as the decimal separator.

Returns
The character used as the decimal separator.
See also
setDecimalPointChar().

§ getFloatMode()

IlBoolean IlvNumberField::getFloatMode ( ) const

Indicates if the floatmode is set.

Returns
IlTrue if the floatmode is set, and IlFalse otherwise.

§ getFloatValue()

IlDouble IlvNumberField::getFloatValue ( IlBoolean error) const

Converts the number field value to a double value and returns this value.

Parameters
errorSpecifies whether an error occurred when trying to convert the number field value to a double value: error is set to IlTrue if the float mode is not set, if the value is outside the specified limits (see IlvNumberField::setMinFloat(), IlvNumberField::setMaxFloat()), or if the value in the number field is not a number.
Returns
The value of the number field converted to a double value. The return value is undefined if error is IlTrue.
See also
IlvNumberFieldFormat, setValue(IlDouble, IlBoolean), setMinFloat(), setMaxFloat(), setFormat().

§ getFormat()

IlUInt IlvNumberField::getFormat ( ) const

Returns the format of the number field.

The format is a bitwise OR combination of IlvNumberFieldFormat values.

Returns
The format of the number field.
See also
IlvNumberFieldFormat, setFormat().

§ getIntValue()

IlInt IlvNumberField::getIntValue ( IlBoolean error) const

Converts the number field value to an integer and returns this value.

Parameters
errorSpecifies whether an error occurred when trying to convert the number field value to an integer: error is set to IlTrue if the float mode is set, if the value is outside the specified limits (see IlvNumberField::setMinInt(), IlvNumberField::setMaxInt()), or if the value in the number field is not a number.
Returns
The number field value converted to an integer value. The return value is undefined if error is IlTrue.
See also
IlvNumberFieldFormat, setValue(IlInt, IlBoolean), setMinInt(), setMaxInt().

§ getMaxFloat()

IlDouble IlvNumberField::getMaxFloat ( ) const

Returns the maximum double value set for the number field.

Note that the minimum and maximum values are tested when IlvNumberField::getFloatValue() and IlvNumberField::setValue(IlDouble, IlBoolean) are called.

Returns
The maximum double value set for the number field.
See also
getMinFloat(), setMaxFloat().

§ getMaxInt()

IlInt IlvNumberField::getMaxInt ( ) const

Returns the maximum integer value defined for the number field.

Note that the minimum and maximum values are tested when IlvNumberField::getIntValue() and IlvNumberField::setValue(IlInt, IlBoolean) are called.

Returns
The maximum integer value of the number field.
See also
getMinInt(), setMaxInt().

§ getMinFloat()

IlDouble IlvNumberField::getMinFloat ( ) const

Returns the minimum double value set for the number field.

Note that the minimum and maximum values are tested when IlvNumberField::getFloatValue() and IlvNumberField::setValue(IlDouble, IlBoolean) are called.

Returns
The minimum double value set for the number field.
See also
getMaxFloat(), setMinFloat().

§ getMinInt()

IlInt IlvNumberField::getMinInt ( ) const

Returns the minimum integer value set for the number field.

Note that the minimum and maximum values are tested when IlvNumberField::getIntValue() and IlvNumberField::setValue(IlInt, IlBoolean) are called.

Returns
The minimum integer value set for the number field.
See also
getMaxInt(), setMinInt().

§ getPadRightMode()

IlBoolean IlvNumberField::getPadRightMode ( ) const

Indicates if the padright mode is set.

Returns
IlTrue if both floatmode and padright mode are set, and IlFalse otherwise.

§ getPrecision()

IlUShort IlvNumberField::getPrecision ( ) const

Returns the precision defined for the number field when the float mode is set.

The precision is the number of digits after the decimal point. The default value is 6. A precision of 0 is supported only when the scientific mode is not set.

Returns
The precision of the number field when the float mode is set.
See also
IlvNumberFieldFormat, setPrecision.

§ getScientificMode()

IlBoolean IlvNumberField::getScientificMode ( ) const

Indicates if the scientific mode is set.

Returns
IlTrue if both floatmode and scientific mode are set, and IlFalse otherwise.

§ getShowPointMode()

IlBoolean IlvNumberField::getShowPointMode ( ) const

Indicates if the showpoint mode is set.

Returns
IlTrue if both floatmode and showpoint mode are set, and IlFalse otherwise.

§ getShowThousandMode()

IlBoolean IlvNumberField::getShowThousandMode ( ) const

Indicates if the thousands mode is set.

Returns
IlTrue if the thousands mode is set, and IlFalse otherwise.

§ getThousandSeparator()

char IlvNumberField::getThousandSeparator ( ) const

Returns the character used as the thousand separator.

Returns
The character used as the thousand separator.
See also
setThousandSeparator().

§ setDecimalPointChar()

void IlvNumberField::setDecimalPointChar ( char  separator)

Sets the character used as the decimal separator.

Parameters
separatorThe decimal separator to be used.
See also
IlvNumberFieldFormat, getDecimalPointChar().

§ setFloatMode()

void IlvNumberField::setFloatMode ( IlBoolean  val)

Sets the floatmode on or off.

The method does nothing if floatmode is already in the requested state. Otherwise, the method sets floatmode and calls setValue(IlInt) or setValue(IlDouble), which recomputes the numerical value according to the new setting.

Parameters
valIlTrue to set to set floatmode on, IlFalse to set it off.

§ setFormat()

void IlvNumberField::setFormat ( IlUInt  format)

Sets the format of the number field.

The format is a bitwise OR combination of IlvNumberFieldFormat values.

Parameters
formatThe new format.
See also
IlvNumberFieldFormat, getFormat().

§ setMaxFloat()

void IlvNumberField::setMaxFloat ( IlDouble  value)

Sets the maximum double value of the number field.

Note that the minimum and maximum values are tested when IlvNumberField::getFloatValue() and IlvNumberField::setValue(IlDouble, IlBoolean) are called.

Parameters
valueThe maximum double value.
See also
getMaxFloat(), getMinFloat().

§ setMaxInt()

void IlvNumberField::setMaxInt ( IlInt  value)

Sets the maximum integer value of the number field.

Note that the minimum and maximum values are tested when IlvNumberField::getIntValue() and IlvNumberField::setValue(IlInt, IlBoolean) are called.

Parameters
valueThe maximum integer value.
See also
getMaxInt(), getMinInt().

§ setMinFloat()

void IlvNumberField::setMinFloat ( IlDouble  value)

Sets the minimum double value of the number field.

Note that the minimum and maximum values are tested when IlvNumberField::getFloatValue() and IlvNumberField::setValue(IlDouble, IlBoolean) are called.

Parameters
valueThe minimum double value.
See also
getMinFloat(), getMaxFloat().

§ setMinInt()

void IlvNumberField::setMinInt ( IlInt  value)

Sets the minimum integer value of the number field.

Note that the minimum and maximum values are tested when IlvNumberField::getIntValue() and IlvNumberField::setValue(IlInt, IlBoolean) are called.

Parameters
valueThe minimum integer value.
See also
getMinInt(), getMaxInt().

§ setPadRightMode()

void IlvNumberField::setPadRightMode ( IlBoolean  val)

Sets the padright mode on or off.

The method does nothing if floatmode is off or if padright mode is already in the requested state. Otherwise, the method sets padright mode and calls setValue(IlInt) or setValue(IlDouble), which recomputes the numerical value according to the new setting.

Parameters
valIlTrue to set to set padright mode on, IlFalse to set it off.

§ setPrecision()

void IlvNumberField::setPrecision ( IlUShort  precision)

Sets the precision defined for the number field when the float mode is set.

Parameters
precisionThe precision to be used.
See also
IlvNumberFieldFormat, getPrecision().

§ setScientificMode()

void IlvNumberField::setScientificMode ( IlBoolean  val)

Sets the scientific mode on or off.

The method does nothing if floatmode is off or if scientific mode is already in the requested state. Otherwise, the method sets scientific mode and calls setValue(IlInt) or setValue(IlDouble), which recomputes the numerical value according to the new setting.

Parameters
valIlTrue to set to set scientific mode on, IlFalse to set it off.

§ setShowPointMode()

void IlvNumberField::setShowPointMode ( IlBoolean  val)

Sets the showpoint mode on or off.

The method does nothing if floatmode is off or if showpoint mode is already in the requested state. Otherwise, the method sets showpoint mode and calls setValue(IlInt) or setValue(IlDouble), which recomputes the numerical value according to the new setting.

Parameters
valIlTrue to set to set showpoint mode on, IlFalse to set it off.

§ setShowThousandMode()

void IlvNumberField::setShowThousandMode ( IlBoolean  val)

Sets the thousands mode on or off.

The method does nothing if thousands mode is already in the requested state. Otherwise, the method sets thousands mode and calls setValue(IlInt) or setValue(IlDouble), which recomputes the numerical value according to the new setting.

Parameters
valIlTrue to set to set thousands mode on, IlFalse to set it off.

§ setThousandSeparator()

void IlvNumberField::setThousandSeparator ( char  separator)

Sets the character used as the thousand separator.

Parameters
separatorThe thousand separator to be used.
See also
IlvNumberFieldFormat, getFormat().

§ setValue() [1/2]

IlBoolean IlvNumberField::setValue ( IlInt  value,
IlBoolean  redraw = IlFalse 
)

Sets the value of the number field to the specified integer.

Does nothing if the float mode is set or if value is outside the specified limits (see IlvNumberField::setMinInt(), IlvNumberField::setMaxInt()).

Parameters
valueThe number field integer value.
redrawSpecifyies whether the number field should be redrawn.
Returns
IlTrue if the operation succeeded and IlFalse otherwise.
See also
getIntValue(), setValue(IlDouble, IlBoolean), setFormat().

§ setValue() [2/2]

IlBoolean IlvNumberField::setValue ( IlDouble  value,
IlBoolean  redraw = IlFalse 
)

Sets the value of the number field to a double value.

Does nothing if the float mode is not set or if value is outside the specified limits (see IlvNumberField::setMinFloat(), IlvNumberField::setMaxFloat() ).

Parameters
valueThe number field double value.
redrawSpecifies whether the number field should be redrawn.
Returns
IlTrue if the operation succeeded, IlFalse otherwise.
See also
getFloatValue(), setValue(IlInt, IlBoolean), setFormat().

§ validate()

virtual void IlvNumberField::validate ( )
virtual

Is called by the interactor when the user presses the Return or the Enter key.

The default implementation invokes the main callback of the text field. If the method IlvTextField::getChangeFocusOnValidation() returns IlTrue, the keyboard focus moves to the next gadget in the focus chain.

See also
getChangeFocusOnValidation(), IlvGraphicHolder::setFocus().

Reimplemented from IlvTextField.


© Copyright 2017, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.