kalarm/lib

colourcombo.h

00001 /*
00002  *  colourcombo.h  -  colour selection combo box
00003  *  Program:  kalarm
00004  *  Copyright (C) 2001 - 2003, 2005 by David Jarvie  software@astrojar.org.uk
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef COLOURCOMBO_H
00022 #define COLOURCOMBO_H
00023 
00024 #include <qcombobox.h>
00025 #include "colourlist.h"
00026 
00027 
00043 class ColourCombo : public QComboBox
00044 {
00045         Q_OBJECT
00046         Q_PROPERTY(QColor color READ color WRITE setColor)
00047     public:
00053         ColourCombo(QWidget* parent = 0, const char* name = 0, const QColor& defaultColour = 0xFFFFFF);
00055         QColor       color() const               { return mSelectedColour; }
00057         QColor       colour() const              { return mSelectedColour; }
00059         void         setColor(const QColor& c)   { setColour(c); }
00061         void         setColour(const QColor& c);
00063         void         setColours(const ColourList& list);
00065         bool         isCustomColour() const      { return !currentItem(); }
00067         bool         isReadOnly() const          { return mReadOnly; }
00071         virtual void setReadOnly(bool readOnly);
00072     signals:
00074         void         activated(const QColor&);    // a new colour box has been selected
00076         void         highlighted(const QColor&);  // a new item has been highlighted
00077     public slots:
00079         virtual void setEnabled(bool enabled);
00080     protected:
00081         virtual void resizeEvent(QResizeEvent*);
00082         virtual void mousePressEvent(QMouseEvent*);
00083         virtual void mouseReleaseEvent(QMouseEvent*);
00084         virtual void mouseMoveEvent(QMouseEvent*);
00085         virtual void keyPressEvent(QKeyEvent*);
00086         virtual void keyReleaseEvent(QKeyEvent*);
00087     private slots:
00088         void         slotActivated(int index);
00089         void         slotHighlighted(int index);
00090         void         slotPreferencesChanged();
00091     private:
00092         void         addColours();
00093         void         drawCustomItem(QRect&, bool insert);
00094 
00095         ColourList   mColourList;      // the sorted colours to display
00096         QColor       mSelectedColour;  // currently selected colour
00097         QColor       mCustomColour;    // current colour of the Custom item
00098         bool         mReadOnly;        // value cannot be changed
00099         bool         mDisabled;
00100 };
00101 
00102 #endif // COLOURCOMBO_H
KDE Home | KDE Accessibility Home | Description of Access Keys