0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtGui module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#ifndef QPALETTE_H
|
|
43 |
#define QPALETTE_H
|
|
44 |
|
|
45 |
#include <QtGui/qwindowdefs.h>
|
|
46 |
#include <QtGui/qcolor.h>
|
|
47 |
#include <QtGui/qbrush.h>
|
|
48 |
|
|
49 |
QT_BEGIN_HEADER
|
|
50 |
|
|
51 |
QT_BEGIN_NAMESPACE
|
|
52 |
|
|
53 |
QT_MODULE(Gui)
|
|
54 |
|
|
55 |
#ifdef QT3_SUPPORT
|
|
56 |
class QColorGroup;
|
|
57 |
#endif
|
|
58 |
class QPalettePrivate;
|
|
59 |
class QVariant;
|
|
60 |
|
|
61 |
class Q_GUI_EXPORT QPalette
|
|
62 |
{
|
|
63 |
Q_GADGET
|
|
64 |
Q_ENUMS(ColorGroup ColorRole)
|
|
65 |
public:
|
|
66 |
QPalette();
|
|
67 |
QPalette(const QColor &button);
|
|
68 |
QPalette(Qt::GlobalColor button);
|
|
69 |
QPalette(const QColor &button, const QColor &window);
|
|
70 |
QPalette(const QBrush &windowText, const QBrush &button, const QBrush &light,
|
|
71 |
const QBrush &dark, const QBrush &mid, const QBrush &text,
|
|
72 |
const QBrush &bright_text, const QBrush &base, const QBrush &window);
|
|
73 |
QPalette(const QColor &windowText, const QColor &window, const QColor &light,
|
|
74 |
const QColor &dark, const QColor &mid, const QColor &text, const QColor &base);
|
|
75 |
#ifdef QT3_SUPPORT
|
|
76 |
QT3_SUPPORT_CONSTRUCTOR QPalette(const QColorGroup &active, const QColorGroup &disabled, const QColorGroup &inactive);
|
|
77 |
#endif
|
|
78 |
QPalette(const QPalette &palette);
|
|
79 |
~QPalette();
|
|
80 |
QPalette &operator=(const QPalette &palette);
|
|
81 |
operator QVariant() const;
|
|
82 |
|
|
83 |
// Do not change the order, the serialization format depends on it
|
|
84 |
enum ColorGroup { Active, Disabled, Inactive, NColorGroups, Current, All, Normal = Active };
|
|
85 |
enum ColorRole { WindowText, Button, Light, Midlight, Dark, Mid,
|
|
86 |
Text, BrightText, ButtonText, Base, Window, Shadow,
|
|
87 |
Highlight, HighlightedText,
|
|
88 |
Link, LinkVisited, // ### Qt 5: remove
|
|
89 |
AlternateBase,
|
|
90 |
NoRole, // ### Qt 5: value should be 0 or -1
|
|
91 |
ToolTipBase, ToolTipText,
|
|
92 |
NColorRoles = ToolTipText + 1,
|
|
93 |
Foreground = WindowText, Background = Window // ### Qt 5: remove
|
|
94 |
};
|
|
95 |
|
|
96 |
inline ColorGroup currentColorGroup() const { return static_cast<ColorGroup>(current_group); }
|
|
97 |
inline void setCurrentColorGroup(ColorGroup cg) { current_group = cg; }
|
|
98 |
|
|
99 |
inline const QColor &color(ColorGroup cg, ColorRole cr) const
|
|
100 |
{ return brush(cg, cr).color(); }
|
|
101 |
const QBrush &brush(ColorGroup cg, ColorRole cr) const;
|
|
102 |
inline void setColor(ColorGroup cg, ColorRole cr, const QColor &color);
|
|
103 |
inline void setColor(ColorRole cr, const QColor &color);
|
|
104 |
inline void setBrush(ColorRole cr, const QBrush &brush);
|
|
105 |
bool isBrushSet(ColorGroup cg, ColorRole cr) const;
|
|
106 |
void setBrush(ColorGroup cg, ColorRole cr, const QBrush &brush);
|
|
107 |
void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
|
|
108 |
const QBrush &light, const QBrush &dark, const QBrush &mid,
|
|
109 |
const QBrush &text, const QBrush &bright_text, const QBrush &base,
|
|
110 |
const QBrush &window);
|
|
111 |
bool isEqual(ColorGroup cr1, ColorGroup cr2) const;
|
|
112 |
|
|
113 |
inline const QColor &color(ColorRole cr) const { return color(Current, cr); }
|
|
114 |
inline const QBrush &brush(ColorRole cr) const { return brush(Current, cr); }
|
|
115 |
inline const QBrush &foreground() const { return brush(WindowText); }
|
|
116 |
inline const QBrush &windowText() const { return brush(WindowText); }
|
|
117 |
inline const QBrush &button() const { return brush(Button); }
|
|
118 |
inline const QBrush &light() const { return brush(Light); }
|
|
119 |
inline const QBrush &dark() const { return brush(Dark); }
|
|
120 |
inline const QBrush &mid() const { return brush(Mid); }
|
|
121 |
inline const QBrush &text() const { return brush(Text); }
|
|
122 |
inline const QBrush &base() const { return brush(Base); }
|
|
123 |
inline const QBrush &alternateBase() const { return brush(AlternateBase); }
|
|
124 |
inline const QBrush &toolTipBase() const { return brush(ToolTipBase); }
|
|
125 |
inline const QBrush &toolTipText() const { return brush(ToolTipText); }
|
|
126 |
inline const QBrush &background() const { return brush(Window); }
|
|
127 |
inline const QBrush &window() const { return brush(Window); }
|
|
128 |
inline const QBrush &midlight() const { return brush(Midlight); }
|
|
129 |
inline const QBrush &brightText() const { return brush(BrightText); }
|
|
130 |
inline const QBrush &buttonText() const { return brush(ButtonText); }
|
|
131 |
inline const QBrush &shadow() const { return brush(Shadow); }
|
|
132 |
inline const QBrush &highlight() const { return brush(Highlight); }
|
|
133 |
inline const QBrush &highlightedText() const { return brush(HighlightedText); }
|
|
134 |
inline const QBrush &link() const { return brush(Link); }
|
|
135 |
inline const QBrush &linkVisited() const { return brush(LinkVisited); }
|
|
136 |
|
|
137 |
#ifdef QT3_SUPPORT
|
|
138 |
inline QT3_SUPPORT QPalette copy() const { QPalette p = *this; p.detach(); return p; }
|
|
139 |
QT3_SUPPORT QColorGroup normal() const;
|
|
140 |
inline QT3_SUPPORT void setNormal(const QColorGroup &cg) { setColorGroup(Active, cg); }
|
|
141 |
|
|
142 |
QT3_SUPPORT QColorGroup active() const;
|
|
143 |
QT3_SUPPORT QColorGroup disabled() const;
|
|
144 |
QT3_SUPPORT QColorGroup inactive() const;
|
|
145 |
inline QT3_SUPPORT void setActive(const QColorGroup &cg) { setColorGroup(Active, cg); }
|
|
146 |
inline QT3_SUPPORT void setDisabled(const QColorGroup &cg) { setColorGroup(Disabled, cg); }
|
|
147 |
inline QT3_SUPPORT void setInactive(const QColorGroup &cg) { setColorGroup(Inactive, cg); }
|
|
148 |
#endif
|
|
149 |
|
|
150 |
bool operator==(const QPalette &p) const;
|
|
151 |
inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
|
|
152 |
bool isCopyOf(const QPalette &p) const;
|
|
153 |
|
|
154 |
int serialNumber() const;
|
|
155 |
qint64 cacheKey() const;
|
|
156 |
|
|
157 |
QPalette resolve(const QPalette &) const;
|
|
158 |
inline uint resolve() const { return resolve_mask; }
|
|
159 |
inline void resolve(uint mask) { resolve_mask = mask; }
|
|
160 |
|
|
161 |
private:
|
|
162 |
void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
|
|
163 |
const QBrush &light, const QBrush &dark, const QBrush &mid,
|
|
164 |
const QBrush &text, const QBrush &bright_text,
|
|
165 |
const QBrush &base, const QBrush &alternate_base,
|
|
166 |
const QBrush &window, const QBrush &midlight,
|
|
167 |
const QBrush &button_text, const QBrush &shadow,
|
|
168 |
const QBrush &highlight, const QBrush &highlighted_text,
|
|
169 |
const QBrush &link, const QBrush &link_visited);
|
|
170 |
void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
|
|
171 |
const QBrush &light, const QBrush &dark, const QBrush &mid,
|
|
172 |
const QBrush &text, const QBrush &bright_text,
|
|
173 |
const QBrush &base, const QBrush &alternate_base,
|
|
174 |
const QBrush &window, const QBrush &midlight,
|
|
175 |
const QBrush &button_text, const QBrush &shadow,
|
|
176 |
const QBrush &highlight, const QBrush &highlighted_text,
|
|
177 |
const QBrush &link, const QBrush &link_visited,
|
|
178 |
const QBrush &toolTipBase, const QBrush &toolTipText);
|
|
179 |
#ifdef QT3_SUPPORT
|
|
180 |
friend class QColorGroup;
|
|
181 |
void setColorGroup(ColorGroup, const QColorGroup &);
|
|
182 |
QColorGroup createColorGroup(ColorGroup) const;
|
|
183 |
#endif
|
|
184 |
void init();
|
|
185 |
void detach();
|
|
186 |
|
|
187 |
QPalettePrivate *d;
|
|
188 |
uint current_group : 4;
|
|
189 |
uint resolve_mask : 28;
|
|
190 |
friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
|
|
191 |
};
|
|
192 |
|
|
193 |
inline void QPalette::setColor(ColorGroup acg, ColorRole acr,
|
|
194 |
const QColor &acolor)
|
|
195 |
{ setBrush(acg, acr, QBrush(acolor)); }
|
|
196 |
inline void QPalette::setColor(ColorRole acr, const QColor &acolor)
|
|
197 |
{ setColor(All, acr, acolor); }
|
|
198 |
inline void QPalette::setBrush(ColorRole acr, const QBrush &abrush)
|
|
199 |
{ setBrush(All, acr, abrush); }
|
|
200 |
|
|
201 |
#ifdef QT3_SUPPORT
|
|
202 |
class Q_GUI_EXPORT QColorGroup : public QPalette
|
|
203 |
{
|
|
204 |
public:
|
|
205 |
inline QColorGroup() : QPalette() {}
|
|
206 |
inline QColorGroup(const QBrush &foreground, const QBrush &button, const QBrush &light,
|
|
207 |
const QBrush &dark, const QBrush &mid, const QBrush &text,
|
|
208 |
const QBrush &bright_text, const QBrush &base, const QBrush &background)
|
|
209 |
: QPalette(foreground, button, light, dark, mid, text, bright_text, base, background)
|
|
210 |
{}
|
|
211 |
inline QColorGroup(const QColor &foreground, const QColor &background, const QColor &light,
|
|
212 |
const QColor &dark, const QColor &mid, const QColor &text, const QColor &base)
|
|
213 |
: QPalette(foreground, background, light, dark, mid, text, base) {}
|
|
214 |
inline QColorGroup(const QColorGroup &cg) : QPalette(cg) {}
|
|
215 |
inline QColorGroup(const QPalette &pal) : QPalette(pal) {}
|
|
216 |
bool operator==(const QColorGroup &other) const;
|
|
217 |
inline bool operator!=(const QColorGroup &other) const { return !(operator==(other)); }
|
|
218 |
operator QVariant() const;
|
|
219 |
|
|
220 |
inline QT3_SUPPORT const QColor &foreground() const { return color(WindowText); }
|
|
221 |
inline QT3_SUPPORT const QColor &button() const { return color(Button); }
|
|
222 |
inline QT3_SUPPORT const QColor &light() const { return color(Light); }
|
|
223 |
inline QT3_SUPPORT const QColor &dark() const { return color(Dark); }
|
|
224 |
inline QT3_SUPPORT const QColor &mid() const { return color(Mid); }
|
|
225 |
inline QT3_SUPPORT const QColor &text() const { return color(Text); }
|
|
226 |
inline QT3_SUPPORT const QColor &base() const { return color(Base); }
|
|
227 |
inline QT3_SUPPORT const QColor &background() const { return color(Window); }
|
|
228 |
inline QT3_SUPPORT const QColor &midlight() const { return color(Midlight); }
|
|
229 |
inline QT3_SUPPORT const QColor &brightText() const { return color(BrightText); }
|
|
230 |
inline QT3_SUPPORT const QColor &buttonText() const { return color(ButtonText); }
|
|
231 |
inline QT3_SUPPORT const QColor &shadow() const { return color(Shadow); }
|
|
232 |
inline QT3_SUPPORT const QColor &highlight() const { return color(Highlight); }
|
|
233 |
inline QT3_SUPPORT const QColor &highlightedText() const { return color(HighlightedText); }
|
|
234 |
inline QT3_SUPPORT const QColor &link() const { return color(Link); }
|
|
235 |
inline QT3_SUPPORT const QColor &linkVisited() const { return color(LinkVisited); }
|
|
236 |
};
|
|
237 |
|
|
238 |
#ifndef QT_NO_DATASTREAM
|
|
239 |
Q_GUI_EXPORT QT3_SUPPORT QDataStream &operator<<(QDataStream &ds, const QColorGroup &cg);
|
|
240 |
Q_GUI_EXPORT QT3_SUPPORT QDataStream &operator>>(QDataStream &ds, QColorGroup &cg);
|
|
241 |
#endif
|
|
242 |
|
|
243 |
inline QColorGroup QPalette::inactive() const { return createColorGroup(Inactive); }
|
|
244 |
inline QColorGroup QPalette::disabled() const { return createColorGroup(Disabled); }
|
|
245 |
inline QColorGroup QPalette::active() const { return createColorGroup(Active); }
|
|
246 |
inline QColorGroup QPalette::normal() const { return createColorGroup(Active); }
|
|
247 |
|
|
248 |
#endif
|
|
249 |
|
|
250 |
/*****************************************************************************
|
|
251 |
QPalette stream functions
|
|
252 |
*****************************************************************************/
|
|
253 |
#ifndef QT_NO_DATASTREAM
|
|
254 |
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const QPalette &p);
|
|
255 |
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &ds, QPalette &p);
|
|
256 |
#endif // QT_NO_DATASTREAM
|
|
257 |
|
|
258 |
QT_END_NAMESPACE
|
|
259 |
|
|
260 |
QT_END_HEADER
|
|
261 |
|
|
262 |
#endif // QPALETTE_H
|