rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Gadgets Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

List of all members | Public Member Functions | Friends
IlvTextField Class Reference

Gadget class. More...

#include <ilviews/gadgets/textfd.h>

Inheritance diagram for IlvTextField:
IlvGadget IlvSimpleGraphic IlvGraphic IlvComboBox IlvDateField IlvNumberField IlvPasswordTextField IlvScrolledComboBox

Public Member Functions

 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...
 
virtual const char * check (IlUShort character)
 Is called by the interactor for each key down event that corresponds to a regular character. 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...
 
virtual void validate ()
 Is called by the interactor when the user presses the Return or the Enter key. More...
 

Friends

class IlvDefaultTextFieldLFHandler
 

Detailed Description

Gadget class.

Library: ilvgadgt

The IlvTextField class defines a one-line text editor that is used to display and edit a short character string.

- IlvTextField -

The contents of a text field can be modified by clicking it and entering new text. Instances of IlvTextField handle a cursor that indicates where new text should be inserted. It is also possible to select a portion of text by dragging the mouse on it.

See Also
IlvText, IlvComboBox

Constructor & Destructor Documentation

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

Constructor.

Initializes a new instance of the class IlvTextField.

Parameters
displayThe connection to the display.
rectThe size and position of the text field.
labelThe label of the text field. The label is copied.
thicknessThe thickness of the text field.
paletteThe palette used by the text field.
IlvTextField::IlvTextField ( IlvDisplay display,
const IlvPoint point,
const char *  label,
IlUShort  thickness = IlvDefaultGadgetThickness,
IlvPalette palette = 0 
)

Constructor.

Initializes a new instance of the class IlvTextField.

Parameters
displayThe connection to the display.
pointThe position of the text field.
labelThe label of the text field. The label is copied.
thicknessThe thickness of the text field.
paletteThe palette used by the text field.

Member Function Documentation

void IlvTextField::addChangeCallback ( IlvGraphicCallback  callback)

Adds a Label Changed callback.

Adds callback to the Label Changed callback list. A Label Changed callback is invoked when the text field contents is changed through the interactor.

Parameters
callbackA pointer to the new callback.
See Also
labelChanged, setChangeCallback, getChangeCallback
void IlvTextField::addChangeCallback ( IlSymbol callbackName)

Adds a named Label Changed callback.

Adds the callback name callbackName to the Label Changed callback list. A Label Changed callback is called when the text field contents is changed through the interactor.

Parameters
callbackNameThe name of the new callback.
See Also
labelChanged, setChangeCallback, getChangeCallbackName
void IlvTextField::addChangeCallback ( IlvGraphicCallback  callback,
IlAny  arg 
)

Adds a Label Changed callback.

Adds callback to the Label Changed callback list. The callback function, when invoked, receives the user parameter arg. A Label Changed callback is invoked when the text field contents is changed through the interactor.

Parameters
callbackA pointer to the new callback.
argThe callback argument.
See Also
labelChanged, setChangeCallback, getChangeCallback
void IlvTextField::addChangeCallback ( IlSymbol callbackName,
IlAny  arg 
)

Adds a named Label Changed callback.

Adds callbackName to the Label Changed callback list. The callback function, when invoked, receives the user parameter arg. A Label Changed callback is invoked when the text field contents is changed through the interactor.

Parameters
callbackNameThe name of the new callback.
argThe callback argument.
See Also
labelChanged, setChangeCallback, getChangeCallbackName
virtual const char* IlvTextField::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 in IlvNumberField, and IlvDateField.

void IlvTextField::ensureVisible ( IlShort  position,
const IlvTransformer t = 0 
)

Ensures that the character located at the specified position is visible.

Parameters
positionThe position of the character to be made visible.
tThe transformer applied to this text field.
IlvPosition IlvTextField::getAlignment ( ) const

Returns the alignment of the text field.

Returns
The alignment of the text field.
See Also
setAlignment
IlvGraphicCallback IlvTextField::getChangeCallback ( ) const

Returns a pointer to the first unnamed callback in the Label Changed callback list.

A Label Changed callback is invoked when the text field contents is changed through the interactor.

Returns
A pointer to the first unnamed callback in the Label Changed callback list.
See Also
labelChanged, setChangeCallback, addChangeCallback
IlSymbol* IlvTextField::getChangeCallbackName ( ) const

Returns the name of the first named callback in the Label Changed callback list.

A Label Changed callback is invoked when the text field contents is changed through the interactor.

Returns
The name of the first named callback in the Label Changed callback list.
See Also
labelChanged, setChangeCallback, addChangeCallback
IlBoolean IlvTextField::getChangeFocusOnValidation ( ) const

Indicates whether the text field moves the keyboard focus to the next gadget once validated.

Returns
IlTrue if the text field moves the keyboard focus to the next gadget when the Return key is pressed (the default) and IlFalse otherwise.
See Also
setChangeFocusOnValidation
IlShort IlvTextField::getCursorPosition ( ) const

Returns the cursor position.

