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

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

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

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

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

void property::paintEvent(QPaintEvent *)
{
	QPainter p;
	p.begin(this);
	p.setRenderHint(QPainter::Antialiasing,true);
	p.setPen(QColor(49,43,35,200)); //Qt::NoPen);
	QLinearGradient Gradient(0.0,0.0,0.0,this->height());
	Gradient.setColorAt(0.0, QColor(69,63,55,180));
	Gradient.setColorAt(0.3, QColor(69,63,55,180));
	Gradient.setColorAt(1.0, QColor(49,43,35,200));
	p.setBrush(Gradient);
	//p.setBrush(QColor(69,63,55,180));

	p.drawRoundedRect(1, 1, this->width()-2, this->height()-2,8,8,Qt::AbsoluteSize);

	/*QRadialGradient Gradient2( -100, -100, this->width(),0,0 );
	Gradient2.setColorAt(0.0, QColor(129,123,115,150));
	Gradient2.setColorAt(1.0, QColor(129,123,115,0));
	p.setBrush(Gradient2);
	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));
	Gradient.setColorAt(0.3, QColor(244,244,241));
	Gradient.setColorAt(1.0, QColor(200,200,200));
	p.setBrush(Gradient);
	p.drawRoundedRect(6, 36, this->width()-12, this->height()-42,7,7,Qt::AbsoluteSize);*/

	if ( this->statusTip() != "" )
	{
		//p.drawPixmap(11,6,QPixmap(":/Interface/Interface/" + this->whatsThis()));
		p.setFont(myfont);
		//p.setPen(QColor(255,255,255));
		p.setPen(QColor(189,183,175));
		p.drawText(QRect(10,0,this->width()-20,36), Qt::AlignCenter,this->statusTip());
	}
	p.end();
}

