NXWidgets: NXWidgets::CTextBox Class Reference

NXWidgets 1.19

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
NXWidgets::CTextBox Class Reference

`#include <ctextbox.hxx>`

Inheritance diagram for NXWidgets::CTextBox:

## Public Member Functions
| CTextBox (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, const CNxString &text, CWidgetStyle *style=(CWidgetStyle *) NULL)
virtual void | showCursor (EShowCursor cursorMode)
virtual void | showCursor (void)
virtual void | hideCursor (void)
virtual void | wrapCursor (bool wrap)
virtual void | setText (const CNxString &text)
virtual void | appendText (const CNxString &text)
virtual void | removeText (const unsigned int startIndex)
virtual void | removeText (const unsigned int startIndex, const unsigned int count)
virtual void | insertText (const CNxString &text, const unsigned int index)
virtual void | insertTextAtCursor (const CNxString &text)
virtual void | moveCursorToPosition (const int position)
virtual const int | getCursorPosition (void) const
void | handleKeyPressEvent (const CWidgetEventArgs &e)
void | handleCursorControlEvent (const CWidgetEventArgs &e)
Public Member Functions inherited from NXWidgets::ITextBox
virtual | ~ITextBox (void)
Public Member Functions inherited from NXWidgets::CLabel
| CLabel (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, const CNxString &text, CWidgetStyle *style=(CWidgetStyle *) NULL)
virtual | ~CLabel ()
virtual void | setTextAlignmentHoriz (TextAlignmentHoriz alignment)
virtual void | setTextAlignmentVert (TextAlignmentVert alignment)
const TextAlignmentHoriz | getTextAlignmentHoriz (void) const
const TextAlignmentVert | getTextAlignmentVert (void) const
virtual const CNxString & | getText (void) const
virtual void | insertText (const CNxString &text, const int index)
virtual void | highlight (bool highlightOn)
virtual bool | isHighlighted (void) const
virtual void | getPreferredDimensions (CRect &rect) const
virtual void | setFont (CNxFont *font)
virtual bool | isTextChange (void) const
Public Member Functions inherited from NXWidgets::CNxWidget
| CNxWidget (CWidgetControl *pWidgetControl, nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height, uint32_t flags, FAR const CWidgetStyle *style=(FAR const CWidgetStyle *) NULL)
virtual | ~CNxWidget (void)
nxgl_coord_t | getX (void) const
nxgl_coord_t | getY (void) const
nxgl_coord_t | getRelativeX (void) const
nxgl_coord_t | getRelativeY (void) const
bool | hasFocus (void) const
bool | isDeleted (void) const
bool | isDrawingEnabled (void) const
bool | isHidden (void) const
bool | isEnabled (void) const
bool | isPermeable (void) const
bool | isDoubleClickable (void) const
bool | isBorderless (void) const
bool | isClicked (void) const
bool | isBeingDragged (void) const
nxgl_coord_t | getWidth (void) const
nxgl_coord_t | getHeight (void) const
void | getSize (struct nxgl_size_s &size) const
void | getPos (struct nxgl_point_s &pos) const
CRect | getBoundingBox (void)
void | getBorderSize (WidgetBorderSize &borderSize)
CNxWidget * | getParent (void) const
CNxWidget * | getFocusedWidget (void)
void | getClientRect (CRect &rect) const
void | getRect (CRect &rect) const
CNxFont * | getFont (void) const
nxgl_mxpixel_t | getBackgroundColor (void) const
nxgl_mxpixel_t | getSelectedBackgroundColor (void) const
nxgl_mxpixel_t | getShineEdgeColor (void) const
nxgl_mxpixel_t | getShadowEdgeColor (void) const
nxgl_mxpixel_t | getHighlightColor (void) const
nxgl_mxpixel_t | getDisabledTextColor (void) const
nxgl_mxpixel_t | getEnabledTextColor (void) const
nxgl_mxpixel_t | getSelectedTextColor (void) const
const CWidgetStyle * | getWidgetStyle () const
void | setBorderless (bool isBorderless)
void | setDraggable (bool isDraggable)
void | setPermeable (bool permeable)
void | setDoubleClickable (bool doubleClickable)
void | addWidgetEventHandler (CWidgetEventHandler *eventHandler)
void | removeWidgetEventHandler (CWidgetEventHandler *eventHandler)
int | nWidgetEventHandlers (void) const
void | setRaisesEvents (bool raises)
bool | raisesEvents (void) const
void | disableDrawing (void)
void | enableDrawing (void)
void | setBackgroundColor (nxgl_mxpixel_t color)
void | setSelectedBackgroundColor (nxgl_mxpixel_t color)
void | setShineEdgeColor (nxgl_mxpixel_t color)
void | setShadowEdgeColor (nxgl_mxpixel_t color)
void | setHighlightColor (nxgl_mxpixel_t color)
void | setDisabledTextColor (nxgl_mxpixel_t color)
void | setEnabledTextColor (nxgl_mxpixel_t color)
void | setSelectedTextColor (nxgl_mxpixel_t color)
void | redraw (void)
bool | enable (void)
bool | disable (void)
void | close (void)
bool | show (void)
bool | hide (void)
virtual bool | click (nxgl_coord_t x, nxgl_coord_t y)
virtual bool | isDoubleClick (nxgl_coord_t x, nxgl_coord_t y)
bool | doubleClick (nxgl_coord_t x, nxgl_coord_t y)
bool | release (nxgl_coord_t x, nxgl_coord_t y)
bool | drag (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t vX, nxgl_coord_t vY)
bool | keyPress (nxwidget_char_t key)
bool | cursorControl (ECursorControl control)
bool | focus (void)
bool | blur (void)
bool | moveTo (nxgl_coord_t x, nxgl_coord_t y)
bool | resize (nxgl_coord_t width, nxgl_coord_t height)
bool | changeDimensions (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height)
void | moveChildToDeleteQueue (CNxWidget *widget)
void | setFocusedWidget (CNxWidget *widget)
virtual bool | checkCollision (nxgl_coord_t x, nxgl_coord_t y) const
virtual bool | checkCollision (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t width, nxgl_coord_t height) const
bool | checkCollision (CNxWidget *widget) const
void | addWidget (CNxWidget *widget)
void | insertWidget (CNxWidget *widget)
void | setParent (CNxWidget *parent)
void | destroy (void)
bool | remove (void)
bool | removeChild (CNxWidget *widget)
const CNxWidget * | getChild (int index) const
int | getChildCount (void) const
void | setBorderSize (const WidgetBorderSize &borderSize)
Public Member Functions inherited from NXWidgets::CWidgetEventHandler
| CWidgetEventHandler ()
virtual | ~CWidgetEventHandler ()
virtual void | handleClickEvent (const CWidgetEventArgs &e)
virtual void | handleDragEvent (const CWidgetEventArgs &e)
virtual void | handleDropEvent (const CWidgetEventArgs &e)
virtual void | handleReleaseEvent (const CWidgetEventArgs &e)
virtual void | handleReleaseOutsideEvent (const CWidgetEventArgs &e)
virtual void | handleFocusEvent (const CWidgetEventArgs &e)
virtual void | handleBlurEvent (const CWidgetEventArgs &e)
virtual void | handleCloseEvent (const CWidgetEventArgs &e)
virtual void | handleHideEvent (const CWidgetEventArgs &e)
virtual void | handleShowEvent (const CWidgetEventArgs &e)
virtual void | handleEnableEvent (const CWidgetEventArgs &e)
virtual void | handleDisableEvent (const CWidgetEventArgs &e)
virtual void | handleValueChangeEvent (const CWidgetEventArgs &e)
virtual void | handleResizeEvent (const CWidgetEventArgs &e)
virtual void | handleMoveEvent (const CWidgetEventArgs &e)
virtual void | handleScrollEvent (const CWidgetEventArgs &e)
virtual void | handleDoubleClickEvent (const CWidgetEventArgs &e)
virtual void | handleActionEvent (const CWidgetEventArgs &e)

