00001 #include "LCDFrame.h" 00002 #include <sstream> 00003 00004 using namespace std; 00005 00006 LCDFrame::LCDFrame(LCDElement *parent, const string &id) : LCDWidget(id, parent, "frame") 00007 { 00008 } 00009 00010 void LCDFrame::set(int left, int top, int right, int bottom, int width, int height, Direction direction, int speed) 00011 { 00012 _left = left; 00013 _top = top; 00014 _right = right; 00015 _bottom = bottom; 00016 _width = width; 00017 _height = height; 00018 _direction = direction; 00019 _speed = speed; 00020 00021 notifyChanged(); 00022 } 00023 void LCDFrame::notifyChanged() 00024 { 00025 ostringstream params; 00026 00027 params << _left 00028 << " " 00029 << _top 00030 << " " 00031 << _right 00032 << " " 00033 << _bottom 00034 << " " 00035 << _width 00036 << " " 00037 << _height 00038 << " " 00039 << (char)_direction 00040 << " " 00041 << _speed; 00042 00043 setWidgetParameters(params.str()); 00044 } 00045 00046 void LCDFrame::sendCommand(const std::string &cmd, const std::string ¶meters) 00047 { 00048 if (_parent) 00049 { 00050 string realParams; 00051 if (cmd == "widget_add") 00052 { 00053 if (parameters == "frame") 00054 { 00055 realParams = _id + " " + parameters; 00056 } 00057 else 00058 { 00059 realParams = parameters + " " + "-in " + _id; 00060 } 00061 } 00062 else 00063 { 00064 realParams = parameters; 00065 } 00066 _parent->sendCommand(cmd, realParams); 00067 } 00068 else 00069 { 00070 _commandBuffer.push_back(Command(cmd, parameters)); 00071 } 00072 }