ArduinoLibs
|
Field that manages the input of an integer value. More...
#include <IntField.h>
Public Member Functions | |
IntField (const String &label) | |
Constructs a new integer field with a specific label. More... | |
IntField (Form &form, const String &label, int minValue, int maxValue, int stepValue, int value) | |
Constructs a new integer field with a specific label, minValue, maxValue, stepValue, and value, and attaches it to a form. More... | |
IntField (Form &form, const String &label, int minValue, int maxValue, int stepValue, int value, const String &suffix) | |
Constructs a new integer field with a specific label, minValue, maxValue, stepValue, value, and suffix and attaches it to a form. | |
int | dispatch (int event) |
Dispatches event via this field. More... | |
void | enterField (bool reverse) |
Enters the field due to form navigation. More... | |
int | minValue () const |
Returns the minimum value for the input field. More... | |
void | setMinValue (int value) |
Sets the minimum value for the input field. More... | |
int | maxValue () const |
Returns the maximum value for the input field. More... | |
void | setMaxValue (int value) |
Sets the maximum value for the input field. More... | |
int | stepValue () const |
Returns the step value to use when increasing or decreasing the value() due to Up and Down button presses. More... | |
void | setStepValue (int value) |
Sets the step value value to use when increasing or decreasing the value() due to Up and Down button presses. More... | |
int | value () const |
Returns the current value of this field. More... | |
void | setValue (int value) |
Sets the current value of this field. More... | |
const String & | suffix () const |
Returns the suffix string to be displayed after the field's value. More... | |
void | setSuffix (const String &suffix) |
Sets the suffix string to be displayed after the field's value. More... | |
Public Member Functions inherited from Field | |
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 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... | |
Additional Inherited Members | |
Protected Member Functions inherited from Field | |
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... | |
Field that manages the input of an integer value.
IntField is intended for field values that are modifiable by the user. Pressing Up adds stepValue() to the current value and pressing Down subtracts stepValue() from the current value. The value is clamped to the range minValue() to maxValue().
The following example creates an integer field with the label "Iterations", that ranges between 1 and 5, with a stepValue() of 1, and an initial default value() of 2:
IntField can be configured to show a suffix() on the screen after the integer value(). This is intended for communicating the units in which the value is expressed. For example:
Use TextField for read-only fields that report integer values but which are not modifiable by the user.
Definition at line 28 of file IntField.h.
|
explicit |
Constructs a new integer 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().
Initially, value() is 0, minValue() is 0, maxValue() is 100, stepValue() is 1, and suffix() is an empty string.
Definition at line 71 of file IntField.cpp.
IntField::IntField | ( | Form & | form, |
const String & | label, | ||
int | minValue, | ||
int | maxValue, | ||
int | stepValue, | ||
int | value | ||
) |
Constructs a new integer field with a specific label, minValue, maxValue, stepValue, and value, and attaches it to a form.
The suffix() is initially set to an empty string.
Definition at line 88 of file IntField.cpp.
|
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 from Field.
Definition at line 114 of file IntField.cpp.
|
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 from Field.
Definition at line 126 of file IntField.cpp.
|
inline |
Returns the maximum value for the input field.
Definition at line 41 of file IntField.h.
|
inline |
Returns the minimum value for the input field.
Definition at line 38 of file IntField.h.
|
inline |
Sets the maximum value for the input field.
The new maximum value will be used to clamp the field's value the next time setValue() is called.
Definition at line 42 of file IntField.h.
|
inline |
Sets the minimum value for the input field.
The new minimum value will be used to clamp the field's value the next time setValue() is called.
Definition at line 39 of file IntField.h.
|
inline |
Sets the step value value to use when increasing or decreasing the value() due to Up and Down button presses.
Definition at line 45 of file IntField.h.
void IntField::setSuffix | ( | const String & | suffix | ) |
Sets the suffix string to be displayed after the field's value.
Suffixes are typically used to indicate the units that the value() is expressed in. For example:
Definition at line 231 of file IntField.cpp.
void IntField::setValue | ( | int | value | ) |
Sets the current value of this field.
The value will be clamped to the range defined by minValue() and maxValue().
Definition at line 198 of file IntField.cpp.
|
inline |
Returns the step value to use when increasing or decreasing the value() due to Up and Down button presses.
Definition at line 44 of file IntField.h.
|
inline |
Returns the suffix string to be displayed after the field's value.
Definition at line 50 of file IntField.h.
|
inline |
Returns the current value of this field.
Definition at line 47 of file IntField.h.