## Protected Member Functions
void | onBlur (void)
virtual void | drawContents (CGraphicsPort *port)
virtual bool | repositionCursor (const int position)
void | moveCursorToClickLocation (nxgl_coord_t x, nxgl_coord_t y)
virtual void | drawBorder (CGraphicsPort *port)
virtual void | onClick (nxgl_coord_t x, nxgl_coord_t y)
virtual void | onDoubleClick (nxgl_coord_t x, nxgl_coord_t y)
virtual bool | isCursorVisible (void) const
virtual const nxgl_coord_t | getCursorXPos (void) const
virtual nxgl_coord_t | getCursorWidth (void) const
virtual void | calculateTextPositionHorizontal (void)
| CTextBox (const CTextBox &textbox)
Protected Member Functions inherited from NXWidgets::CLabel
virtual void | onResize (nxgl_coord_t width, nxgl_coord_t height)
virtual void | calculateTextPositionVertical (void)
virtual void | onTextChange (void)
| CLabel (const CLabel &label)
Protected Member Functions inherited from NXWidgets::CNxWidget
void | useWidgetStyle (const CWidgetStyle *style)
void | drawChildren (void)
void | closeChild (CNxWidget *widget)
void | startDragging (nxgl_coord_t x, nxgl_coord_t y)
void | stopDragging (nxgl_coord_t x, nxgl_coord_t y)
| CNxWidget (const CNxWidget &widget)
virtual void | onPreRelease (nxgl_coord_t x, nxgl_coord_t y)
virtual void | onRelease (nxgl_coord_t x, nxgl_coord_t y)
virtual void | onReleaseOutside (nxgl_coord_t x, nxgl_coord_t y)
virtual void | onDrag (nxgl_coord_t x, nxgl_coord_t y, nxgl_coord_t vX, nxgl_coord_t vY)
virtual void | onDragStart (void)
virtual void | onDragStop (void)
virtual void | onFocus (void)
virtual void | onEnable (void)
virtual void | onDisable (void)