Returns
The cursor position. A value of 0 means that the cursor is placed just before the first character.
See Also
setCursorPosition
IlShort IlvTextField::getEndSelection ( ) const

Returns the index of the last selected character.

Returns
The index of the last selected character.
See Also
getStartSelection
IlFloat IlvTextField::getFloatValue ( ) const

Converts the text field contents to a floating point value and returns the result of the conversion.

Returns
The conversion of the text field label to an IlFloat. The atof function is used to perform the conversion.
See Also
setValue(IlFloat, const char*, IlBoolean), getIntValue
IlInt IlvTextField::getIntValue ( ) const

Converts the text field contents to an integer and returns the result of the conversion.

Returns
The conversion of the text field label to an IlInt . The atoi function is used to perform the conversion.
See Also
setValue(IlInt, IlBoolean), getFloatValue
const char* IlvTextField::getLabel ( ) const

Returns the label displayed by the text field.

Returns
The label displayed by the text field.
See Also
setLabel, setValue(IlInt, IlBoolean), setValue(IlFloat, const char*, IlBoolean)
IlShort IlvTextField::getMaxChar ( ) const

Returns the maximum number of characters that the user can type in the text field.

Returns
The maximum number of characters that can be typed in the text field. The member function returns -1 if no limit has been defined.
See Also
setMaxChar
virtual const char* IlvTextField::getMessage ( ) const
virtual

Returns the message displayed by this text field.

If the text field cannot be edited, the message database is used to find the translation of the text field contents to the current language. If the text field can be edited, the method returns the result of IlvTextField::getLabel.

Returns
The message displayed by this text field.
See Also
getLabel, IlvMessageDatabase, IlvDisplay::getCurrentLanguage

Reimplemented in IlvPasswordTextField.

IlShort IlvTextField::getStartSelection ( ) const

Returns the index of the first selected character.

Returns
The index of the first selected character. The first character has an index of 0.
See Also
getEndSelection
IlShort IlvTextField::getTextPosition ( ) const

Returns the index of the first visible character of the text field.

Returns
The index of the first visible character of the text field. A value of 0 means that the first character is visible.
See Also
setTextPosition
virtual IlBoolean IlvTextField::handleControl ( IlUShort  character)
virtual

Is called by the interactor to handle control keys.

Should only handle control characters, that is, characters for which calling iscntrl returns a value different from 0. The control characters used are:

  • Ctrl A or Home Key: Cursor goes to beginning.

  • Ctrl X: Cuts the selected text.

  • Ctrl C: Copies the selected text.

  • Ctrl V: Pastes text from clipboard.

  • Ctrl B: Cursor goes backward one character.

  • Ctrl F: Cursor goes forward one character.

  • Ctrl E or End Key: Cursor goes to end.

  • Ctrl K: Removes characters after the cursor.

  • Ctrl U: Removes characters before the cursor.

  • Ctrl D or Delete Key: Removes one character after the cursor.

  • Ctrl H or Backspace Key: Removes one character before the cursor.

  • Left Key: Moves cursor to left one character.

  • Right Key: Moves cursor to right one character.

Parameters
characterThe ASCII code of the control character.
IlBoolean IlvTextField::isCursorShown ( ) const

Indicates whether the cursor is visible.

Returns
IlTrue if the cursor is visible, and IlFalse if it is not.
See Also
showCursor
IlBoolean IlvTextField::isEditable ( ) const

Indicates whether the text field can be edited.

The contents of a noneditable text field can be copied and localized. See IlvTextField::getMessage.

Returns
IlTrue if the text field can be edited and IlFalse otherwise.
See Also
setEditable, getMessage
virtual void IlvTextField::labelChanged ( )
virtual

Is called by the interactor whenever the label of the text field changes.

The default implementation calls the Label Changed callback.

See Also
setChangeCallback

Reimplemented in IlvComboBox.

IlShort IlvTextField::pointToPosition ( const IlvPoint point,
const IlvTransformer t = 0 
) const

Returns the index of the character located at the specified point.

Parameters
pointThe point where the character is located.
tThe transformer applied to the text field.
Returns
The index of the character located at point when the text is drawn with the transformer t.
virtual void IlvTextField::removeSelection ( )
virtual

Removes the selected label from the text field.

The text field is not redrawn.

void IlvTextField::setAlignment ( IlvPosition  alignment)

Sets the alignment of the text field.

Parameters
alignmentThe new text field alignment. Valid values are: IlvRight, IlvLeft and IlvCenter.
See Also
getAlignment
void IlvTextField::setChangeCallback ( IlvGraphicCallback  callback)

Sets a Label Changed callback.

Removes all the existing Label Changed callbacks before adding callback to the Label Changed callback list. A Label Changed callback is invoked when the text field contents is changed through the interactor.

Parameters
callbackA pointer to the new callback.
See Also
labelChanged, addChangeCallback, getChangeCallback
void IlvTextField::setChangeCallback ( IlSymbol callbackName)

Sets a named Label Changed callback.

Removes all the existing Label Changed callbacks before adding the callback name callbackName to the Label Changed callback list. A Label Changed callback is called when the text field contents is changed through the interactor.

