Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Examples

LCDBar.cpp

00001 #include "LCDBar.h"
00002 #include <sstream>
00003 #include <stdlib.h>
00004 
00005 using namespace std;
00006 
00007 LCDBar::LCDBar(const string &widgetType, const string &id, LCDElement *parent) : LCDWidget(id, parent, widgetType)
00008 {
00009   _length = 0;  
00010   _max = 100;
00011 }
00012 
00013 LCDBar::LCDBar(const string &widgetType, int length, int x, int y, const string &id, LCDElement *parent) : LCDWidget(id, parent, widgetType)
00014 {
00015   set(length, x, y);
00016 }
00017 
00018 void LCDBar::notifyChanged()
00019 {
00020   ostringstream params;
00021 
00022   params << _x
00023          << " "
00024          << _y
00025          << " "
00026          << _length;
00027 
00028   setWidgetParameters(params.str());
00029 }
00030 
00031 void LCDBar::set(int length, int x, int y)
00032 {
00033   _length = length;
00034   _x = x;
00035   _y =y;
00036   notifyChanged();
00037 }
00038 
00039 void LCDBar::setPercentage(int value)
00040 {
00041   _length = (value * _max) / 100;
00042   notifyChanged();
00043 }
00044 
00045 int LCDBar::getPercentage()
00046 {
00047   return ((_length * 100) / _max);
00048 
00049 }
00050 
00051 void LCDBar::setPercentageMax(int max)
00052 {
00053   _max = max;
00054 }
00055 
00056 void LCDBar::valueCallback(string value)
00057 {
00058   setPercentage(atoi(value.c_str()));
00059 }

Generated on Wed Aug 4 19:39:09 2004 for LCDApi by doxygen 1.3.6