1/* This file is part of the KDE libraries
2 *
3 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KCOLORVALUESELECTOR_H
22#define KCOLORVALUESELECTOR_H
23
24#include "kselector.h"
25#include "kcolorchoosermode.h"
26#include <QtGui/QPixmap>
27
28class KDEUI_EXPORT KColorValueSelector : public KSelector
29{
30 Q_OBJECT
31 Q_PROPERTY( int hue READ hue WRITE setHue )
32 Q_PROPERTY( int saturation READ saturation WRITE setSaturation )
33 Q_PROPERTY( int colorValue READ colorValue WRITE setColorValue )
34public:
35 /**
36 * Constructs a widget for color selection.
37 */
38 explicit KColorValueSelector( QWidget *parent=0 );
39 /**
40 * Constructs a widget for color selection with a given orientation
41 */
42 explicit KColorValueSelector( Qt::Orientation o, QWidget *parent = 0 );
43
44 ~KColorValueSelector();
45
46 /**
47 * Updates the widget's contents.
48 */
49 void updateContents();
50
51 /**
52 * Returns the current hue value.
53 *
54 * @return The hue value (0-359)
55 */
56 int hue() const;
57
58 /**
59 * Sets the hue value. Doesn't automatically update the widget;
60 * you have to call updateContents manually.
61 *
62 * @param hue Sets the hue value (0-359)
63 */
64 void setHue( int hue );
65
66 /**
67 * Returns the current saturation value.
68 *
69 * @return The saturation value (0-255)
70 */
71 int saturation() const;
72
73 /**
74 * Sets the saturation value. Doesn't automatically update the widget;
75 * you have to call updateContents manually.
76 *
77 * @param saturation Sets the saturation value (0-255)
78 */
79 void setSaturation( int saturation );
80
81 /**
82 * Returns the current color value.
83 *
84 * @return The color value (0-255)
85 */
86 int colorValue() const;
87
88 /**
89 * Sets the color value. Doesn't automatically update the widget;
90 * you have to call updateContents manually.
91 *
92 * @param colorValue Sets the color value (0-255)
93 */
94 void setColorValue( int colorValue );
95
96 /**
97 * Sets the chooser mode. Doesn't automatically update the widget;
98 * you have to call updateContents manually.
99 *
100 * @param chooserMode Sets the chooser mode (one of the KColorChooserMode constants)
101 */
102 void setChooserMode (KColorChooserMode chooserMode);
103
104 /**
105 * Returns the current chooser mode.
106 *
107 * @return The chooser mode (one of the KColorChooserMode constants)
108 */
109 KColorChooserMode chooserMode () const;
110
111protected:
112 /**
113 * Draws the contents of the widget on a pixmap,
114 * which is used for buffering.
115 */
116 virtual void drawPalette( QPixmap *pixmap );
117 virtual void resizeEvent( QResizeEvent * );
118
119 /**
120 * Reimplemented from KSelector. The drawing is
121 * buffered in a pixmap here. As real drawing
122 * routine, drawPalette() is used.
123 */
124 virtual void drawContents( QPainter *painter );
125
126private:
127 class Private;
128 friend class Private;
129
130 Private *const d;
131
132 Q_DISABLE_COPY(KColorValueSelector)
133};
134
135#endif /* KCOLORVALUESELECTOR_H */
136
137