ArduinoLibs
Main Page
Related Pages
Modules
Classes
Files
File List
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
libraries
LCD
Field.cpp
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
#include "Field.h"
24
40
Field::Field
(
const
String &label)
41
: _label(label)
42
, _form(0)
43
, next(0)
44
, prev(0)
45
{
46
}
47
52
Field::Field
(
Form
&form,
const
String &label)
53
: _label(label)
54
, _form(0)
55
, next(0)
56
, prev(0)
57
{
58
form.
addField
(
this
);
59
}
60
66
Field::~Field
()
67
{
68
if
(_form)
69
_form->
removeField
(
this
);
70
}
71
96
int
Field::dispatch
(
int
event)
97
{
98
// Nothing to do here.
99
return
-1;
100
}
101
116
void
Field::enterField
(
bool
reverse)
117
{
118
lcd
()->print(_label);
119
}
120
129
void
Field::exitField
()
130
{
131
// Nothing to do here.
132
}
133
146
void
Field::setLabel
(
const
String &label)
147
{
148
if
(
isCurrent
()) {
149
unsigned
int
prevLen = _label.length();
150
unsigned
int
newLen = label.length();
151
_label =
label
;
152
lcd
()->setCursor(0, 0);
153
lcd
()->print(label);
154
while
(newLen++ < prevLen)
155
lcd
()->write(
' '
);
156
updateCursor
();
157
}
else
{
158
_label =
label
;
159
}
160
}
161
169
bool
Field::isCurrent
()
const
170
{
171
if
(!_form->
isVisible
())
172
return
false
;
173
return
_form->
currentField
() ==
this
;
174
}
175
191
void
Field::updateCursor
()
192
{
193
// Nothing to do here.
194
}
Generated on Sun Sep 29 2013 09:30:46 for ArduinoLibs by
1.8.1.2