NXWidgets: NXWidgets::CText Class Reference

NXWidgets 1.19

Classes | Public Member Functions | Private Attributes | List of all members
NXWidgets::CText Class Reference

`#include <ctext.hxx>`

Inheritance diagram for NXWidgets::CText:

## Classes
struct | LongestLine

## Public Member Functions
| CText (CNxFont *font, const CNxString &text, nxgl_coord_t width)
virtual | ~CText (void)
virtual void | setText (const CNxString &text)
virtual void | setText (FAR const char *text)
virtual void | setText (const nxwidget_char_t text)
virtual void | append (const CNxString &text)
virtual void | insert (const CNxString &text, const int index)
virtual void | remove (const int startIndex)
virtual void | remove (const int startIndex, const int count)
void | setLineSpacing (nxgl_coord_t lineSpacing)
void | setWidth (nxgl_coord_t width)
void | setFont (CNxFont *font)
const int | getLineLength (const int lineNumber) const
const int | getLineTrimmedLength (const int lineNumber) const
const nxgl_coord_t | getLinePixelLength (const int lineNumber) const
const nxgl_coord_t | getLineTrimmedPixelLength (const int lineNumber) const
const int32_t | getPixelHeight (void) const
const uint8_t | getPixelWidth (void) const
const uint8_t | getLineSpacing (void) const
const uint8_t | getLineHeight (void) const
const int | getLineCount (void) const
CNxFont * | getFont (void) const
void | stripTopLines (const int lines)
void | wrap (void)
void | wrap (int charIndex)
const int | getLineContainingCharIndex (const int index) const
const int | getLineStartIndex (const int line) const
Public Member Functions inherited from NXWidgets::CNxString
| CNxString ()
| CNxString (FAR const char *text)
| CNxString (const nxwidget_char_t letter)
| CNxString (const CNxString &string)
virtual | ~CNxString ()
CStringIterator * | newStringIterator (void) const
void | copyToCharArray (FAR nxwidget_char_t *buffer) const
void | setText (const CNxString &text)
void | setText (FAR const char *text)
void | setText (FAR const nxwidget_char_t *text, int nchars)
void | setText (const nxwidget_char_t text)
void | append (const CNxString &text)
void | insert (const CNxString &text, const int index)
void | remove (const int startIndex)
void | remove (const int startIndex, const int count)
const unsigned int | getLength (void) const
const unsigned int | getAllocSize (void) const
const nxwidget_char_t | getCharAt (int index) const
const int | indexOf (nxwidget_char_t letter) const
const int | indexOf (nxwidget_char_t letter, int startIndex) const
const int | indexOf (nxwidget_char_t letter, int startIndex, int count) const
const int | lastIndexOf (nxwidget_char_t letter) const
const int | lastIndexOf (nxwidget_char_t letter, int startIndex) const
const int | lastIndexOf (nxwidget_char_t letter, int startIndex, int count) const
CNxString * | subString (int startIndex) const
CNxString * | subString (int startIndex, int length) const
CNxString & | operator= (const CNxString &string)
CNxString & | operator= (const char *string)
CNxString & | operator= (nxwidget_char_t letter)
int | compareTo (const CNxString &string) const

## Private Attributes
CNxFont * | m_font
TNxArray< int > | m_linePositions
TNxArray< LongestLine > | m_longestLines
nxgl_coord_t | m_lineSpacing
int32_t | m_textPixelHeight
uint8_t | m_textPixelWidth
nxgl_coord_t | m_width

## Additional Inherited Members
Protected Member Functions inherited from NXWidgets::CNxString
void | allocateMemory (int chars, bool preserve)
bool | hasData (void) const
int | getAllocatedSize (void) const
FAR const nxwidget_char_t * | getCharArray (void) const
FAR nxwidget_char_t * | getCharPointer (const int index) const
Protected Attributes inherited from NXWidgets::CNxString
FAR nxwidget_char_t * | m_text

## Detailed Description

This class functions as a wrapper around a char array offering more advanced functionality - it can wrap text, calculate its height in pixels, calculate the width of a row, etc.

Definition at line 108 of file ctext.hxx.

## Constructor & Destructor Documentation

## ◆ CText()

