mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
189 lines
15 KiB
HTML
189 lines
15 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<title>ArduinoLibs: IntField.cpp Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body onload='searchBox.OnSelectItem(0);'>
|
|
<!-- Generated by Doxygen 1.7.4 -->
|
|
<script type="text/javascript"><!--
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
--></script>
|
|
<div id="top">
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">ArduinoLibs</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
<li id="searchli">
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">IntField.cpp</div> </div>
|
|
</div>
|
|
<div class="contents">
|
|
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
|
|
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2012 Southern Storm Software, Pty Ltd.</span>
|
|
<a name="l00003"></a>00003 <span class="comment"> *</span>
|
|
<a name="l00004"></a>00004 <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</span>
|
|
<a name="l00005"></a>00005 <span class="comment"> * copy of this software and associated documentation files (the "Software"),</span>
|
|
<a name="l00006"></a>00006 <span class="comment"> * to deal in the Software without restriction, including without limitation</span>
|
|
<a name="l00007"></a>00007 <span class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</span>
|
|
<a name="l00008"></a>00008 <span class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</span>
|
|
<a name="l00009"></a>00009 <span class="comment"> * Software is furnished to do so, subject to the following conditions:</span>
|
|
<a name="l00010"></a>00010 <span class="comment"> *</span>
|
|
<a name="l00011"></a>00011 <span class="comment"> * The above copyright notice and this permission notice shall be included</span>
|
|
<a name="l00012"></a>00012 <span class="comment"> * in all copies or substantial portions of the Software.</span>
|
|
<a name="l00013"></a>00013 <span class="comment"> *</span>
|
|
<a name="l00014"></a>00014 <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</span>
|
|
<a name="l00015"></a>00015 <span class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
|
|
<a name="l00016"></a>00016 <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
|
|
<a name="l00017"></a>00017 <span class="comment"> * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
|
|
<a name="l00018"></a>00018 <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span>
|
|
<a name="l00019"></a>00019 <span class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span>
|
|
<a name="l00020"></a>00020 <span class="comment"> * DEALINGS IN THE SOFTWARE.</span>
|
|
<a name="l00021"></a>00021 <span class="comment"> */</span>
|
|
<a name="l00022"></a>00022
|
|
<a name="l00023"></a>00023 <span class="preprocessor">#include "IntField.h"</span>
|
|
<a name="l00024"></a>00024
|
|
<a name="l00071"></a><a class="code" href="classIntField.html#a9df274c4100ed37d2d78738f09fc53b6">00071</a> <a class="code" href="classIntField.html#a9df274c4100ed37d2d78738f09fc53b6" title="Constructs a new integer field with a specific label.">IntField::IntField</a>(<span class="keyword">const</span> String &label)
|
|
<a name="l00072"></a>00072 : <a class="code" href="classField.html" title="Manages a single data input/output field within a Form.">Field</a>(label)
|
|
<a name="l00073"></a>00073 , _minValue(0)
|
|
<a name="l00074"></a>00074 , _maxValue(100)
|
|
<a name="l00075"></a>00075 , _stepValue(1)
|
|
<a name="l00076"></a>00076 , _value(0)
|
|
<a name="l00077"></a>00077 , _printLen(0)
|
|
<a name="l00078"></a>00078 {
|
|
<a name="l00079"></a>00079 }
|
|
<a name="l00080"></a>00080
|
|
<a name="l00088"></a><a class="code" href="classIntField.html#a10c9c958bcde276698f1f1f9bff949dd">00088</a> <a class="code" href="classIntField.html#a9df274c4100ed37d2d78738f09fc53b6" title="Constructs a new integer field with a specific label.">IntField::IntField</a>(<a class="code" href="classForm.html" title="Manager for a form containing data input/output fields.">Form</a> &form, <span class="keyword">const</span> String &label, <span class="keywordtype">int</span> minValue, <span class="keywordtype">int</span> maxValue, <span class="keywordtype">int</span> stepValue, <span class="keywordtype">int</span> value)
|
|
<a name="l00089"></a>00089 : <a class="code" href="classField.html" title="Manages a single data input/output field within a Form.">Field</a>(form, label)
|
|
<a name="l00090"></a>00090 , _minValue(minValue)
|
|
<a name="l00091"></a>00091 , _maxValue(maxValue)
|
|
<a name="l00092"></a>00092 , _stepValue(stepValue)
|
|
<a name="l00093"></a>00093 , _value(value)
|
|
<a name="l00094"></a>00094 , _printLen(0)
|
|
<a name="l00095"></a>00095 {
|
|
<a name="l00096"></a>00096 }
|
|
<a name="l00097"></a>00097
|
|
<a name="l00103"></a><a class="code" href="classIntField.html#a2b99fa19be6a0ed01ddc4939352b372e">00103</a> <a class="code" href="classIntField.html#a9df274c4100ed37d2d78738f09fc53b6" title="Constructs a new integer field with a specific label.">IntField::IntField</a>(<a class="code" href="classForm.html" title="Manager for a form containing data input/output fields.">Form</a> &form, <span class="keyword">const</span> String &label, <span class="keywordtype">int</span> minValue, <span class="keywordtype">int</span> maxValue, <span class="keywordtype">int</span> stepValue, <span class="keywordtype">int</span> value, <span class="keyword">const</span> String &suffix)
|
|
<a name="l00104"></a>00104 : <a class="code" href="classField.html" title="Manages a single data input/output field within a Form.">Field</a>(form, label)
|
|
<a name="l00105"></a>00105 , _minValue(minValue)
|
|
<a name="l00106"></a>00106 , _maxValue(maxValue)
|
|
<a name="l00107"></a>00107 , _stepValue(stepValue)
|
|
<a name="l00108"></a>00108 , _value(value)
|
|
<a name="l00109"></a>00109 , _printLen(0)
|
|
<a name="l00110"></a>00110 , _suffix(suffix)
|
|
<a name="l00111"></a>00111 {
|
|
<a name="l00112"></a>00112 }
|
|
<a name="l00113"></a>00113
|
|
<a name="l00114"></a><a class="code" href="classIntField.html#a01a17d5a89c76c42c4f0516984ce653f">00114</a> <span class="keywordtype">int</span> <a class="code" href="classIntField.html#a01a17d5a89c76c42c4f0516984ce653f" title="Dispatches event via this field.">IntField::dispatch</a>(<span class="keywordtype">int</span> event)
|
|
<a name="l00115"></a>00115 {
|
|
<a name="l00116"></a>00116 <span class="keywordflow">if</span> (event == LCD_BUTTON_UP) {
|
|
<a name="l00117"></a>00117 <a class="code" href="classIntField.html#aed421e2c52946f2c7643534b4f6f13f7" title="Sets the current value of this field.">setValue</a>(_value + _stepValue);
|
|
<a name="l00118"></a>00118 <span class="keywordflow">return</span> FORM_CHANGED;
|
|
<a name="l00119"></a>00119 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (event == LCD_BUTTON_DOWN) {
|
|
<a name="l00120"></a>00120 <a class="code" href="classIntField.html#aed421e2c52946f2c7643534b4f6f13f7" title="Sets the current value of this field.">setValue</a>(_value - _stepValue);
|
|
<a name="l00121"></a>00121 <span class="keywordflow">return</span> FORM_CHANGED;
|
|
<a name="l00122"></a>00122 }
|
|
<a name="l00123"></a>00123 <span class="keywordflow">return</span> -1;
|
|
<a name="l00124"></a>00124 }
|
|
<a name="l00125"></a>00125
|
|
<a name="l00126"></a><a class="code" href="classIntField.html#a51d9127b660e8dd7f87718acd230202a">00126</a> <span class="keywordtype">void</span> <a class="code" href="classIntField.html#a51d9127b660e8dd7f87718acd230202a" title="Enters the field due to form navigation.">IntField::enterField</a>(<span class="keywordtype">bool</span> reverse)
|
|
<a name="l00127"></a>00127 {
|
|
<a name="l00128"></a>00128 <a class="code" href="classIntField.html#a51d9127b660e8dd7f87718acd230202a" title="Enters the field due to form navigation.">Field::enterField</a>(reverse);
|
|
<a name="l00129"></a>00129 printValue();
|
|
<a name="l00130"></a>00130 }
|
|
<a name="l00131"></a>00131
|
|
<a name="l00198"></a><a class="code" href="classIntField.html#aed421e2c52946f2c7643534b4f6f13f7">00198</a> <span class="keywordtype">void</span> <a class="code" href="classIntField.html#aed421e2c52946f2c7643534b4f6f13f7" title="Sets the current value of this field.">IntField::setValue</a>(<span class="keywordtype">int</span> value)
|
|
<a name="l00199"></a>00199 {
|
|
<a name="l00200"></a>00200 <span class="keywordflow">if</span> (value < _minValue)
|
|
<a name="l00201"></a>00201 value = _minValue;
|
|
<a name="l00202"></a>00202 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (value > _maxValue)
|
|
<a name="l00203"></a>00203 value = _maxValue;
|
|
<a name="l00204"></a>00204 <span class="keywordflow">if</span> (value != _value) {
|
|
<a name="l00205"></a>00205 _value = <a class="code" href="classIntField.html#a2fb650827ce8cb4662253bb6c32acb52" title="Returns the current value of this field.">value</a>;
|
|
<a name="l00206"></a>00206 <span class="keywordflow">if</span> (<a class="code" href="classField.html#a25d86a67b321e8c642edf75a10a35f72" title="Returns true if this field is the currently-displayed field in its owning form; false otherwise...">isCurrent</a>())
|
|
<a name="l00207"></a>00207 printValue();
|
|
<a name="l00208"></a>00208 }
|
|
<a name="l00209"></a>00209 }
|
|
<a name="l00210"></a>00210
|
|
<a name="l00231"></a><a class="code" href="classIntField.html#a9324bba994389f3a4563d9c18bd2f1cd">00231</a> <span class="keywordtype">void</span> <a class="code" href="classIntField.html#a9324bba994389f3a4563d9c18bd2f1cd" title="Sets the suffix string to be displayed after the field's value.">IntField::setSuffix</a>(<span class="keyword">const</span> String &suffix)
|
|
<a name="l00232"></a>00232 {
|
|
<a name="l00233"></a>00233 _suffix = <a class="code" href="classIntField.html#a1a1de6a1836dfdb820c92b7f188a1b05" title="Returns the suffix string to be displayed after the field's value.">suffix</a>;
|
|
<a name="l00234"></a>00234 <span class="keywordflow">if</span> (<a class="code" href="classField.html#a25d86a67b321e8c642edf75a10a35f72" title="Returns true if this field is the currently-displayed field in its owning form; false otherwise...">isCurrent</a>())
|
|
<a name="l00235"></a>00235 printValue();
|
|
<a name="l00236"></a>00236 }
|
|
<a name="l00237"></a>00237
|
|
<a name="l00238"></a>00238 <span class="keywordtype">void</span> IntField::printValue()
|
|
<a name="l00239"></a>00239 {
|
|
<a name="l00240"></a>00240 String str(_value);
|
|
<a name="l00241"></a>00241 <span class="keywordflow">if</span> (_suffix.length())
|
|
<a name="l00242"></a>00242 str += _suffix;
|
|
<a name="l00243"></a>00243 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()->setCursor(0, 1);
|
|
<a name="l00244"></a>00244 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()->print(str);
|
|
<a name="l00245"></a>00245 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> len = str.length();
|
|
<a name="l00246"></a>00246 <span class="keywordflow">while</span> (len++ < _printLen)
|
|
<a name="l00247"></a>00247 <a class="code" href="classField.html#a5cf21bf958a71e51feac9e1bf9f599d1" title="Returns the LCD that this field is being drawn on.">lcd</a>()->write(<span class="charliteral">' '</span>);
|
|
<a name="l00248"></a>00248 _printLen = str.length();
|
|
<a name="l00249"></a>00249 }
|
|
</pre></div></div>
|
|
</div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerator</a></div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<hr class="footer"/><address class="footer"><small>Generated on Mon May 28 2012 20:55:50 for ArduinoLibs by 
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
|
|
</body>
|
|
</html>
|