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

top_bar::top_bar ( QWidget * parent )
    : QFrame(parent)
{
	this->setAttribute(Qt::WA_DeleteOnClose);
}

void top_bar::mouseMoveEvent( QMouseEvent * )
{
	/*if (!(event->buttons() & Qt::LeftButton) ) return;
	if ( dragPosition == QPoint(0,0) )
	{
	}
	else
	{
		if ( event->globalPos().x() - dragPosition.x() > 0 && event->globalPos().x() - dragPosition.x() < (window_width-this->width() ))
		{
			move(event->globalPos().x() - dragPosition.x(),0);
		}
	}*/
}

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

void top_bar::mouseReleaseEvent ( QMouseEvent * ) 
{
	//dragPosition = QPoint(0,0);
}

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

void top_bar::paintEvent(QPaintEvent *)
{
	QPainter p;
	p.begin(this);

	p.setPen(Qt::NoPen);

	QLinearGradient Gradient1(0.0, 0.0, 0.0, this->height());
	Gradient1.setColorAt(1.0, QColor(171,164,154));
	Gradient1.setColorAt(0.3, QColor(183,178,168));

	p.setBrush(Gradient1);
	p.drawRect(0, 0, this->width(), this->height());

	p.setPen(QColor(182,177,168));
	p.drawLine(0, this->height()-2, this->width(), this->height()-2);
	p.setPen(QColor(109,104,97));
	p.drawLine(0, this->height()-1, this->width(), this->height()-1);

	p.end();
}

