Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Gadget class. More...
#include <ilviews/gadgets/text.h>
Public Member Functions | |
IlvText (IlvDisplay *display, const IlvRect &rect, const char *text, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0) | |
Constructor. | |
IlvText (IlvDisplay *display, const IlvPoint &point, const char *text, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0) | |
Constructor. | |
IlvText (IlvDisplay *display, const IlvRect &rect, const char *const *labels=0, IlUShort count=0, IlBoolean copy=IlTrue, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0) | |
Constructor. | |
IlvText (IlvDisplay *display, const IlvPoint &point, const char *const *labels=0, IlUShort count=0, IlBoolean copy=IlTrue, IlUShort thickness=IlvDefaultGadgetThickness, IlvPalette *palette=0) | |
Constructor. | |
void | addLine (const char *text, IlShort line=-1) |
Inserts a new text line at the specified location. | |
virtual void | addLines (const char *const *labels, IlUShort count, IlShort line=-1, IlBoolean redraw=IlFalse) |
Adds the specified text lines to the text gadget. | |
void | addText (const char *text, IlShort line=-1, IlBoolean redraw=IlFalse) |
Adds the specified text to the text gadget. | |
virtual void | adjustScrollBars (IlBoolean redraw=IlFalse) |
Recomputes the scroll bars. | |
virtual IlBoolean | check (IlUShort character) |
Is called by the interactor for each key down event that corresponds to a regular character. | |
virtual void | cursorMoved () |
Is called from the interactor when the cursor is moved. | |
void | cutLine (const IlvTextLocation &location) |
Removes the end of the specified line. | |
virtual void | drawBackground (IlvPort *, const IlvTransformer *, const IlvRegion *) const |
Draws the gadget background. | |
virtual void | drawFrame (IlvPort *, const IlvTransformer *, const IlvRegion *) const |
Draws the gadget frame. | |
virtual void | drawGadgetContents (IlvPort *dst, const IlvTransformer *t=0, const IlvRegion *clip=0) const |
Draws the gadget contents. | |
void | ensureVisible (const IlvTextLocation &location, const IlvTransformer *t=0) |
Changes the first line and the offset of the text gadget to ensure that the specified text location is visible. | |
IlvTextLocation | getCursorLocation () const |
Returns the current location of the cursor. | |
IlvTextLocation | getEndLocation () const |
Returns the last location of the text. | |
IlUShort | getFirstLine () const |
Returns the index of the first text line displayed. | |
IlUShort | getLastFullVisibleLine (const IlvTransformer *t=0) const |
Returns the index of the last visible line that can be seen without scrolling. | |
IlUShort | getLastLine (const IlvTransformer *t=0) const |
Returns the index of the last text line displayed. | |
const char * | getLine (IlUShort index) const |
Returns the specified text line. | |
IlUShort | getLineLength (IlUShort index) const |
Returns the number of characters in the specified text line. | |
const char *const * | getLines (IlUShort &count) const |
Returns an array of strings representing the text stored in the gadget. | |
IlvDim | getMaxWidth () const |
Returns the width of the largest visible line. | |
IlUShort | getNumberOfLines () const |
Returns the number of text lines stored in the object. | |
IlUShort | getNumberOfVisibleLines (const IlvTransformer *t=0) const |
Returns the number of visible text lines. | |
IlvDim | getOffset () const |
Returns the text gadget offset. | |
const char * | getSelectedText () const |
Returns the selected text. | |
void | getSelection (IlvTextLocation &from, IlvTextLocation &to) const |
Returns the location of the current selection. | |
const char * | getText () const |
Returns the text stored in the text gadget. | |
virtual IlBoolean | handleAltKey (IlUShort character) |
Is called by the interactor to handle keys pressed with the IlvMetaModifier . | |
virtual IlBoolean | handleControl (IlUShort character) |
Is called by the interactor to handle the control keys. | |
virtual IlBoolean | handleGadgetEvent (IlvEvent &) |
Handles the gadget events. | |
void | insertChar (const IlvTextLocation &location, IlUShort character) |
Inserts a character at the specified location. | |
void | insertText (const char *text, IlvTextLocation &location, IlBoolean redraw=IlFalse) |
Inserts text into the text gadget at the specified location. | |
IlBoolean | isCursorShown () const |
Indicates whether the cursor is visible. | |
IlBoolean | isEditable () const |
Indicates whether the text gadget can be edited. | |
void | locateWord (const IlvTextLocation &location, IlvTextLocation &start, IlvTextLocation &end) const |
Finds the word at the specified location. | |
IlvTextLocation | pointToPosition (const IlvPoint &point, const IlvTransformer *t=0) const |
Returns the location of the specified point in the text. | |
void | readText (istream &istream, const IlvTransformer *t=0) |
Inserts the contents of the specified stream into the text gadget. | |
IlBoolean | readText (const char *filename=0, const IlvTransformer *t=0) |
Inserts the contents of the specified file into the text gadget. | |
void | removeChar (const IlvTextLocation &location) |
Removes a character from a specified location. | |
void | removeLine (IlUShort line) |
Removes and deletes the specified text line. | |
void | removeLines (IlUShort line, IlUShort count) |
Removes and deletes several text lines. | |
virtual void | scrollBarVisibilityChanged (IlvDirection) |
Is called when an internal scroll bar is shown or hidden. | |
virtual void | selectionChanged () |
Is called from the interactor when the selection is modified. | |
void | setCursorLocation (const IlvTextLocation &location) |
Sets the cursor location to a new location. | |
void | setEditable (IlBoolean value) |
Specifies whether editing is allowed for the text gadget. | |
void | setFirstLine (IlUShort line) |
Sets the first text line to be displayed. | |
void | setLine (IlUShort line, const char *text, IlBoolean copy=IlTrue) |
Replaces the text line specified by line with text. | |
virtual void | setLines (const char *const *labels, IlUShort count, IlBoolean copy=IlTrue) |
Replaces all the text in the text gadget. | |
void | setOffset (IlvDim offset) |
Sets the text gadget offset. | |
void | setSelection (const IlvTextLocation &from, const IlvTextLocation &to) |
Sets the location of the current selection. | |
virtual void | setText (const char *text) |
Sets the text to be stored in the text gadget. | |
void | showCursor (IlBoolean value) |
Specifies whether the cursor should be visible. | |
virtual void | valueChanged () |
Is called from the interactor when the value is modified. | |
Static Public Member Functions | |
static IlSymbol * | CursorMovedSymbol () |
Returns the callback type of the Cursor Moved callback. | |
static IlSymbol * | SelectionChangedSymbol () |
Returns the callback type of the Selection Changed callback. | |
static IlSymbol * | ValueChangedSymbol () |
Returns the callback type of the Value Changed callback. | |
Protected Member Functions | |
virtual void | adjustFromScrollBar (const IlvScrollBar *sb, IlvDirection dir) |
Is called to adjust the gadget to the scroll bars values. | |
void | adjustScrollBarValue (IlvScrollBar *sb, IlvDirection dir) |
Is called to adjust the scroll bar values. | |
virtual void | scrollBarHasMoved (IlvDirection dir) |
Is called when an internal scroll bar has moved. | |
Friends | |
class | IlvDefaultTextLFHandler |
Gadget class.
Library: ilvadvgdt
The IlvText
class defines a multiline text editor that can contain up to 65535 lines of text. The contents of a text gadget can be edited.
A Multiline Text Gadget
IlvText::IlvText | ( | IlvDisplay * | display, | |
const IlvPoint & | point, | |||
const char *const * | labels = 0 , |
|||
IlUShort | count = 0 , |
|||
IlBoolean | copy = IlTrue , |
|||
IlUShort | thickness = IlvDefaultGadgetThickness , |
|||
IlvPalette * | palette = 0 | |||
) |
Constructor.
Initializes a new instance of the class IlvText
. The size of the object is computed by calling the method IlvGadget::fitToContents
. If you want to specify its size, use a constructor that takes an IlvRect
reference instead of an IlvPoint
object as parameter.
display | The connection to the display. | |
point | The position of the text gadget. | |
labels | An array of strings representing the lines of the text gadget. | |
count | The number of elements in the labels array. | |
copy | A Boolean value indicating whether the labels array should be copied. | |
thickness | The thickness of the text gadget. | |
palette | The palette used by the text gadget. |
IlvText::IlvText | ( | IlvDisplay * | display, | |
const IlvRect & | rect, | |||
const char *const * | labels = 0 , |
|||
IlUShort | count = 0 , |
|||
IlBoolean | copy = IlTrue , |
|||
IlUShort | thickness = IlvDefaultGadgetThickness , |
|||
IlvPalette * | palette = 0 | |||
) |
Constructor.
Initializes a new instance of the class IlvText
.
display | The connection to the display. | |
rect | The size and position of the text gadget. | |
labels | An array of strings representing the lines of the text gadget. | |
count | The number of elements in the labels array. | |
copy | A Boolean value indicating whether the labels array should be copied. | |
thickness | The thickness of the text gadget. | |
palette | The palette used by the text gadget. |
IlvText::IlvText | ( | IlvDisplay * | display, | |
const IlvPoint & | point, | |||
const char * | text, | |||
IlUShort | thickness = IlvDefaultGadgetThickness , |
|||
IlvPalette * | palette = 0 | |||
) |
Constructor.
Initializes a new instance of the class IlvText
. The size of the object is computed by calling the IlvGadget::fitToContents
method. If you want to specify its size, use a constructor that takes an IlvRect
reference instead of an IlvPoint
object as parameter.
display | The connection to the display. | |
point | The position of the text gadget. | |
text | The text of the text gadget. The ' ' character identifies a new line. The text is copied. | |
thickness | The thickness of the text gadget. | |
palette | The palette used by the text gadget. |
IlvText::IlvText | ( | IlvDisplay * | display, | |
const IlvRect & | rect, | |||
const char * | text, | |||
IlUShort | thickness = IlvDefaultGadgetThickness , |
|||
IlvPalette * | palette = 0 | |||
) |
Constructor.
Initializes a new instance of the class IlvText
.
display | The connection to the display. | |
rect | The size and position of the text gadget. | |
text | The text of the text gadget. The ' ' character identifies a new line. The text is copied. | |
thickness | The thickness of the text gadget. | |
palette | The palette used by the text gadget. |
void IlvText::addLine | ( | const char * | text, | |
IlShort | line = -1 | |||
) |
Inserts a new text line at the specified location.
text | The new text line. This string is copied. | |
line | The index where text should be inserted. |
virtual void IlvText::addLines | ( | const char *const * | labels, | |
IlUShort | count, | |||
IlShort | line = -1 , |
|||
IlBoolean | redraw = IlFalse | |||
) | [virtual] |
Adds the specified text lines to the text gadget.
The labels are copied.
labels | The array of strings to be added. | |
count | The number of elements in the labels array. | |
line | The index of the line where the labels array will be inserted. | |
redraw | A Boolean value specifying whether the text gadget should be redrawn. |
Adds the specified text to the text gadget.
text | The text to be added. The ' ' character identifies a new line. The text is copied. | |
line | The index of the line where the text will be inserted. | |
redraw | A Boolean value specifying whether the text gadget should be redrawn. |
virtual void IlvText::adjustFromScrollBar | ( | const IlvScrollBar * | scrollbar, | |
IlvDirection | direction | |||
) | [protected, virtual] |
Is called to adjust the gadget to the scroll bars values.
Is called each time the scroll bar scrollbar of direction direction moves. If you want to detect these events, you must redefine this member function in a subclass. The default implementation does nothing.
scrollbar | The scroll bar object. | |
direction | The direction of the scroll bar. Valid values are: IlvHorizontal and IlvVertical . |
Reimplemented from IlvScrolledGadget.
virtual void IlvText::adjustScrollBars | ( | IlBoolean | redraw = IlFalse |
) | [virtual] |
Recomputes the scroll bars.
Sets the right values to the scroll bars.
redraw | A Boolean value specifying whether the gadget should be redrawn. |
Reimplemented from IlvScrolledGadget.
void IlvText::adjustScrollBarValue | ( | IlvScrollBar * | scrollbar, | |
IlvDirection | direction | |||
) | [protected, virtual] |
Is called to adjust the scroll bar values.
Is called by the member function IlvScrolledGadget::adjustScrollBars
to adjust the values of the scroll bar scrollbar of direction direction. This member function must modify the scrollbar values to match the gadget scrolling mode. If you want to detect these events, you must redefine this member function in a subclass. The default implementation does nothing.
scrollbar | The scroll bar object. | |
direction | The direction of the scroll bar. Valid values are: IlvHorizontal and IlvVertical . |
Reimplemented from IlvScrolledGadget.
Is called by the interactor for each key down event that corresponds to a regular character.
Its default implementation inserts the character (erasing the selection if there is one) and updates the display accordingly.
character | The ASCII code of the character. |
virtual void IlvText::cursorMoved | ( | ) | [virtual] |
Is called from the interactor when the cursor is moved.
The default implementation calls the Cursor Moved callback.
static IlSymbol* IlvText::CursorMovedSymbol | ( | ) | [static] |
Returns the callback type of the Cursor Moved callback.
The Cursor Moved callback is invoked after the cursor of the text gadget is moved through the interactor.
void IlvText::cutLine | ( | const IlvTextLocation & | location | ) |
Removes the end of the specified line.
location | The location from which the line will be removed. |
virtual void IlvText::drawBackground | ( | IlvPort * | dst, | |
const IlvTransformer * | t, | |||
const IlvRegion * | clip | |||
) | const [virtual] |
Draws the gadget background.
Is called from the draw
method. This method is not called if the gadget is transparent.
dst | The destination drawing port. | |
t | The transformer applied to the gadget. | |
clip | The clipping area. |
Reimplemented from IlvScrolledGadget.
virtual void IlvText::drawFrame | ( | IlvPort * | dst, | |
const IlvTransformer * | t, | |||
const IlvRegion * | clip | |||
) | const [virtual] |
Draws the gadget frame.
Is called from the draw
method. This method is not called if the method IlvScrolledGadget::isShowingFrame
returns IlFalse
.
dst | The destination drawing port. | |
t | The transformer applied to the gadget. | |
clip | The clipping area. |
Reimplemented from IlvScrolledGadget.
virtual void IlvText::drawGadgetContents | ( | IlvPort * | dst, | |
const IlvTransformer * | t = 0 , |
|||
const IlvRegion * | clip = 0 | |||
) | const [virtual] |
Draws the gadget contents.
Is called from the draw
method. The default implementation does nothing.
dst | The destination drawing port. | |
t | The transformer applied to the gadget. | |
clip | The clipping area. |
Reimplemented from IlvScrolledGadget.
void IlvText::ensureVisible | ( | const IlvTextLocation & | location, | |
const IlvTransformer * | t = 0 | |||
) |
Changes the first line and the offset of the text gadget to ensure that the specified text location is visible.
location | The text location. | |
t | The transformer applied to the text gadget. |
IlvTextLocation IlvText::getCursorLocation | ( | ) | const |
Returns the current location of the cursor.
IlvTextLocation IlvText::getEndLocation | ( | ) | const |
Returns the last location of the text.
IlUShort IlvText::getFirstLine | ( | ) | const |
Returns the index of the first text line displayed.
IlUShort IlvText::getLastFullVisibleLine | ( | const IlvTransformer * | t = 0 |
) | const |
Returns the index of the last visible line that can be seen without scrolling.
t | The transformer applied to the text gadget. |
IlUShort IlvText::getLastLine | ( | const IlvTransformer * | t = 0 |
) | const |
Returns the index of the last text line displayed.
t | The transformer applied to the text gadget. |
const char* IlvText::getLine | ( | IlUShort | index | ) | const |
Returns the number of characters in the specified text line.
index | The index of the line. |
const char* const* IlvText::getLines | ( | IlUShort & | count | ) | const |
IlvDim IlvText::getMaxWidth | ( | ) | const |
Returns the width of the largest visible line.
IlUShort IlvText::getNumberOfLines | ( | ) | const |
Returns the number of text lines stored in the object.
IlvText::addLine
IlUShort IlvText::getNumberOfVisibleLines | ( | const IlvTransformer * | t = 0 |
) | const |
Returns the number of visible text lines.
The last line is not taken into account if it is not entirely visible.
t | The transformer applied to the text gadget. |
IlvText::getNumberOfLines
IlvDim IlvText::getOffset | ( | ) | const |
Returns the text gadget offset.
This offset value is the distance between the left side of the text gadget bounding box and the starting point of the text.
const char* IlvText::getSelectedText | ( | ) | const |
Returns the selected text.
void IlvText::getSelection | ( | IlvTextLocation & | from, | |
IlvTextLocation & | to | |||
) | const |
Returns the location of the current selection.
from | The returned starting location of the current selection. | |
to | The returned ending location of the current selection. |
const char* IlvText::getText | ( | ) | const |
Returns the text stored in the text gadget.
Is called by the interactor to handle keys pressed with the IlvMetaModifier
.
character | The ASCII code of the character. |
Is called by the interactor to handle the control keys.
Should only handle control characters, that is, characters for which a call to iscntrl
returns a value different from 0
.
character | The ASCII code of the control character. |
Handles the gadget events.
Is called by IlvScrolledGadget::handleEvent
when the member function handleScrollBarsEvent
returns IlFalse
. Its default implementation does nothing. You can override this member function to implement your own gadget behavior.
event | The event. |
Reimplemented from IlvScrolledGadget.
void IlvText::insertChar | ( | const IlvTextLocation & | location, | |
IlUShort | character | |||
) |
Inserts a character at the specified location.
location | The location where the character is inserted. | |
character | The character to be inserted. |
void IlvText::insertText | ( | const char * | text, | |
IlvTextLocation & | location, | |||
IlBoolean | redraw = IlFalse | |||
) |
Inserts text into the text gadget at the specified location.
text | The text to be inserted. The "\n" character identifies a new line. The text is copied. | |
location | The location where text will be inserted. If this location is not valid, the new text is inserted at the end of the existing text. | |
redraw | A Boolean value specifying whether the text gadget should be redrawn. |
IlBoolean IlvText::isCursorShown | ( | ) | const |
Indicates whether the cursor is visible.
IlTrue
if the cursor is visible. Otherwise, returns IlFalse
. IlBoolean IlvText::isEditable | ( | ) | const |
Indicates whether the text gadget can be edited.
The user cannot type in a text gadget for which editing is not allowed. However, the text can still be selected and copied.
IlTrue
if the text gadget is editable. Otherwise, returns IlFalse
. void IlvText::locateWord | ( | const IlvTextLocation & | location, | |
IlvTextLocation & | start, | |||
IlvTextLocation & | end | |||
) | const |
Finds the word at the specified location.
Uses start and end to return the locators of the word at the specified location. A word is composed of successive characters that are not in the set: _.,;:-=+/()[]{}*&!|'
location | The initial location. | |
start | The returned starting location of the word found. | |
end | The returned ending location of the word found. |
IlvTextLocation IlvText::pointToPosition | ( | const IlvPoint & | point, | |
const IlvTransformer * | t = 0 | |||
) | const |
Returns the location of the specified point in the text.
point | The point to be located. | |
t | The transformer applied to the text gadget. |
void IlvText::readText | ( | istream & | istream, | |
const IlvTransformer * | t = 0 | |||
) |
Inserts the contents of the specified stream into the text gadget.
Removes the existing text and inserts the contents of istream.
istream | The input stream. | |
t | Not used. |
IlBoolean IlvText::readText | ( | const char * | filename = 0 , |
|
const IlvTransformer * | t = 0 | |||
) |
Inserts the contents of the specified file into the text gadget.
Removes the existing text and inserts the contents of filename.
filename | The name of the file to be inserted. | |
t | Not used. |
void IlvText::removeChar | ( | const IlvTextLocation & | location | ) |
Removes a character from a specified location.
location | The location of the character to be removed. | |
character | The character to be removed. |
void IlvText::removeLine | ( | IlUShort | line | ) |
Removes and deletes several text lines.
line | The index of the first text line to be removed. | |
count | The number of lines to delete. |
virtual void IlvText::scrollBarHasMoved | ( | IlvDirection | direction | ) | [protected, virtual] |
Is called when an internal scroll bar has moved.
Is called by handleEvent
each time the value of the internal scroll bar specified by direction changes. The default implementation invokes the Scroll Bar Moved callback.
direction | The direction of the internal scroll bar. Valid values are: IlvHorizontal and IlvVertical . |
Reimplemented from IlvScrolledGadget.
virtual void IlvText::scrollBarVisibilityChanged | ( | IlvDirection | direction | ) | [virtual] |
Is called when an internal scroll bar is shown or hidden.
Is called by handleEvent
each time the internal scroll bar specified by direction is shown or hidden. The default implementation invokes the Scroll Bar Visibility Changed callback.
direction | The direction of the internal scroll bar. Valid values are: IlvHorizontal and IlvVertical . |
Reimplemented from IlvScrolledGadget.
virtual void IlvText::selectionChanged | ( | ) | [virtual] |
Is called from the interactor when the selection is modified.
The default implementation calls the Selection Changed callback.
static IlSymbol* IlvText::SelectionChangedSymbol | ( | ) | [static] |
Returns the callback type of the Selection Changed callback.
The Selection Changed callback is invoked after the selection of the text gadget has changed through the interactor.
void IlvText::setCursorLocation | ( | const IlvTextLocation & | location | ) |
Sets the cursor location to a new location.
If location is not a valid value, it is converted to the nearest valid location.
location | The new cursor location. |
void IlvText::setEditable | ( | IlBoolean | value | ) |
Specifies whether editing is allowed for the text gadget.
The user cannot type in a text gadget for which editing is not allowed. However, the text can still be selected and copied.
IlTrue
) or not (IlFalse
). void IlvText::setFirstLine | ( | IlUShort | line | ) |
Sets the first text line to be displayed.
line | The index of the new first line of text. |
IlvText::getFirstLine
Replaces the text line specified by line with text.
line | The index of the text line to be replaced. | |
text | The new text line. | |
copy | A Boolean value specifying whether the text should be copied. |
virtual void IlvText::setLines | ( | const char *const * | labels, | |
IlUShort | count, | |||
IlBoolean | copy = IlTrue | |||
) | [virtual] |
Replaces all the text in the text gadget.
Sets the contents of this object to the labels array of count text lines.
labels | The array of new strings. | |
count | The number of elements in the labels array. | |
copy | A Boolean value specifying whether the array and each label are copied. |
void IlvText::setOffset | ( | IlvDim | offset | ) |
Sets the text gadget offset.
offset | The new text gadget offset. |
void IlvText::setSelection | ( | const IlvTextLocation & | from, | |
const IlvTextLocation & | to | |||
) |
Sets the location of the current selection.
from | The location where the new selection starts. | |
to | The location where the new selection ends. |
virtual void IlvText::setText | ( | const char * | text | ) | [virtual] |
Sets the text to be stored in the text gadget.
text | The text to be stored in the text gadget. The ' ' character identifies a new line. The text is copied. |
void IlvText::showCursor | ( | IlBoolean | value | ) |
Specifies whether the cursor should be visible.
value | A Boolean value specifying whether the cursor should be visible (IlTrue ) or not (IlFalse ). |
virtual void IlvText::valueChanged | ( | ) | [virtual] |
Is called from the interactor when the value is modified.
The default implementation calls the Value Changed callback.
static IlSymbol* IlvText::ValueChangedSymbol | ( | ) | [static] |
Returns the callback type of the Value Changed callback.
The Value Changed callback is invoked after the text gadget has been modified through the interactor.
© 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.