## Protected Attributes
int | m_cursorPos
uint8_t | m_showCursor
bool | m_wrapCursor
Protected Attributes inherited from NXWidgets::CLabel
CNxString | m_text
struct nxgl_point_s | m_align
TextAlignmentHoriz | m_hAlignment
TextAlignmentVert | m_vAlignment
bool | m_textChange
bool | m_highlighted
Protected Attributes inherited from NXWidgets::CNxWidget
CWidgetControl * | m_widgetControl
CRect | m_rect
nxgl_coord_t | m_grabPointX
nxgl_coord_t | m_grabPointY
nxgl_coord_t | m_newX
nxgl_coord_t | m_newY
CWidgetStyle | m_style
Flags | m_flags
CWidgetEventHandlerList * | m_widgetEventHandlers
struct timespec | m_lastClickTime
nxgl_coord_t | m_lastClickX
nxgl_coord_t | m_lastClickY
int | m_doubleClickBounds
CNxWidget * | m_parent
CNxWidget * | m_focusedChild
TNxArray< CNxWidget * > | m_children
WidgetBorderSize | m_borderSize

## Additional Inherited Members
Public Types inherited from NXWidgets::CLabel
enum | TextAlignmentHoriz { TEXT_ALIGNMENT_HORIZ_CENTER = 0, TEXT_ALIGNMENT_HORIZ_LEFT = 1, TEXT_ALIGNMENT_HORIZ_RIGHT = 2 }
enum | TextAlignmentVert { TEXT_ALIGNMENT_VERT_CENTER = 0, TEXT_ALIGNMENT_VERT_TOP = 1, TEXT_ALIGNMENT_VERT_BOTTOM = 2 }
Public Types inherited from NXWidgets::CNxWidget
enum | WidgetFlagType { WIDGET_BORDERLESS = 0x0001, WIDGET_DRAGGABLE = 0x0002, WIDGET_PERMEABLE = 0x0004, WIDGET_DOUBLE_CLICKABLE = 0x0008, WIDGET_NO_RAISE_EVENTS = 0x0010 }

