Gadget class. More...
#include <ilviews/gadgets/textfd.h>
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 (IlSymbol *callbackName) |
Adds a named Label Changed callback. More... | |
void | addChangeCallback (IlSymbol *callbackName, IlAny arg) |
Adds a named Label Changed callback. More... | |
void | addChangeCallback (IlvGraphicCallback callback) |
Adds a Label Changed callback. More... | |
void | addChangeCallback (IlvGraphicCallback callback, IlAny arg) |
Adds a 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... | |
IlSymbol * | getChangeCallbackName () 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 (IlSymbol *callbackName) |
Sets a named Label Changed callback. More... | |
void | setChangeCallback (IlSymbol *callbackName, IlAny arg) |
Sets a named Label Changed callback. More... | |
void | setChangeCallback (IlvGraphicCallback callback) |
Sets a Label Changed callback. More... | |
void | setChangeCallback (IlvGraphicCallback callback, IlAny arg) |
Sets a 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 (IlFloat value, const char *format=0, IlBoolean redraw=IlFalse) |
Sets the text field label to a floating-point value. More... | |
void | setValue (IlInt value, IlBoolean redraw=IlFalse) |
Sets the text field label to an integer 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 |
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.
IlvText
, IlvComboBox
.Name | Type | Equivalent methods |
---|---|---|
alignment | Direction | getAlignment() , setAlignment() |
label | String | getLabel() , setLabel() |
cursorPosition | Int | getCursorPosition() , setCursorPosition() |
selectionStart | Int | getStartSelection() , setSelection() |
selectionEnd | Int | getEndSelection() , setSelection() |
maxChar | Int | getMaxChar() , setMaxChar() |
editable | Boolean | isEditable() , setEditable() |
focusChange | Boolean | getChangeFocusOnValidation() , setChangeFocusOnValidation() |
Graphic property | CSS property | Type |
---|---|---|
Background color | background-color | Color |
Text color | color | Color |
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
.
display | The connection to the display. |
rect | The size and position of the text field. |
label | The label of the text field. The label is copied. |
thickness | The thickness of the text field. |
palette | The 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
.
display | The connection to the display. |
point | The position of the text field. |
label | The label of the text field. The label is copied. |
thickness | The thickness of the text field. |
palette | The palette used by the text field. |
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.
callbackName | The name of the new callback. |
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.
callbackName | The name of the new callback. |
arg | The callback argument. |
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.
callback | A pointer to the new callback. |
labelChanged()
, setChangeCallback()
, getChangeCallback()
. 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.
callback | A pointer to the new callback. |
arg | The callback argument. |
labelChanged()
, setChangeCallback()
, getChangeCallback()
.
|
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).
character | The ASCII code of the character. |
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.
position | The position of the character to be made visible. |
t | The transformer applied to this text field. |
IlvPosition IlvTextField::getAlignment | ( | ) | const |
Returns the alignment of the text field.
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.
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.
labelChanged()
, setChangeCallback()
, addChangeCallback()
. IlBoolean IlvTextField::getChangeFocusOnValidation | ( | ) | const |
Indicates whether the text field moves the keyboard focus to the next gadget once validated.
IlTrue
if the text field moves the keyboard focus to the next gadget when the Return key is pressed (the default) and IlFalse
otherwise. setChangeFocusOnValidation()
. IlShort IlvTextField::getCursorPosition | ( | ) | const |
Returns the cursor position.
0
means that the cursor is placed just before the first character. setCursorPosition()
. IlShort IlvTextField::getEndSelection | ( | ) | const |
Returns the index of the last selected character.
getStartSelection()
. IlFloat IlvTextField::getFloatValue | ( | ) | const |
Converts the text field contents to a floating point value and returns the result of the conversion.
IlFloat
. The function atof()
is used to perform the conversion. IlInt IlvTextField::getIntValue | ( | ) | const |
Converts the text field contents to an integer and returns the result of the conversion.
IlInt
. The function atoi()
is used to perform the conversion. setValue(IlInt, IlBoolean)
, getFloatValue()
. const char* IlvTextField::getLabel | ( | ) | const |
Returns the label displayed by the text field.
IlShort IlvTextField::getMaxChar | ( | ) | const |
Returns the maximum number of characters that the user can type in the text field.
-1
if no limit has been defined. setMaxChar()
.
|
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()
.
Reimplemented in IlvPasswordTextField.
IlShort IlvTextField::getStartSelection | ( | ) | const |
Returns the index of the first selected character.
0
. getEndSelection()
. IlShort IlvTextField::getTextPosition | ( | ) | const |
Returns the index of the first visible character of the text field.
0
means that the first character is visible. setTextPosition()
. 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:
character | The ASCII code of the control character. |
IlBoolean IlvTextField::isCursorShown | ( | ) | const |
Indicates whether the cursor is visible.
IlTrue
if the cursor is visible, and IlFalse
if it is not. 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()
.
IlTrue
if the text field can be edited and IlFalse
otherwise. setEditable()
, getMessage()
.
|
virtual |
Is called by the interactor whenever the label of the text field changes.
The default implementation calls the Label Changed callback.
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.
point | The point where the character is located. |
t | The transformer applied to the text field. |
|
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.
alignment | The new text field alignment. Valid values are: IlvRight , IlvLeft and IlvCenter . |
getAlignment()
. 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.
callbackName | The name of the new callback. |
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.
callbackName | The name of the new callback. |
arg | The callback argument. |
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.
callback | A pointer to the new callback. |
labelChanged()
, addChangeCallback()
, getChangeCallback()
. 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.
callback | A pointer to the new callback. |
arg | The callback argument. |
labelChanged()
, addChangeCallback()
, getChangeCallback()
. void IlvTextField::setChangeFocusOnValidation | ( | IlBoolean | value | ) |
Specifies whether the text field should move the keyboard focus to the next gadget once validated.
value | Specifies 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.
position | The new cursor position. If position is greater than the number of characters in the text field, the cursor is placed after the last character. |
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()
.
value | Specifies whether the text field can be edited (IlTrue ) or not (IlFalse ). |
isEditable()
, getMessage()
. void IlvTextField::setEndSelection | ( | IlShort | position | ) |
Sets the index of the last selected character.
position | The index of the last selected character. |
setFirstSelection()
, getEndSelection()
. Sets the label of the text field.
label | The new label of the text field. The old label is deleted and the new one is copied. |
redraw | Specifies whether the text field should be redrawn. |
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.
count | The maximum number of characters that can be typed in the text field. |
getMaxChar()
. 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
.
start | The index of the first selected character. |
end | The index of the last selected character. |
setStartSelection()
, setEndSelection()
. void IlvTextField::setStartSelection | ( | IlShort | position | ) |
Sets the index of the first selected character.
position | The index of the first selected character. |
setEndSelection()
, getStartSelection()
. void IlvTextField::setTextPosition | ( | IlShort | position | ) |
Sets the index of the first visible character of the text field.
position | The index of the first visible character. |
getTextPosition()
, ensureVisible()
. 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.
value | The floating-point value. |
format | A 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" . |
redraw | Specifies whether the text field should be redrawn. |
getFloatValue()
. Sets the text field label to an integer value.
Sets the text field label to the ASCII representation of value.
value | The integer value. |
redraw | Specifies whether the text field should be redrawn. |
getIntValue()
. Specifies whether the cursor should be visible.
value | Specifies whether the cursor should be visible (IlTrue ) or not (IlFalse ). |
redraw | Specifies whether the text field should be redrawn. |
isCursorShown()
.
|
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.
Reimplemented in IlvNumberField, and IlvDateField.