ArduinoLibs
|
Manages a single data input/output field within a Form. More...
#include <Field.h>
Public Member Functions | |
Field (const String &label) | |
Constructs a new field with a specific label. More... | |
Field (Form &form, const String &label) | |
Constructs a new field with a specific label and attaches it to a form. | |
~Field () | |
Destroys this field and removes it from its owning Form. More... | |
Form * | form () const |
Returns the Form that owns this field; null if not associated with a Form. | |
virtual int | dispatch (int event) |
Dispatches event via this field. More... | |
virtual void | enterField (bool reverse) |
Enters the field due to form navigation. More... | |
virtual void | exitField () |
Exits the field due to form navigation. More... | |
const String & | label () const |
Returns the label to display in the first line of this field. More... | |
void | setLabel (const String &label) |
Sets the label to display in the first line of this field. More... | |
bool | isCurrent () const |
Returns true if this field is the currently-displayed field in its owning form; false otherwise. More... | |
Protected Member Functions | |
LiquidCrystal * | lcd () const |
Returns the LCD that this field is being drawn on. | |
virtual void | updateCursor () |
Updates the cursor position after the label has been drawn by setLabel(). More... | |
Friends | |
class | Form |
Manages a single data input/output field within a Form.
|
explicit |
Constructs a new field with a specific label.
The field is initially not associated with a Form. The field can be added to a form later using Form::addField().
Field::~Field | ( | ) |
Destroys this field and removes it from its owning Form.
|
virtual |
Dispatches event via this field.
The event is usually obtained from LCD::getButton().
Returns zero if the event has been handled and no further action is required.
Returns FORM_CHANGED if the event has changed the value of this field in a manner that may require the application to take further action based on the new field value.
Returns -1 if the event is not handled by this field, and should be handled by the Form itself (particularly for Left and Right buttons). The default implementation returns -1 for all events.
Reimplemented in ListField, TimeField, IntField, and BoolField.
|
virtual |
Enters the field due to form navigation.
This function is typically called when the user presses Left and Right buttons to navigate to the field. If reverse is true, then navigation was due to the Left button being pressed.
This function can assume that the display has been cleared and the cursor is positioned at (0, 0).
The default implementation prints the label().
Reimplemented in ListField, TimeField, IntField, BoolField, and TextField.
|
virtual |
Exits the field due to form navigation.
This function is typically called when the user presses Left and Right buttons to navigate from the field.
Reimplemented in TimeField.
bool Field::isCurrent | ( | ) | const |
|
inline |
Returns the label to display in the first line of this field.
void Field::setLabel | ( | const String & | label | ) |
|
protectedvirtual |
Updates the cursor position after the label has been drawn by setLabel().
The default implementation does nothing. Subclasses that use an LCD cursor may override this to ensure that the cursor position stays valid after the label is modified.