CText::CText | ( | CNxFont * | font,
|  | const CNxString & | text,
|  | nxgl_coord_t | width
| ) |  |

Constructor.

Parameters

  font | The font to use for this text object.
  text | A string that this text object should wrap around.
  width | The pixel width at which the text should wrap.

Definition at line 100 of file ctext.cxx.

## ◆ ~CText()

virtual NXWidgets::CText::~CText | ( | void |  | ) |
| inlinevirtual

Destructor.

Definition at line 153 of file ctext.hxx.

## Member Function Documentation

## ◆ append()

void CText::append | ( | const CNxString & | text | ) |
| virtual

Append text to the end of the string.

Parameters

  text | String to append.

Definition at line 151 of file ctext.cxx.

## ◆ getFont()

CNxFont * CText::getFont | ( | void |  | ) | const

Get a pointer to the CText object's font.

Returns
  Pointer to the font.

Definition at line 323 of file ctext.cxx.

## ◆ getLineContainingCharIndex()

const int CText::getLineContainingCharIndex | ( | const int | index | ) | const

Get the index of the line of text that contains the specified index within the raw char array.

Parameters

  index | The index to locate within the wrapped lines of text.

Returns
  The number of the line of wrapped text that contains the specified index.

Definition at line 609 of file ctext.cxx.

## ◆ getLineCount()

const int NXWidgets::CText::getLineCount | ( | void |  | ) | const
| inline

Get the total number of lines in the text.

Returns
  The line count.

Definition at line 327 of file ctext.hxx.

## ◆ getLineHeight()

const uint8_t NXWidgets::CText::getLineHeight | ( | void |  | ) | const
| inline

Get the height in pixels of a line, given as the height of the font plus the line spacing.

Returns
  The height of a line.

Definition at line 316 of file ctext.hxx.

## ◆ getLineLength()

const int CText::getLineLength | ( | const int | lineNumber | ) | const

Get the number of characters in the specified line number.

Parameters

  lineNumber | The line number to check.

Returns
  The number of characters in the line.

Definition at line 240 of file ctext.cxx.

## ◆ getLinePixelLength()

const nxgl_coord_t CText::getLinePixelLength | ( | const int | lineNumber | ) | const

Get the width in pixels of the specified line number.

Parameters

  lineNumber | The line number to check.

Returns
  The pixel width of the line.

Definition at line 297 of file ctext.cxx.

## ◆ getLineSpacing()

const uint8_t NXWidgets::CText::getLineSpacing | ( | void |  | ) | const
| inline

Get the pixel spacing between each line of text.

Returns
  The line spacing.

Definition at line 304 of file ctext.hxx.

## ◆ getLineStartIndex()

const int NXWidgets::CText::getLineStartIndex | ( | const int | line | ) | const
| inline

Gets the index within the char array that represents the start of the line of text indicated by the line parameter.

Parameters

  line | The line number to locate within the char array.

Returns
  The index within the char array of the start of the supplied line.

Definition at line 382 of file ctext.hxx.

## ◆ getLineTrimmedLength()

const int CText::getLineTrimmedLength | ( | const int | lineNumber | ) | const

Get the number of characters in the specified line number, ignoring any trailing blank characters.

Parameters

  lineNumber | The line number to check.

Returns
  The number of characters in the line.

Definition at line 258 of file ctext.cxx.

## ◆ getLineTrimmedPixelLength()

const nxgl_coord_t CText::getLineTrimmedPixelLength | ( | const int | lineNumber | ) | const

Get the width in pixels of the specified line number, ignoring any trailing blank characters.

Parameters

  lineNumber | The line number to check.

Returns
  The pixel width of the line.

Definition at line 311 of file ctext.cxx.

## ◆ getPixelHeight()

const int32_t NXWidgets::CText::getPixelHeight | ( | void |  | ) | const
| inline

Get the total height of the text in pixels.

Returns
  The total height of the text.

Definition at line 282 of file ctext.hxx.

## ◆ getPixelWidth()

const uint8_t NXWidgets::CText::getPixelWidth | ( | void |  | ) | const
| inline

Get the width of the longest line in pixels.

Returns
  The width of the longest line.

Definition at line 293 of file ctext.hxx.