## Detailed Description

Single-line textbox widget. Can align text both vertically and horizontally in different ways. The widget gains this functionality by inheriting from the CLabel class. However, if the amount of text exceeds the dimensions of the widget, the widget will ignore its horizontal alignment settings and switch to left-aligned instead. This ensures that moving the cursor over the text will scroll through it correctly.

Definition at line 119 of file ctextbox.hxx.

## Constructor & Destructor Documentation

## ◆ CTextBox() [1/2]

NXWidgets::CTextBox::CTextBox | ( | const CTextBox & | textbox | ) |
| inlineprotected

Copy constructor is protected to prevent usage.

Definition at line 222 of file ctextbox.hxx.

## ◆ CTextBox() [2/2]

CTextBox::CTextBox | ( | CWidgetControl * | pWidgetControl,
|  | nxgl_coord_t | x,
|  | nxgl_coord_t | y,
|  | nxgl_coord_t | width,
|  | nxgl_coord_t | height,
|  | const CNxString & | text,
|  | CWidgetStyle * | style = `(CWidgetStyle *)NULL`
| ) |  |

Constructor for a textbox containing a string.

Parameters

  pWidgetControl | The controlling widget for the window
  x | The x coordinate of the text box, relative to its parent.
  y | The y coordinate of the text box, relative to its parent.
  width | The width of the textbox.
  height | The height of the textbox.
  text | Pointer to a string to display in the textbox.
  style | The style that the button should use. If this is not specified, the button will use the global default widget style.

Constructor for a textbox containing a string.

Parameters

  pWidgetControl | The controlling widget for the window
  x | The x coordinate of the text box, relative to its parent.
  y | The y coordinate of the text box, relative to its parent.
  width | The width of the textbox.
  height | The height of the textbox.
  text | Pointer to a string to display in the textbox.
  style | The style that the widget should use. If this is not specified, the widget will use the values stored in the global defaultCWidgetStyle object. The widget will copy the properties of the style into its own internal style object.

Definition at line 113 of file ctextbox.cxx.

## Member Function Documentation

## ◆ appendText()

void CTextBox::appendText | ( | const CNxString & | text | ) |
| virtual

Append new text to the end of the current text displayed in the label.

Parameters

  text | String to append.

Reimplemented from NXWidgets::CLabel.

Definition at line 177 of file ctextbox.cxx.

## ◆ calculateTextPositionHorizontal()

void CTextBox::calculateTextPositionHorizontal | ( | void |  | ) |
| protectedvirtual

Calculate the horizontal position of the string based on its length and the alignment options. Alignment options are overridden if the width of the string exceeds the width of the textbox.

Reimplemented from NXWidgets::CLabel.

Definition at line 595 of file ctextbox.cxx.

## ◆ drawBorder()

void CTextBox::drawBorder | ( | CGraphicsPort * | port | ) |
| protectedvirtual

Draw the area of this widget that falls within the clipping region. Called by the redraw() function to draw all visible regions.

Parameters

  port | The CGraphicsPort to draw to.

See also
  redraw()

Reimplemented from NXWidgets::CLabel.

Definition at line 493 of file ctextbox.cxx.

## ◆ drawContents()

void CTextBox::drawContents | ( | CGraphicsPort * | port | ) |
| protectedvirtual

Draw the area of this widget that falls within the clipping region. Called by the redraw() function to draw all visible regions.

Parameters

  port | The CGraphicsPort to draw to.

See also
  redraw()

