rwlogo

Rogue Wave Views
Gadgets Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
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

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...
 
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...
 
IlUShort getPrecision () const
 Returns the precision defined for the number field when the float 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 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 setPrecision (IlUShort precision)
 Sets the precision defined for the number field when the float mode is set. 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.

Styling

This class support the following CSS properties:

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

Member Enumeration Documentation

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::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::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::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::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

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.

char IlvNumberField::getDecimalPointChar ( ) const

Returns the character used as the decimal separator.

Returns
The character used as the decimal separator.
See Also
setDecimalPointChar().
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().
IlUInt IlvNumberField::getFormat ( ) const

Returns the format of the number field.

Returns
The format of the number field.
See Also
IlvNumberFieldFormat, setFormat().
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().
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().
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().
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().
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().
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.
char IlvNumberField::getThousandSeparator ( ) const

Returns the character used as the thousand separator.

Returns
The character used as the thousand separator.
See Also
setThousandSeparator().
void IlvNumberField::setDecimalPointChar ( char  separator)

Sets the character used as the decimal separator.

Parameters
separatorThe decimal separator to be used.
See Also
IlvNumberFieldFormat, getDecimalPointChar().
void IlvNumberField::setFormat ( IlUInt  format)

Sets the format of the number field.

Parameters
formatThe new format.
See Also
IlvNumberFieldFormat, getFormat().
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().
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().
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().
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().
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().
void IlvNumberField::setThousandSeparator ( char  separator)

Sets the character used as the thousand separator.

Parameters
separatorThe thousand separator to be used.
See Also
IlvNumberFieldFormat, getFormat().
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().
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().
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 2015, 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.