Phoenard
Public Member Functions | List of all members
PHN_TextBox Class Reference

Shows an area of text that allows selections and dynamic editing. More...

#include <PHNTextBox.h>

Inheritance diagram for PHN_TextBox:
PHN_Widget PHN_TextContainer PHN_WidgetContainer

Public Member Functions

 PHN_TextBox (void)
 Initializes some defaults.
 
void setDimension (int columns, int rows)
 Updates the width and height of the textbox to fit the columns and rows specified.
 
void setTextSize (int size)
 Sets the font size of the text.
 
void setMaxLength (int length)
 Sets the maximum length of the text that can be displayed.
 
const int maxLength ()
 Gets the maximum length of the text that can be displayed.
 
int textSize (void)
 Gets the font size of the text.
 
void showScrollbar (bool visible)
 Sets whether the scrollbar is displayed.
 
void showBackspace (bool visible)
 Sets whether a button to perform a backspace is displayed.
 
void showCursor (bool visible)
 Sets whether the cursor is displayed.
 
PHN_Scrollbarscrollbar (void)
 Gets the scrollbar widget used to scroll text.
 
bool ensureVisible (int charPosition)
 Ensures the character specified is displayed.
 
int selectionStart (void)
 Gets the start of the user selection.
 
int selectionLength (void)
 Gets the length of the user selection.
 
void setSelectionRange (int position, int length)
 Sets up a new selection range for the user.
 
void setSelection (const char *text)
 Replaces the selected text with the text specified.
 
void setSelection (char character)
 Replaces the selected text with the character specified.
 
void backspace (void)
 Performs a backspace, deleting the selection or character before the cursor.
 
void invalidate (int startPosition)
 Invalidates the text starting from a position.
 
void invalidate (int startPosition, int endPosition)
 Invalidates the text between two positions.
 
virtual void setTextRaw (const char *text, int textLen)
 Sets the new text to display using a buffer and length.
 
virtual int textLength (void)
 Gets the length of the text displayed.
 
virtual const char * text (void)
 Gets the text displayed.
 
virtual void update (void)
 Update function routine, where widget logic must be performed.
 
virtual void draw (void)
 Draw function routine, where widgets must perform drawing.
 
- Public Member Functions inherited from PHN_Widget
 PHN_Widget ()
 Constructor for a new widget, initializing all fields to the default values.
 
virtual ~PHN_Widget ()
 Destructor for a widget, clearing any child widgets and freeing memory.
 
const int getX (void)
 Gets the x-coordinate of the widget.
 
const int getY (void)
 Gets the y-coordinate of the widget.
 
const int getWidth (void)
 Gets the width of the widget.
 
const int getHeight (void)
 Gets the height of the widget.
 
void setBounds (int x, int y, int width, int height)
 Sets the new bounds (x, y, width, height) of the widget.
 
void setSize (int width, int height)
 Sets the size (width, height) of the widget.
 
virtual void setColor (int colorId, color_t color)
 Sets a style color for this widget. More...
 
const color_t color (int colorId)
 Gets a style color set for this widget. More...
 
bool isTouched ()
 Gets whether the widget is touched down by the user.
 
bool isTouchEnter ()
 Gets whether the user's touch input entered the widget.
 
bool isTouchLeave ()
 Gets whether the user's touch input left the widget.
 
bool isTouchChange ()
 Gets whether the user clicked, entered or left the widget.
 
bool isClicked ()
 Gets whether the user clicked (pressed and released) the widget.
 
void setVisible (bool visible)
 Sets whether the widget is displayed and updated.
 
bool isVisible (void)
 Gets whether the widget is displayed and updated.
 
bool isDrawn (void)
 Gets whether the widget has been drawn.
 
void setDrawingEnabled (bool drawing)
 Sets whether the widget is drawn and undrawn.
 
bool isDrawingEnabled (void)
 Gets whether the widget is drawn and undrawn.
 
void invalidate (void)
 Invalidated the widget, causing it to be re-drawn at a later time.
 
bool isInvalidated (void)
 Checks whether the widget is invalidated and needs to be redrawn.
 
void draw_validate ()
 Draws the widget if invalidated, clearing the invalidated state.
 
virtual void undraw (void)
 Clear draw function routine, where widgets perform un-drawing (to background)
 
- Public Member Functions inherited from PHN_WidgetContainer
 PHN_WidgetContainer (void)
 Constructor for a new widget container.
 
void updateWidgets (bool update, bool draw, bool forceRedraw)
 Updates all the widgets contained. More...
 
void addWidget (PHN_Widget &widget)
 Adds a single widget. More...
 
void removeWidget (PHN_Widget &widget)
 Removes a single widget. More...
 
void clearWidgets ()
 Removes all contained widgets. More...
 
PHN_Widgetwidget (int index)
 Gets the widget stored at an index.
 
const int widgetCount ()
 Gets how many widgets are stored.
 
- Public Member Functions inherited from PHN_TextContainer
void setText (String textString)
 Sets the new text to display using an Arduino type String.
 
void setText (int valueText)
 Sets the new text to display using an integer value.
 
void setText (long valueText)
 Sets the new text to display using a long value.
 
void setText (double valueText)
 Sets the new text to display using a float value.
 
void setText (const char *text)
 Sets the new text to display using a null-terminated String.
 
void clearText ()
 Clears all the text, setting it to an Empty String.
 

Additional Inherited Members

- Protected Member Functions inherited from PHN_WidgetContainer
void clearSilent ()
 Removes all child widgets from this container without handling proper redrawing. More...
 
void setWidgetCapacity (int capacity)
 Resizes the internal array of widgets to a new capacity. More...
 
- Protected Attributes inherited from PHN_Widget
PHN_Palette colors
 A palette of colors set for the widget.
 
unsigned char visible
 Draw state flags of the widget (0=invisible, 0x1=visible, 0x2=drawn, 0x4=draw_disabled)
 
bool invalidated
 Invalidated state of the widget.
 
int x
 
int y
 
int width
 
int height
 
- Protected Attributes inherited from PHN_WidgetContainer
bool deleteAddedWidgets
 Sets whether added widgets are deleted (were added with new)
 

Detailed Description

Shows an area of text that allows selections and dynamic editing.

Call showScrollbar(bool), setTextSize(int) before use. This makes sure all the styling is set up correctly. You can then proceed to set the text and display it. You can make use of setSelection(const char*) to insert or replace the selections the user has set in the field.

The amount of columns and rows displayed is automatically calculated from the bounds. To make it easier to specify the bounds to fit the text, you can make use of setDimension(int, int). It automatically calculates the width and height to fit the text. Make sure you have set the text size earlier, otherwise the results are unpredictable.


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