Reimplemented from NXWidgets::CLabel.

Definition at line 337 of file ctextbox.cxx.

## ◆ getCursorPosition()

virtual const int NXWidgets::CTextBox::getCursorPosition | ( | void |  | ) | const
| inlinevirtual

Get the cursor position. This is the index within the string that the cursor is currently positioned over.

Returns
  position The cursor position.

Implements NXWidgets::ITextBox.

Definition at line 350 of file ctextbox.hxx.

## ◆ getCursorWidth()

nxgl_coord_t CTextBox::getCursorWidth | ( | void |  | ) | const
| protectedvirtual

Get the width of the cursor in pixels.

Returns
  The width of the cursor in pixels.

Definition at line 573 of file ctextbox.cxx.

## ◆ getCursorXPos()

const nxgl_coord_t CTextBox::getCursorXPos | ( | void |  | ) | const
| protectedvirtual

Get the x coordinate of the cursor in pixels relative to the left-hand edge of the client rect.

Returns
  The x coordinate of the cursor in pixels.

Definition at line 549 of file ctextbox.cxx.

## ◆ handleCursorControlEvent()

void CTextBox::handleCursorControlEvent | ( | const CWidgetEventArgs & | e | ) |
| virtual

Handle a cursor control event. Replaces CWidgetEventHandler method.

Parameters

  e | The event data.

Reimplemented from NXWidgets::CWidgetEventHandler.

Definition at line 292 of file ctextbox.cxx.

## ◆ handleKeyPressEvent()

void CTextBox::handleKeyPressEvent | ( | const CWidgetEventArgs & | e | ) |
| virtual

Handle a keyboard press event. Replaces CWidgetEventHandler method.

Parameters

  e | The event data.

Handle a keyboard press event.

Parameters

  e | The event data.

Reimplemented from NXWidgets::CWidgetEventHandler.

Definition at line 260 of file ctextbox.cxx.

## ◆ hideCursor()

virtual void NXWidgets::CTextBox::hideCursor | ( | void |  | ) |
| inlinevirtual

Hides the cursor.

Definition at line 265 of file ctextbox.hxx.

## ◆ insertText()

void CTextBox::insertText | ( | const CNxString & | text,
|  | const unsigned int | index
| ) |  |
| virtual

Insert text at the specified index.

Parameters

  text | The text to insert.
  index | Index at which to insert the text.

Implements NXWidgets::ITextBox.

Definition at line 219 of file ctextbox.cxx.

## ◆ insertTextAtCursor()

void CTextBox::insertTextAtCursor | ( | const CNxString & | text | ) |
| virtual

Insert text at the current cursor position.

Parameters

  text | The text to insert.

Implements NXWidgets::ITextBox.

Definition at line 232 of file ctextbox.cxx.

## ◆ isCursorVisible()

bool CTextBox::isCursorVisible | ( | void |  | ) | const
| protectedvirtual

Return true if the cursor is visible

Definition at line 536 of file ctextbox.cxx.

## ◆ moveCursorToClickLocation()

void CTextBox::moveCursorToClickLocation | ( | nxgl_coord_t | x,
|  | nxgl_coord_t | y
| ) |  |
| protected

Move the cursor to the specified coordinates. The coordinates are expected to be the result of a click, and therefore in world-space rather than widget-space.

Definition at line 438 of file ctextbox.cxx.

## ◆ moveCursorToPosition()

void CTextBox::moveCursorToPosition | ( | const int | position | ) |
| virtual

Move the cursor to the text position specified. 0 indicates the start of the string. If position is greater than the length of the string, the cursor is moved to the end of the string.

Parameters

  position | The new cursor position.

Implements NXWidgets::ITextBox.

Definition at line 245 of file ctextbox.cxx.

## ◆ onBlur()

void CTextBox::onBlur | ( | void |  | ) |
| inlineprotectedvirtual

Redraws the widget

