/* ============================================================
 * File  : frame_bk.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_bk.h"

frame_bk::frame_bk ( QWidget * parent )
    : QFrame(parent)
{
	this->setAttribute(Qt::WA_DeleteOnClose);
	this->setMouseTracking(true);
	myfont.setFamily("Nimbus Sans L");
	myfont.setPixelSize(11);
	myfont.setBold(true);
	//dragPosition = frameGeometry().topLeft();
}

void frame_bk::mouseMoveEvent(QMouseEvent *event)
{
	//if (!(event->buttons() & Qt::LeftButton)) return;
	//move(event->globalPos() - dragPosition);
	if ( event->y() > 50 && event->y() < 200 && event->x() < 40 )
	{
		emit show_frame_bk();
	}
}

/*void frame_bk::mousePressEvent ( QMouseEvent * event ) 
{
	dragPosition = event->globalPos() - frameGeometry().topLeft();
}*/

/*void frame_bk::enterEvent ( QEvent * ) 
{
	emit show_frame_bk();
}*/

void frame_bk::leaveEvent ( QEvent * ) 
{
	emit hide_frame_bk();
}

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

void frame_bk::paintEvent(QPaintEvent *)
{
	QPainter p;
	p.begin(this);
	p.setPen(Qt::NoPen);
	p.setRenderHint(QPainter::Antialiasing,true);

	/*QLinearGradient GradientS(35.0,0.0,40.0,0.0);
	GradientS.setColorAt(0.0, QColor(255,255,255,0));
	GradientS.setColorAt(1.0, QColor(255,255,255,100));

	p.setBrush(GradientS);
	p.drawRect(35, 0, 5, this->height());*/

	p.setBrush(QColor(50,59,45,150));
	p.drawRoundedRect(0, 50, this->width()+60, 150,10,10,Qt::AbsoluteSize);
	p.eraseRect(40, 50, this->width(), 150);

	/*QLinearGradient Gradient(0.0,0.0,0.0,this->height());
	Gradient.setColorAt(0.0, QColor(244,244,241,240));
	Gradient.setColorAt(0.3, QColor(244,244,241,240));
	Gradient.setColorAt(1.0, QColor(244,244,241,140));*/
	//p.setBrush(QColor(50,59,45,150));
	p.drawRect(40, 0, this->width()-5, this->height());

	p.setFont(myfont);
	p.setPen(QColor(255,255,255));
	p.translate(25,170);
	p.rotate(-90);
	p.translate(-25,-170);
	p.drawText(25,170, this->statusTip());

	p.end();
}

