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

menu_editor::menu_editor ( QWidget * parent )
    : QFrame(parent)
{
	//this->setMouseTracking(true);
	//QPalette mypal;
	//mypal.setPalette(QPalette QApplication::palette ());
	wincolor = QApplication::palette ().color(QPalette::Active,QPalette::Window);
	dragPosition = frameGeometry().topLeft();
}

void menu_editor::mouseMoveEvent(QMouseEvent *event)
{
	if (!(event->buttons() & Qt::LeftButton)) return;
	move(event->globalPos() - dragPosition);
}

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

void menu_editor::paintEvent(QPaintEvent *)
{
	QPainter p;
	p.begin(this);
	p.setRenderHint(QPainter::Antialiasing,true);
	QPen pen;
	pen.setWidth(1);
	pen.setColor(QColor(100,100,100));
	pen.setCapStyle(Qt::RoundCap);
	pen.setJoinStyle(Qt::RoundJoin);
	p.setPen(pen);
	p.setBrush(wincolor);
	p.drawRoundedRect ( 0, 0,this->width(), this->height(), 5.0, 5.0, Qt::AbsoluteSize );
	p.end();
}

