Library for 3.2'' uLcd Picaso Display4D system Picaso Serial Environment Command Set web: http://www.4dsystems.com.au/product/20/67/Processors_Graphics/PICASO/

Committer:
adelino
Date:
Sun Jul 06 10:36:27 2014 +0000
Revision:
0:65fd8b1cbf86
Library to communicate and draw on an LCD

Who changed what in which revision?

UserRevisionLine numberNew contents of line
adelino 0:65fd8b1cbf86 1
adelino 0:65fd8b1cbf86 2 #include "ObjetGraphic.h"
adelino 0:65fd8b1cbf86 3
adelino 0:65fd8b1cbf86 4 PicasoSerial* ps=0;
adelino 0:65fd8b1cbf86 5
adelino 0:65fd8b1cbf86 6 Screen::Screen(PicasoSerial* serial,UINT16 _x,UINT16 _y,UINT16 _w,UINT16 _h,Color _colorBkg):
adelino 0:65fd8b1cbf86 7 myXpos(_x),myYpos(_y),myWidth(_w),myHeight(_h),myColorBkg(_colorBkg)
adelino 0:65fd8b1cbf86 8 {
adelino 0:65fd8b1cbf86 9 mySerial=serial;
adelino 0:65fd8b1cbf86 10 }
adelino 0:65fd8b1cbf86 11 //------------------------------------
adelino 0:65fd8b1cbf86 12 Screen::~Screen(void)
adelino 0:65fd8b1cbf86 13 {
adelino 0:65fd8b1cbf86 14 ps=0;
adelino 0:65fd8b1cbf86 15
adelino 0:65fd8b1cbf86 16 for(int i=0; i<myVectorObjet.size(); i++) {
adelino 0:65fd8b1cbf86 17 delete myVectorObjet[i];
adelino 0:65fd8b1cbf86 18 myVectorObjet[i]=0;
adelino 0:65fd8b1cbf86 19 }
adelino 0:65fd8b1cbf86 20 }
adelino 0:65fd8b1cbf86 21 //------------------------------------
adelino 0:65fd8b1cbf86 22 UINT16 Screen::getXpos(void)
adelino 0:65fd8b1cbf86 23 {
adelino 0:65fd8b1cbf86 24 return this->myXpos;
adelino 0:65fd8b1cbf86 25 }
adelino 0:65fd8b1cbf86 26 //----------------------------------
adelino 0:65fd8b1cbf86 27 UINT16 Screen::getYpos(void)
adelino 0:65fd8b1cbf86 28 {
adelino 0:65fd8b1cbf86 29 return this->myYpos;
adelino 0:65fd8b1cbf86 30 }
adelino 0:65fd8b1cbf86 31 //------------------------------------
adelino 0:65fd8b1cbf86 32 UINT16 Screen::getWidth(void)
adelino 0:65fd8b1cbf86 33 {
adelino 0:65fd8b1cbf86 34 return this->myWidth;
adelino 0:65fd8b1cbf86 35 }
adelino 0:65fd8b1cbf86 36 //-------------------------------------
adelino 0:65fd8b1cbf86 37 UINT16 Screen::getHeight(void)
adelino 0:65fd8b1cbf86 38 {
adelino 0:65fd8b1cbf86 39 return this->myHeight;
adelino 0:65fd8b1cbf86 40 }
adelino 0:65fd8b1cbf86 41 //------------------------------------
adelino 0:65fd8b1cbf86 42 void Screen::drawObj(ObjetHeader* pObj)
adelino 0:65fd8b1cbf86 43 {
adelino 0:65fd8b1cbf86 44 pObj->draw();
adelino 0:65fd8b1cbf86 45
adelino 0:65fd8b1cbf86 46 }
adelino 0:65fd8b1cbf86 47 //------------------------------------
adelino 0:65fd8b1cbf86 48 void Screen::drawAll(void)
adelino 0:65fd8b1cbf86 49 {
adelino 0:65fd8b1cbf86 50 mySerial->draw_filled_rectangle(myXpos,myYpos,myXpos+myWidth,myYpos+myHeight,myColorBkg);
adelino 0:65fd8b1cbf86 51
adelino 0:65fd8b1cbf86 52 //
adelino 0:65fd8b1cbf86 53 for(int i=0; i<myVectorObjet.size(); i++) {
adelino 0:65fd8b1cbf86 54 drawObj(myVectorObjet[i]);
adelino 0:65fd8b1cbf86 55 }
adelino 0:65fd8b1cbf86 56 }
adelino 0:65fd8b1cbf86 57 //-------------------------------------
adelino 0:65fd8b1cbf86 58 void Screen::drawCells(void)
adelino 0:65fd8b1cbf86 59 {
adelino 0:65fd8b1cbf86 60 for(int i=1; i<3; i++) {
adelino 0:65fd8b1cbf86 61 mySerial->draw_line(80*i,0,80*i,320,BLACK);
adelino 0:65fd8b1cbf86 62 }
adelino 0:65fd8b1cbf86 63 //
adelino 0:65fd8b1cbf86 64 for(int i=1; i<4; i++) {
adelino 0:65fd8b1cbf86 65 mySerial->draw_line(0,80*i,240,80*i,BLACK);
adelino 0:65fd8b1cbf86 66 }
adelino 0:65fd8b1cbf86 67
adelino 0:65fd8b1cbf86 68 }
adelino 0:65fd8b1cbf86 69 //-------------------------------------
adelino 0:65fd8b1cbf86 70 void Screen::addObj(ObjetHeader* pObj)
adelino 0:65fd8b1cbf86 71 {
adelino 0:65fd8b1cbf86 72 myVectorObjet.push_back(pObj);
adelino 0:65fd8b1cbf86 73 }
adelino 0:65fd8b1cbf86 74 //---------------------------------------
adelino 0:65fd8b1cbf86 75 PicasoSerial* Screen::getPicasoSerial(void)
adelino 0:65fd8b1cbf86 76 {
adelino 0:65fd8b1cbf86 77 return mySerial;
adelino 0:65fd8b1cbf86 78 }
adelino 0:65fd8b1cbf86 79 //---------------------------------------
adelino 0:65fd8b1cbf86 80 Color Screen::getColorBkg(void)
adelino 0:65fd8b1cbf86 81 {
adelino 0:65fd8b1cbf86 82 return myColorBkg;
adelino 0:65fd8b1cbf86 83 }
adelino 0:65fd8b1cbf86 84 //--------------------------------------
adelino 0:65fd8b1cbf86 85 bool Screen::isContent(ObjetHeader* pObj, UINT16 _x,UINT16 _y)
adelino 0:65fd8b1cbf86 86 {
adelino 0:65fd8b1cbf86 87 UINT16 xd=pObj->getXpos();
adelino 0:65fd8b1cbf86 88 UINT16 w=pObj->getWidth();
adelino 0:65fd8b1cbf86 89 UINT16 xf=xd+w;
adelino 0:65fd8b1cbf86 90
adelino 0:65fd8b1cbf86 91 UINT16 yd=pObj->getYpos();
adelino 0:65fd8b1cbf86 92 UINT16 h=pObj->getHeight();
adelino 0:65fd8b1cbf86 93 UINT16 yf=yd+h;
adelino 0:65fd8b1cbf86 94
adelino 0:65fd8b1cbf86 95 if(_x >= xd && _x<= xf && _y>=yd && _y<= yf) {
adelino 0:65fd8b1cbf86 96 return true;
adelino 0:65fd8b1cbf86 97 }
adelino 0:65fd8b1cbf86 98
adelino 0:65fd8b1cbf86 99 return false;
adelino 0:65fd8b1cbf86 100
adelino 0:65fd8b1cbf86 101 }
adelino 0:65fd8b1cbf86 102 //-------------------------------------
adelino 0:65fd8b1cbf86 103 ObjetHeader* Screen::getObjetPosition(UINT16 _x,UINT16 _y)
adelino 0:65fd8b1cbf86 104 {
adelino 0:65fd8b1cbf86 105
adelino 0:65fd8b1cbf86 106 if(myVectorObjet.size()==0)
adelino 0:65fd8b1cbf86 107 return NULL;
adelino 0:65fd8b1cbf86 108
adelino 0:65fd8b1cbf86 109 //
adelino 0:65fd8b1cbf86 110 for(int i=0; i<myVectorObjet.size(); i++) {
adelino 0:65fd8b1cbf86 111 if(isContent(myVectorObjet[i],_x,_y))
adelino 0:65fd8b1cbf86 112 return myVectorObjet[i];
adelino 0:65fd8b1cbf86 113 }
adelino 0:65fd8b1cbf86 114 return NULL;
adelino 0:65fd8b1cbf86 115 }
adelino 0:65fd8b1cbf86 116 //-------------------------------------
adelino 0:65fd8b1cbf86 117 ObjetHeader* Screen::getObjetById(UINT16 _id)
adelino 0:65fd8b1cbf86 118 {
adelino 0:65fd8b1cbf86 119 if(myVectorObjet.size()==0)
adelino 0:65fd8b1cbf86 120 return NULL;
adelino 0:65fd8b1cbf86 121
adelino 0:65fd8b1cbf86 122 //
adelino 0:65fd8b1cbf86 123 for(int i=0; i<myVectorObjet.size(); i++) {
adelino 0:65fd8b1cbf86 124 if((myVectorObjet[i]->getElementId())== _id)
adelino 0:65fd8b1cbf86 125 return myVectorObjet[i];
adelino 0:65fd8b1cbf86 126 }
adelino 0:65fd8b1cbf86 127 return NULL;
adelino 0:65fd8b1cbf86 128
adelino 0:65fd8b1cbf86 129 }
adelino 0:65fd8b1cbf86 130 //-------------------------------------
adelino 0:65fd8b1cbf86 131 TouchEvent Screen::getTouchEvent(GraphicMessage* msg)
adelino 0:65fd8b1cbf86 132 {
adelino 0:65fd8b1cbf86 133 TouchEvent ev=EVENT_NO_ACTIVITY;
adelino 0:65fd8b1cbf86 134 UINT16 xp=0;
adelino 0:65fd8b1cbf86 135 UINT16 yp=0;
adelino 0:65fd8b1cbf86 136
adelino 0:65fd8b1cbf86 137 ev=mySerial->touch_get_status();
adelino 0:65fd8b1cbf86 138
adelino 0:65fd8b1cbf86 139 //
adelino 0:65fd8b1cbf86 140 if(ev >EVENT_NO_ACTIVITY) {
adelino 0:65fd8b1cbf86 141 xp=mySerial->touch_get_x();
adelino 0:65fd8b1cbf86 142 yp=mySerial->touch_get_y();
adelino 0:65fd8b1cbf86 143
adelino 0:65fd8b1cbf86 144 msg->event=ev;
adelino 0:65fd8b1cbf86 145 msg->posiX=xp;
adelino 0:65fd8b1cbf86 146 msg->posiY=yp;
adelino 0:65fd8b1cbf86 147 msg->objId=0;
adelino 0:65fd8b1cbf86 148
adelino 0:65fd8b1cbf86 149 return ev;
adelino 0:65fd8b1cbf86 150 } else {
adelino 0:65fd8b1cbf86 151
adelino 0:65fd8b1cbf86 152 msg->event=EVENT_NO_ACTIVITY;
adelino 0:65fd8b1cbf86 153 msg->posiX=0;
adelino 0:65fd8b1cbf86 154 msg->posiY=0;
adelino 0:65fd8b1cbf86 155 msg->objId=0;
adelino 0:65fd8b1cbf86 156 }
adelino 0:65fd8b1cbf86 157 //
adelino 0:65fd8b1cbf86 158 return ev;
adelino 0:65fd8b1cbf86 159 }
adelino 0:65fd8b1cbf86 160 //-------------------------------------
adelino 0:65fd8b1cbf86 161 void Screen::getProcessMessage(GraphicMessage* msg)
adelino 0:65fd8b1cbf86 162 {
adelino 0:65fd8b1cbf86 163 UINT16 xt=msg->posiX;
adelino 0:65fd8b1cbf86 164 UINT16 yt=msg->posiY;
adelino 0:65fd8b1cbf86 165 UINT16 res=0;
adelino 0:65fd8b1cbf86 166
adelino 0:65fd8b1cbf86 167 ObjetHeader* obj=NULL;
adelino 0:65fd8b1cbf86 168
adelino 0:65fd8b1cbf86 169 obj=getObjetPosition(xt,yt);
adelino 0:65fd8b1cbf86 170
adelino 0:65fd8b1cbf86 171 if(obj!=NULL && obj->getIsVisible()==true) {
adelino 0:65fd8b1cbf86 172 res=obj->getElementId();
adelino 0:65fd8b1cbf86 173 msg->objId=res;
adelino 0:65fd8b1cbf86 174 } else {
adelino 0:65fd8b1cbf86 175 msg->objId=0;
adelino 0:65fd8b1cbf86 176 }
adelino 0:65fd8b1cbf86 177
adelino 0:65fd8b1cbf86 178 }
adelino 0:65fd8b1cbf86 179 //-------------------------------------
adelino 0:65fd8b1cbf86 180 //
adelino 0:65fd8b1cbf86 181 //
adelino 0:65fd8b1cbf86 182 //
adelino 0:65fd8b1cbf86 183 //---------------------------------------
adelino 0:65fd8b1cbf86 184 ObjetHeader::ObjetHeader(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _w,UINT16 _h,Color _color,bool _isVisible):
adelino 0:65fd8b1cbf86 185 myScreen(mScreen),myElementId(_id),myX(_x),myY(_y),myWidth(_w),myHeight(_h),myColor(_color),myElementIsVisible(_isVisible)
adelino 0:65fd8b1cbf86 186 {
adelino 0:65fd8b1cbf86 187
adelino 0:65fd8b1cbf86 188 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 189 myIsUpdateAutomatic=true;
adelino 0:65fd8b1cbf86 190
adelino 0:65fd8b1cbf86 191 myXMoveMin=myScreen->getXpos();
adelino 0:65fd8b1cbf86 192 myYMoveMin=myScreen->getYpos();
adelino 0:65fd8b1cbf86 193
adelino 0:65fd8b1cbf86 194 myXMoveMax=myXMoveMin+myScreen->getWidth();
adelino 0:65fd8b1cbf86 195 myYMoveMax= myYMoveMin+myScreen->getHeight();
adelino 0:65fd8b1cbf86 196
adelino 0:65fd8b1cbf86 197 mySpeedX=0.0;
adelino 0:65fd8b1cbf86 198 mySpeedY=0.0;
adelino 0:65fd8b1cbf86 199 }
adelino 0:65fd8b1cbf86 200 //-------------------------------------
adelino 0:65fd8b1cbf86 201 ObjetHeader::~ObjetHeader(void)
adelino 0:65fd8b1cbf86 202 {
adelino 0:65fd8b1cbf86 203 }
adelino 0:65fd8b1cbf86 204 //-------------------------------------
adelino 0:65fd8b1cbf86 205 void ObjetHeader::updateCellId(void)
adelino 0:65fd8b1cbf86 206 {
adelino 0:65fd8b1cbf86 207 UINT16 cellX=myX/(ObjetHeader::CELL_DIM);
adelino 0:65fd8b1cbf86 208 UINT16 cellY=myY/(ObjetHeader::CELL_DIM);
adelino 0:65fd8b1cbf86 209
adelino 0:65fd8b1cbf86 210 myCellId=cellX+(cellY*ObjetHeader::CELL_COL);
adelino 0:65fd8b1cbf86 211 }
adelino 0:65fd8b1cbf86 212 //-------------------------------------
adelino 0:65fd8b1cbf86 213 UINT16 ObjetHeader::getCellId(void)
adelino 0:65fd8b1cbf86 214 {
adelino 0:65fd8b1cbf86 215 return this->myCellId;
adelino 0:65fd8b1cbf86 216 }
adelino 0:65fd8b1cbf86 217 //-------------------------------------
adelino 0:65fd8b1cbf86 218 void ObjetHeader::setUpdateAutomatic(bool _state)
adelino 0:65fd8b1cbf86 219 {
adelino 0:65fd8b1cbf86 220 myIsUpdateAutomatic=_state;
adelino 0:65fd8b1cbf86 221 }
adelino 0:65fd8b1cbf86 222 //---------------------------------------
adelino 0:65fd8b1cbf86 223 bool ObjetHeader::getUpdateAutomatic(void)
adelino 0:65fd8b1cbf86 224 {
adelino 0:65fd8b1cbf86 225 return this->myIsUpdateAutomatic;
adelino 0:65fd8b1cbf86 226 }
adelino 0:65fd8b1cbf86 227 //-------------------------------------
adelino 0:65fd8b1cbf86 228 bool ObjetHeader::overlapWith(ObjetHeader* pObj)
adelino 0:65fd8b1cbf86 229 {
adelino 0:65fd8b1cbf86 230 return overlap(this,pObj);
adelino 0:65fd8b1cbf86 231 }
adelino 0:65fd8b1cbf86 232 //-------------------------------------
adelino 0:65fd8b1cbf86 233 bool ObjetHeader::overlap(ObjetHeader* pObj1,ObjetHeader* pObj2)
adelino 0:65fd8b1cbf86 234 {
adelino 0:65fd8b1cbf86 235 UINT16 x1=pObj1->getXpos();
adelino 0:65fd8b1cbf86 236 UINT16 x2=pObj2->getXpos();
adelino 0:65fd8b1cbf86 237
adelino 0:65fd8b1cbf86 238 UINT16 y1=pObj1->getYpos();
adelino 0:65fd8b1cbf86 239 UINT16 y2=pObj2->getYpos();
adelino 0:65fd8b1cbf86 240
adelino 0:65fd8b1cbf86 241 UINT16 xa=pObj1->getXpos()+pObj1->getWidth();
adelino 0:65fd8b1cbf86 242 UINT16 xb=pObj2->getXpos()+pObj2->getWidth();
adelino 0:65fd8b1cbf86 243
adelino 0:65fd8b1cbf86 244 UINT16 ya=pObj1->getYpos()+pObj1->getHeight();
adelino 0:65fd8b1cbf86 245 UINT16 yb=pObj2->getYpos()+pObj2->getHeight();
adelino 0:65fd8b1cbf86 246
adelino 0:65fd8b1cbf86 247 //
adelino 0:65fd8b1cbf86 248 if(x1 <xb && xa>x2 && y1<yb && ya>y2) {
adelino 0:65fd8b1cbf86 249
adelino 0:65fd8b1cbf86 250 return true;
adelino 0:65fd8b1cbf86 251 } else {
adelino 0:65fd8b1cbf86 252 return false;
adelino 0:65fd8b1cbf86 253 }
adelino 0:65fd8b1cbf86 254
adelino 0:65fd8b1cbf86 255 }
adelino 0:65fd8b1cbf86 256 //-------------------------------------
adelino 0:65fd8b1cbf86 257 void ObjetHeader::elementUpdate(void)
adelino 0:65fd8b1cbf86 258 {
adelino 0:65fd8b1cbf86 259 switch(myElementState) {
adelino 0:65fd8b1cbf86 260 //
adelino 0:65fd8b1cbf86 261 case BUMP_DOWN:
adelino 0:65fd8b1cbf86 262 setInvertSpeedY();
adelino 0:65fd8b1cbf86 263 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 264 break;
adelino 0:65fd8b1cbf86 265 //
adelino 0:65fd8b1cbf86 266 case BUMP_LEFT:
adelino 0:65fd8b1cbf86 267 setInvertSpeedX();
adelino 0:65fd8b1cbf86 268 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 269 break;
adelino 0:65fd8b1cbf86 270 //
adelino 0:65fd8b1cbf86 271 case BUMP_RIGHT:
adelino 0:65fd8b1cbf86 272 setInvertSpeedX();
adelino 0:65fd8b1cbf86 273 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 274 break;
adelino 0:65fd8b1cbf86 275 //
adelino 0:65fd8b1cbf86 276 case BUMP_UP:
adelino 0:65fd8b1cbf86 277 setInvertSpeedY();
adelino 0:65fd8b1cbf86 278 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 279 break;
adelino 0:65fd8b1cbf86 280 //
adelino 0:65fd8b1cbf86 281 case STATE_OFF:
adelino 0:65fd8b1cbf86 282 break;
adelino 0:65fd8b1cbf86 283 //
adelino 0:65fd8b1cbf86 284 default:
adelino 0:65fd8b1cbf86 285 break;
adelino 0:65fd8b1cbf86 286 }
adelino 0:65fd8b1cbf86 287 //
adelino 0:65fd8b1cbf86 288 }
adelino 0:65fd8b1cbf86 289 //-------------------------------------
adelino 0:65fd8b1cbf86 290 void ObjetHeader::draw(void)
adelino 0:65fd8b1cbf86 291 {
adelino 0:65fd8b1cbf86 292 //to do
adelino 0:65fd8b1cbf86 293 }
adelino 0:65fd8b1cbf86 294 //-------------------------------------
adelino 0:65fd8b1cbf86 295 UINT16 ObjetHeader::getXpos(void)
adelino 0:65fd8b1cbf86 296 {
adelino 0:65fd8b1cbf86 297 return this->myX;
adelino 0:65fd8b1cbf86 298 }
adelino 0:65fd8b1cbf86 299 //---------------------------------------
adelino 0:65fd8b1cbf86 300 UINT16 ObjetHeader::getYpos(void)
adelino 0:65fd8b1cbf86 301 {
adelino 0:65fd8b1cbf86 302 return this->myY;
adelino 0:65fd8b1cbf86 303 }
adelino 0:65fd8b1cbf86 304 //----------------------------------------
adelino 0:65fd8b1cbf86 305 UINT16 ObjetHeader::getWidth(void)
adelino 0:65fd8b1cbf86 306 {
adelino 0:65fd8b1cbf86 307 return this->myWidth;
adelino 0:65fd8b1cbf86 308 }
adelino 0:65fd8b1cbf86 309 //----------------------------------------
adelino 0:65fd8b1cbf86 310 UINT16 ObjetHeader::getHeight(void)
adelino 0:65fd8b1cbf86 311 {
adelino 0:65fd8b1cbf86 312 return this->myHeight;
adelino 0:65fd8b1cbf86 313 }
adelino 0:65fd8b1cbf86 314 //----------------------------------------
adelino 0:65fd8b1cbf86 315 UINT16 ObjetHeader::getElementId(void)
adelino 0:65fd8b1cbf86 316 {
adelino 0:65fd8b1cbf86 317 return this->myElementId;
adelino 0:65fd8b1cbf86 318 }
adelino 0:65fd8b1cbf86 319 //----------------------------------------
adelino 0:65fd8b1cbf86 320 GRAPHIC_OBJ_TYPE ObjetHeader::getElementType(void)
adelino 0:65fd8b1cbf86 321 {
adelino 0:65fd8b1cbf86 322 return this->myElementType;
adelino 0:65fd8b1cbf86 323 }
adelino 0:65fd8b1cbf86 324 //----------------------------------------
adelino 0:65fd8b1cbf86 325 bool ObjetHeader::getIsVisible(void)
adelino 0:65fd8b1cbf86 326 {
adelino 0:65fd8b1cbf86 327 return this->myElementIsVisible;
adelino 0:65fd8b1cbf86 328 }
adelino 0:65fd8b1cbf86 329 //----------------------------------------
adelino 0:65fd8b1cbf86 330 float ObjetHeader::getSpeedX(void)
adelino 0:65fd8b1cbf86 331 {
adelino 0:65fd8b1cbf86 332 return this->mySpeedX;
adelino 0:65fd8b1cbf86 333 }
adelino 0:65fd8b1cbf86 334 //----------------------------------------
adelino 0:65fd8b1cbf86 335 float ObjetHeader::getSpeedY(void)
adelino 0:65fd8b1cbf86 336 {
adelino 0:65fd8b1cbf86 337 return this->mySpeedY;
adelino 0:65fd8b1cbf86 338 }
adelino 0:65fd8b1cbf86 339 //----------------------------------------
adelino 0:65fd8b1cbf86 340 Color ObjetHeader::getColor(void)
adelino 0:65fd8b1cbf86 341 {
adelino 0:65fd8b1cbf86 342 return myColor;
adelino 0:65fd8b1cbf86 343 }
adelino 0:65fd8b1cbf86 344 //----------------------------------------
adelino 0:65fd8b1cbf86 345 void ObjetHeader::setVisibility(bool _val)
adelino 0:65fd8b1cbf86 346 {
adelino 0:65fd8b1cbf86 347 (this->myElementIsVisible)=_val;
adelino 0:65fd8b1cbf86 348 }
adelino 0:65fd8b1cbf86 349 //----------------------------------------
adelino 0:65fd8b1cbf86 350 State ObjetHeader::getElementState(void)
adelino 0:65fd8b1cbf86 351 {
adelino 0:65fd8b1cbf86 352 return this->myElementState;
adelino 0:65fd8b1cbf86 353 }
adelino 0:65fd8b1cbf86 354 //----------------------------------------
adelino 0:65fd8b1cbf86 355 void ObjetHeader::setInvertSpeedX(void)
adelino 0:65fd8b1cbf86 356 {
adelino 0:65fd8b1cbf86 357 mySpeedX=-(this->mySpeedX);
adelino 0:65fd8b1cbf86 358 }
adelino 0:65fd8b1cbf86 359 //----------------------------------------
adelino 0:65fd8b1cbf86 360 void ObjetHeader::setInvertSpeedY(void)
adelino 0:65fd8b1cbf86 361 {
adelino 0:65fd8b1cbf86 362 mySpeedY=-(this->mySpeedY);
adelino 0:65fd8b1cbf86 363 }
adelino 0:65fd8b1cbf86 364 //----------------------------------------
adelino 0:65fd8b1cbf86 365 void ObjetHeader::setSpeedX(float _speedX)
adelino 0:65fd8b1cbf86 366 {
adelino 0:65fd8b1cbf86 367 mySpeedX=_speedX;
adelino 0:65fd8b1cbf86 368 }
adelino 0:65fd8b1cbf86 369 //----------------------------------------
adelino 0:65fd8b1cbf86 370 void ObjetHeader::setSpeedY(float _speedY)
adelino 0:65fd8b1cbf86 371 {
adelino 0:65fd8b1cbf86 372 mySpeedY=_speedY;
adelino 0:65fd8b1cbf86 373 }
adelino 0:65fd8b1cbf86 374 //----------------------------------------
adelino 0:65fd8b1cbf86 375 void ObjetHeader::setSpeedXY(float _speedX,float _speedY)
adelino 0:65fd8b1cbf86 376 {
adelino 0:65fd8b1cbf86 377 mySpeedX=_speedX;
adelino 0:65fd8b1cbf86 378 mySpeedY=_speedY;
adelino 0:65fd8b1cbf86 379 }
adelino 0:65fd8b1cbf86 380 //------------------------------------------
adelino 0:65fd8b1cbf86 381 void ObjetHeader::setColor(Color _color)
adelino 0:65fd8b1cbf86 382 {
adelino 0:65fd8b1cbf86 383 myColor=_color;
adelino 0:65fd8b1cbf86 384 }
adelino 0:65fd8b1cbf86 385 //------------------------------------------
adelino 0:65fd8b1cbf86 386 void ObjetHeader::setElementState(State _state)
adelino 0:65fd8b1cbf86 387 {
adelino 0:65fd8b1cbf86 388 myElementState=_state;
adelino 0:65fd8b1cbf86 389 }
adelino 0:65fd8b1cbf86 390 //------------------------------------------
adelino 0:65fd8b1cbf86 391 void ObjetHeader::setElementId(UINT16 _id)
adelino 0:65fd8b1cbf86 392 {
adelino 0:65fd8b1cbf86 393 myElementId=_id;
adelino 0:65fd8b1cbf86 394 }
adelino 0:65fd8b1cbf86 395 //------------------------------------------
adelino 0:65fd8b1cbf86 396 void ObjetHeader::setXpos(UINT16 _xpos)
adelino 0:65fd8b1cbf86 397 {
adelino 0:65fd8b1cbf86 398 this->myX=_xpos;
adelino 0:65fd8b1cbf86 399 }
adelino 0:65fd8b1cbf86 400 //------------------------------------------
adelino 0:65fd8b1cbf86 401 void ObjetHeader::setYpos(UINT16 _ypos)
adelino 0:65fd8b1cbf86 402 {
adelino 0:65fd8b1cbf86 403 this->myY=_ypos;
adelino 0:65fd8b1cbf86 404 }
adelino 0:65fd8b1cbf86 405 //-------------------------------------------
adelino 0:65fd8b1cbf86 406 //
adelino 0:65fd8b1cbf86 407 //
adelino 0:65fd8b1cbf86 408 //
adelino 0:65fd8b1cbf86 409 //--------------------------------------------
adelino 0:65fd8b1cbf86 410 void Isocele::updateOrientation(void)
adelino 0:65fd8b1cbf86 411 {
adelino 0:65fd8b1cbf86 412 switch(myOrientation) {
adelino 0:65fd8b1cbf86 413 //
adelino 0:65fd8b1cbf86 414 case Isocele::ORIENTATION_UP:
adelino 0:65fd8b1cbf86 415 mySpeedX=0.0;
adelino 0:65fd8b1cbf86 416 mySpeedY=-mySpeed;
adelino 0:65fd8b1cbf86 417
adelino 0:65fd8b1cbf86 418 myX=myXcenter-myRadius;
adelino 0:65fd8b1cbf86 419 myY=myYcenter-myRadius;
adelino 0:65fd8b1cbf86 420 myWidth=myRadius+myRadius;
adelino 0:65fd8b1cbf86 421 myHeight=myRadius;
adelino 0:65fd8b1cbf86 422
adelino 0:65fd8b1cbf86 423 myX1=myXcenter;
adelino 0:65fd8b1cbf86 424 myY1=myYcenter-myRadius;
adelino 0:65fd8b1cbf86 425
adelino 0:65fd8b1cbf86 426 myX2=myXcenter-myRadius;
adelino 0:65fd8b1cbf86 427 myY2=myYcenter;
adelino 0:65fd8b1cbf86 428
adelino 0:65fd8b1cbf86 429 myX3=myXcenter+myRadius;
adelino 0:65fd8b1cbf86 430 myY3=myYcenter;
adelino 0:65fd8b1cbf86 431 break;
adelino 0:65fd8b1cbf86 432
adelino 0:65fd8b1cbf86 433 //
adelino 0:65fd8b1cbf86 434 case Isocele::ORIENTATION_RIGHT:
adelino 0:65fd8b1cbf86 435 mySpeedX=mySpeed;
adelino 0:65fd8b1cbf86 436 mySpeedY=0.0;
adelino 0:65fd8b1cbf86 437
adelino 0:65fd8b1cbf86 438 myX=myXcenter;
adelino 0:65fd8b1cbf86 439 myY=myYcenter-myRadius;
adelino 0:65fd8b1cbf86 440 myWidth=myRadius;
adelino 0:65fd8b1cbf86 441 myHeight=myRadius+myRadius;
adelino 0:65fd8b1cbf86 442
adelino 0:65fd8b1cbf86 443 myX1=myXcenter;
adelino 0:65fd8b1cbf86 444 myY1=myYcenter-myRadius;
adelino 0:65fd8b1cbf86 445
adelino 0:65fd8b1cbf86 446 myX2=myXcenter;
adelino 0:65fd8b1cbf86 447 myY2=myYcenter+myRadius;
adelino 0:65fd8b1cbf86 448
adelino 0:65fd8b1cbf86 449 myX3=myXcenter+myRadius;
adelino 0:65fd8b1cbf86 450 myY3=myYcenter;
adelino 0:65fd8b1cbf86 451 break;
adelino 0:65fd8b1cbf86 452
adelino 0:65fd8b1cbf86 453 //
adelino 0:65fd8b1cbf86 454 case Isocele::ORIENTATION_DOWN:
adelino 0:65fd8b1cbf86 455 mySpeedX=0.0;
adelino 0:65fd8b1cbf86 456 mySpeedY=mySpeed;
adelino 0:65fd8b1cbf86 457
adelino 0:65fd8b1cbf86 458 myX=myXcenter-myRadius;
adelino 0:65fd8b1cbf86 459 myY=myYcenter;
adelino 0:65fd8b1cbf86 460 myWidth=myRadius+myRadius;
adelino 0:65fd8b1cbf86 461 myHeight=myRadius;
adelino 0:65fd8b1cbf86 462
adelino 0:65fd8b1cbf86 463 myX1=myXcenter-myRadius;
adelino 0:65fd8b1cbf86 464 myY1=myYcenter;
adelino 0:65fd8b1cbf86 465
adelino 0:65fd8b1cbf86 466 myX2=myXcenter;
adelino 0:65fd8b1cbf86 467 myY2=myYcenter+myRadius;
adelino 0:65fd8b1cbf86 468
adelino 0:65fd8b1cbf86 469 myX3=myXcenter+myRadius;
adelino 0:65fd8b1cbf86 470 myY3=myYcenter;
adelino 0:65fd8b1cbf86 471 break;
adelino 0:65fd8b1cbf86 472
adelino 0:65fd8b1cbf86 473 //
adelino 0:65fd8b1cbf86 474 case Isocele::ORIENTATION_LEFT:
adelino 0:65fd8b1cbf86 475 mySpeedX=-mySpeed;
adelino 0:65fd8b1cbf86 476 mySpeedY=0.0;
adelino 0:65fd8b1cbf86 477
adelino 0:65fd8b1cbf86 478 myX=myXcenter-myRadius;
adelino 0:65fd8b1cbf86 479 myY=myYcenter-myRadius;
adelino 0:65fd8b1cbf86 480 myWidth=myRadius;
adelino 0:65fd8b1cbf86 481 myHeight=myRadius+myRadius;
adelino 0:65fd8b1cbf86 482
adelino 0:65fd8b1cbf86 483 myX1=myXcenter-myRadius;
adelino 0:65fd8b1cbf86 484 myY1=myYcenter;
adelino 0:65fd8b1cbf86 485
adelino 0:65fd8b1cbf86 486 myX2=myXcenter;
adelino 0:65fd8b1cbf86 487 myY2=myYcenter+myRadius;
adelino 0:65fd8b1cbf86 488
adelino 0:65fd8b1cbf86 489 myX3=myXcenter;
adelino 0:65fd8b1cbf86 490 myY3=myYcenter-myRadius;
adelino 0:65fd8b1cbf86 491 break;
adelino 0:65fd8b1cbf86 492
adelino 0:65fd8b1cbf86 493 //
adelino 0:65fd8b1cbf86 494 default:
adelino 0:65fd8b1cbf86 495 break;
adelino 0:65fd8b1cbf86 496
adelino 0:65fd8b1cbf86 497 }
adelino 0:65fd8b1cbf86 498
adelino 0:65fd8b1cbf86 499 }
adelino 0:65fd8b1cbf86 500 //--------------------------------------------
adelino 0:65fd8b1cbf86 501 Isocele::Isocele(Screen* mScreen,UINT16 _id,UINT16 xc,UINT16 yc,UINT16 radius,int orientation,float _speed,
adelino 0:65fd8b1cbf86 502 Color color,bool isVisible): ObjetHeader(mScreen,_id,xc-radius,yc-radius,radius+radius,radius,color,isVisible)
adelino 0:65fd8b1cbf86 503 {
adelino 0:65fd8b1cbf86 504 myXcenter=xc;
adelino 0:65fd8b1cbf86 505 myYcenter=yc;
adelino 0:65fd8b1cbf86 506 myRadius=radius;
adelino 0:65fd8b1cbf86 507 myOrientation=orientation;
adelino 0:65fd8b1cbf86 508 mySpeed=_speed;
adelino 0:65fd8b1cbf86 509
adelino 0:65fd8b1cbf86 510 updateOrientation();
adelino 0:65fd8b1cbf86 511
adelino 0:65fd8b1cbf86 512 myIsUpdateAutomatic=false;
adelino 0:65fd8b1cbf86 513
adelino 0:65fd8b1cbf86 514 myElementType=OBJ_ISOCELE;
adelino 0:65fd8b1cbf86 515
adelino 0:65fd8b1cbf86 516 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 517 }
adelino 0:65fd8b1cbf86 518 //--------------------------------------------
adelino 0:65fd8b1cbf86 519 void Isocele::draw(void)
adelino 0:65fd8b1cbf86 520 {
adelino 0:65fd8b1cbf86 521 // isVisible ?
adelino 0:65fd8b1cbf86 522 if(myElementIsVisible==false) {
adelino 0:65fd8b1cbf86 523 return;
adelino 0:65fd8b1cbf86 524 }
adelino 0:65fd8b1cbf86 525 //
adelino 0:65fd8b1cbf86 526 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 527
adelino 0:65fd8b1cbf86 528 if(ps!=0) {
adelino 0:65fd8b1cbf86 529 ps->draw_filled_triangle(myX1,myY1,myX2,myY2,myX3,myY3,myColor);
adelino 0:65fd8b1cbf86 530 //
adelino 0:65fd8b1cbf86 531 //ps->draw_rectangle(myX,myY,myX+myWidth,myY+myHeight,BLACK);
adelino 0:65fd8b1cbf86 532 }
adelino 0:65fd8b1cbf86 533 }
adelino 0:65fd8b1cbf86 534 //---------------------------------------------
adelino 0:65fd8b1cbf86 535 Isocele::~Isocele(void)
adelino 0:65fd8b1cbf86 536 {
adelino 0:65fd8b1cbf86 537 }
adelino 0:65fd8b1cbf86 538 //--------------------------------------------
adelino 0:65fd8b1cbf86 539 void Isocele:: setInvisible(bool _state)
adelino 0:65fd8b1cbf86 540 {
adelino 0:65fd8b1cbf86 541 // element devient invisible
adelino 0:65fd8b1cbf86 542 if(_state==true) {
adelino 0:65fd8b1cbf86 543 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 544 return;
adelino 0:65fd8b1cbf86 545
adelino 0:65fd8b1cbf86 546 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 547
adelino 0:65fd8b1cbf86 548 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 549
adelino 0:65fd8b1cbf86 550 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 551
adelino 0:65fd8b1cbf86 552 if(ps!=0) {
adelino 0:65fd8b1cbf86 553 ps->draw_filled_triangle(myX1,myY1,myX2,myY2,myX3,myY3,c);
adelino 0:65fd8b1cbf86 554 //ps->draw_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
adelino 0:65fd8b1cbf86 555 }
adelino 0:65fd8b1cbf86 556 }
adelino 0:65fd8b1cbf86 557
adelino 0:65fd8b1cbf86 558 // element devient visible
adelino 0:65fd8b1cbf86 559 else {
adelino 0:65fd8b1cbf86 560 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 561
adelino 0:65fd8b1cbf86 562 this->draw();
adelino 0:65fd8b1cbf86 563 }
adelino 0:65fd8b1cbf86 564 }
adelino 0:65fd8b1cbf86 565 //-------------------------------------------
adelino 0:65fd8b1cbf86 566 void Isocele::setNewPosition(INT16 _xcnew,INT16 _ycnew)
adelino 0:65fd8b1cbf86 567 {
adelino 0:65fd8b1cbf86 568 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 569 return;
adelino 0:65fd8b1cbf86 570 //
adelino 0:65fd8b1cbf86 571 if(myXcenter==_xcnew && myYcenter==_ycnew)
adelino 0:65fd8b1cbf86 572 return;
adelino 0:65fd8b1cbf86 573 //
adelino 0:65fd8b1cbf86 574 this->setInvisible(true); // colorie le cir avec couleur de la screen
adelino 0:65fd8b1cbf86 575
adelino 0:65fd8b1cbf86 576 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 577
adelino 0:65fd8b1cbf86 578 //test Xmax
adelino 0:65fd8b1cbf86 579 if(_xcnew+myRadius >= myXMoveMax) {
adelino 0:65fd8b1cbf86 580 _xcnew=myXMoveMax-myRadius;
adelino 0:65fd8b1cbf86 581
adelino 0:65fd8b1cbf86 582 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 583 myElementState=BUMP_RIGHT;
adelino 0:65fd8b1cbf86 584 }
adelino 0:65fd8b1cbf86 585
adelino 0:65fd8b1cbf86 586 //test Xmin
adelino 0:65fd8b1cbf86 587 if(_xcnew <= myRadius) {
adelino 0:65fd8b1cbf86 588 _xcnew=myXMoveMin+myRadius;
adelino 0:65fd8b1cbf86 589
adelino 0:65fd8b1cbf86 590 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 591 myElementState=BUMP_LEFT;
adelino 0:65fd8b1cbf86 592 }
adelino 0:65fd8b1cbf86 593 //test Ymax
adelino 0:65fd8b1cbf86 594 if(_ycnew +myRadius >= myYMoveMax && _ycnew >0) {
adelino 0:65fd8b1cbf86 595 _ycnew = myYMoveMax- myRadius;
adelino 0:65fd8b1cbf86 596
adelino 0:65fd8b1cbf86 597 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 598 myElementState=BUMP_DOWN;
adelino 0:65fd8b1cbf86 599 }
adelino 0:65fd8b1cbf86 600 //test yminMin;
adelino 0:65fd8b1cbf86 601 if(_ycnew <= myRadius) {
adelino 0:65fd8b1cbf86 602 _ycnew=myYMoveMin+myRadius;
adelino 0:65fd8b1cbf86 603
adelino 0:65fd8b1cbf86 604 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 605 myElementState=BUMP_UP;
adelino 0:65fd8b1cbf86 606 }
adelino 0:65fd8b1cbf86 607 //
adelino 0:65fd8b1cbf86 608 myXcenter=_xcnew;
adelino 0:65fd8b1cbf86 609 myYcenter=_ycnew;
adelino 0:65fd8b1cbf86 610
adelino 0:65fd8b1cbf86 611 updateOrientation();
adelino 0:65fd8b1cbf86 612
adelino 0:65fd8b1cbf86 613
adelino 0:65fd8b1cbf86 614 this->draw();
adelino 0:65fd8b1cbf86 615 }
adelino 0:65fd8b1cbf86 616 //--------------------------------------------
adelino 0:65fd8b1cbf86 617 void Isocele::myElementUpdate(void)
adelino 0:65fd8b1cbf86 618 {
adelino 0:65fd8b1cbf86 619 switch(myElementState) {
adelino 0:65fd8b1cbf86 620 //
adelino 0:65fd8b1cbf86 621 case BUMP_DOWN:
adelino 0:65fd8b1cbf86 622 setInvertSpeedY();
adelino 0:65fd8b1cbf86 623 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 624 myOrientation=Isocele::ORIENTATION_UP;
adelino 0:65fd8b1cbf86 625 break;
adelino 0:65fd8b1cbf86 626 //
adelino 0:65fd8b1cbf86 627 case BUMP_LEFT:
adelino 0:65fd8b1cbf86 628 setInvertSpeedX();
adelino 0:65fd8b1cbf86 629 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 630 myOrientation=Isocele::ORIENTATION_RIGHT;
adelino 0:65fd8b1cbf86 631 break;
adelino 0:65fd8b1cbf86 632 //
adelino 0:65fd8b1cbf86 633 case BUMP_RIGHT:
adelino 0:65fd8b1cbf86 634 setInvertSpeedX();
adelino 0:65fd8b1cbf86 635 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 636 myOrientation=Isocele::ORIENTATION_LEFT;
adelino 0:65fd8b1cbf86 637 break;
adelino 0:65fd8b1cbf86 638 //
adelino 0:65fd8b1cbf86 639 case BUMP_UP:
adelino 0:65fd8b1cbf86 640 setInvertSpeedY();
adelino 0:65fd8b1cbf86 641 myElementState=STATE_ON;
adelino 0:65fd8b1cbf86 642 myOrientation=Isocele::ORIENTATION_DOWN;
adelino 0:65fd8b1cbf86 643 break;
adelino 0:65fd8b1cbf86 644 //
adelino 0:65fd8b1cbf86 645 case STATE_OFF:
adelino 0:65fd8b1cbf86 646 break;
adelino 0:65fd8b1cbf86 647 //
adelino 0:65fd8b1cbf86 648 default:
adelino 0:65fd8b1cbf86 649 break;
adelino 0:65fd8b1cbf86 650 }
adelino 0:65fd8b1cbf86 651 }
adelino 0:65fd8b1cbf86 652 //--------------------------------------------
adelino 0:65fd8b1cbf86 653 void Isocele::update(float delta)
adelino 0:65fd8b1cbf86 654 {
adelino 0:65fd8b1cbf86 655 if(myIsUpdateAutomatic)
adelino 0:65fd8b1cbf86 656 myElementUpdate();
adelino 0:65fd8b1cbf86 657 //
adelino 0:65fd8b1cbf86 658 float xnew=myXcenter+mySpeedX*delta;
adelino 0:65fd8b1cbf86 659 float ynew=myYcenter+mySpeedY*delta;
adelino 0:65fd8b1cbf86 660
adelino 0:65fd8b1cbf86 661 this->setNewPosition((INT16)xnew,(INT16)ynew);
adelino 0:65fd8b1cbf86 662
adelino 0:65fd8b1cbf86 663 updateCellId();
adelino 0:65fd8b1cbf86 664 }
adelino 0:65fd8b1cbf86 665 //--------------------------------------------
adelino 0:65fd8b1cbf86 666 void Isocele::setOrientation(int _orientation)
adelino 0:65fd8b1cbf86 667 {
adelino 0:65fd8b1cbf86 668 myOrientation=_orientation;
adelino 0:65fd8b1cbf86 669
adelino 0:65fd8b1cbf86 670 }
adelino 0:65fd8b1cbf86 671 //--------------------------------------------
adelino 0:65fd8b1cbf86 672 int Isocele::getOrientation(void)
adelino 0:65fd8b1cbf86 673 {
adelino 0:65fd8b1cbf86 674 return this->myOrientation;
adelino 0:65fd8b1cbf86 675 }
adelino 0:65fd8b1cbf86 676 //--------------------------------------------
adelino 0:65fd8b1cbf86 677 UINT16 Isocele::getXcenter(void)
adelino 0:65fd8b1cbf86 678 {
adelino 0:65fd8b1cbf86 679 return this->myXcenter;
adelino 0:65fd8b1cbf86 680 }
adelino 0:65fd8b1cbf86 681 //--------------------------------------------
adelino 0:65fd8b1cbf86 682 UINT16 Isocele::getYcenter(void)
adelino 0:65fd8b1cbf86 683 {
adelino 0:65fd8b1cbf86 684 return this->myYcenter;
adelino 0:65fd8b1cbf86 685 }
adelino 0:65fd8b1cbf86 686 //--------------------------------------------
adelino 0:65fd8b1cbf86 687 void Isocele::turnLeft(void)
adelino 0:65fd8b1cbf86 688 {
adelino 0:65fd8b1cbf86 689 myOrientation+=1;
adelino 0:65fd8b1cbf86 690
adelino 0:65fd8b1cbf86 691 if(myOrientation >Isocele::ORIENTATION_RIGHT)
adelino 0:65fd8b1cbf86 692 myOrientation=ORIENTATION_UP;
adelino 0:65fd8b1cbf86 693
adelino 0:65fd8b1cbf86 694 }
adelino 0:65fd8b1cbf86 695 //--------------------------------------------
adelino 0:65fd8b1cbf86 696 void Isocele::turnRight(void)
adelino 0:65fd8b1cbf86 697 {
adelino 0:65fd8b1cbf86 698 myOrientation-=1;
adelino 0:65fd8b1cbf86 699
adelino 0:65fd8b1cbf86 700 if(myOrientation <Isocele::ORIENTATION_UP)
adelino 0:65fd8b1cbf86 701 myOrientation=ORIENTATION_RIGHT;
adelino 0:65fd8b1cbf86 702
adelino 0:65fd8b1cbf86 703 }
adelino 0:65fd8b1cbf86 704 //--------------------------------------------
adelino 0:65fd8b1cbf86 705 //
adelino 0:65fd8b1cbf86 706 //
adelino 0:65fd8b1cbf86 707 //
adelino 0:65fd8b1cbf86 708 Rectangle::Rectangle(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _w,UINT16 _h,Color _color,bool _isVisible):
adelino 0:65fd8b1cbf86 709 ObjetHeader(mScreen,_id,_x,_y,_w,_h,_color,_isVisible)
adelino 0:65fd8b1cbf86 710 {
adelino 0:65fd8b1cbf86 711 myElementType=OBJ_RECTANGLE;
adelino 0:65fd8b1cbf86 712
adelino 0:65fd8b1cbf86 713 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 714 }
adelino 0:65fd8b1cbf86 715 //------------------------------------
adelino 0:65fd8b1cbf86 716 Rectangle::~Rectangle(void)
adelino 0:65fd8b1cbf86 717 {
adelino 0:65fd8b1cbf86 718 }
adelino 0:65fd8b1cbf86 719 //------------------------------------
adelino 0:65fd8b1cbf86 720 void Rectangle::draw(void)
adelino 0:65fd8b1cbf86 721 {
adelino 0:65fd8b1cbf86 722 // isVisible ?
adelino 0:65fd8b1cbf86 723 if(myElementIsVisible==false) {
adelino 0:65fd8b1cbf86 724 return;
adelino 0:65fd8b1cbf86 725 }
adelino 0:65fd8b1cbf86 726 //
adelino 0:65fd8b1cbf86 727
adelino 0:65fd8b1cbf86 728 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 729
adelino 0:65fd8b1cbf86 730 if(ps!=0) {
adelino 0:65fd8b1cbf86 731 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,myColor);
adelino 0:65fd8b1cbf86 732 }
adelino 0:65fd8b1cbf86 733 }
adelino 0:65fd8b1cbf86 734 //-------------------------------------
adelino 0:65fd8b1cbf86 735 void Rectangle::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 736 {
adelino 0:65fd8b1cbf86 737 // element devient invisible
adelino 0:65fd8b1cbf86 738 if(_state==true) {
adelino 0:65fd8b1cbf86 739 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 740 return;
adelino 0:65fd8b1cbf86 741
adelino 0:65fd8b1cbf86 742 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 743
adelino 0:65fd8b1cbf86 744 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 745
adelino 0:65fd8b1cbf86 746 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 747
adelino 0:65fd8b1cbf86 748 if(ps!=0) {
adelino 0:65fd8b1cbf86 749 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
adelino 0:65fd8b1cbf86 750 }
adelino 0:65fd8b1cbf86 751 }
adelino 0:65fd8b1cbf86 752
adelino 0:65fd8b1cbf86 753 // element devient visible
adelino 0:65fd8b1cbf86 754 else {
adelino 0:65fd8b1cbf86 755 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 756
adelino 0:65fd8b1cbf86 757 this->draw();
adelino 0:65fd8b1cbf86 758 }
adelino 0:65fd8b1cbf86 759 }
adelino 0:65fd8b1cbf86 760 //--------------------------------------
adelino 0:65fd8b1cbf86 761 void Rectangle::setNewPosition(INT16 _xnew,INT16 _ynew)
adelino 0:65fd8b1cbf86 762 {
adelino 0:65fd8b1cbf86 763 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 764 return;
adelino 0:65fd8b1cbf86 765
adelino 0:65fd8b1cbf86 766 //
adelino 0:65fd8b1cbf86 767 if(myX==_xnew && myY==_ynew)
adelino 0:65fd8b1cbf86 768 return;
adelino 0:65fd8b1cbf86 769
adelino 0:65fd8b1cbf86 770 setInvisible(true); // colorie le rec avec couleur de la screen
adelino 0:65fd8b1cbf86 771
adelino 0:65fd8b1cbf86 772 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 773
adelino 0:65fd8b1cbf86 774 //test Xmax
adelino 0:65fd8b1cbf86 775 if(_xnew+myWidth >= myXMoveMax) {
adelino 0:65fd8b1cbf86 776 _xnew=myXMoveMax-myWidth;
adelino 0:65fd8b1cbf86 777
adelino 0:65fd8b1cbf86 778 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 779 myElementState=BUMP_RIGHT;
adelino 0:65fd8b1cbf86 780
adelino 0:65fd8b1cbf86 781 }
adelino 0:65fd8b1cbf86 782
adelino 0:65fd8b1cbf86 783 //test Xmin
adelino 0:65fd8b1cbf86 784 if(_xnew <= myXMoveMin) {
adelino 0:65fd8b1cbf86 785 _xnew=myXMoveMin;
adelino 0:65fd8b1cbf86 786
adelino 0:65fd8b1cbf86 787 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 788 myElementState=BUMP_LEFT;
adelino 0:65fd8b1cbf86 789
adelino 0:65fd8b1cbf86 790 }
adelino 0:65fd8b1cbf86 791 //test Ymax
adelino 0:65fd8b1cbf86 792 if(_ynew +myHeight >= myYMoveMax && _ynew >0) {
adelino 0:65fd8b1cbf86 793 _ynew = myYMoveMax- myHeight;
adelino 0:65fd8b1cbf86 794
adelino 0:65fd8b1cbf86 795 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 796 myElementState=BUMP_DOWN;
adelino 0:65fd8b1cbf86 797 }
adelino 0:65fd8b1cbf86 798 //test yminMin;
adelino 0:65fd8b1cbf86 799 if(_ynew <= myYMoveMin) {
adelino 0:65fd8b1cbf86 800 _ynew=myYMoveMin;
adelino 0:65fd8b1cbf86 801
adelino 0:65fd8b1cbf86 802 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 803 myElementState=BUMP_UP;
adelino 0:65fd8b1cbf86 804
adelino 0:65fd8b1cbf86 805 }
adelino 0:65fd8b1cbf86 806 //
adelino 0:65fd8b1cbf86 807 myX=_xnew;
adelino 0:65fd8b1cbf86 808 myY=_ynew;
adelino 0:65fd8b1cbf86 809
adelino 0:65fd8b1cbf86 810
adelino 0:65fd8b1cbf86 811 this->draw();
adelino 0:65fd8b1cbf86 812 }
adelino 0:65fd8b1cbf86 813 //--------------------------------------
adelino 0:65fd8b1cbf86 814 void Rectangle::update(float delta)
adelino 0:65fd8b1cbf86 815 {
adelino 0:65fd8b1cbf86 816 if(myIsUpdateAutomatic)
adelino 0:65fd8b1cbf86 817 elementUpdate();
adelino 0:65fd8b1cbf86 818 //
adelino 0:65fd8b1cbf86 819 float xnew=myX+mySpeedX*delta;
adelino 0:65fd8b1cbf86 820 float ynew=myY+mySpeedY*delta;
adelino 0:65fd8b1cbf86 821
adelino 0:65fd8b1cbf86 822 this->setNewPosition((INT16)xnew,(INT16)ynew);
adelino 0:65fd8b1cbf86 823
adelino 0:65fd8b1cbf86 824 updateCellId();
adelino 0:65fd8b1cbf86 825 }
adelino 0:65fd8b1cbf86 826 //-------------------------------------
adelino 0:65fd8b1cbf86 827 //
adelino 0:65fd8b1cbf86 828 //
adelino 0:65fd8b1cbf86 829 Circle::Circle(Screen* mScreen,UINT16 _id,UINT16 _xc,UINT16 _yc,UINT16 _radius,Color _color,bool _isVisible):
adelino 0:65fd8b1cbf86 830 ObjetHeader(mScreen,_id,_xc-_radius,_yc-_radius,_radius+_radius,_radius+_radius,_color,_isVisible)
adelino 0:65fd8b1cbf86 831 {
adelino 0:65fd8b1cbf86 832 myRadius=_radius;
adelino 0:65fd8b1cbf86 833 myCenterX=_xc;
adelino 0:65fd8b1cbf86 834 myCenterY=_yc;
adelino 0:65fd8b1cbf86 835 myElementType=OBJ_CIRCLE;
adelino 0:65fd8b1cbf86 836
adelino 0:65fd8b1cbf86 837 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 838
adelino 0:65fd8b1cbf86 839 }
adelino 0:65fd8b1cbf86 840 //-----------------------------------------
adelino 0:65fd8b1cbf86 841 Circle::~Circle(void)
adelino 0:65fd8b1cbf86 842 {
adelino 0:65fd8b1cbf86 843 }
adelino 0:65fd8b1cbf86 844 //------------------------------------------
adelino 0:65fd8b1cbf86 845 void Circle::draw(void)
adelino 0:65fd8b1cbf86 846 {
adelino 0:65fd8b1cbf86 847 // isVisible ?
adelino 0:65fd8b1cbf86 848 if(myElementIsVisible==false) {
adelino 0:65fd8b1cbf86 849 return;
adelino 0:65fd8b1cbf86 850 }
adelino 0:65fd8b1cbf86 851 //
adelino 0:65fd8b1cbf86 852
adelino 0:65fd8b1cbf86 853 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 854
adelino 0:65fd8b1cbf86 855 if(ps!=0) {
adelino 0:65fd8b1cbf86 856 ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColor);
adelino 0:65fd8b1cbf86 857 }
adelino 0:65fd8b1cbf86 858 }
adelino 0:65fd8b1cbf86 859 //------------------------------------------
adelino 0:65fd8b1cbf86 860 void Circle::setCenterX(UINT16 _xcenter)
adelino 0:65fd8b1cbf86 861 {
adelino 0:65fd8b1cbf86 862 this->myCenterX=_xcenter;
adelino 0:65fd8b1cbf86 863 }
adelino 0:65fd8b1cbf86 864 //------------------------------------------
adelino 0:65fd8b1cbf86 865 void Circle::setCenterY(UINT16 _ycenter)
adelino 0:65fd8b1cbf86 866 {
adelino 0:65fd8b1cbf86 867 this->myCenterY=_ycenter;
adelino 0:65fd8b1cbf86 868 }
adelino 0:65fd8b1cbf86 869 //------------------------------------------
adelino 0:65fd8b1cbf86 870 UINT16 Circle::getCenterX(void)
adelino 0:65fd8b1cbf86 871 {
adelino 0:65fd8b1cbf86 872 return this->myCenterX;
adelino 0:65fd8b1cbf86 873 }
adelino 0:65fd8b1cbf86 874 //-------------------------------------------
adelino 0:65fd8b1cbf86 875 UINT16 Circle::getCenterY(void)
adelino 0:65fd8b1cbf86 876 {
adelino 0:65fd8b1cbf86 877 return this->myCenterY;
adelino 0:65fd8b1cbf86 878 }
adelino 0:65fd8b1cbf86 879 //--------------------------------------------
adelino 0:65fd8b1cbf86 880 void Circle::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 881 {
adelino 0:65fd8b1cbf86 882 // element devient invisible
adelino 0:65fd8b1cbf86 883 if(_state==true) {
adelino 0:65fd8b1cbf86 884 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 885 return;
adelino 0:65fd8b1cbf86 886
adelino 0:65fd8b1cbf86 887 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 888
adelino 0:65fd8b1cbf86 889 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 890
adelino 0:65fd8b1cbf86 891
adelino 0:65fd8b1cbf86 892 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 893
adelino 0:65fd8b1cbf86 894 if(ps!=0) {
adelino 0:65fd8b1cbf86 895 ps->draw_filled_circle(myCenterX,myCenterY,myRadius,c);
adelino 0:65fd8b1cbf86 896 }
adelino 0:65fd8b1cbf86 897 }
adelino 0:65fd8b1cbf86 898
adelino 0:65fd8b1cbf86 899 // element devient visible
adelino 0:65fd8b1cbf86 900 else {
adelino 0:65fd8b1cbf86 901 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 902
adelino 0:65fd8b1cbf86 903
adelino 0:65fd8b1cbf86 904 this->draw();
adelino 0:65fd8b1cbf86 905 }
adelino 0:65fd8b1cbf86 906 }
adelino 0:65fd8b1cbf86 907 //---------------------------------------------
adelino 0:65fd8b1cbf86 908 void Circle::setNewPosition(INT16 _xcnew,INT16 _ycnew)
adelino 0:65fd8b1cbf86 909 {
adelino 0:65fd8b1cbf86 910 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 911 return;
adelino 0:65fd8b1cbf86 912 //
adelino 0:65fd8b1cbf86 913 if(myCenterX==_xcnew && myCenterY==_ycnew)
adelino 0:65fd8b1cbf86 914 return;
adelino 0:65fd8b1cbf86 915 //
adelino 0:65fd8b1cbf86 916 this->setInvisible(true); // colorie le cir avec couleur de la screen
adelino 0:65fd8b1cbf86 917
adelino 0:65fd8b1cbf86 918 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 919
adelino 0:65fd8b1cbf86 920 //test Xmax
adelino 0:65fd8b1cbf86 921 if(_xcnew+myRadius >= myXMoveMax) {
adelino 0:65fd8b1cbf86 922 _xcnew=myXMoveMax-myRadius;
adelino 0:65fd8b1cbf86 923
adelino 0:65fd8b1cbf86 924 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 925 myElementState=BUMP_RIGHT;
adelino 0:65fd8b1cbf86 926 }
adelino 0:65fd8b1cbf86 927
adelino 0:65fd8b1cbf86 928 //test Xmin
adelino 0:65fd8b1cbf86 929 if(_xcnew <= myRadius) {
adelino 0:65fd8b1cbf86 930 _xcnew=myXMoveMin+myRadius;
adelino 0:65fd8b1cbf86 931
adelino 0:65fd8b1cbf86 932 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 933 myElementState=BUMP_LEFT;
adelino 0:65fd8b1cbf86 934 }
adelino 0:65fd8b1cbf86 935 //test Ymax
adelino 0:65fd8b1cbf86 936 if(_ycnew +myRadius >= myYMoveMax && _ycnew >0) {
adelino 0:65fd8b1cbf86 937 _ycnew = myYMoveMax- myRadius;
adelino 0:65fd8b1cbf86 938
adelino 0:65fd8b1cbf86 939 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 940 myElementState=BUMP_DOWN;
adelino 0:65fd8b1cbf86 941 }
adelino 0:65fd8b1cbf86 942 //test yminMin;
adelino 0:65fd8b1cbf86 943 if(_ycnew <= myRadius) {
adelino 0:65fd8b1cbf86 944 _ycnew=myYMoveMin+myRadius;
adelino 0:65fd8b1cbf86 945
adelino 0:65fd8b1cbf86 946 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 947 myElementState=BUMP_UP;
adelino 0:65fd8b1cbf86 948 }
adelino 0:65fd8b1cbf86 949 //
adelino 0:65fd8b1cbf86 950 myCenterX=_xcnew;
adelino 0:65fd8b1cbf86 951 myCenterY=_ycnew;
adelino 0:65fd8b1cbf86 952
adelino 0:65fd8b1cbf86 953 myX=_xcnew-myRadius;
adelino 0:65fd8b1cbf86 954 myY=_ycnew-myRadius;
adelino 0:65fd8b1cbf86 955
adelino 0:65fd8b1cbf86 956
adelino 0:65fd8b1cbf86 957 this->draw();
adelino 0:65fd8b1cbf86 958 }
adelino 0:65fd8b1cbf86 959 //----------------------------------------------
adelino 0:65fd8b1cbf86 960 void Circle::update(float delta)
adelino 0:65fd8b1cbf86 961 {
adelino 0:65fd8b1cbf86 962 if(myIsUpdateAutomatic)
adelino 0:65fd8b1cbf86 963 elementUpdate();
adelino 0:65fd8b1cbf86 964
adelino 0:65fd8b1cbf86 965 float xcnew=myCenterX+mySpeedX*delta;
adelino 0:65fd8b1cbf86 966 float ycnew=myCenterY+mySpeedY*delta;
adelino 0:65fd8b1cbf86 967
adelino 0:65fd8b1cbf86 968 this->setNewPosition((INT16)xcnew,(INT16)ycnew);
adelino 0:65fd8b1cbf86 969
adelino 0:65fd8b1cbf86 970 updateCellId();
adelino 0:65fd8b1cbf86 971 }
adelino 0:65fd8b1cbf86 972 //----------------------------------------------
adelino 0:65fd8b1cbf86 973 //
adelino 0:65fd8b1cbf86 974 //
adelino 0:65fd8b1cbf86 975 //
adelino 0:65fd8b1cbf86 976 Ellipse::Ellipse(Screen* mScreen,UINT16 _id,UINT16 _xc,UINT16 _yc,UINT16 _radiusX,UINT16 _radiusY,Color _color,
adelino 0:65fd8b1cbf86 977 bool _isVisible):ObjetHeader(mScreen,_id,_xc-_radiusX,_yc-_radiusY,_radiusX+_radiusX,_radiusY+_radiusY,_color,_isVisible)
adelino 0:65fd8b1cbf86 978 {
adelino 0:65fd8b1cbf86 979 myCenterX=_xc;
adelino 0:65fd8b1cbf86 980 myCenterY=_yc;
adelino 0:65fd8b1cbf86 981 myRadiusX=_radiusX;
adelino 0:65fd8b1cbf86 982 myRadiusY=_radiusY;
adelino 0:65fd8b1cbf86 983
adelino 0:65fd8b1cbf86 984 myElementType=OBJ_ELLIPSE;
adelino 0:65fd8b1cbf86 985
adelino 0:65fd8b1cbf86 986 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 987 }
adelino 0:65fd8b1cbf86 988 //----------------------------------------------
adelino 0:65fd8b1cbf86 989 void Ellipse::draw(void)
adelino 0:65fd8b1cbf86 990 {
adelino 0:65fd8b1cbf86 991 // isVisible ?
adelino 0:65fd8b1cbf86 992 if(myElementIsVisible==false) {
adelino 0:65fd8b1cbf86 993 return;
adelino 0:65fd8b1cbf86 994 }
adelino 0:65fd8b1cbf86 995 //
adelino 0:65fd8b1cbf86 996 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 997
adelino 0:65fd8b1cbf86 998 if(ps!=0) {
adelino 0:65fd8b1cbf86 999 ps->draw_filled_ellipse(myCenterX,myCenterY,myRadiusX,myRadiusY,myColor);
adelino 0:65fd8b1cbf86 1000 }
adelino 0:65fd8b1cbf86 1001 }
adelino 0:65fd8b1cbf86 1002 //----------------------------------------------
adelino 0:65fd8b1cbf86 1003 void Ellipse::update(float delta)
adelino 0:65fd8b1cbf86 1004 {
adelino 0:65fd8b1cbf86 1005 if(myIsUpdateAutomatic)
adelino 0:65fd8b1cbf86 1006 elementUpdate();
adelino 0:65fd8b1cbf86 1007
adelino 0:65fd8b1cbf86 1008 float xcnew=myCenterX+mySpeedX*delta;
adelino 0:65fd8b1cbf86 1009 float ycnew=myCenterY+mySpeedY*delta;
adelino 0:65fd8b1cbf86 1010
adelino 0:65fd8b1cbf86 1011 this->setNewPosition((INT16)xcnew,(INT16)ycnew);
adelino 0:65fd8b1cbf86 1012
adelino 0:65fd8b1cbf86 1013 updateCellId();
adelino 0:65fd8b1cbf86 1014 }
adelino 0:65fd8b1cbf86 1015 //-----------------------------------------------
adelino 0:65fd8b1cbf86 1016 void Ellipse::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 1017 {
adelino 0:65fd8b1cbf86 1018 // element devient invisible
adelino 0:65fd8b1cbf86 1019 if(_state==true) {
adelino 0:65fd8b1cbf86 1020 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1021 return;
adelino 0:65fd8b1cbf86 1022
adelino 0:65fd8b1cbf86 1023 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 1024
adelino 0:65fd8b1cbf86 1025 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 1026
adelino 0:65fd8b1cbf86 1027
adelino 0:65fd8b1cbf86 1028 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1029
adelino 0:65fd8b1cbf86 1030 if(ps!=0) {
adelino 0:65fd8b1cbf86 1031 ps->draw_filled_ellipse(myCenterX,myCenterY,myRadiusX,myRadiusY,c);
adelino 0:65fd8b1cbf86 1032 }
adelino 0:65fd8b1cbf86 1033 }
adelino 0:65fd8b1cbf86 1034
adelino 0:65fd8b1cbf86 1035 // element devient visible
adelino 0:65fd8b1cbf86 1036 else {
adelino 0:65fd8b1cbf86 1037 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1038
adelino 0:65fd8b1cbf86 1039
adelino 0:65fd8b1cbf86 1040 this->draw();
adelino 0:65fd8b1cbf86 1041 }
adelino 0:65fd8b1cbf86 1042 }
adelino 0:65fd8b1cbf86 1043 //-----------------------------------------------
adelino 0:65fd8b1cbf86 1044 void Ellipse::setNewPosition(INT16 _xcnew,INT16 _ycnew)
adelino 0:65fd8b1cbf86 1045 {
adelino 0:65fd8b1cbf86 1046 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1047 return;
adelino 0:65fd8b1cbf86 1048 //
adelino 0:65fd8b1cbf86 1049 if(myCenterX==_xcnew && myCenterY==_ycnew)
adelino 0:65fd8b1cbf86 1050 return;
adelino 0:65fd8b1cbf86 1051 //
adelino 0:65fd8b1cbf86 1052 this->setInvisible(true); // colorie le cir avec couleur de la screen
adelino 0:65fd8b1cbf86 1053
adelino 0:65fd8b1cbf86 1054 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1055
adelino 0:65fd8b1cbf86 1056 //test Xmax
adelino 0:65fd8b1cbf86 1057 if(_xcnew+myRadiusX >= myXMoveMax) {
adelino 0:65fd8b1cbf86 1058 _xcnew=myXMoveMax-myRadiusX;
adelino 0:65fd8b1cbf86 1059
adelino 0:65fd8b1cbf86 1060 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1061 myElementState=BUMP_RIGHT;
adelino 0:65fd8b1cbf86 1062 }
adelino 0:65fd8b1cbf86 1063
adelino 0:65fd8b1cbf86 1064 //test Xmin
adelino 0:65fd8b1cbf86 1065 if(_xcnew <= myRadiusX) {
adelino 0:65fd8b1cbf86 1066 _xcnew=myXMoveMin+myRadiusX;
adelino 0:65fd8b1cbf86 1067
adelino 0:65fd8b1cbf86 1068 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1069 myElementState=BUMP_LEFT;
adelino 0:65fd8b1cbf86 1070 }
adelino 0:65fd8b1cbf86 1071 //test Ymax
adelino 0:65fd8b1cbf86 1072 if(_ycnew +myRadiusY >= myYMoveMax && _ycnew >0) {
adelino 0:65fd8b1cbf86 1073 _ycnew = myYMoveMax- myRadiusY;
adelino 0:65fd8b1cbf86 1074
adelino 0:65fd8b1cbf86 1075 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1076 myElementState=BUMP_DOWN;
adelino 0:65fd8b1cbf86 1077 }
adelino 0:65fd8b1cbf86 1078 //test yminMin;
adelino 0:65fd8b1cbf86 1079 if(_ycnew <= myRadiusY) {
adelino 0:65fd8b1cbf86 1080 _ycnew=myYMoveMin+myRadiusY;
adelino 0:65fd8b1cbf86 1081
adelino 0:65fd8b1cbf86 1082 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1083 myElementState=BUMP_UP;
adelino 0:65fd8b1cbf86 1084 }
adelino 0:65fd8b1cbf86 1085 //
adelino 0:65fd8b1cbf86 1086 myCenterX=_xcnew;
adelino 0:65fd8b1cbf86 1087 myCenterY=_ycnew;
adelino 0:65fd8b1cbf86 1088
adelino 0:65fd8b1cbf86 1089 myX=_xcnew-myRadiusX;
adelino 0:65fd8b1cbf86 1090 myY=_ycnew-myRadiusY;
adelino 0:65fd8b1cbf86 1091
adelino 0:65fd8b1cbf86 1092
adelino 0:65fd8b1cbf86 1093 this->draw();
adelino 0:65fd8b1cbf86 1094 }
adelino 0:65fd8b1cbf86 1095 //-----------------------------------------------
adelino 0:65fd8b1cbf86 1096 Ellipse::~Ellipse(void)
adelino 0:65fd8b1cbf86 1097 {
adelino 0:65fd8b1cbf86 1098 }
adelino 0:65fd8b1cbf86 1099 //----------------------------------------------
adelino 0:65fd8b1cbf86 1100 UINT16 Ellipse::getCenterX(void)
adelino 0:65fd8b1cbf86 1101 {
adelino 0:65fd8b1cbf86 1102 return this->myCenterX;
adelino 0:65fd8b1cbf86 1103 }
adelino 0:65fd8b1cbf86 1104 //---------------------------------------------
adelino 0:65fd8b1cbf86 1105 UINT16 Ellipse::getCenterY(void)
adelino 0:65fd8b1cbf86 1106 {
adelino 0:65fd8b1cbf86 1107 return this->myCenterY;
adelino 0:65fd8b1cbf86 1108 }
adelino 0:65fd8b1cbf86 1109 //----------------------------------------------
adelino 0:65fd8b1cbf86 1110 void Ellipse::setCenterX(UINT16 _xcenter)
adelino 0:65fd8b1cbf86 1111 {
adelino 0:65fd8b1cbf86 1112 myCenterX=_xcenter;
adelino 0:65fd8b1cbf86 1113 }
adelino 0:65fd8b1cbf86 1114 //----------------------------------------------
adelino 0:65fd8b1cbf86 1115 void Ellipse::setCenterY(UINT16 _ycenter)
adelino 0:65fd8b1cbf86 1116 {
adelino 0:65fd8b1cbf86 1117 myCenterY=_ycenter;
adelino 0:65fd8b1cbf86 1118 }
adelino 0:65fd8b1cbf86 1119 //----------------------------------------------
adelino 0:65fd8b1cbf86 1120 //
adelino 0:65fd8b1cbf86 1121 //
adelino 0:65fd8b1cbf86 1122 //
adelino 0:65fd8b1cbf86 1123 Triangle::Triangle(Screen* mScreen,UINT16 _id,UINT16 _x1,UINT16 _y1,
adelino 0:65fd8b1cbf86 1124 UINT16 _x2,UINT16 _y2,
adelino 0:65fd8b1cbf86 1125 UINT16 _x3,UINT16 _y3,Color _color,bool _isVisible):
adelino 0:65fd8b1cbf86 1126 ObjetHeader(mScreen,_id,_x2,_y1,_x3-_x2,_y3-_y1,_color,_isVisible)
adelino 0:65fd8b1cbf86 1127 {
adelino 0:65fd8b1cbf86 1128 myX1=_x1;
adelino 0:65fd8b1cbf86 1129 myY1=_y1;
adelino 0:65fd8b1cbf86 1130 myX2=_x2;
adelino 0:65fd8b1cbf86 1131 myY2=_y2;
adelino 0:65fd8b1cbf86 1132 myX3=_x3;
adelino 0:65fd8b1cbf86 1133 myY3=_y3;
adelino 0:65fd8b1cbf86 1134 myU=_x1-_x2;
adelino 0:65fd8b1cbf86 1135 myV=_y2-_y1;
adelino 0:65fd8b1cbf86 1136
adelino 0:65fd8b1cbf86 1137 myElementType=OBJ_TRIANGLE;
adelino 0:65fd8b1cbf86 1138
adelino 0:65fd8b1cbf86 1139 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 1140 }
adelino 0:65fd8b1cbf86 1141 //-----------------------------------------------
adelino 0:65fd8b1cbf86 1142 Triangle::~Triangle(void)
adelino 0:65fd8b1cbf86 1143 {
adelino 0:65fd8b1cbf86 1144 }
adelino 0:65fd8b1cbf86 1145 //-----------------------------------------------
adelino 0:65fd8b1cbf86 1146 void Triangle::draw(void)
adelino 0:65fd8b1cbf86 1147 {
adelino 0:65fd8b1cbf86 1148 // isVisible ?
adelino 0:65fd8b1cbf86 1149 if(myElementIsVisible==false) {
adelino 0:65fd8b1cbf86 1150 return;
adelino 0:65fd8b1cbf86 1151 }
adelino 0:65fd8b1cbf86 1152 //
adelino 0:65fd8b1cbf86 1153 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1154
adelino 0:65fd8b1cbf86 1155 if(ps!=0) {
adelino 0:65fd8b1cbf86 1156 ps->draw_filled_triangle(myX1,myY1,myX2,myY2,myX3,myY3,myColor);
adelino 0:65fd8b1cbf86 1157 }
adelino 0:65fd8b1cbf86 1158 }
adelino 0:65fd8b1cbf86 1159 //------------------------------------------------
adelino 0:65fd8b1cbf86 1160 void Triangle::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 1161 {
adelino 0:65fd8b1cbf86 1162 // element devient invisible
adelino 0:65fd8b1cbf86 1163 if(_state==true) {
adelino 0:65fd8b1cbf86 1164 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1165 return;
adelino 0:65fd8b1cbf86 1166
adelino 0:65fd8b1cbf86 1167 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 1168
adelino 0:65fd8b1cbf86 1169 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 1170
adelino 0:65fd8b1cbf86 1171
adelino 0:65fd8b1cbf86 1172 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1173
adelino 0:65fd8b1cbf86 1174 if(ps!=0) {
adelino 0:65fd8b1cbf86 1175 ps->draw_filled_triangle(myX1,myY1,myX2,myY2,myX3,myY3,c);
adelino 0:65fd8b1cbf86 1176 }
adelino 0:65fd8b1cbf86 1177 }
adelino 0:65fd8b1cbf86 1178
adelino 0:65fd8b1cbf86 1179 // element devient visible
adelino 0:65fd8b1cbf86 1180 else {
adelino 0:65fd8b1cbf86 1181 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1182
adelino 0:65fd8b1cbf86 1183 this->draw();
adelino 0:65fd8b1cbf86 1184 }
adelino 0:65fd8b1cbf86 1185 }
adelino 0:65fd8b1cbf86 1186 //------------------------------------------------
adelino 0:65fd8b1cbf86 1187 void Triangle::setNewPosition(INT16 _xnew,INT16 _ynew)
adelino 0:65fd8b1cbf86 1188 {
adelino 0:65fd8b1cbf86 1189 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1190 return;
adelino 0:65fd8b1cbf86 1191 //
adelino 0:65fd8b1cbf86 1192 if(myX==_xnew && myY==_ynew)
adelino 0:65fd8b1cbf86 1193 return;
adelino 0:65fd8b1cbf86 1194 setInvisible(true); // colorie le tri avec couleur de la screen
adelino 0:65fd8b1cbf86 1195
adelino 0:65fd8b1cbf86 1196 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1197
adelino 0:65fd8b1cbf86 1198 //test Xmax
adelino 0:65fd8b1cbf86 1199 if(_xnew+myWidth >= myXMoveMax) {
adelino 0:65fd8b1cbf86 1200 _xnew=myXMoveMax-myWidth;
adelino 0:65fd8b1cbf86 1201
adelino 0:65fd8b1cbf86 1202 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1203 myElementState=BUMP_RIGHT;
adelino 0:65fd8b1cbf86 1204 }
adelino 0:65fd8b1cbf86 1205 //
adelino 0:65fd8b1cbf86 1206 //test Xmin
adelino 0:65fd8b1cbf86 1207 if(_xnew <= myXMoveMin) {
adelino 0:65fd8b1cbf86 1208 _xnew=myXMoveMin;
adelino 0:65fd8b1cbf86 1209
adelino 0:65fd8b1cbf86 1210 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1211 myElementState=BUMP_LEFT;
adelino 0:65fd8b1cbf86 1212 }
adelino 0:65fd8b1cbf86 1213 //test Ymax
adelino 0:65fd8b1cbf86 1214 if(_ynew +myHeight >= myYMoveMax && _ynew >0) {
adelino 0:65fd8b1cbf86 1215 _ynew = myYMoveMax- myHeight;
adelino 0:65fd8b1cbf86 1216
adelino 0:65fd8b1cbf86 1217 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1218 myElementState=BUMP_DOWN;
adelino 0:65fd8b1cbf86 1219 }
adelino 0:65fd8b1cbf86 1220 //test yminMin;
adelino 0:65fd8b1cbf86 1221 if(_ynew <= myYMoveMin) {
adelino 0:65fd8b1cbf86 1222 _ynew=myYMoveMin;
adelino 0:65fd8b1cbf86 1223
adelino 0:65fd8b1cbf86 1224 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1225 myElementState=BUMP_UP;
adelino 0:65fd8b1cbf86 1226 }
adelino 0:65fd8b1cbf86 1227
adelino 0:65fd8b1cbf86 1228 //
adelino 0:65fd8b1cbf86 1229 myX=_xnew;
adelino 0:65fd8b1cbf86 1230 myY=_ynew;
adelino 0:65fd8b1cbf86 1231
adelino 0:65fd8b1cbf86 1232 myX1=_xnew+myU;
adelino 0:65fd8b1cbf86 1233 myY1=_ynew;
adelino 0:65fd8b1cbf86 1234
adelino 0:65fd8b1cbf86 1235 myX2=_xnew;
adelino 0:65fd8b1cbf86 1236 myY2=_ynew+myV;
adelino 0:65fd8b1cbf86 1237
adelino 0:65fd8b1cbf86 1238 myX3=_xnew+myWidth;
adelino 0:65fd8b1cbf86 1239 myY3=_ynew+myHeight;
adelino 0:65fd8b1cbf86 1240
adelino 0:65fd8b1cbf86 1241 this->draw();
adelino 0:65fd8b1cbf86 1242 }
adelino 0:65fd8b1cbf86 1243 //------------------------------------------------
adelino 0:65fd8b1cbf86 1244 void Triangle::update(float delta)
adelino 0:65fd8b1cbf86 1245 {
adelino 0:65fd8b1cbf86 1246 if(myIsUpdateAutomatic)
adelino 0:65fd8b1cbf86 1247 elementUpdate();
adelino 0:65fd8b1cbf86 1248 //
adelino 0:65fd8b1cbf86 1249 float xnew=myX+mySpeedX*delta;
adelino 0:65fd8b1cbf86 1250 float ynew=myY+mySpeedY*delta;
adelino 0:65fd8b1cbf86 1251
adelino 0:65fd8b1cbf86 1252 this->setNewPosition((INT16)xnew,(INT16)ynew);
adelino 0:65fd8b1cbf86 1253
adelino 0:65fd8b1cbf86 1254 updateCellId();
adelino 0:65fd8b1cbf86 1255 }
adelino 0:65fd8b1cbf86 1256 //-------------------------------------------------
adelino 0:65fd8b1cbf86 1257 //
adelino 0:65fd8b1cbf86 1258 //
adelino 0:65fd8b1cbf86 1259 Diamond::Diamond(Screen* mScreen,UINT16 _id,UINT16 x1,UINT16 y1,UINT16 x2,UINT16 y2,
adelino 0:65fd8b1cbf86 1260 UINT16 x3,UINT16 y3,UINT16 x4,UINT16 y4,Color _color,bool _isVisible):ObjetHeader(mScreen,_id,x1,y4,x3-x1,y2-y4,_color,_isVisible)
adelino 0:65fd8b1cbf86 1261 {
adelino 0:65fd8b1cbf86 1262 myX1=x1;
adelino 0:65fd8b1cbf86 1263 myY1=y1;
adelino 0:65fd8b1cbf86 1264
adelino 0:65fd8b1cbf86 1265 myX2=x2;
adelino 0:65fd8b1cbf86 1266 myY2=y2;
adelino 0:65fd8b1cbf86 1267
adelino 0:65fd8b1cbf86 1268 myX3=x3;
adelino 0:65fd8b1cbf86 1269 myY3=y3;
adelino 0:65fd8b1cbf86 1270
adelino 0:65fd8b1cbf86 1271 myX4=x4;
adelino 0:65fd8b1cbf86 1272 myY4=y4;
adelino 0:65fd8b1cbf86 1273
adelino 0:65fd8b1cbf86 1274 myU1=x4-x1;
adelino 0:65fd8b1cbf86 1275 myU2=x2-x1;
adelino 0:65fd8b1cbf86 1276
adelino 0:65fd8b1cbf86 1277 myV1=y1-y4;
adelino 0:65fd8b1cbf86 1278 myV2=y3-y4;
adelino 0:65fd8b1cbf86 1279
adelino 0:65fd8b1cbf86 1280
adelino 0:65fd8b1cbf86 1281 myElementType=OBJ_DIAMOND;
adelino 0:65fd8b1cbf86 1282
adelino 0:65fd8b1cbf86 1283 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 1284 }
adelino 0:65fd8b1cbf86 1285 //-----------------------------------------
adelino 0:65fd8b1cbf86 1286 void Diamond::draw(void)
adelino 0:65fd8b1cbf86 1287 {
adelino 0:65fd8b1cbf86 1288 // isVisible ?
adelino 0:65fd8b1cbf86 1289 if(myElementIsVisible==false) {
adelino 0:65fd8b1cbf86 1290 return;
adelino 0:65fd8b1cbf86 1291 }
adelino 0:65fd8b1cbf86 1292 //
adelino 0:65fd8b1cbf86 1293 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1294
adelino 0:65fd8b1cbf86 1295 if(ps!=0) {
adelino 0:65fd8b1cbf86 1296 ps->draw_filled_diamond(myX1,myY1,myX2,myY2,myX3,myY3,myX4,myY4,myColor);
adelino 0:65fd8b1cbf86 1297 }
adelino 0:65fd8b1cbf86 1298 }
adelino 0:65fd8b1cbf86 1299 //-----------------------------------------
adelino 0:65fd8b1cbf86 1300 Diamond::~Diamond(void)
adelino 0:65fd8b1cbf86 1301 {
adelino 0:65fd8b1cbf86 1302 }
adelino 0:65fd8b1cbf86 1303 //----------------------------
adelino 0:65fd8b1cbf86 1304 void Diamond::update(float delta)
adelino 0:65fd8b1cbf86 1305 {
adelino 0:65fd8b1cbf86 1306 if(myIsUpdateAutomatic)
adelino 0:65fd8b1cbf86 1307 elementUpdate();
adelino 0:65fd8b1cbf86 1308 //
adelino 0:65fd8b1cbf86 1309 float xnew=myX+mySpeedX*delta;
adelino 0:65fd8b1cbf86 1310 float ynew=myY+mySpeedY*delta;
adelino 0:65fd8b1cbf86 1311
adelino 0:65fd8b1cbf86 1312 this->setNewPosition((INT16)xnew,(INT16)ynew);
adelino 0:65fd8b1cbf86 1313
adelino 0:65fd8b1cbf86 1314 updateCellId();
adelino 0:65fd8b1cbf86 1315 }
adelino 0:65fd8b1cbf86 1316 //-------------------------------
adelino 0:65fd8b1cbf86 1317 void Diamond::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 1318 {
adelino 0:65fd8b1cbf86 1319 // element devient invisible
adelino 0:65fd8b1cbf86 1320 if(_state==true) {
adelino 0:65fd8b1cbf86 1321 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1322 return;
adelino 0:65fd8b1cbf86 1323
adelino 0:65fd8b1cbf86 1324 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 1325
adelino 0:65fd8b1cbf86 1326 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 1327
adelino 0:65fd8b1cbf86 1328 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1329
adelino 0:65fd8b1cbf86 1330 if(ps!=0) {
adelino 0:65fd8b1cbf86 1331 ps->draw_filled_diamond(myX1,myY1,myX2,myY2,myX3,myY3,myX4,myY4,c);
adelino 0:65fd8b1cbf86 1332 }
adelino 0:65fd8b1cbf86 1333 }
adelino 0:65fd8b1cbf86 1334
adelino 0:65fd8b1cbf86 1335 // element devient visible
adelino 0:65fd8b1cbf86 1336 else {
adelino 0:65fd8b1cbf86 1337 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1338
adelino 0:65fd8b1cbf86 1339 this->draw();
adelino 0:65fd8b1cbf86 1340 }
adelino 0:65fd8b1cbf86 1341 }
adelino 0:65fd8b1cbf86 1342 //---------------------------------
adelino 0:65fd8b1cbf86 1343 void Diamond::setNewPosition(INT16 _xnew,INT16 _ynew)
adelino 0:65fd8b1cbf86 1344 {
adelino 0:65fd8b1cbf86 1345 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1346 return;
adelino 0:65fd8b1cbf86 1347 //
adelino 0:65fd8b1cbf86 1348 if(myX==_xnew && myY==_ynew)
adelino 0:65fd8b1cbf86 1349 return;
adelino 0:65fd8b1cbf86 1350 setInvisible(true); // colorie le tri avec couleur de la screen
adelino 0:65fd8b1cbf86 1351
adelino 0:65fd8b1cbf86 1352 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1353
adelino 0:65fd8b1cbf86 1354 //test Xmax
adelino 0:65fd8b1cbf86 1355 if(_xnew+myWidth >= myXMoveMax) {
adelino 0:65fd8b1cbf86 1356 _xnew=myXMoveMax-myWidth;
adelino 0:65fd8b1cbf86 1357
adelino 0:65fd8b1cbf86 1358 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1359 myElementState=BUMP_RIGHT;
adelino 0:65fd8b1cbf86 1360 }
adelino 0:65fd8b1cbf86 1361 //
adelino 0:65fd8b1cbf86 1362 //test Xmin
adelino 0:65fd8b1cbf86 1363 if(_xnew <= myXMoveMin) {
adelino 0:65fd8b1cbf86 1364 _xnew=myXMoveMin;
adelino 0:65fd8b1cbf86 1365
adelino 0:65fd8b1cbf86 1366 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1367 myElementState=BUMP_LEFT;
adelino 0:65fd8b1cbf86 1368 }
adelino 0:65fd8b1cbf86 1369 //test Ymax
adelino 0:65fd8b1cbf86 1370 if(_ynew +myHeight >= myYMoveMax && _ynew >0) {
adelino 0:65fd8b1cbf86 1371 _ynew = myYMoveMax- myHeight;
adelino 0:65fd8b1cbf86 1372
adelino 0:65fd8b1cbf86 1373 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1374 myElementState=BUMP_DOWN;
adelino 0:65fd8b1cbf86 1375 }
adelino 0:65fd8b1cbf86 1376 //test yminMin;
adelino 0:65fd8b1cbf86 1377 if(_ynew <= myYMoveMin) {
adelino 0:65fd8b1cbf86 1378 _ynew=myYMoveMin;
adelino 0:65fd8b1cbf86 1379
adelino 0:65fd8b1cbf86 1380 if(myElementState==STATE_ON)
adelino 0:65fd8b1cbf86 1381 myElementState=BUMP_UP;
adelino 0:65fd8b1cbf86 1382 }
adelino 0:65fd8b1cbf86 1383
adelino 0:65fd8b1cbf86 1384 //
adelino 0:65fd8b1cbf86 1385 myX=_xnew;
adelino 0:65fd8b1cbf86 1386 myY=_ynew;
adelino 0:65fd8b1cbf86 1387
adelino 0:65fd8b1cbf86 1388 myX1=_xnew;
adelino 0:65fd8b1cbf86 1389 myY1=_ynew+myV1;
adelino 0:65fd8b1cbf86 1390
adelino 0:65fd8b1cbf86 1391 myX2=_xnew+myU2;
adelino 0:65fd8b1cbf86 1392 myY2=_ynew+myHeight;
adelino 0:65fd8b1cbf86 1393
adelino 0:65fd8b1cbf86 1394 myX3=_xnew+myWidth;
adelino 0:65fd8b1cbf86 1395 myY3=_ynew+myV2;
adelino 0:65fd8b1cbf86 1396
adelino 0:65fd8b1cbf86 1397 myX4=_xnew+myU1;
adelino 0:65fd8b1cbf86 1398 myY4=_ynew;
adelino 0:65fd8b1cbf86 1399
adelino 0:65fd8b1cbf86 1400 this->draw();
adelino 0:65fd8b1cbf86 1401 }
adelino 0:65fd8b1cbf86 1402 //---------------------------------
adelino 0:65fd8b1cbf86 1403 //
adelino 0:65fd8b1cbf86 1404 //
adelino 0:65fd8b1cbf86 1405 //
adelino 0:65fd8b1cbf86 1406 Label::Label(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,
adelino 0:65fd8b1cbf86 1407 string _text,Font _font,Color _colorText,Color _colorBkg,
adelino 0:65fd8b1cbf86 1408 bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,10,10,_colorBkg,_isVisible)
adelino 0:65fd8b1cbf86 1409
adelino 0:65fd8b1cbf86 1410 {
adelino 0:65fd8b1cbf86 1411 myText=_text;
adelino 0:65fd8b1cbf86 1412 myFont=_font;
adelino 0:65fd8b1cbf86 1413 myColorText=_colorText;
adelino 0:65fd8b1cbf86 1414
adelino 0:65fd8b1cbf86 1415 myElementType=OBJ_LABEL;
adelino 0:65fd8b1cbf86 1416
adelino 0:65fd8b1cbf86 1417 //
adelino 0:65fd8b1cbf86 1418 UINT16 largeur=0;
adelino 0:65fd8b1cbf86 1419 UINT16 hauteur=16;
adelino 0:65fd8b1cbf86 1420 UINT16 taille=0;
adelino 0:65fd8b1cbf86 1421 UINT16 incLargeur=12;
adelino 0:65fd8b1cbf86 1422
adelino 0:65fd8b1cbf86 1423 switch(_font) {
adelino 0:65fd8b1cbf86 1424 //
adelino 0:65fd8b1cbf86 1425 case FONT_2:
adelino 0:65fd8b1cbf86 1426 incLargeur=8;
adelino 0:65fd8b1cbf86 1427 hauteur=8;
adelino 0:65fd8b1cbf86 1428 largeur=8;
adelino 0:65fd8b1cbf86 1429 break;
adelino 0:65fd8b1cbf86 1430
adelino 0:65fd8b1cbf86 1431 //
adelino 0:65fd8b1cbf86 1432 case FONT_3:
adelino 0:65fd8b1cbf86 1433 incLargeur=8;
adelino 0:65fd8b1cbf86 1434 hauteur=12;
adelino 0:65fd8b1cbf86 1435 largeur=8;
adelino 0:65fd8b1cbf86 1436 break;
adelino 0:65fd8b1cbf86 1437 //
adelino 0:65fd8b1cbf86 1438 case FONT_1:
adelino 0:65fd8b1cbf86 1439 incLargeur=5;
adelino 0:65fd8b1cbf86 1440 hauteur=7;
adelino 0:65fd8b1cbf86 1441 largeur=5;
adelino 0:65fd8b1cbf86 1442 break;
adelino 0:65fd8b1cbf86 1443
adelino 0:65fd8b1cbf86 1444 //
adelino 0:65fd8b1cbf86 1445 default:
adelino 0:65fd8b1cbf86 1446 incLargeur=12;
adelino 0:65fd8b1cbf86 1447 hauteur=16;
adelino 0:65fd8b1cbf86 1448 largeur=8;
adelino 0:65fd8b1cbf86 1449 break;
adelino 0:65fd8b1cbf86 1450 }
adelino 0:65fd8b1cbf86 1451 //cherche taille
adelino 0:65fd8b1cbf86 1452
adelino 0:65fd8b1cbf86 1453 /*
adelino 0:65fd8b1cbf86 1454 while(*_text)
adelino 0:65fd8b1cbf86 1455 {
adelino 0:65fd8b1cbf86 1456 taille++;
adelino 0:65fd8b1cbf86 1457 largeur=largeur+incLargeur;
adelino 0:65fd8b1cbf86 1458 _text++;
adelino 0:65fd8b1cbf86 1459 }
adelino 0:65fd8b1cbf86 1460 _text=_text-taille;
adelino 0:65fd8b1cbf86 1461
adelino 0:65fd8b1cbf86 1462 */
adelino 0:65fd8b1cbf86 1463 taille=_text.size();
adelino 0:65fd8b1cbf86 1464 largeur=incLargeur*taille;
adelino 0:65fd8b1cbf86 1465
adelino 0:65fd8b1cbf86 1466 if(largeur > incLargeur)
adelino 0:65fd8b1cbf86 1467 largeur=largeur-incLargeur;
adelino 0:65fd8b1cbf86 1468
adelino 0:65fd8b1cbf86 1469 myWidth=largeur;
adelino 0:65fd8b1cbf86 1470 myHeight=hauteur;
adelino 0:65fd8b1cbf86 1471
adelino 0:65fd8b1cbf86 1472 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 1473 }
adelino 0:65fd8b1cbf86 1474 //-----------------------------------------------------
adelino 0:65fd8b1cbf86 1475 Label::~Label(void)
adelino 0:65fd8b1cbf86 1476 {
adelino 0:65fd8b1cbf86 1477 //myText=0;
adelino 0:65fd8b1cbf86 1478 }
adelino 0:65fd8b1cbf86 1479 //-----------------------------------------------------
adelino 0:65fd8b1cbf86 1480 void Label::draw(void)
adelino 0:65fd8b1cbf86 1481 {
adelino 0:65fd8b1cbf86 1482 // isVisible ?
adelino 0:65fd8b1cbf86 1483 if(myElementIsVisible==false) {
adelino 0:65fd8b1cbf86 1484 return;
adelino 0:65fd8b1cbf86 1485 }
adelino 0:65fd8b1cbf86 1486 //
adelino 0:65fd8b1cbf86 1487
adelino 0:65fd8b1cbf86 1488 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1489
adelino 0:65fd8b1cbf86 1490 if(ps!=0) {
adelino 0:65fd8b1cbf86 1491
adelino 0:65fd8b1cbf86 1492 ps->draw_string(myText,myX,myY,myFont,myColorText,myColor);
adelino 0:65fd8b1cbf86 1493 }
adelino 0:65fd8b1cbf86 1494 }
adelino 0:65fd8b1cbf86 1495 //------------------------------------------------------
adelino 0:65fd8b1cbf86 1496 void Label::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 1497 {
adelino 0:65fd8b1cbf86 1498 // element devient invisible
adelino 0:65fd8b1cbf86 1499 if(_state==true) {
adelino 0:65fd8b1cbf86 1500 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1501 return;
adelino 0:65fd8b1cbf86 1502
adelino 0:65fd8b1cbf86 1503 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 1504
adelino 0:65fd8b1cbf86 1505 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 1506
adelino 0:65fd8b1cbf86 1507 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1508
adelino 0:65fd8b1cbf86 1509 if(ps!=0) {
adelino 0:65fd8b1cbf86 1510 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
adelino 0:65fd8b1cbf86 1511 }
adelino 0:65fd8b1cbf86 1512 }
adelino 0:65fd8b1cbf86 1513
adelino 0:65fd8b1cbf86 1514 // element devient visible
adelino 0:65fd8b1cbf86 1515 else {
adelino 0:65fd8b1cbf86 1516 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1517
adelino 0:65fd8b1cbf86 1518 this->draw();
adelino 0:65fd8b1cbf86 1519 }
adelino 0:65fd8b1cbf86 1520 }
adelino 0:65fd8b1cbf86 1521 //-------------------------------------------------------
adelino 0:65fd8b1cbf86 1522 void Label::setNewText(string _newText)
adelino 0:65fd8b1cbf86 1523 {
adelino 0:65fd8b1cbf86 1524 //if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1525 // return;
adelino 0:65fd8b1cbf86 1526
adelino 0:65fd8b1cbf86 1527 UINT16 hauteur=16;
adelino 0:65fd8b1cbf86 1528 UINT16 incLargeur=12;
adelino 0:65fd8b1cbf86 1529 UINT16 taille=0;
adelino 0:65fd8b1cbf86 1530
adelino 0:65fd8b1cbf86 1531 switch(myFont) {
adelino 0:65fd8b1cbf86 1532 //
adelino 0:65fd8b1cbf86 1533 case FONT_2:
adelino 0:65fd8b1cbf86 1534 incLargeur=8;
adelino 0:65fd8b1cbf86 1535 hauteur=8;
adelino 0:65fd8b1cbf86 1536 break;
adelino 0:65fd8b1cbf86 1537
adelino 0:65fd8b1cbf86 1538 //
adelino 0:65fd8b1cbf86 1539 case FONT_3:
adelino 0:65fd8b1cbf86 1540 incLargeur=8;
adelino 0:65fd8b1cbf86 1541 hauteur=12;
adelino 0:65fd8b1cbf86 1542 break;
adelino 0:65fd8b1cbf86 1543 //
adelino 0:65fd8b1cbf86 1544 case FONT_1:
adelino 0:65fd8b1cbf86 1545 incLargeur=5;
adelino 0:65fd8b1cbf86 1546 hauteur=7;
adelino 0:65fd8b1cbf86 1547 break;
adelino 0:65fd8b1cbf86 1548
adelino 0:65fd8b1cbf86 1549 //
adelino 0:65fd8b1cbf86 1550 default:
adelino 0:65fd8b1cbf86 1551 incLargeur=12;
adelino 0:65fd8b1cbf86 1552 hauteur=16;
adelino 0:65fd8b1cbf86 1553 break;
adelino 0:65fd8b1cbf86 1554 }
adelino 0:65fd8b1cbf86 1555
adelino 0:65fd8b1cbf86 1556 taille=_newText.size();
adelino 0:65fd8b1cbf86 1557
adelino 0:65fd8b1cbf86 1558 //myWidth=_nbChar*incLargeur;
adelino 0:65fd8b1cbf86 1559 myWidth=taille*incLargeur;
adelino 0:65fd8b1cbf86 1560 myHeight=hauteur;
adelino 0:65fd8b1cbf86 1561 myText=_newText;
adelino 0:65fd8b1cbf86 1562
adelino 0:65fd8b1cbf86 1563 setInvisible(true);
adelino 0:65fd8b1cbf86 1564 setInvisible(false);
adelino 0:65fd8b1cbf86 1565 // this->draw();
adelino 0:65fd8b1cbf86 1566 }
adelino 0:65fd8b1cbf86 1567 //-------------------------------------------------------
adelino 0:65fd8b1cbf86 1568 GraphicLed::GraphicLed(Screen* mScreen,UINT16 _id,UINT16 _xc,UINT16 _yc,UINT16 _radius,
adelino 0:65fd8b1cbf86 1569 Color _colorOn,Color _colorOff,State _state,
adelino 0:65fd8b1cbf86 1570 bool _isVisible):ObjetHeader(mScreen,_id,_xc-_radius,_yc-_radius,_radius+_radius,_radius+_radius,_colorOn,_isVisible)
adelino 0:65fd8b1cbf86 1571 {
adelino 0:65fd8b1cbf86 1572 myColorOn=_colorOn;
adelino 0:65fd8b1cbf86 1573 myColorOff=_colorOff;
adelino 0:65fd8b1cbf86 1574 myRadius=_radius;
adelino 0:65fd8b1cbf86 1575 myCenterX=_xc;
adelino 0:65fd8b1cbf86 1576 myCenterY=_yc;
adelino 0:65fd8b1cbf86 1577
adelino 0:65fd8b1cbf86 1578 myElementState=_state;
adelino 0:65fd8b1cbf86 1579 myElementType=OBJ_LED;
adelino 0:65fd8b1cbf86 1580 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 1581 }
adelino 0:65fd8b1cbf86 1582 //---------------------------------------
adelino 0:65fd8b1cbf86 1583 GraphicLed::~GraphicLed(void)
adelino 0:65fd8b1cbf86 1584 {
adelino 0:65fd8b1cbf86 1585 }
adelino 0:65fd8b1cbf86 1586 //---------------------------------------
adelino 0:65fd8b1cbf86 1587 void GraphicLed::draw(void)
adelino 0:65fd8b1cbf86 1588 {
adelino 0:65fd8b1cbf86 1589 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1590 return;
adelino 0:65fd8b1cbf86 1591
adelino 0:65fd8b1cbf86 1592 UINT16 state=getElementState();
adelino 0:65fd8b1cbf86 1593
adelino 0:65fd8b1cbf86 1594 //static PicasoSerial* ps=0;
adelino 0:65fd8b1cbf86 1595 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1596
adelino 0:65fd8b1cbf86 1597 switch(state) {
adelino 0:65fd8b1cbf86 1598 //
adelino 0:65fd8b1cbf86 1599 case LED_STATE_ON:
adelino 0:65fd8b1cbf86 1600 if(ps!=0) {
adelino 0:65fd8b1cbf86 1601 ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColorOn);
adelino 0:65fd8b1cbf86 1602 ps->draw_circle(myCenterX,myCenterY,myRadius,BLACK);
adelino 0:65fd8b1cbf86 1603 }
adelino 0:65fd8b1cbf86 1604 return;
adelino 0:65fd8b1cbf86 1605 //
adelino 0:65fd8b1cbf86 1606 case LED_STATE_OFF:
adelino 0:65fd8b1cbf86 1607 if(ps!=0) {
adelino 0:65fd8b1cbf86 1608 ps->draw_filled_circle(myCenterX,myCenterY,myRadius,myColorOff);
adelino 0:65fd8b1cbf86 1609 ps->draw_circle(myCenterX,myCenterY,myRadius,BLACK);
adelino 0:65fd8b1cbf86 1610 }
adelino 0:65fd8b1cbf86 1611 return;
adelino 0:65fd8b1cbf86 1612 //
adelino 0:65fd8b1cbf86 1613 default:
adelino 0:65fd8b1cbf86 1614 break;
adelino 0:65fd8b1cbf86 1615 }
adelino 0:65fd8b1cbf86 1616 }
adelino 0:65fd8b1cbf86 1617 //---------------------------------------
adelino 0:65fd8b1cbf86 1618 void GraphicLed::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 1619 {
adelino 0:65fd8b1cbf86 1620 // element devient invisible
adelino 0:65fd8b1cbf86 1621 if(_state==true) {
adelino 0:65fd8b1cbf86 1622 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1623 return;
adelino 0:65fd8b1cbf86 1624
adelino 0:65fd8b1cbf86 1625 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 1626
adelino 0:65fd8b1cbf86 1627 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 1628
adelino 0:65fd8b1cbf86 1629 //static PicasoSerial* ps=0;
adelino 0:65fd8b1cbf86 1630 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1631
adelino 0:65fd8b1cbf86 1632 if(ps!=0) {
adelino 0:65fd8b1cbf86 1633 ps->draw_filled_circle(myCenterX,myCenterY,myRadius,c);
adelino 0:65fd8b1cbf86 1634 }
adelino 0:65fd8b1cbf86 1635 }
adelino 0:65fd8b1cbf86 1636
adelino 0:65fd8b1cbf86 1637 // element devient visible
adelino 0:65fd8b1cbf86 1638 else {
adelino 0:65fd8b1cbf86 1639 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1640
adelino 0:65fd8b1cbf86 1641
adelino 0:65fd8b1cbf86 1642 this->draw();
adelino 0:65fd8b1cbf86 1643 }
adelino 0:65fd8b1cbf86 1644 }
adelino 0:65fd8b1cbf86 1645 //---------------------------------------
adelino 0:65fd8b1cbf86 1646 void GraphicLed::setState(State _state)
adelino 0:65fd8b1cbf86 1647 {
adelino 0:65fd8b1cbf86 1648 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1649 return;
adelino 0:65fd8b1cbf86 1650
adelino 0:65fd8b1cbf86 1651 if(myElementState==_state)
adelino 0:65fd8b1cbf86 1652 return;
adelino 0:65fd8b1cbf86 1653
adelino 0:65fd8b1cbf86 1654 myElementState=_state;
adelino 0:65fd8b1cbf86 1655
adelino 0:65fd8b1cbf86 1656 this->draw();
adelino 0:65fd8b1cbf86 1657 }
adelino 0:65fd8b1cbf86 1658 //---------------------------------------
adelino 0:65fd8b1cbf86 1659 Button::Button(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,string _text,Font _font,
adelino 0:65fd8b1cbf86 1660 Color _colorText,Color _colorBtn,State _state,
adelino 0:65fd8b1cbf86 1661 bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,0,0,_colorBtn,_isVisible)
adelino 0:65fd8b1cbf86 1662
adelino 0:65fd8b1cbf86 1663 {
adelino 0:65fd8b1cbf86 1664 myText=_text;
adelino 0:65fd8b1cbf86 1665 myFont=_font;
adelino 0:65fd8b1cbf86 1666 myColorText=_colorText;
adelino 0:65fd8b1cbf86 1667
adelino 0:65fd8b1cbf86 1668 myElementState=_state;
adelino 0:65fd8b1cbf86 1669 myElementType=OBJ_BUTTON;
adelino 0:65fd8b1cbf86 1670
adelino 0:65fd8b1cbf86 1671 //
adelino 0:65fd8b1cbf86 1672 UINT16 largeur=0;
adelino 0:65fd8b1cbf86 1673 UINT16 hauteur=16;
adelino 0:65fd8b1cbf86 1674 UINT16 taille=0;
adelino 0:65fd8b1cbf86 1675 UINT16 incLargeur=12;
adelino 0:65fd8b1cbf86 1676
adelino 0:65fd8b1cbf86 1677 switch(_font) {
adelino 0:65fd8b1cbf86 1678 //
adelino 0:65fd8b1cbf86 1679 case FONT_2:
adelino 0:65fd8b1cbf86 1680 incLargeur=8;
adelino 0:65fd8b1cbf86 1681 hauteur=8;
adelino 0:65fd8b1cbf86 1682 largeur=8;
adelino 0:65fd8b1cbf86 1683 break;
adelino 0:65fd8b1cbf86 1684
adelino 0:65fd8b1cbf86 1685 //
adelino 0:65fd8b1cbf86 1686 case FONT_3:
adelino 0:65fd8b1cbf86 1687 incLargeur=8;
adelino 0:65fd8b1cbf86 1688 hauteur=12;
adelino 0:65fd8b1cbf86 1689 largeur=8;
adelino 0:65fd8b1cbf86 1690 break;
adelino 0:65fd8b1cbf86 1691 //
adelino 0:65fd8b1cbf86 1692 case FONT_1:
adelino 0:65fd8b1cbf86 1693 incLargeur=5;
adelino 0:65fd8b1cbf86 1694 hauteur=7;
adelino 0:65fd8b1cbf86 1695 largeur=5;
adelino 0:65fd8b1cbf86 1696 break;
adelino 0:65fd8b1cbf86 1697
adelino 0:65fd8b1cbf86 1698 //
adelino 0:65fd8b1cbf86 1699 default:
adelino 0:65fd8b1cbf86 1700 incLargeur=12;
adelino 0:65fd8b1cbf86 1701 hauteur=16;
adelino 0:65fd8b1cbf86 1702 largeur=8;
adelino 0:65fd8b1cbf86 1703 break;
adelino 0:65fd8b1cbf86 1704 }
adelino 0:65fd8b1cbf86 1705
adelino 0:65fd8b1cbf86 1706 //cherche taille
adelino 0:65fd8b1cbf86 1707 /*
adelino 0:65fd8b1cbf86 1708 while(*_text) {
adelino 0:65fd8b1cbf86 1709 taille++;
adelino 0:65fd8b1cbf86 1710 largeur=largeur+incLargeur;
adelino 0:65fd8b1cbf86 1711 _text++;
adelino 0:65fd8b1cbf86 1712 }
adelino 0:65fd8b1cbf86 1713 _text=_text-taille;
adelino 0:65fd8b1cbf86 1714 */
adelino 0:65fd8b1cbf86 1715 taille=_text.size();
adelino 0:65fd8b1cbf86 1716
adelino 0:65fd8b1cbf86 1717 largeur=taille*incLargeur;
adelino 0:65fd8b1cbf86 1718
adelino 0:65fd8b1cbf86 1719 if(largeur > incLargeur)
adelino 0:65fd8b1cbf86 1720 largeur=largeur-incLargeur;
adelino 0:65fd8b1cbf86 1721
adelino 0:65fd8b1cbf86 1722 myWidth=largeur+incLargeur+incLargeur;
adelino 0:65fd8b1cbf86 1723 myHeight=hauteur+incLargeur+incLargeur;
adelino 0:65fd8b1cbf86 1724
adelino 0:65fd8b1cbf86 1725 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 1726
adelino 0:65fd8b1cbf86 1727 //
adelino 0:65fd8b1cbf86 1728
adelino 0:65fd8b1cbf86 1729 }
adelino 0:65fd8b1cbf86 1730 //--------------------------------------
adelino 0:65fd8b1cbf86 1731 Button::~Button(void)
adelino 0:65fd8b1cbf86 1732 {
adelino 0:65fd8b1cbf86 1733 }
adelino 0:65fd8b1cbf86 1734 //---------------------------------------
adelino 0:65fd8b1cbf86 1735 void Button::draw(void)
adelino 0:65fd8b1cbf86 1736 {
adelino 0:65fd8b1cbf86 1737 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1738 return;
adelino 0:65fd8b1cbf86 1739
adelino 0:65fd8b1cbf86 1740 UINT16 state=getElementState();
adelino 0:65fd8b1cbf86 1741
adelino 0:65fd8b1cbf86 1742 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1743
adelino 0:65fd8b1cbf86 1744 switch(state) {
adelino 0:65fd8b1cbf86 1745 //
adelino 0:65fd8b1cbf86 1746 case BUTTON_STATE_PRESSED:
adelino 0:65fd8b1cbf86 1747 if(ps!=0) {
adelino 0:65fd8b1cbf86 1748 ps->draw_button(myText,myX,myY,myFont,BUTTON_STATE_PRESSED,myColor,WHITE);
adelino 0:65fd8b1cbf86 1749
adelino 0:65fd8b1cbf86 1750 }
adelino 0:65fd8b1cbf86 1751 return;
adelino 0:65fd8b1cbf86 1752 //
adelino 0:65fd8b1cbf86 1753 case BUTTON_STATE_RELEASED:
adelino 0:65fd8b1cbf86 1754 if(ps!=0) {
adelino 0:65fd8b1cbf86 1755 ps->draw_button(myText,myX,myY,myFont,BUTTON_STATE_RELEASED,myColor,myColorText);
adelino 0:65fd8b1cbf86 1756
adelino 0:65fd8b1cbf86 1757 }
adelino 0:65fd8b1cbf86 1758 return;
adelino 0:65fd8b1cbf86 1759 //
adelino 0:65fd8b1cbf86 1760 default:
adelino 0:65fd8b1cbf86 1761 break;
adelino 0:65fd8b1cbf86 1762 }
adelino 0:65fd8b1cbf86 1763 }
adelino 0:65fd8b1cbf86 1764
adelino 0:65fd8b1cbf86 1765 //-----------------------------------
adelino 0:65fd8b1cbf86 1766 void Button::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 1767 {
adelino 0:65fd8b1cbf86 1768 // element devient invisible
adelino 0:65fd8b1cbf86 1769 if(_state==true) {
adelino 0:65fd8b1cbf86 1770 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1771 return;
adelino 0:65fd8b1cbf86 1772
adelino 0:65fd8b1cbf86 1773 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 1774
adelino 0:65fd8b1cbf86 1775 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 1776
adelino 0:65fd8b1cbf86 1777 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1778
adelino 0:65fd8b1cbf86 1779 if(ps!=0) {
adelino 0:65fd8b1cbf86 1780 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
adelino 0:65fd8b1cbf86 1781 }
adelino 0:65fd8b1cbf86 1782 }
adelino 0:65fd8b1cbf86 1783
adelino 0:65fd8b1cbf86 1784 // element devient visible
adelino 0:65fd8b1cbf86 1785 else {
adelino 0:65fd8b1cbf86 1786 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1787
adelino 0:65fd8b1cbf86 1788
adelino 0:65fd8b1cbf86 1789 this->draw();
adelino 0:65fd8b1cbf86 1790 }
adelino 0:65fd8b1cbf86 1791 }
adelino 0:65fd8b1cbf86 1792 //------------------------------------
adelino 0:65fd8b1cbf86 1793 void Button::setState(State _state)
adelino 0:65fd8b1cbf86 1794 {
adelino 0:65fd8b1cbf86 1795 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1796 return;
adelino 0:65fd8b1cbf86 1797
adelino 0:65fd8b1cbf86 1798 if(myElementState==_state)
adelino 0:65fd8b1cbf86 1799 return;
adelino 0:65fd8b1cbf86 1800
adelino 0:65fd8b1cbf86 1801 myElementState=_state;
adelino 0:65fd8b1cbf86 1802
adelino 0:65fd8b1cbf86 1803 this->draw();
adelino 0:65fd8b1cbf86 1804 }
adelino 0:65fd8b1cbf86 1805 //-------------------------------------
adelino 0:65fd8b1cbf86 1806 Slider::Slider(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _width,UINT16 _height,int _valMax,int _value,
adelino 0:65fd8b1cbf86 1807 Color _colorBkg,bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,_width,_height,_colorBkg,_isVisible)
adelino 0:65fd8b1cbf86 1808 {
adelino 0:65fd8b1cbf86 1809
adelino 0:65fd8b1cbf86 1810 myValueMax=_valMax;
adelino 0:65fd8b1cbf86 1811 myValue=_value;
adelino 0:65fd8b1cbf86 1812
adelino 0:65fd8b1cbf86 1813 myElementType=OBJ_SLIDER;
adelino 0:65fd8b1cbf86 1814 myElementState=SLIDER_STATE_RELEASED;
adelino 0:65fd8b1cbf86 1815
adelino 0:65fd8b1cbf86 1816 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 1817 }
adelino 0:65fd8b1cbf86 1818 //---------------------------------------
adelino 0:65fd8b1cbf86 1819 Slider::~Slider(void)
adelino 0:65fd8b1cbf86 1820 {
adelino 0:65fd8b1cbf86 1821 }
adelino 0:65fd8b1cbf86 1822 //---------------------------------------
adelino 0:65fd8b1cbf86 1823 void Slider::draw(void)
adelino 0:65fd8b1cbf86 1824 {
adelino 0:65fd8b1cbf86 1825 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1826 return;
adelino 0:65fd8b1cbf86 1827
adelino 0:65fd8b1cbf86 1828
adelino 0:65fd8b1cbf86 1829 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1830
adelino 0:65fd8b1cbf86 1831 if(ps!=0) {
adelino 0:65fd8b1cbf86 1832 ps->draw_slider(0x0000,myX,myY,myX+myWidth,myY+myHeight,myColor,myValueMax,myValue);
adelino 0:65fd8b1cbf86 1833 }
adelino 0:65fd8b1cbf86 1834
adelino 0:65fd8b1cbf86 1835 }
adelino 0:65fd8b1cbf86 1836 //--------------------------------------
adelino 0:65fd8b1cbf86 1837 void Slider::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 1838 {
adelino 0:65fd8b1cbf86 1839 // element devient invisible
adelino 0:65fd8b1cbf86 1840 if(_state==true) {
adelino 0:65fd8b1cbf86 1841 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1842 return;
adelino 0:65fd8b1cbf86 1843
adelino 0:65fd8b1cbf86 1844 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 1845
adelino 0:65fd8b1cbf86 1846 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 1847
adelino 0:65fd8b1cbf86 1848 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1849
adelino 0:65fd8b1cbf86 1850 if(ps!=0) {
adelino 0:65fd8b1cbf86 1851 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
adelino 0:65fd8b1cbf86 1852 }
adelino 0:65fd8b1cbf86 1853 }
adelino 0:65fd8b1cbf86 1854
adelino 0:65fd8b1cbf86 1855 // element devient visible
adelino 0:65fd8b1cbf86 1856 else {
adelino 0:65fd8b1cbf86 1857 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1858
adelino 0:65fd8b1cbf86 1859
adelino 0:65fd8b1cbf86 1860 this->draw();
adelino 0:65fd8b1cbf86 1861 }
adelino 0:65fd8b1cbf86 1862 }
adelino 0:65fd8b1cbf86 1863 //-------------------------------------
adelino 0:65fd8b1cbf86 1864 int Slider::getValue(GraphicMessage* pmsg)
adelino 0:65fd8b1cbf86 1865 {
adelino 0:65fd8b1cbf86 1866 TouchEvent msgEvent=pmsg->event;
adelino 0:65fd8b1cbf86 1867
adelino 0:65fd8b1cbf86 1868 UINT16 xn=pmsg->posiX;
adelino 0:65fd8b1cbf86 1869
adelino 0:65fd8b1cbf86 1870
adelino 0:65fd8b1cbf86 1871 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1872 return 0;
adelino 0:65fd8b1cbf86 1873 //
adelino 0:65fd8b1cbf86 1874
adelino 0:65fd8b1cbf86 1875 if(msgEvent==EVENT_RELEASE) {
adelino 0:65fd8b1cbf86 1876 myElementState=SLIDER_STATE_RELEASED;
adelino 0:65fd8b1cbf86 1877 }
adelino 0:65fd8b1cbf86 1878 //
adelino 0:65fd8b1cbf86 1879 if(msgEvent==EVENT_MOVE) {
adelino 0:65fd8b1cbf86 1880 myElementState=SLIDER_STATE_MOVE;
adelino 0:65fd8b1cbf86 1881 UINT16 dis=xn-myX;
adelino 0:65fd8b1cbf86 1882 UINT16 a=dis*myValueMax;
adelino 0:65fd8b1cbf86 1883 myValue=(a/myWidth);
adelino 0:65fd8b1cbf86 1884
adelino 0:65fd8b1cbf86 1885 this->draw();
adelino 0:65fd8b1cbf86 1886 }
adelino 0:65fd8b1cbf86 1887 return myValue;
adelino 0:65fd8b1cbf86 1888 }
adelino 0:65fd8b1cbf86 1889 //-------------------------------------
adelino 0:65fd8b1cbf86 1890 Input::Input(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _width,UINT16 _height,float _valMin,float _valInc,
adelino 0:65fd8b1cbf86 1891 float _valMax,bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,_width,_height,WHITE,_isVisible)
adelino 0:65fd8b1cbf86 1892 {
adelino 0:65fd8b1cbf86 1893 myValMin=_valMin;
adelino 0:65fd8b1cbf86 1894 myValInc=_valInc;
adelino 0:65fd8b1cbf86 1895 myValMax=_valMax;
adelino 0:65fd8b1cbf86 1896 myValue=0.0;
adelino 0:65fd8b1cbf86 1897 myColorBkg=WHITE;
adelino 0:65fd8b1cbf86 1898 myColorCursorUp=BLUE;
adelino 0:65fd8b1cbf86 1899 myColorCursorDown=BLUE;
adelino 0:65fd8b1cbf86 1900
adelino 0:65fd8b1cbf86 1901 myElementType=OBJ_INPUT;
adelino 0:65fd8b1cbf86 1902 myElementState=INPUT_STATE_RELEASED;
adelino 0:65fd8b1cbf86 1903
adelino 0:65fd8b1cbf86 1904 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 1905 }
adelino 0:65fd8b1cbf86 1906 //-------------------------------------
adelino 0:65fd8b1cbf86 1907 Input::~Input(void)
adelino 0:65fd8b1cbf86 1908 {
adelino 0:65fd8b1cbf86 1909 }
adelino 0:65fd8b1cbf86 1910 //-------------------------------------
adelino 0:65fd8b1cbf86 1911 void Input::setColorBkg(Color _color)
adelino 0:65fd8b1cbf86 1912 {
adelino 0:65fd8b1cbf86 1913 myColorBkg=_color;
adelino 0:65fd8b1cbf86 1914 this->draw();
adelino 0:65fd8b1cbf86 1915 }
adelino 0:65fd8b1cbf86 1916 //--------------------------------------
adelino 0:65fd8b1cbf86 1917 void Input::setColorCursorUp(Color _color)
adelino 0:65fd8b1cbf86 1918 {
adelino 0:65fd8b1cbf86 1919 myColorCursorUp=_color;
adelino 0:65fd8b1cbf86 1920 this->draw();
adelino 0:65fd8b1cbf86 1921 }
adelino 0:65fd8b1cbf86 1922 //-------------------------------------
adelino 0:65fd8b1cbf86 1923 void Input::setColorCursorDown(Color _color)
adelino 0:65fd8b1cbf86 1924 {
adelino 0:65fd8b1cbf86 1925 myColorCursorDown=_color;
adelino 0:65fd8b1cbf86 1926 this->draw();
adelino 0:65fd8b1cbf86 1927 }
adelino 0:65fd8b1cbf86 1928 //-------------------------------------
adelino 0:65fd8b1cbf86 1929 void Input::draw(void)
adelino 0:65fd8b1cbf86 1930 {
adelino 0:65fd8b1cbf86 1931 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1932 return;
adelino 0:65fd8b1cbf86 1933 //
adelino 0:65fd8b1cbf86 1934 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1935
adelino 0:65fd8b1cbf86 1936 //rect up
adelino 0:65fd8b1cbf86 1937 if(ps!=0)
adelino 0:65fd8b1cbf86 1938 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight/2,myColorBkg);
adelino 0:65fd8b1cbf86 1939
adelino 0:65fd8b1cbf86 1940 //rect down
adelino 0:65fd8b1cbf86 1941 if(ps!=0)
adelino 0:65fd8b1cbf86 1942 ps->draw_filled_rectangle(myX,myY+myHeight/2+3,myX+myWidth,myY+3+myHeight,myColorBkg);
adelino 0:65fd8b1cbf86 1943
adelino 0:65fd8b1cbf86 1944 //fleche up
adelino 0:65fd8b1cbf86 1945 UINT16 x1=myX+myWidth/2;
adelino 0:65fd8b1cbf86 1946 UINT16 y1=myY;
adelino 0:65fd8b1cbf86 1947
adelino 0:65fd8b1cbf86 1948 UINT16 x2=myX+myWidth;
adelino 0:65fd8b1cbf86 1949 UINT16 y2=myY+myHeight/2;
adelino 0:65fd8b1cbf86 1950
adelino 0:65fd8b1cbf86 1951 UINT16 x3=myX;
adelino 0:65fd8b1cbf86 1952 UINT16 y3=myY+myHeight/2;
adelino 0:65fd8b1cbf86 1953 if(ps!=0)
adelino 0:65fd8b1cbf86 1954 ps->draw_filled_triangle(x1,y1,x2,y2,x3,y3, myColorCursorUp);
adelino 0:65fd8b1cbf86 1955
adelino 0:65fd8b1cbf86 1956 //fleche down
adelino 0:65fd8b1cbf86 1957 x1=myX;
adelino 0:65fd8b1cbf86 1958 y1=myY+3+myHeight/2;
adelino 0:65fd8b1cbf86 1959
adelino 0:65fd8b1cbf86 1960 x2=myX+myWidth;
adelino 0:65fd8b1cbf86 1961 y2=y1;
adelino 0:65fd8b1cbf86 1962
adelino 0:65fd8b1cbf86 1963 x3=myX+myWidth/2;
adelino 0:65fd8b1cbf86 1964 y3=y2+myHeight/2;
adelino 0:65fd8b1cbf86 1965 if(ps!=0)
adelino 0:65fd8b1cbf86 1966 ps->draw_filled_triangle(x1,y1,x2,y2,x3,y3, myColorCursorDown);
adelino 0:65fd8b1cbf86 1967
adelino 0:65fd8b1cbf86 1968 //cadre
adelino 0:65fd8b1cbf86 1969 if(ps!=0)
adelino 0:65fd8b1cbf86 1970 ps->draw_rectangle(myX,myY,myX+myWidth,myY+myHeight+3,BLACK);
adelino 0:65fd8b1cbf86 1971
adelino 0:65fd8b1cbf86 1972 }
adelino 0:65fd8b1cbf86 1973 //-------------------------------------
adelino 0:65fd8b1cbf86 1974 void Input::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 1975 {
adelino 0:65fd8b1cbf86 1976 // element devient invisible
adelino 0:65fd8b1cbf86 1977 if(_state==true) {
adelino 0:65fd8b1cbf86 1978 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 1979 return;
adelino 0:65fd8b1cbf86 1980
adelino 0:65fd8b1cbf86 1981 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 1982
adelino 0:65fd8b1cbf86 1983 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 1984
adelino 0:65fd8b1cbf86 1985 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 1986
adelino 0:65fd8b1cbf86 1987 if(ps!=0) {
adelino 0:65fd8b1cbf86 1988 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight+3,c);
adelino 0:65fd8b1cbf86 1989 }
adelino 0:65fd8b1cbf86 1990 }
adelino 0:65fd8b1cbf86 1991
adelino 0:65fd8b1cbf86 1992 // element devient visible
adelino 0:65fd8b1cbf86 1993 else {
adelino 0:65fd8b1cbf86 1994 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 1995
adelino 0:65fd8b1cbf86 1996
adelino 0:65fd8b1cbf86 1997 this->draw();
adelino 0:65fd8b1cbf86 1998 }
adelino 0:65fd8b1cbf86 1999 }
adelino 0:65fd8b1cbf86 2000 //--------------------------------------
adelino 0:65fd8b1cbf86 2001 float Input::getValue(GraphicMessage* msg)
adelino 0:65fd8b1cbf86 2002 {
adelino 0:65fd8b1cbf86 2003 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2004 return 0.0;
adelino 0:65fd8b1cbf86 2005 float val=0.0;
adelino 0:65fd8b1cbf86 2006 //
adelino 0:65fd8b1cbf86 2007 TouchEvent ev=msg->event;
adelino 0:65fd8b1cbf86 2008 UINT16 yn=msg->posiY;
adelino 0:65fd8b1cbf86 2009
adelino 0:65fd8b1cbf86 2010 UINT16 y0=myY;
adelino 0:65fd8b1cbf86 2011 UINT16 ybut1=y0+myHeight/2;
adelino 0:65fd8b1cbf86 2012 UINT16 ybut2=y0+myHeight;
adelino 0:65fd8b1cbf86 2013 Color couleurUp=myColorCursorUp;
adelino 0:65fd8b1cbf86 2014 Color couleurDown=myColorCursorDown;
adelino 0:65fd8b1cbf86 2015
adelino 0:65fd8b1cbf86 2016 if(ev==EVENT_PRESS && myElementState==INPUT_STATE_RELEASED) {
adelino 0:65fd8b1cbf86 2017 //up ?
adelino 0:65fd8b1cbf86 2018 if(yn >= y0 && yn <= ybut1) {
adelino 0:65fd8b1cbf86 2019 myElementState=INPUT_STATE_PRESSED_UP;
adelino 0:65fd8b1cbf86 2020 setColorCursorUp(WHITE);
adelino 0:65fd8b1cbf86 2021 wait(0.1);
adelino 0:65fd8b1cbf86 2022 setColorCursorUp(couleurUp);
adelino 0:65fd8b1cbf86 2023
adelino 0:65fd8b1cbf86 2024 val=myValue+myValInc;
adelino 0:65fd8b1cbf86 2025 if(val >myValMax)
adelino 0:65fd8b1cbf86 2026 val=myValMax;
adelino 0:65fd8b1cbf86 2027
adelino 0:65fd8b1cbf86 2028 myValue=val;
adelino 0:65fd8b1cbf86 2029 }
adelino 0:65fd8b1cbf86 2030 //
adelino 0:65fd8b1cbf86 2031 //down?
adelino 0:65fd8b1cbf86 2032 if(yn >= ybut1 && yn <= ybut2) {
adelino 0:65fd8b1cbf86 2033 myElementState=INPUT_STATE_PRESSED_DOWN;
adelino 0:65fd8b1cbf86 2034 setColorCursorDown(WHITE);
adelino 0:65fd8b1cbf86 2035 wait(0.1);
adelino 0:65fd8b1cbf86 2036 setColorCursorDown(couleurDown);
adelino 0:65fd8b1cbf86 2037
adelino 0:65fd8b1cbf86 2038 val=myValue-myValInc;
adelino 0:65fd8b1cbf86 2039 if(val <myValMin)
adelino 0:65fd8b1cbf86 2040 val=myValMin;
adelino 0:65fd8b1cbf86 2041
adelino 0:65fd8b1cbf86 2042 myValue=val;
adelino 0:65fd8b1cbf86 2043 }
adelino 0:65fd8b1cbf86 2044 }
adelino 0:65fd8b1cbf86 2045 //
adelino 0:65fd8b1cbf86 2046 if(ev==EVENT_RELEASE || ev==EVENT_MOVE) {
adelino 0:65fd8b1cbf86 2047 myElementState=INPUT_STATE_RELEASED;
adelino 0:65fd8b1cbf86 2048 }
adelino 0:65fd8b1cbf86 2049
adelino 0:65fd8b1cbf86 2050 return myValue;
adelino 0:65fd8b1cbf86 2051 }
adelino 0:65fd8b1cbf86 2052 //--------------------------------------
adelino 0:65fd8b1cbf86 2053 Switch::Switch(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,UINT16 _width,UINT16 _height,
adelino 0:65fd8b1cbf86 2054 bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,_width,_height,WHITE,_isVisible)
adelino 0:65fd8b1cbf86 2055 {
adelino 0:65fd8b1cbf86 2056 myColorOn=GREEN;
adelino 0:65fd8b1cbf86 2057 myColorOff=RED;
adelino 0:65fd8b1cbf86 2058 myColorCursor=WHITE;
adelino 0:65fd8b1cbf86 2059
adelino 0:65fd8b1cbf86 2060 myElementType=OBJ_SWITCH;
adelino 0:65fd8b1cbf86 2061 myElementState=SWITCH_STATE_OFF;
adelino 0:65fd8b1cbf86 2062
adelino 0:65fd8b1cbf86 2063 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 2064 }
adelino 0:65fd8b1cbf86 2065 //---------------------------------------
adelino 0:65fd8b1cbf86 2066 Switch::~Switch(void)
adelino 0:65fd8b1cbf86 2067 {
adelino 0:65fd8b1cbf86 2068 }
adelino 0:65fd8b1cbf86 2069 //---------------------------------------
adelino 0:65fd8b1cbf86 2070 void Switch::draw(void)
adelino 0:65fd8b1cbf86 2071 {
adelino 0:65fd8b1cbf86 2072 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2073 return;
adelino 0:65fd8b1cbf86 2074 //
adelino 0:65fd8b1cbf86 2075 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 2076
adelino 0:65fd8b1cbf86 2077 State state=myElementState;
adelino 0:65fd8b1cbf86 2078
adelino 0:65fd8b1cbf86 2079 Color gauche=WHITE;
adelino 0:65fd8b1cbf86 2080 Color droite=WHITE;
adelino 0:65fd8b1cbf86 2081
adelino 0:65fd8b1cbf86 2082 switch(state) {
adelino 0:65fd8b1cbf86 2083 //
adelino 0:65fd8b1cbf86 2084 case SWITCH_STATE_ON:
adelino 0:65fd8b1cbf86 2085 droite=myColorOn;
adelino 0:65fd8b1cbf86 2086 gauche=myColorCursor;
adelino 0:65fd8b1cbf86 2087 break;
adelino 0:65fd8b1cbf86 2088
adelino 0:65fd8b1cbf86 2089 //
adelino 0:65fd8b1cbf86 2090 case SWITCH_STATE_OFF:
adelino 0:65fd8b1cbf86 2091 droite=myColorCursor;
adelino 0:65fd8b1cbf86 2092 gauche=myColorOff;
adelino 0:65fd8b1cbf86 2093 break;
adelino 0:65fd8b1cbf86 2094
adelino 0:65fd8b1cbf86 2095 //
adelino 0:65fd8b1cbf86 2096 default:
adelino 0:65fd8b1cbf86 2097 break;
adelino 0:65fd8b1cbf86 2098 }
adelino 0:65fd8b1cbf86 2099 //
adelino 0:65fd8b1cbf86 2100
adelino 0:65fd8b1cbf86 2101 //rect gauche
adelino 0:65fd8b1cbf86 2102 if(ps!=0)
adelino 0:65fd8b1cbf86 2103 ps->draw_filled_rectangle(myX,myY,myX+myWidth/2,myY+myHeight,gauche);
adelino 0:65fd8b1cbf86 2104
adelino 0:65fd8b1cbf86 2105 //rect droite
adelino 0:65fd8b1cbf86 2106 if(ps!=0)
adelino 0:65fd8b1cbf86 2107 ps->draw_filled_rectangle(myX+myWidth/2,myY,myX+myWidth,myY+myHeight,droite);
adelino 0:65fd8b1cbf86 2108
adelino 0:65fd8b1cbf86 2109 //cadre
adelino 0:65fd8b1cbf86 2110 if(ps!=0) {
adelino 0:65fd8b1cbf86 2111 ps->draw_rectangle(myX,myY,myX+myWidth,myY+myHeight,BLACK);
adelino 0:65fd8b1cbf86 2112 ps->draw_rectangle(myX,myY,myX+myWidth/2,myY+myHeight,BLACK);
adelino 0:65fd8b1cbf86 2113
adelino 0:65fd8b1cbf86 2114 }
adelino 0:65fd8b1cbf86 2115
adelino 0:65fd8b1cbf86 2116 }
adelino 0:65fd8b1cbf86 2117 //----------------------------------------
adelino 0:65fd8b1cbf86 2118 void Switch::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 2119 {
adelino 0:65fd8b1cbf86 2120 // element devient invisible
adelino 0:65fd8b1cbf86 2121 if(_state==true) {
adelino 0:65fd8b1cbf86 2122 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2123 return;
adelino 0:65fd8b1cbf86 2124
adelino 0:65fd8b1cbf86 2125 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 2126
adelino 0:65fd8b1cbf86 2127 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 2128
adelino 0:65fd8b1cbf86 2129 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 2130
adelino 0:65fd8b1cbf86 2131 if(ps!=0) {
adelino 0:65fd8b1cbf86 2132 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
adelino 0:65fd8b1cbf86 2133 }
adelino 0:65fd8b1cbf86 2134 }
adelino 0:65fd8b1cbf86 2135
adelino 0:65fd8b1cbf86 2136 // element devient visible
adelino 0:65fd8b1cbf86 2137 else {
adelino 0:65fd8b1cbf86 2138 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 2139
adelino 0:65fd8b1cbf86 2140
adelino 0:65fd8b1cbf86 2141 this->draw();
adelino 0:65fd8b1cbf86 2142 }
adelino 0:65fd8b1cbf86 2143 }
adelino 0:65fd8b1cbf86 2144 //-----------------------------------------
adelino 0:65fd8b1cbf86 2145 void Switch::setState(State _state)
adelino 0:65fd8b1cbf86 2146 {
adelino 0:65fd8b1cbf86 2147 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2148 return;
adelino 0:65fd8b1cbf86 2149
adelino 0:65fd8b1cbf86 2150 if(myElementState==_state)
adelino 0:65fd8b1cbf86 2151 return;
adelino 0:65fd8b1cbf86 2152
adelino 0:65fd8b1cbf86 2153 myElementState=_state;
adelino 0:65fd8b1cbf86 2154
adelino 0:65fd8b1cbf86 2155 this->draw();
adelino 0:65fd8b1cbf86 2156 }
adelino 0:65fd8b1cbf86 2157 //-----------------------------------------
adelino 0:65fd8b1cbf86 2158 void Switch::changeState(GraphicMessage* msg)
adelino 0:65fd8b1cbf86 2159 {
adelino 0:65fd8b1cbf86 2160 TouchEvent ev=msg->event;
adelino 0:65fd8b1cbf86 2161
adelino 0:65fd8b1cbf86 2162 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2163 return;
adelino 0:65fd8b1cbf86 2164
adelino 0:65fd8b1cbf86 2165 if(ev==EVENT_PRESS && myElementState==SWITCH_STATE_OFF) {
adelino 0:65fd8b1cbf86 2166 this->setState(SWITCH_STATE_ON);
adelino 0:65fd8b1cbf86 2167 return;
adelino 0:65fd8b1cbf86 2168 }
adelino 0:65fd8b1cbf86 2169 //
adelino 0:65fd8b1cbf86 2170 if(ev==EVENT_PRESS && myElementState==SWITCH_STATE_ON) {
adelino 0:65fd8b1cbf86 2171 this->setState(SWITCH_STATE_OFF);
adelino 0:65fd8b1cbf86 2172 return;
adelino 0:65fd8b1cbf86 2173 }
adelino 0:65fd8b1cbf86 2174 //
adelino 0:65fd8b1cbf86 2175 if(ev==EVENT_MOVE || ev==EVENT_RELEASE)
adelino 0:65fd8b1cbf86 2176 return;
adelino 0:65fd8b1cbf86 2177 }
adelino 0:65fd8b1cbf86 2178 //----------------------------------------
adelino 0:65fd8b1cbf86 2179 DigitLed::DigitLed(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,bool _ptVisible,
adelino 0:65fd8b1cbf86 2180 bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,36,52,WHITE,_isVisible)
adelino 0:65fd8b1cbf86 2181 {
adelino 0:65fd8b1cbf86 2182 myValue=0;
adelino 0:65fd8b1cbf86 2183 myColorBkg=YELLOW;
adelino 0:65fd8b1cbf86 2184 myColorSeg=RED;
adelino 0:65fd8b1cbf86 2185 myIncX=4;
adelino 0:65fd8b1cbf86 2186 myIncY=4;
adelino 0:65fd8b1cbf86 2187
adelino 0:65fd8b1cbf86 2188 isPtVisible=_ptVisible;
adelino 0:65fd8b1cbf86 2189
adelino 0:65fd8b1cbf86 2190 myElementType=OBJ_DIGIT_LED;
adelino 0:65fd8b1cbf86 2191 myElementState=DIGIT_LED_STATE_ON;
adelino 0:65fd8b1cbf86 2192
adelino 0:65fd8b1cbf86 2193 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 2194 }
adelino 0:65fd8b1cbf86 2195 //-----------------------------------------
adelino 0:65fd8b1cbf86 2196 DigitLed::~DigitLed(void)
adelino 0:65fd8b1cbf86 2197 {
adelino 0:65fd8b1cbf86 2198 }
adelino 0:65fd8b1cbf86 2199 //-----------------------------------------
adelino 0:65fd8b1cbf86 2200 void DigitLed::setColorBkg(Color _colorBkg)
adelino 0:65fd8b1cbf86 2201 {
adelino 0:65fd8b1cbf86 2202 if(myColorBkg==_colorBkg)
adelino 0:65fd8b1cbf86 2203 return;
adelino 0:65fd8b1cbf86 2204
adelino 0:65fd8b1cbf86 2205 myColorBkg=_colorBkg;
adelino 0:65fd8b1cbf86 2206 this->draw();
adelino 0:65fd8b1cbf86 2207 }
adelino 0:65fd8b1cbf86 2208 //------------------------------------------
adelino 0:65fd8b1cbf86 2209 void DigitLed::setColorSeg(Color _colorSeg)
adelino 0:65fd8b1cbf86 2210 {
adelino 0:65fd8b1cbf86 2211 if(myColorSeg==_colorSeg)
adelino 0:65fd8b1cbf86 2212 return;
adelino 0:65fd8b1cbf86 2213
adelino 0:65fd8b1cbf86 2214 myColorSeg=_colorSeg;
adelino 0:65fd8b1cbf86 2215 this->draw();
adelino 0:65fd8b1cbf86 2216 }
adelino 0:65fd8b1cbf86 2217 //-----------------------------------------
adelino 0:65fd8b1cbf86 2218 void DigitLed::draw(void)
adelino 0:65fd8b1cbf86 2219 {
adelino 0:65fd8b1cbf86 2220 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2221 return;
adelino 0:65fd8b1cbf86 2222 //
adelino 0:65fd8b1cbf86 2223 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 2224
adelino 0:65fd8b1cbf86 2225 //rec
adelino 0:65fd8b1cbf86 2226 if(ps!=0) {
adelino 0:65fd8b1cbf86 2227 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,myColorBkg);
adelino 0:65fd8b1cbf86 2228 }
adelino 0:65fd8b1cbf86 2229
adelino 0:65fd8b1cbf86 2230 if(isPtVisible)
adelino 0:65fd8b1cbf86 2231 draw_seg_pt(ps);
adelino 0:65fd8b1cbf86 2232
adelino 0:65fd8b1cbf86 2233 //
adelino 0:65fd8b1cbf86 2234 switch(myValue) {
adelino 0:65fd8b1cbf86 2235 case 0:
adelino 0:65fd8b1cbf86 2236 draw_seg_a(ps);
adelino 0:65fd8b1cbf86 2237 draw_seg_b(ps);
adelino 0:65fd8b1cbf86 2238 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2239 draw_seg_d(ps);
adelino 0:65fd8b1cbf86 2240 draw_seg_e(ps);
adelino 0:65fd8b1cbf86 2241 draw_seg_f(ps);
adelino 0:65fd8b1cbf86 2242 break;
adelino 0:65fd8b1cbf86 2243 //
adelino 0:65fd8b1cbf86 2244 case 1:
adelino 0:65fd8b1cbf86 2245 draw_seg_b(ps);
adelino 0:65fd8b1cbf86 2246 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2247 break;
adelino 0:65fd8b1cbf86 2248 //
adelino 0:65fd8b1cbf86 2249 case 2:
adelino 0:65fd8b1cbf86 2250 draw_seg_a(ps);
adelino 0:65fd8b1cbf86 2251 draw_seg_b(ps);
adelino 0:65fd8b1cbf86 2252 draw_seg_d(ps);
adelino 0:65fd8b1cbf86 2253 draw_seg_e(ps);
adelino 0:65fd8b1cbf86 2254 draw_seg_g(ps);
adelino 0:65fd8b1cbf86 2255 break;
adelino 0:65fd8b1cbf86 2256 //
adelino 0:65fd8b1cbf86 2257 case 3:
adelino 0:65fd8b1cbf86 2258 draw_seg_a(ps);
adelino 0:65fd8b1cbf86 2259 draw_seg_b(ps);
adelino 0:65fd8b1cbf86 2260 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2261 draw_seg_d(ps);
adelino 0:65fd8b1cbf86 2262 draw_seg_g(ps);
adelino 0:65fd8b1cbf86 2263 break;
adelino 0:65fd8b1cbf86 2264 //
adelino 0:65fd8b1cbf86 2265 case 4:
adelino 0:65fd8b1cbf86 2266 draw_seg_b(ps);
adelino 0:65fd8b1cbf86 2267 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2268 draw_seg_f(ps);
adelino 0:65fd8b1cbf86 2269 draw_seg_g(ps);
adelino 0:65fd8b1cbf86 2270 break;
adelino 0:65fd8b1cbf86 2271 //
adelino 0:65fd8b1cbf86 2272 case 5:
adelino 0:65fd8b1cbf86 2273 draw_seg_a(ps);
adelino 0:65fd8b1cbf86 2274 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2275 draw_seg_d(ps);
adelino 0:65fd8b1cbf86 2276 draw_seg_f(ps);
adelino 0:65fd8b1cbf86 2277 draw_seg_g(ps);
adelino 0:65fd8b1cbf86 2278 break;
adelino 0:65fd8b1cbf86 2279 //
adelino 0:65fd8b1cbf86 2280 case 6:
adelino 0:65fd8b1cbf86 2281 draw_seg_a(ps);
adelino 0:65fd8b1cbf86 2282 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2283 draw_seg_d(ps);
adelino 0:65fd8b1cbf86 2284 draw_seg_e(ps);
adelino 0:65fd8b1cbf86 2285 draw_seg_f(ps);
adelino 0:65fd8b1cbf86 2286 draw_seg_g(ps);
adelino 0:65fd8b1cbf86 2287 break;
adelino 0:65fd8b1cbf86 2288 //
adelino 0:65fd8b1cbf86 2289 case 7:
adelino 0:65fd8b1cbf86 2290 draw_seg_a(ps);
adelino 0:65fd8b1cbf86 2291 draw_seg_b(ps);
adelino 0:65fd8b1cbf86 2292 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2293 break;
adelino 0:65fd8b1cbf86 2294 //
adelino 0:65fd8b1cbf86 2295 case 8:
adelino 0:65fd8b1cbf86 2296 draw_seg_a(ps);
adelino 0:65fd8b1cbf86 2297 draw_seg_b(ps);
adelino 0:65fd8b1cbf86 2298 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2299 draw_seg_d(ps);
adelino 0:65fd8b1cbf86 2300 draw_seg_e(ps);
adelino 0:65fd8b1cbf86 2301 draw_seg_f(ps);
adelino 0:65fd8b1cbf86 2302 draw_seg_g(ps);
adelino 0:65fd8b1cbf86 2303 break;
adelino 0:65fd8b1cbf86 2304 //
adelino 0:65fd8b1cbf86 2305 case 9:
adelino 0:65fd8b1cbf86 2306 draw_seg_a(ps);
adelino 0:65fd8b1cbf86 2307 draw_seg_b(ps);
adelino 0:65fd8b1cbf86 2308 draw_seg_c(ps);
adelino 0:65fd8b1cbf86 2309 draw_seg_d(ps);
adelino 0:65fd8b1cbf86 2310 draw_seg_f(ps);
adelino 0:65fd8b1cbf86 2311 draw_seg_g(ps);
adelino 0:65fd8b1cbf86 2312 break;
adelino 0:65fd8b1cbf86 2313 }
adelino 0:65fd8b1cbf86 2314
adelino 0:65fd8b1cbf86 2315 }
adelino 0:65fd8b1cbf86 2316 //-----------------------------------------
adelino 0:65fd8b1cbf86 2317 void DigitLed::setValue(char _value)
adelino 0:65fd8b1cbf86 2318 {
adelino 0:65fd8b1cbf86 2319 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2320 return;
adelino 0:65fd8b1cbf86 2321
adelino 0:65fd8b1cbf86 2322 if(myValue==_value)
adelino 0:65fd8b1cbf86 2323 return;
adelino 0:65fd8b1cbf86 2324
adelino 0:65fd8b1cbf86 2325
adelino 0:65fd8b1cbf86 2326 if(_value >9)
adelino 0:65fd8b1cbf86 2327 _value=9;
adelino 0:65fd8b1cbf86 2328
adelino 0:65fd8b1cbf86 2329 myValue=_value;
adelino 0:65fd8b1cbf86 2330
adelino 0:65fd8b1cbf86 2331 this->draw();
adelino 0:65fd8b1cbf86 2332 }
adelino 0:65fd8b1cbf86 2333 //-----------------------------------------
adelino 0:65fd8b1cbf86 2334 void DigitLed::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 2335 {
adelino 0:65fd8b1cbf86 2336 // element devient invisible
adelino 0:65fd8b1cbf86 2337 if(_state==true) {
adelino 0:65fd8b1cbf86 2338 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2339 return;
adelino 0:65fd8b1cbf86 2340
adelino 0:65fd8b1cbf86 2341 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 2342
adelino 0:65fd8b1cbf86 2343 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 2344
adelino 0:65fd8b1cbf86 2345 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 2346
adelino 0:65fd8b1cbf86 2347 if(ps!=0) {
adelino 0:65fd8b1cbf86 2348 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
adelino 0:65fd8b1cbf86 2349 }
adelino 0:65fd8b1cbf86 2350 }
adelino 0:65fd8b1cbf86 2351
adelino 0:65fd8b1cbf86 2352 // element devient visible
adelino 0:65fd8b1cbf86 2353 else {
adelino 0:65fd8b1cbf86 2354 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 2355
adelino 0:65fd8b1cbf86 2356
adelino 0:65fd8b1cbf86 2357 this->draw();
adelino 0:65fd8b1cbf86 2358 }
adelino 0:65fd8b1cbf86 2359 }
adelino 0:65fd8b1cbf86 2360 //-----------------------------------------
adelino 0:65fd8b1cbf86 2361 void DigitLed::setPtVisible(bool _state)
adelino 0:65fd8b1cbf86 2362 {
adelino 0:65fd8b1cbf86 2363 if(isPtVisible==_state)
adelino 0:65fd8b1cbf86 2364 return;
adelino 0:65fd8b1cbf86 2365
adelino 0:65fd8b1cbf86 2366 isPtVisible=_state;
adelino 0:65fd8b1cbf86 2367 }
adelino 0:65fd8b1cbf86 2368 //-----------------------------------------
adelino 0:65fd8b1cbf86 2369 void DigitLed::draw_seg_a(PicasoSerial* ps)
adelino 0:65fd8b1cbf86 2370 {
adelino 0:65fd8b1cbf86 2371 if(ps!=0)
adelino 0:65fd8b1cbf86 2372 ps->draw_filled_rectangle(myX+myIncX,
adelino 0:65fd8b1cbf86 2373 myY,
adelino 0:65fd8b1cbf86 2374 myX+7*myIncX,
adelino 0:65fd8b1cbf86 2375 myY+myIncY,
adelino 0:65fd8b1cbf86 2376 myColorSeg);
adelino 0:65fd8b1cbf86 2377 }
adelino 0:65fd8b1cbf86 2378 //------------------------------------------
adelino 0:65fd8b1cbf86 2379 void DigitLed::draw_seg_b(PicasoSerial* ps)
adelino 0:65fd8b1cbf86 2380 {
adelino 0:65fd8b1cbf86 2381 if(ps!=0)
adelino 0:65fd8b1cbf86 2382 ps->draw_filled_rectangle(myX+6*myIncX,
adelino 0:65fd8b1cbf86 2383 myY,
adelino 0:65fd8b1cbf86 2384 myX+7*myIncX,
adelino 0:65fd8b1cbf86 2385 myY+5*myIncY,
adelino 0:65fd8b1cbf86 2386 myColorSeg);
adelino 0:65fd8b1cbf86 2387 }
adelino 0:65fd8b1cbf86 2388 //-------------------------------------------
adelino 0:65fd8b1cbf86 2389 void DigitLed::draw_seg_c(PicasoSerial* ps)
adelino 0:65fd8b1cbf86 2390 {
adelino 0:65fd8b1cbf86 2391 if(ps!=0)
adelino 0:65fd8b1cbf86 2392 ps->draw_filled_rectangle(myX+6*myIncX,
adelino 0:65fd8b1cbf86 2393 myY+8*myIncY,
adelino 0:65fd8b1cbf86 2394 myX+7*myIncX,
adelino 0:65fd8b1cbf86 2395 myY+myHeight,
adelino 0:65fd8b1cbf86 2396 myColorSeg);
adelino 0:65fd8b1cbf86 2397 }
adelino 0:65fd8b1cbf86 2398 //--------------------------------------------
adelino 0:65fd8b1cbf86 2399 void DigitLed::draw_seg_d(PicasoSerial* ps)
adelino 0:65fd8b1cbf86 2400 {
adelino 0:65fd8b1cbf86 2401 if(ps!=0)
adelino 0:65fd8b1cbf86 2402 ps->draw_filled_rectangle(myX+myIncX,
adelino 0:65fd8b1cbf86 2403 myY+myHeight-myIncY,
adelino 0:65fd8b1cbf86 2404 myX+7*myIncX,
adelino 0:65fd8b1cbf86 2405 myY+myHeight,
adelino 0:65fd8b1cbf86 2406 myColorSeg);
adelino 0:65fd8b1cbf86 2407 }
adelino 0:65fd8b1cbf86 2408 //-----------------------------------------
adelino 0:65fd8b1cbf86 2409 void DigitLed::draw_seg_e(PicasoSerial* ps)
adelino 0:65fd8b1cbf86 2410 {
adelino 0:65fd8b1cbf86 2411 if(ps!=0)
adelino 0:65fd8b1cbf86 2412 ps->draw_filled_rectangle(myX+myIncX,
adelino 0:65fd8b1cbf86 2413 myY+myHeight-5*myIncY,
adelino 0:65fd8b1cbf86 2414 myX+2*myIncX,
adelino 0:65fd8b1cbf86 2415 myY+myHeight,
adelino 0:65fd8b1cbf86 2416 myColorSeg);
adelino 0:65fd8b1cbf86 2417 }
adelino 0:65fd8b1cbf86 2418 //-----------------------------------------
adelino 0:65fd8b1cbf86 2419 void DigitLed::draw_seg_f(PicasoSerial* ps)
adelino 0:65fd8b1cbf86 2420 {
adelino 0:65fd8b1cbf86 2421 if(ps!=0)
adelino 0:65fd8b1cbf86 2422 ps->draw_filled_rectangle(myX+myIncX,
adelino 0:65fd8b1cbf86 2423 myY,
adelino 0:65fd8b1cbf86 2424 myX+2*myIncX,
adelino 0:65fd8b1cbf86 2425 myY+5*myIncY,
adelino 0:65fd8b1cbf86 2426 myColorSeg);
adelino 0:65fd8b1cbf86 2427 }
adelino 0:65fd8b1cbf86 2428 //------------------------------------------
adelino 0:65fd8b1cbf86 2429 void DigitLed::draw_seg_g(PicasoSerial* ps)
adelino 0:65fd8b1cbf86 2430 {
adelino 0:65fd8b1cbf86 2431 if(ps!=0)
adelino 0:65fd8b1cbf86 2432 ps->draw_filled_rectangle(myX+myIncX,
adelino 0:65fd8b1cbf86 2433 myY+6*myIncY,
adelino 0:65fd8b1cbf86 2434 myX+7*myIncX,
adelino 0:65fd8b1cbf86 2435 myY+7*myIncY,
adelino 0:65fd8b1cbf86 2436 myColorSeg);
adelino 0:65fd8b1cbf86 2437 }
adelino 0:65fd8b1cbf86 2438 //------------------------------------------
adelino 0:65fd8b1cbf86 2439 void DigitLed::draw_seg_pt(PicasoSerial* ps)
adelino 0:65fd8b1cbf86 2440 {
adelino 0:65fd8b1cbf86 2441 if(ps!=0)
adelino 0:65fd8b1cbf86 2442 ps->draw_filled_rectangle(myX+myWidth-myIncX,
adelino 0:65fd8b1cbf86 2443 myY+myHeight-myIncY,
adelino 0:65fd8b1cbf86 2444 myX+myWidth,
adelino 0:65fd8b1cbf86 2445 myY+myHeight,
adelino 0:65fd8b1cbf86 2446 myColorSeg);
adelino 0:65fd8b1cbf86 2447 }
adelino 0:65fd8b1cbf86 2448 //-------------------------------------------
adelino 0:65fd8b1cbf86 2449 Digit3Led::Digit3Led(Screen* mScreen,UINT16 _id,UINT16 _x,UINT16 _y,
adelino 0:65fd8b1cbf86 2450 UINT8 _resolution,bool _isVisible):ObjetHeader(mScreen,_id,_x,_y,108,52,YELLOW,_isVisible)
adelino 0:65fd8b1cbf86 2451 {
adelino 0:65fd8b1cbf86 2452 myColorBkg=YELLOW;
adelino 0:65fd8b1cbf86 2453 myColorSeg=RED;
adelino 0:65fd8b1cbf86 2454 myValue=0.0;
adelino 0:65fd8b1cbf86 2455 myResolution=_resolution;
adelino 0:65fd8b1cbf86 2456
adelino 0:65fd8b1cbf86 2457 myDigitLedCentaine= new DigitLed(mScreen,_id,_x,_y,false,true);
adelino 0:65fd8b1cbf86 2458 myDigitLedDizaine=new DigitLed(mScreen,_id,_x+36,_y,false,true);
adelino 0:65fd8b1cbf86 2459 myDigitLedUnite= new DigitLed(mScreen,_id,_x+36+36,_y,false,true);
adelino 0:65fd8b1cbf86 2460
adelino 0:65fd8b1cbf86 2461
adelino 0:65fd8b1cbf86 2462 myElementType= OBJ_DIGITAL_3_LED;
adelino 0:65fd8b1cbf86 2463 myElementState=DIGIT_LED_STATE_ON;
adelino 0:65fd8b1cbf86 2464
adelino 0:65fd8b1cbf86 2465 myScreen->addObj((ObjetHeader*) this);
adelino 0:65fd8b1cbf86 2466 }
adelino 0:65fd8b1cbf86 2467 //------------------------------------------
adelino 0:65fd8b1cbf86 2468 Digit3Led::~Digit3Led(void)
adelino 0:65fd8b1cbf86 2469 {
adelino 0:65fd8b1cbf86 2470 delete(myDigitLedCentaine);
adelino 0:65fd8b1cbf86 2471 myDigitLedCentaine=0;
adelino 0:65fd8b1cbf86 2472 delete(myDigitLedDizaine);
adelino 0:65fd8b1cbf86 2473 myDigitLedDizaine=0;
adelino 0:65fd8b1cbf86 2474 delete(myDigitLedUnite);
adelino 0:65fd8b1cbf86 2475 myDigitLedUnite=0;
adelino 0:65fd8b1cbf86 2476 }
adelino 0:65fd8b1cbf86 2477 //------------------------------------------
adelino 0:65fd8b1cbf86 2478 void Digit3Led::draw(void)
adelino 0:65fd8b1cbf86 2479 {
adelino 0:65fd8b1cbf86 2480 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2481 return;
adelino 0:65fd8b1cbf86 2482
adelino 0:65fd8b1cbf86 2483 myDigitLedCentaine->draw();
adelino 0:65fd8b1cbf86 2484 myDigitLedDizaine->draw();
adelino 0:65fd8b1cbf86 2485 myDigitLedUnite->draw();
adelino 0:65fd8b1cbf86 2486
adelino 0:65fd8b1cbf86 2487 }
adelino 0:65fd8b1cbf86 2488 //------------------------------------------
adelino 0:65fd8b1cbf86 2489 void Digit3Led::setInvisible(bool _state)
adelino 0:65fd8b1cbf86 2490 {
adelino 0:65fd8b1cbf86 2491 // element devient invisible
adelino 0:65fd8b1cbf86 2492 if(_state==true) {
adelino 0:65fd8b1cbf86 2493 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2494 return;
adelino 0:65fd8b1cbf86 2495
adelino 0:65fd8b1cbf86 2496 myElementIsVisible=false;
adelino 0:65fd8b1cbf86 2497
adelino 0:65fd8b1cbf86 2498 Color c= myScreen->getColorBkg();
adelino 0:65fd8b1cbf86 2499
adelino 0:65fd8b1cbf86 2500 ps=myScreen->getPicasoSerial();
adelino 0:65fd8b1cbf86 2501
adelino 0:65fd8b1cbf86 2502 if(ps!=0) {
adelino 0:65fd8b1cbf86 2503 ps->draw_filled_rectangle(myX,myY,myX+myWidth,myY+myHeight,c);
adelino 0:65fd8b1cbf86 2504 }
adelino 0:65fd8b1cbf86 2505 }
adelino 0:65fd8b1cbf86 2506
adelino 0:65fd8b1cbf86 2507 // element devient visible
adelino 0:65fd8b1cbf86 2508 else {
adelino 0:65fd8b1cbf86 2509 myElementIsVisible=true;
adelino 0:65fd8b1cbf86 2510
adelino 0:65fd8b1cbf86 2511
adelino 0:65fd8b1cbf86 2512 this->draw();
adelino 0:65fd8b1cbf86 2513 }
adelino 0:65fd8b1cbf86 2514 }
adelino 0:65fd8b1cbf86 2515 //-----------------------------------------
adelino 0:65fd8b1cbf86 2516 void Digit3Led::setValue(float _value)
adelino 0:65fd8b1cbf86 2517 {
adelino 0:65fd8b1cbf86 2518 if(myElementIsVisible==false)
adelino 0:65fd8b1cbf86 2519 return;
adelino 0:65fd8b1cbf86 2520 //
adelino 0:65fd8b1cbf86 2521 if(myValue==_value)
adelino 0:65fd8b1cbf86 2522 return;
adelino 0:65fd8b1cbf86 2523 //
adelino 0:65fd8b1cbf86 2524 myValue=_value;
adelino 0:65fd8b1cbf86 2525 UINT16 temp=0;
adelino 0:65fd8b1cbf86 2526
adelino 0:65fd8b1cbf86 2527 char centaine=0;
adelino 0:65fd8b1cbf86 2528 char dizaine=0;
adelino 0:65fd8b1cbf86 2529 char unite=0;
adelino 0:65fd8b1cbf86 2530
adelino 0:65fd8b1cbf86 2531 //the Pt?
adelino 0:65fd8b1cbf86 2532 switch(myResolution) {
adelino 0:65fd8b1cbf86 2533 case 1: //xxx
adelino 0:65fd8b1cbf86 2534 temp=(UINT16)_value;
adelino 0:65fd8b1cbf86 2535 myDigitLedCentaine->setPtVisible(false);
adelino 0:65fd8b1cbf86 2536 myDigitLedDizaine->setPtVisible(false);
adelino 0:65fd8b1cbf86 2537 myDigitLedUnite->setPtVisible(false);
adelino 0:65fd8b1cbf86 2538 break;
adelino 0:65fd8b1cbf86 2539 //
adelino 0:65fd8b1cbf86 2540 case 10: //xx.x
adelino 0:65fd8b1cbf86 2541 temp=(UINT16)(_value*10);
adelino 0:65fd8b1cbf86 2542 myDigitLedCentaine->setPtVisible(false);
adelino 0:65fd8b1cbf86 2543 myDigitLedDizaine->setPtVisible(true);
adelino 0:65fd8b1cbf86 2544 myDigitLedUnite->setPtVisible(false);
adelino 0:65fd8b1cbf86 2545 break;
adelino 0:65fd8b1cbf86 2546 //
adelino 0:65fd8b1cbf86 2547 case 100: //x.xx
adelino 0:65fd8b1cbf86 2548 temp=(UINT16)(_value*100);
adelino 0:65fd8b1cbf86 2549 myDigitLedCentaine->setPtVisible(true);
adelino 0:65fd8b1cbf86 2550 myDigitLedDizaine->setPtVisible(false);
adelino 0:65fd8b1cbf86 2551 myDigitLedUnite->setPtVisible(false);
adelino 0:65fd8b1cbf86 2552 break;
adelino 0:65fd8b1cbf86 2553
adelino 0:65fd8b1cbf86 2554 default:
adelino 0:65fd8b1cbf86 2555 break;
adelino 0:65fd8b1cbf86 2556 }
adelino 0:65fd8b1cbf86 2557 //
adelino 0:65fd8b1cbf86 2558 if(temp <100) {
adelino 0:65fd8b1cbf86 2559 centaine=0;
adelino 0:65fd8b1cbf86 2560 myDigitLedCentaine->setInvisible(true);
adelino 0:65fd8b1cbf86 2561 } else {
adelino 0:65fd8b1cbf86 2562 myDigitLedCentaine->setInvisible(false);
adelino 0:65fd8b1cbf86 2563 centaine=(char)(temp/100);
adelino 0:65fd8b1cbf86 2564 temp=temp-(centaine*100);
adelino 0:65fd8b1cbf86 2565 }
adelino 0:65fd8b1cbf86 2566 //
adelino 0:65fd8b1cbf86 2567 if(temp <10) {
adelino 0:65fd8b1cbf86 2568 dizaine=0;
adelino 0:65fd8b1cbf86 2569 } else {
adelino 0:65fd8b1cbf86 2570 dizaine=(char)(temp/10);
adelino 0:65fd8b1cbf86 2571 temp=temp-(dizaine*10);
adelino 0:65fd8b1cbf86 2572 }
adelino 0:65fd8b1cbf86 2573 //
adelino 0:65fd8b1cbf86 2574 unite=(char)temp;
adelino 0:65fd8b1cbf86 2575
adelino 0:65fd8b1cbf86 2576 myDigitLedCentaine->setValue(centaine);
adelino 0:65fd8b1cbf86 2577 myDigitLedDizaine->setValue(dizaine);
adelino 0:65fd8b1cbf86 2578 myDigitLedUnite->setValue(unite);
adelino 0:65fd8b1cbf86 2579
adelino 0:65fd8b1cbf86 2580 this->draw();
adelino 0:65fd8b1cbf86 2581 }
adelino 0:65fd8b1cbf86 2582 //------------------------------------------
adelino 0:65fd8b1cbf86 2583 void Digit3Led::setColorBkg(Color _colorBkg)
adelino 0:65fd8b1cbf86 2584 {
adelino 0:65fd8b1cbf86 2585 if(myColorBkg==_colorBkg)
adelino 0:65fd8b1cbf86 2586 return;
adelino 0:65fd8b1cbf86 2587
adelino 0:65fd8b1cbf86 2588 myColorBkg=_colorBkg;
adelino 0:65fd8b1cbf86 2589 myDigitLedCentaine->setColorBkg(_colorBkg);
adelino 0:65fd8b1cbf86 2590 myDigitLedDizaine->setColorBkg(_colorBkg);
adelino 0:65fd8b1cbf86 2591 myDigitLedUnite->setColorBkg(_colorBkg);
adelino 0:65fd8b1cbf86 2592
adelino 0:65fd8b1cbf86 2593 this->draw();
adelino 0:65fd8b1cbf86 2594 }
adelino 0:65fd8b1cbf86 2595 //------------------------------------------
adelino 0:65fd8b1cbf86 2596 void Digit3Led::setColorSeg(Color _colorSeg)
adelino 0:65fd8b1cbf86 2597 {
adelino 0:65fd8b1cbf86 2598 if(myColorSeg==_colorSeg)
adelino 0:65fd8b1cbf86 2599 return;
adelino 0:65fd8b1cbf86 2600
adelino 0:65fd8b1cbf86 2601 myColorSeg=_colorSeg;
adelino 0:65fd8b1cbf86 2602 myDigitLedCentaine->setColorSeg(_colorSeg);
adelino 0:65fd8b1cbf86 2603 myDigitLedDizaine->setColorSeg(_colorSeg);
adelino 0:65fd8b1cbf86 2604 myDigitLedUnite->setColorSeg(_colorSeg);
adelino 0:65fd8b1cbf86 2605
adelino 0:65fd8b1cbf86 2606 this->draw();
adelino 0:65fd8b1cbf86 2607 }
adelino 0:65fd8b1cbf86 2608 //-----------------------------------------