Parameters
callbackNameThe name of the new callback.
See Also
labelChanged, addChangeCallback, getChangeCallbackName
void IlvTextField::setChangeCallback ( IlvGraphicCallback  callback,
IlAny  arg 
)

Sets a Label Changed callback.

Removes all the existing Label Changed callbacks before adding callback to the Label Changed callback list. The callback function, when invoked, receives the user parameter arg. A Label Changed callback is invoked when the text field contents is changed through the interactor.

Parameters
callbackA pointer to the new callback.
argThe callback argument.
See Also
labelChanged, addChangeCallback, getChangeCallback
void IlvTextField::setChangeCallback ( IlSymbol callbackName,
IlAny  arg 
)

Sets a named Label Changed callback.

Removes all the existing Label Changed callbacks before adding callbackName to the Label Changed callback list. The callback function, when invoked, receives the user parameter arg. A Label Changed callback is invoked when the text field contents is changed through the interactor.

Parameters
callbackNameThe name of the new callback.
argThe callback argument.
See Also
labelChanged, addChangeCallback, getChangeCallbackName
void IlvTextField::setChangeFocusOnValidation ( IlBoolean  value)

Specifies whether the text field should move the keyboard focus to the next gadget once validated.

Parameters
valueA Boolean value specifying whether the text field should move the keyboard focus to the next gadget in the focus chain when the when the user presses the Return key.
void IlvTextField::setCursorPosition ( IlShort  position)

Sets the cursor position.

Parameters
positionThe new cursor position. If position is greater than the number of characters in the text field, the cursor is placed after the last character.
See Also
getCursorPosition
void IlvTextField::setEditable ( IlBoolean  value)

Specifies whether the text field can be edited.

The contents of a noneditable text field can be copied and localized. See IlvTextField::getMessage.

Parameters
valueA Boolean value specifying whether the text field can be edited (IlTrue) or not (IlFalse).
See Also
isEditable, getMessage
void IlvTextField::setEndSelection ( IlShort  position)

Sets the index of the last selected character.

Parameters
positionThe index of the last selected character.
See Also
setFirstSelection, getEndSelection
virtual void IlvTextField::setLabel ( const char *  label,
IlBoolean  redraw = IlFalse 
)
virtual

Sets the label of the text field.

Parameters
labelThe new label of the text field. The old label is deleted and the new one is copied.
redrawA Boolean value specifying whether the text field should be redrawn.
See Also
getLabel, getIntValue, getFloatValue

Reimplemented in IlvComboBox.

void IlvTextField::setMaxChar ( IlShort  count)

Sets the maximum number of characters that the user can type in the text field.

When the maximum number of characters has been reached, typing additional characters is not taken into account.

Parameters
countThe maximum number of characters that can be typed in the text field.
See Also
getMaxChar
void IlvTextField::setSelection ( IlShort  start,
IlShort  end 
)

Selects a portion of the text field content.

Entirely defines the selection range by setting the index of the first selected character to start and the index of the last selected character to end. To set the selected characters, count the number of delimiters rather than the number of intervals, as follows: If there are six characters: |A|B|C|D|E|F|, there are seven delimiters from 0 to 6 starting from the left. Thus setSelection(1,5) selects B,C,D and E ; and setSelection(1,2) selects B.

Parameters
startThe index of the first selected character.
endThe index of the last selected character.
See Also
setStartSelection, setEndSelection
void IlvTextField::setStartSelection ( IlShort  position)

Sets the index of the first selected character.

Parameters
positionThe index of the first selected character.
See Also
setEndSelection, getStartSelection
void IlvTextField::setTextPosition ( IlShort  position)

Sets the index of the first visible character of the text field.

Parameters
positionThe index of the first visible character.
See Also
getTextPosition, ensureVisible
void IlvTextField::setValue ( IlInt  value,
IlBoolean  redraw = IlFalse 
)

Sets the text field label to an integer value.

Sets the text field label to the ASCII representation of value.

Parameters
valueThe integer value.
redrawA Boolean value specifying whether the text field should be redrawn.
See Also
getIntValue
void IlvTextField::setValue ( IlFloat  value,
const char *  format = 0,
IlBoolean  redraw = IlFalse 
)

Sets the text field label to a floating-point value.

Sets the text field label to the ASCII representation of value and displays it with the specified format.

Parameters
valueThe floating-point value.
formatA string representing the format in which value will be displayed. The syntax is the one used by the function printf. The default format is "%.f".
redrawA Boolean value specifying whether the text field should be redrawn.
See Also
getFloatValue
void IlvTextField::showCursor ( IlBoolean  value,
IlBoolean  redraw = IlFalse 
)

Specifies whether the cursor should be visible.

Parameters
valueA Boolean value specifying whether the cursor should be visible (IlTrue) or not (IlFalse).
redrawA Boolean value specifying whether the text field should be redrawn.
See Also
isCursorShown
virtual void IlvTextField::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 in IlvNumberField, and IlvDateField.


© Copyright 2012, 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.