ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Field.h
1 /*
2  * Copyright (C) 2012 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef Field_h
24 #define Field_h
25 
26 #include "Form.h"
27 
28 class Field {
29 public:
30  explicit Field(const String &label);
31  Field(Form &form, const String &label);
32  ~Field();
33 
34  Form *form() const { return _form; }
35 
36  virtual int dispatch(int event);
37 
38  virtual void enterField(bool reverse);
39  virtual void exitField();
40 
41  const String &label() const { return _label; }
42  void setLabel(const String &label);
43 
44  bool isCurrent() const;
45 
46 protected:
47  LiquidCrystal *lcd() const { return _form->_lcd; }
48 
49  virtual void updateCursor();
50 
51 private:
52  String _label;
53  Form *_form;
54  Field *next;
55  Field *prev;
56 
57  friend class Form;
58 };
59 
60 #endif
Manages a single data input/output field within a Form.
Definition: Field.h:28
Manager for a form containing data input/output fields.
Definition: Form.h:32
virtual void enterField(bool reverse)
Enters the field due to form navigation.
Definition: Field.cpp:116
Form * form() const
Returns the Form that owns this field; null if not associated with a Form.
Definition: Field.h:34
virtual int dispatch(int event)
Dispatches event via this field.
Definition: Field.cpp:96
const String & label() const
Returns the label to display in the first line of this field.
Definition: Field.h:41
LiquidCrystal * lcd() const
Returns the LCD that this field is being drawn on.
Definition: Field.h:47
Field(const String &label)
Constructs a new field with a specific label.
Definition: Field.cpp:40
virtual void exitField()
Exits the field due to form navigation.
Definition: Field.cpp:129
virtual void updateCursor()
Updates the cursor position after the label has been drawn by setLabel().
Definition: Field.cpp:191
void setLabel(const String &label)
Sets the label to display in the first line of this field.
Definition: Field.cpp:146
~Field()
Destroys this field and removes it from its owning Form.
Definition: Field.cpp:66
bool isCurrent() const
Returns true if this field is the currently-displayed field in its owning form; false otherwise...
Definition: Field.cpp:169