/*******************************************************************************
*                                                                              *
* Société de Transports de Montréal.                                    	   *
* 2013                                                                         *
*                                                                              *
* Projet Zones Tests                                                           *
*                                                                              *
*                                                                              *
*                                                                              *
*******************************************************************************/
/*
    Description:
    .

*/

/* ************************************************************************** */
/* Revision:
### 20130306 JFM
    Verision d'origine.

### YYYYMMDD Description du besoin ou du bug
    Description du changement.
 */

/* ************************************************************************** */

#include "ONOFFStatusWidget.h"
#include <QPainter>
#define ON_OFF_WIDGET_SIZE 30

CONOFFStatusWidget::CONOFFStatusWidget(QString Label)
{
	mONLedOffPixmap = new QGraphicsPixmapItem(QPixmap("./Images/green-led-off-md.png").scaled(ON_OFF_WIDGET_SIZE,ON_OFF_WIDGET_SIZE),this);
	mONLedOnPixmap = new QGraphicsPixmapItem(QPixmap("./Images/green-led-on-md.png").scaled(ON_OFF_WIDGET_SIZE,ON_OFF_WIDGET_SIZE),this);
	mOFFLedOffPixmap = new QGraphicsPixmapItem(QPixmap("./Images/red-led-off-md.png").scaled(ON_OFF_WIDGET_SIZE,ON_OFF_WIDGET_SIZE),this);
	mOFFLedOnPixmap = new QGraphicsPixmapItem(QPixmap("./Images/red-led-on-md.png").scaled(ON_OFF_WIDGET_SIZE,ON_OFF_WIDGET_SIZE),this);

	mOFFLedOffPixmap->setPos(0,20);
	mOFFLedOnPixmap->setPos(0,20);
	mONLedOffPixmap->setPos(30,20);
	mONLedOnPixmap->setPos(30,20);

	mONLedOnPixmap->hide();
	mOFFLedOffPixmap->hide();

    mLabel = new QGraphicsTextItem(this);
    mLabel->setPlainText(Label);
    mLabel->setPos(5,0);



}

CONOFFStatusWidget::~CONOFFStatusWidget()
{
}

void CONOFFStatusWidget::SetON()
{
	mONLedOnPixmap->show();
	mONLedOffPixmap->hide();
	mOFFLedOnPixmap->hide();
	mOFFLedOffPixmap->show();
}

void CONOFFStatusWidget::SetOFF()
{
	mONLedOnPixmap->hide();
	mONLedOffPixmap->show();
	mOFFLedOnPixmap->show();
	mOFFLedOffPixmap->hide();
}

void CONOFFStatusWidget::Toggle()
{
	if(mONLedOnPixmap->isVisible())
	{
		SetOFF();
	}
	else
	{
		SetON();
	}
}