Reimplemented from NXWidgets::CNxWidget.

Definition at line 324 of file ctextbox.cxx.

## ◆ onClick()

void CTextBox::onClick | ( | nxgl_coord_t | x,
|  | nxgl_coord_t | y
| ) |  |
| protectedvirtual

Moves the cursor to the clicked coordinates.

Parameters

  x | The x coordinates of the click.
  y | The y coordinates of the click.

Reimplemented from NXWidgets::CNxWidget.

Definition at line 515 of file ctextbox.cxx.

## ◆ onDoubleClick()

void CTextBox::onDoubleClick | ( | nxgl_coord_t | x,
|  | nxgl_coord_t | y
| ) |  |
| protectedvirtual

Does nothing.

Parameters

  x | The x coordinates of the click.
  y | The y coordinates of the click.

Reimplemented from NXWidgets::CNxWidget.

Definition at line 527 of file ctextbox.cxx.

## ◆ removeText() [1/2]

void CTextBox::removeText | ( | const unsigned int | startIndex | ) |
| virtual

Remove all characters from the string from the start index onwards.

Parameters

  startIndex | Index to remove from.

Implements NXWidgets::ITextBox.

Definition at line 190 of file ctextbox.cxx.

## ◆ removeText() [2/2]

void CTextBox::removeText | ( | const unsigned int | startIndex,
|  | const unsigned int | count
| ) |  |
| virtual

Remove specified number of characters from the string from the start index onwards.

Parameters

  startIndex | Index to remove from.
  count | Number of characters to remove.

Implements NXWidgets::ITextBox.

Definition at line 205 of file ctextbox.cxx.

## ◆ repositionCursor()

bool CTextBox::repositionCursor | ( | const int | position | ) |
| protectedvirtual

Moves the cursor without redrawing.

Parameters

  position | New cursor position.

Returns
  True if the cursor position changed

Moves the cursor without redrawing.

Parameters

  position | New cursor position.

Definition at line 417 of file ctextbox.cxx.

## ◆ setText()

void CTextBox::setText | ( | const CNxString & | text | ) |
| virtual

Set the text displayed in the label.

Parameters

  text | String to display.

Reimplemented from NXWidgets::CLabel.

Definition at line 163 of file ctextbox.cxx.

## ◆ showCursor() [1/2]

void CTextBox::showCursor | ( | EShowCursor | cursorMode | ) |
| virtual

Sets the cursor display mode.

Parameters

  cursorMode | Determines cursor display mode

Shows the cursor.

Parameters

  cursorMode | Determines cursor display mode

Implements NXWidgets::ITextBox.

Definition at line 148 of file ctextbox.cxx.

## ◆ showCursor() [2/2]

virtual void NXWidgets::CTextBox::showCursor | ( | void |  | ) |
| inlinevirtual

Shows the cursor in default mode (only when the TextBox has focus).

Definition at line 256 of file ctextbox.hxx.

## ◆ wrapCursor()

virtual void NXWidgets::CTextBox::wrapCursor | ( | bool | wrap | ) |
| inlinevirtual

Enables/disables cursor wrapping

Parameters

  wrap | True enables cursor wrapping

Implements NXWidgets::ITextBox.

Definition at line 276 of file ctextbox.hxx.

## Member Data Documentation

## ◆ m_cursorPos

int NXWidgets::CTextBox::m_cursorPos
| protected

Position of the cursor within the string.

Definition at line 122 of file ctextbox.hxx.

## ◆ m_showCursor

uint8_t NXWidgets::CTextBox::m_showCursor
| protected

Controls cursor visibility.

Definition at line 123 of file ctextbox.hxx.

## ◆ m_wrapCursor

bool NXWidgets::CTextBox::m_wrapCursor
| protected

True wrap cursor at the ends of the text

Definition at line 124 of file ctextbox.hxx.

The documentation for this class was generated from the following files:

- ctextbox.hxx
- ctextbox.cxx