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

The keyboard widget shows character-labeled keys. More...

#include <PHNKeyboard.h>

Inheritance diagram for PHN_Keyboard:
PHN_Widget PHN_WidgetContainer

Public Member Functions

 PHN_Keyboard ()
 Initializes a new Keyboard.
 
void setDimension (int columns, int rows)
 Sets the amount of columns and rows in the grid.
 
void setSpacing (int spacing)
 Sets the horizontal and vertical spacing between buttons.
 
void setSpacing (int spacingW, int spacingH)
 Sets the horizontal and vertical spacing between buttons.
 
void setKeys (const char *keyChars)
 Sets all the character keys to display.
 
void addKeys (const char *keyChars)
 Adds a new keyboard format selectable using the key.
 
void addKeys (const char *formatName, const char *keyChars)
 Adds a new keyboard format selectable using the key.
 
void clearKeys ()
 Clears all key formats added.
 
int formatIndex () const
 Gets the currently used format index.
 
void setFormatIndex (int index)
 Sets the currently used format index.
 
void nextFormat ()
 Switches the keyboard to the next key format.
 
char key (int index)
 Obtains the character for a given key index.
 
int clickedIndex () const
 Obtains the key character index clicked, -1 when there is none.
 
char clickedKey ()
 Obtains the key character clicked, NULL when there is none.
 
virtual void undraw (void)
 Clear draw function routine, where widgets perform un-drawing (to background)
 
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.
 
- 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.
 

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

The keyboard widget shows character-labeled keys.

This widget can show a keyboard layout with a single character clickable on every key. The user can press and release on a key to initiate a key-press. This functionality can be useful to add a field where the user can enter text or numeric input.

This keyboard supports multiple formats. You can add multiple key layout using addKeys() also specifying the name of the format. By adding '\f' keys to the layout, the user can switch layouts using the keyboard. In place of these keys, the next format to switch to is displayed. For simple operation it is sufficient to use setKeys() with the character mapping to use, ignoring the multi-format support.

Setup the dimension, spacing and keys of this widget before use. For key buttons spanning multiple keys, use the same character in a row in the key mapping.


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