00001 #include "LCDScroller.h" 00002 #include <sstream> 00003 #include <string> 00004 00005 using namespace std; 00006 00007 LCDScroller::LCDScroller(LCDElement *parent, const string &id) : LCDWidget(id, parent, "scroller") 00008 { 00009 _x = 1; 00010 _bottom = 1; 00011 _y = 1; 00012 _right = 10; 00013 _speed = 8; 00014 _direction = Horizontal; 00015 } 00016 00017 void LCDScroller::notifyChanged() 00018 { 00019 ostringstream params; 00020 00021 params << _x 00022 << " " 00023 << _y 00024 << " " 00025 << _right 00026 << " " 00027 << _bottom 00028 << " " 00029 << (char)_direction 00030 << " " 00031 << _speed 00032 << " \"" 00033 << _text 00034 << '"'; 00035 00036 setWidgetParameters(params.str()); 00037 } 00038 00039 void LCDScroller::set(const string &text, int left, int top, int right, int bottom, int speed, Direction direction) 00040 { 00041 _text = text; 00042 _x = left; 00043 _y = top; 00044 _right = right; 00045 _bottom = bottom; 00046 _speed = speed; 00047 _direction = direction; 00048 notifyChanged(); 00049 } 00050 00051 void LCDScroller::setText(const string &text) 00052 { 00053 _text = text; 00054 notifyChanged(); 00055 } 00056 string LCDScroller::getText() 00057 { 00058 return _text; 00059 } 00060 void LCDScroller::setWidth(int width) 00061 { 00062 _right = _x + width - 1; 00063 notifyChanged(); 00064 } 00065 void LCDScroller::setHeight(int height) 00066 { 00067 _bottom = _y + height - 1; 00068 notifyChanged(); 00069 } 00070 void LCDScroller::setSpeed(int speed) 00071 { 00072 _speed = speed; 00073 notifyChanged(); 00074 } 00075 00076 void LCDScroller::valueCallback(std::string value) 00077 { 00078 setText(value); 00079 }