Solo Controller Documentation 1.0
Documentation for the Solo Controller
 
Loading...
Searching...
No Matches
DynamicText Class Reference

Defines a simple text box for displaying dynamic text onto a Canvas. More...

#include <TextBox.h>

Public Types

enum  TextAlign { LEFT , CENTER , RIGHT }
 Enumeration used to specify text alignment within the DynamicText. More...
 

Public Member Functions

 DynamicText (Canvas &DestCanvas, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t baseline, FontList::FontID Font, TextAlign align=CENTER)
 DynamicText Constructor.
 
virtual void begin (void)
 Initializes the DynamicText. This method must be called before using calling DynamicText::update()
 
virtual void align (TextAlign align)
 Changes the text alignment. Takes effect after next call to DynamicText::update()
 
void update (const char *text, uint16_t textBuffSize)
 Updates the text inside a DynamicText.
 
void update (int value)
 Updates the numerical value (int) inside a DynamicText.
 

Public Attributes

const uint16_t X
 UL x position of the text box within _DestCanvas.
 
const uint16_t Y
 UL y position of the text box within _DestCanvas.
 
const uint16_t WIDTH
 Width of the text box within _DestCanvas.
 
const uint16_t HEIGHT
 Height of the text box within _DestCanvas.
 

Detailed Description

Defines a simple text box for displaying dynamic text onto a Canvas.

Before attempting to use this class, the caller must do two things. First the caller must fully initialize the font object provided to the DynamicText constructor. This means instantiating the GrFont object followed by a call to the GrFont::begin(), which loads and colorizes the fonts. Second, the caller must call the DynamicText::begin() method after object instantiation.

// Create Font
auto font = WorkSans_SemiBold_180();
font.begin(Red);
//Create and use DynamicText
auto myDynamicText = DynamicText(myCanvas, x0, y0, width, height, baseline, font);
myDynamicText.begin();
myDynamicText.update(value);
Font Definition.
#define Red
Definition TFTM070A1.h:58
DynamicText(Canvas &DestCanvas, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t baseline, FontList::FontID Font, TextAlign align=CENTER)
DynamicText Constructor.
Definition TextBox.h:87

Member Enumeration Documentation

◆ TextAlign

Enumeration used to specify text alignment within the DynamicText.

Enumerator
LEFT 
CENTER 
RIGHT 

Constructor & Destructor Documentation

◆ DynamicText()

DynamicText::DynamicText ( Canvas & DestCanvas,
uint16_t x,
uint16_t y,
uint16_t width,
uint16_t height,
uint16_t baseline,
FontList::FontID Font,
TextAlign align = CENTER )
inline

DynamicText Constructor.

Parameters
[in]DestCanvasCanvas that will 'display' the DynamicText
[in]xUL x-position of the DynamicText within Canvas
[in]yUL y-position of the DynamicText within Canvas
[in]widthWidth of the DynamicText in pixels
[in]heightHeight of the DynamicText in pixels
[in]baselinePosition of the font's baseline within the DynamicText
[in]FontGrFont object to be used
[in]alignAlignment of the text within the box. Defaults to DynamicText::CENTER.

Member Function Documentation

◆ align()

virtual void DynamicText::align ( TextAlign align)
inlinevirtual

Changes the text alignment. Takes effect after next call to DynamicText::update()

Parameters
[in]alignText alignment

◆ begin()

void DynamicText::begin ( void )
virtual

Initializes the DynamicText. This method must be called before using calling DynamicText::update()

Parameters
None.

◆ update() [1/2]

void DynamicText::update ( const char * text,
uint16_t textBuffSize )

Updates the text inside a DynamicText.

Parameters
[in]textNull-terminated character array containing the text
[in]textBuffSizeNumber of characters in text

◆ update() [2/2]

void DynamicText::update ( int value)

Updates the numerical value (int) inside a DynamicText.

Parameters
[in]valueValue to be written to DynamicText

Member Data Documentation

◆ HEIGHT

const uint16_t DynamicText::HEIGHT

Height of the text box within _DestCanvas.

◆ WIDTH

const uint16_t DynamicText::WIDTH

Width of the text box within _DestCanvas.

◆ X

const uint16_t DynamicText::X

UL x position of the text box within _DestCanvas.

◆ Y

const uint16_t DynamicText::Y

UL y position of the text box within _DestCanvas.


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