QGIS API Documentation  master-3f58142
src/gui/qgscolorbutton.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     qgscolorbutton.h - Color button
00003      --------------------------------------
00004     Date                 : 12-Dec-2006
00005     Copyright            : (C) 2006 by Tom Elwertowski
00006     Email                : telwertowski at users dot sourceforge dot net
00007  ***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 #ifndef QGSCOLORBUTTON_H
00016 #define QGSCOLORBUTTON_H
00017 
00018 #include <QColorDialog>
00019 #include <QPushButton>
00020 #include <QTemporaryFile>
00021 
00022 
00030 class GUI_EXPORT QgsColorButton: public QPushButton
00031 {
00032     Q_OBJECT
00033 
00034   public:
00043     QgsColorButton( QWidget *parent = 0, QString cdt = "", QColorDialog::ColorDialogOptions cdo = 0 );
00044     ~QgsColorButton();
00045 
00052     void setColor( const QColor &color );
00059     QColor color() const;
00060 
00067     void setColorDialogOptions( QColorDialog::ColorDialogOptions cdo );
00068 
00075     QColorDialog::ColorDialogOptions colorDialogOptions();
00076 
00083     void setColorDialogTitle( QString cdt );
00084 
00091     QString colorDialogTitle();
00092 
00098     bool acceptLiveUpdates() { return mAcceptLiveUpdates; }
00099 
00106     void setAcceptLiveUpdates( bool accept ) { mAcceptLiveUpdates = accept; }
00107 
00108   public slots:
00117     void setButtonBackground();
00118 
00119   signals:
00127     void colorChanged( const QColor &color );
00128 
00129   protected:
00130     void changeEvent( QEvent* e );
00131 #if 0 // causes too many cyclical updates, but may be needed on some platforms
00132     void paintEvent( QPaintEvent* e );
00133 #endif
00134     void showEvent( QShowEvent* e );
00135     static const QPixmap& transpBkgrd();
00136 
00137   private:
00138     QString mColorDialogTitle;
00139     QColor mColor;
00140     QColorDialog::ColorDialogOptions mColorDialogOptions;
00141     bool mAcceptLiveUpdates;
00142     QTemporaryFile mTempPNG;
00143 
00144   private slots:
00145     void onButtonClicked();
00146 
00152     void setValidColor( const QColor& newColor );
00153 };
00154 
00155 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines