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

list_menus::list_menus ( QWidget * parent )
    : QFrame(parent)
{
	dragPosition = QPoint(0,0);
	myfont.setFamily("DejaVu Sans Condensed");
	myfont.setPixelSize ( 11 );
	myfont.setBold ( true );
}

void list_menus::mouseMoveEvent(QMouseEvent *event)
{
	if (!(event->buttons() & Qt::LeftButton) ) return;
	if ( dragPosition == QPoint(0,0) )
	{
	}
	else
	{
		move(event->globalPos() - dragPosition);
	}
}

void list_menus::mousePressEvent ( QMouseEvent * event ) 
{
	dragPosition = event->globalPos() - frameGeometry().topLeft();
	this->raise();
}

void list_menus::mouseReleaseEvent ( QMouseEvent * event ) 
{
	dragPosition = QPoint(0,0);
}

void list_menus::paintEvent(QPaintEvent *)
{
	QPainter p;
	p.begin(this);
	p.setRenderHint(QPainter::Antialiasing,true);
	p.setPen(Qt::NoPen);
	p.setBrush(QColor(159,163,156,100));
	p.drawRoundedRect(1, 1, this->width()-2, this->height()-2,8,8,Qt::AbsoluteSize);

	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,220));
	Gradient.setColorAt(1.0, QColor(244,244,241,180));
	p.setBrush(Gradient);
	p.drawRoundedRect(3, 3, this->width()-6, this->height()-6,7,7,Qt::AbsoluteSize);
	p.setFont(myfont);
	p.setPen(QColor(0,0,0));
	p.drawText(QRect(4,4,this->width(),40), Qt::AlignVCenter,this->statusTip());
	p.end();
}