## ◆ insert()

void CText::insert | ( | const CNxString & | text,
|  | const int | index
| ) |  |
| virtual

Insert text at the specified character index.

Parameters

  text | The text to insert.
  index | The char index to insert at.

Definition at line 164 of file ctext.cxx.

## ◆ remove() [1/2]

void CText::remove | ( | const int | startIndex | ) |
| virtual

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

Parameters

  startIndex | The char index to start removing from.

Definition at line 176 of file ctext.cxx.

## ◆ remove() [2/2]

void CText::remove | ( | const int | startIndex,
|  | const int | count
| ) |  |
| virtual

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

Parameters

  startIndex | The char index to start removing from.
  count | The number of chars to remove.

Definition at line 189 of file ctext.cxx.

## ◆ setFont()

void CText::setFont | ( | CNxFont * | font | ) |

Set the font to use.

Parameters

  font | Pointer to the new font.

Definition at line 227 of file ctext.cxx.

## ◆ setLineSpacing()

void CText::setLineSpacing | ( | nxgl_coord_t | lineSpacing | ) |

Set the vertical spacing between rows of text.

Parameters

  lineSpacing | The line spacing.

Definition at line 202 of file ctext.cxx.

## ◆ setText() [1/3]

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

Set the text in the string.

Parameters

  text | Char array to use as the new data for this string.

Definition at line 115 of file ctext.cxx.

## ◆ setText() [2/3]

void CText::setText | ( | FAR const char * | text | ) |
| virtual

Set the text in the string.

Parameters

  text | Char array to use as the new data for this string.

Definition at line 127 of file ctext.cxx.

## ◆ setText() [3/3]

void CText::setText | ( | const nxwidget_char_t | text | ) |
| virtual

Set the text in the string.

Parameters

  text | Character to to use as the new data for this string.

Definition at line 139 of file ctext.cxx.

## ◆ setWidth()

void CText::setWidth | ( | nxgl_coord_t | width | ) |

Sets the pixel width of the text; text wider than this will automatically wrap.

Parameters

  width | Maximum pixel width of the text.

Definition at line 215 of file ctext.cxx.

## ◆ stripTopLines()

void CText::stripTopLines | ( | const int | lines | ) |

Removes lines of text from the start of the text buffer.

Parameters

  lines | Number of lines to remove

Definition at line 334 of file ctext.cxx.

## ◆ wrap() [1/2]

void CText::wrap | ( | void |  | ) |

Wrap all of the text.

Definition at line 358 of file ctext.cxx.

## ◆ wrap() [2/2]

void CText::wrap | ( | int | charIndex | ) |

Wrap the text from the line containing the specified char index onwards.

Parameters

  charIndex | The index of the char to start wrapping from; note that the wrapping function will re-wrap that entire line of text.

Definition at line 370 of file ctext.cxx.

## Member Data Documentation

## ◆ m_font

CNxFont* NXWidgets::CText::m_font
| private

Font to be used for output

Definition at line 123 of file ctext.hxx.

## ◆ m_linePositions

TNxArray<int> NXWidgets::CText::m_linePositions
| private

Array containing start indexes of each wrapped line

Definition at line 124 of file ctext.hxx.

## ◆ m_lineSpacing

nxgl_coord_t NXWidgets::CText::m_lineSpacing
| private

Spacing between lines of text

Definition at line 129 of file ctext.hxx.

## ◆ m_longestLines

TNxArray<LongestLine> NXWidgets::CText::m_longestLines
| private

Array containing data describing successively longer wrapped lines

Definition at line 126 of file ctext.hxx.

## ◆ m_textPixelHeight

int32_t NXWidgets::CText::m_textPixelHeight
| private

Total height of the wrapped text in pixels

Definition at line 130 of file ctext.hxx.

## ◆ m_textPixelWidth

uint8_t NXWidgets::CText::m_textPixelWidth
| private

Total width of the wrapped text in pixels

Definition at line 132 of file ctext.hxx.

## ◆ m_width

nxgl_coord_t NXWidgets::CText::m_width
| private

Width in pixels available t the text

Definition at line 134 of file ctext.hxx.

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

- ctext.hxx
- ctext.cxx