kalarm/lib

colourcombo.h
1 /*
2  * colourcombo.h - colour selection combo box
3  * Program: kalarm
4  * Copyright © 2001-2003,2005,2006 by David Jarvie <software@astrojar.org.uk>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef COLOURCOMBO_H
22 #define COLOURCOMBO_H
23 
24 #include <tqcombobox.h>
25 #include "colourlist.h"
26 
27 
43 class ColourCombo : public TQComboBox
44 {
45  TQ_OBJECT
46 
47  TQ_PROPERTY(TQColor color READ color WRITE setColor)
48  public:
54  explicit ColourCombo(TQWidget* parent = 0, const char* name = 0, const TQColor& defaultColour = 0xFFFFFF);
56  TQColor color() const { return mSelectedColour; }
58  TQColor colour() const { return mSelectedColour; }
60  void setColor(const TQColor& c) { setColour(c); }
62  void setColour(const TQColor& c);
64  void setColours(const ColourList& list);
66  bool isCustomColour() const { return !currentItem(); }
68  bool isReadOnly() const { return mReadOnly; }
72  virtual void setReadOnly(bool readOnly);
73  signals:
75  void activated(const TQColor&); // a new colour box has been selected
77  void highlighted(const TQColor&); // a new item has been highlighted
78  public slots:
80  virtual void setEnabled(bool enabled);
81  protected:
82  virtual void resizeEvent(TQResizeEvent*);
83  virtual void mousePressEvent(TQMouseEvent*);
84  virtual void mouseReleaseEvent(TQMouseEvent*);
85  virtual void mouseMoveEvent(TQMouseEvent*);
86  virtual void keyPressEvent(TQKeyEvent*);
87  virtual void keyReleaseEvent(TQKeyEvent*);
88  private slots:
89  void slotActivated(int index);
90  void slotHighlighted(int index);
91  void slotPreferencesChanged();
92  private:
93  void addColours();
94  void drawCustomItem(TQRect&, bool insert);
95 
96  ColourList mColourList; // the sorted colours to display
97  TQColor mSelectedColour; // currently selected colour
98  TQColor mCustomColour; // current colour of the Custom item
99  bool mReadOnly; // value cannot be changed
100  bool mDisabled;
101 };
102 
103 #endif // COLOURCOMBO_H
A colour selection combo box whose colour list can be specified.
Definition: colourcombo.h:44
void activated(const TQColor &)
Signal emitted when a new colour has been selected.
bool isCustomColour() const
Returns true if the first entry in the list, i.e.
Definition: colourcombo.h:66
void setColours(const ColourList &list)
Initialises the list of colours to list.
Definition: colourcombo.cpp:56
TQColor colour() const
Returns the selected colour.
Definition: colourcombo.h:58
void setColor(const TQColor &c)
Sets the selected colour to c.
Definition: colourcombo.h:60
TQColor color() const
Returns the selected colour.
Definition: colourcombo.h:56
virtual void setEnabled(bool enabled)
Enables or disables the widget.
Definition: colourcombo.cpp:83
virtual void setReadOnly(bool readOnly)
Sets whether the combo box can be changed by the user.
bool isReadOnly() const
Returns true if the widget is read only.
Definition: colourcombo.h:68
void highlighted(const TQColor &)
Signal emitted when a new colour has been highlighted.
void setColour(const TQColor &c)
Sets the selected colour to c.
Definition: colourcombo.cpp:47
ColourCombo(TQWidget *parent=0, const char *name=0, const TQColor &defaultColour=0xFFFFFF)
Constructor.
Definition: colourcombo.cpp:33
Represents a sorted list of colours.
Definition: colourlist.h:40