ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Friends | List of all members
Field Class Reference

Manages a single data input/output field within a Form. More...

#include <Field.h>

Inheritance diagram for Field:
BoolField IntField ListField TextField TimeField

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...
 
Formform () 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
 

Detailed Description

Manages a single data input/output field within a Form.

See Also
Form, BoolField, IntField, ListField, TextField, TimeField

Definition at line 28 of file Field.h.

Constructor & Destructor Documentation

Field::Field ( const String &  label)
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().

See Also
Form::addField()

Definition at line 40 of file Field.cpp.

Field::~Field ( )

Destroys this field and removes it from its owning Form.

See Also
Form::removeField()

Definition at line 66 of file Field.cpp.

Member Function Documentation

int Field::dispatch ( int  event)
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.

See Also
Form::dispatch(), LCD::getButton()

Reimplemented in ListField, TimeField, IntField, and BoolField.

Definition at line 96 of file Field.cpp.

void Field::enterField ( bool  reverse)
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().

See Also
exitField()

Reimplemented in ListField, TimeField, IntField, BoolField, and TextField.

Definition at line 116 of file Field.cpp.

void Field::exitField ( )
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.

See Also
enterField()

Reimplemented in TimeField.

Definition at line 129 of file Field.cpp.

bool Field::isCurrent ( ) const

Returns true if this field is the currently-displayed field in its owning form; false otherwise.

This function should be called from property setters in subclasses to determine if the screen should be updated when a property is modified.

Definition at line 169 of file Field.cpp.

const String & Field::label ( ) const
inline

Returns the label to display in the first line of this field.

See Also
setLabel()

Definition at line 41 of file Field.h.

void Field::setLabel ( const String &  label)

Sets the label to display in the first line of this field.

See Also
label()

Definition at line 146 of file Field.cpp.

void Field::updateCursor ( )
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.

See Also
setLabel()

Definition at line 191 of file Field.cpp.


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