Avogadro  1.1.0
/home/kitware/dashboards/avogadro/libavogadro/src/colorbutton.h
00001 /**********************************************************************
00002   ColorButton - Button widget to display the current selected color
00003                 and bring up the color picker when clicked
00004 
00005   Copyright (c) 2008-2009 Geoff Hutchison
00006   Copyright (c) 2008 Tim Vandermeersch
00007   Copyright (c) 2009 Marcus D. Hanwell
00008 
00009   This file is part of the Avogadro molecular editor project.
00010   For more information, see <http://avogadro.openmolecules.net/>
00011 
00012   Avogadro is free software; you can redistribute it and/or modify
00013   it under the terms of the GNU General Public License as published by
00014   the Free Software Foundation; either version 2 of the License, or
00015   (at your option) any later version.
00016 
00017   Avogadro is distributed in the hope that it will be useful,
00018   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020   GNU General Public License for more details.
00021 
00022   You should have received a copy of the GNU General Public License
00023   along with this program; if not, write to the Free Software
00024   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00025   02110-1301, USA.
00026  **********************************************************************/
00027 
00028 #ifndef COLORBUTTON_H
00029 #define COLORBUTTON_H
00030 
00031 #include <avogadro/global.h>
00032 
00033 #include <QAbstractButton>
00034 #include <QColor>
00035 
00036 namespace Avogadro {
00037 
00050   class A_EXPORT ColorButton : public QAbstractButton
00051   {
00052     Q_OBJECT
00053 
00054   public:
00055     ColorButton(QWidget *parent = 0);
00056     explicit ColorButton(const QColor& initial, QWidget *parent = 0);
00057 
00061     void paintEvent(QPaintEvent *);
00062 
00066     void setColor(const QColor& color);
00067 
00071     void setDialogTitle(const QString title = "");
00072 
00076     QColor color() const;
00077 
00078   Q_SIGNALS:
00082     void colorChanged(QColor);
00083 
00084   public Q_SLOTS:
00088     void changeColor();
00089 
00090   protected:
00095     bool event(QEvent *e);
00096 
00097     QColor m_color; 
00098     QString m_title;
00099   };
00100 
00101 } // end namespace Avogadro
00102 
00103 #endif