/* ============================================================
 * File  : frame_info.cpp
 * Author: Stephane Gibault
 * Date  : Sun Feb 4 2007
 * Description :
 *
 * 
 *  (C) 2007 by Stephane Gibault
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * ============================================================ */
#include <QtGui>
#include "frame_info.h"

frame_info::frame_info ( QWidget * parent )
    : QFrame(parent)
{
	this->setAttribute(Qt::WA_DeleteOnClose);
	wl_action = "";
	wl_playlist = "";
	wl_row_playlist = 0;
	myfont.setFamily("Nimbus Sans L");
	myfont.setPixelSize ( 11 );
	myfont.setBold(false);
}

// ********************************
// *** DESSIN DU FOND DU WIDGET ***
// ********************************

void frame_info::paintEvent(QPaintEvent *)
{
	QPainter p;
	p.begin(this);
	p.setPen(Qt::NoPen);
	p.setFont(myfont);
	p.setRenderHint(QPainter::Antialiasing,true);
	QLinearGradient Gradient1(0.0,0.0,0.0,this->height());
	Gradient1.setColorAt(0.0, QColor(40,40,40,230));
	Gradient1.setColorAt(0.7, QColor(40,40,40,200));
	p.setBrush(Gradient1);
	p.drawRoundedRect(0, 0, this->width(), this->height()-20,5,5,Qt::AbsoluteSize);
	QPointF points[3] = {
		QPointF(25.0, this->height()-20),
		QPointF(45.0, this->height()-20),
		QPointF(35.0, this->height())
	};
	p.setBrush(QColor(40,40,40,200));
	p.drawPolygon(points, 3);

	if ( wl_action != "FAKEFORARBO" )
	{
		if ( wl_action == "" )
		{
			p.drawPixmap(5,2,32,32,QPixmap(":/Interface/Interface/error.png"));
			p.setPen(QColor(240,240,240));
			p.drawText(QRect(37,0,this->width()-37,this->height()-20), Qt::AlignCenter,tr("Aucune action n'est associee a ce bouton")); 
		}
		else
		{
			if ( wl_playlist == "" )
			{
				p.drawPixmap(5,2,32,32,QPixmap(":/Interface/Interface/select.png"));
				p.setPen(QColor(240,240,240));
				p.drawText(QRect(37,0,this->width()-37,this->height()-20), Qt::AlignCenter,wl_action);
			}
			else
			{
				p.drawPixmap(5,2,32,32,QPixmap(":/Interface/Interface/select.png"));
				p.setPen(QColor(240,240,240));
				p.drawText(QRect(37,0,this->width()-37,this->height()-(20+(wl_row_playlist*12))), Qt::AlignCenter,wl_action);
				myfont.setPixelSize ( 10 );
				p.setFont(myfont);
				p.setPen(QColor(132,212,44));
				p.drawText(QRect(37,this->height()-(20+(wl_row_playlist*15)),this->width()-37,20*wl_row_playlist), Qt::AlignCenter,wl_playlist); 
				myfont.setPixelSize ( 11 );
			}
		}
	}
	p.end();
}

