Home

Download

Features

Screenshots

Handbook

Browse Source

Authors

SourceForge.net Logo
Hosted by SourceForge.net

OSI Certified


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Search  

fungcolorbutton.cpp

00001 /***************************************************************************
00002                           fungcolorbutton.cpp  -  description
00003                              -------------------
00004     begin                : Thu Nov 28 2002
00005     copyright            : (C) 2002 by Fungmeista
00006     email                : mizunoami44@sourceforge.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include <qcolordialog.h>
00019 #include <qpainter.h>
00020 
00021 #include "fungcolorbutton.h"
00022 
00023 FungColorButton::FungColorButton( QWidget *parent, const char *name, const QColor & color ) : QPushButton(parent,name), currentColor(color)
00024 {
00025     p = QPixmap(width()/2, height()/2);
00026     setColor(currentColor);
00027 }
00028 
00029 void FungColorButton::mouseReleaseEvent(QMouseEvent *e)
00030 {
00031     QPushButton::mouseReleaseEvent(e);
00032 
00033     if (hasMouse())
00034     {
00035         QColor color = QColorDialog::getColor();
00036         if (color.isValid())
00037             setColor(color);
00038     }
00039 }
00040 
00041 void FungColorButton::setColor(const QColor &color)
00042 {
00043     currentColor = color;
00044 
00045     p.fill(currentColor);
00046     QPainter painter(&p);
00047     painter.drawRect( 0, 0, p.width(), p.height() );
00048     setPixmap(p);
00049 }
00050