| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2011 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 | ** Commercial Usage | 
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 14 | ** a written agreement between you and Nokia. | 
|---|
| 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 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #include "qpalette.h" | 
|---|
| 43 | #include "qapplication.h" | 
|---|
| 44 | #include "qdatastream.h" | 
|---|
| 45 | #include "qvariant.h" | 
|---|
| 46 |  | 
|---|
| 47 | QT_BEGIN_NAMESPACE | 
|---|
| 48 |  | 
|---|
| 49 | static int qt_palette_count = 1; | 
|---|
| 50 |  | 
|---|
| 51 | class QPalettePrivate { | 
|---|
| 52 | public: | 
|---|
| 53 | QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { } | 
|---|
| 54 | QAtomicInt ref; | 
|---|
| 55 | QBrush br[QPalette::NColorGroups][QPalette::NColorRoles]; | 
|---|
| 56 | int ser_no; | 
|---|
| 57 | int detach_no; | 
|---|
| 58 | }; | 
|---|
| 59 |  | 
|---|
| 60 | static QColor qt_mix_colors(QColor a, QColor b) | 
|---|
| 61 | { | 
|---|
| 62 | return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2, | 
|---|
| 63 | (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2); | 
|---|
| 64 | } | 
|---|
| 65 |  | 
|---|
| 66 | #ifdef QT3_SUPPORT | 
|---|
| 67 |  | 
|---|
| 68 | #ifndef QT_NO_DATASTREAM | 
|---|
| 69 | QDataStream &qt_stream_out_qcolorgroup(QDataStream &s, const QColorGroup &g) | 
|---|
| 70 | { | 
|---|
| 71 | if(s.version() == 1) { | 
|---|
| 72 | // Qt 1.x | 
|---|
| 73 | s << g.color(QPalette::Foreground) << g.color(QPalette::Background) | 
|---|
| 74 | << g.color(QPalette::Light) << g.color(QPalette::Dark) | 
|---|
| 75 | << g.color(QPalette::Mid) << g.color(QPalette::Text) << g.color(QPalette::Base); | 
|---|
| 76 | } else { | 
|---|
| 77 | int max = QPalette::NColorRoles; | 
|---|
| 78 | if (s.version() <= QDataStream::Qt_2_1) | 
|---|
| 79 | max = QPalette::HighlightedText + 1; | 
|---|
| 80 | else if (s.version() <= QDataStream::Qt_4_3) | 
|---|
| 81 | max = QPalette::AlternateBase + 1; | 
|---|
| 82 | for(int r = 0 ; r < max ; r++) | 
|---|
| 83 | s << g.brush((QPalette::ColorRole)r); | 
|---|
| 84 | } | 
|---|
| 85 | return s; | 
|---|
| 86 | } | 
|---|
| 87 |  | 
|---|
| 88 | QDataStream &qt_stream_in_qcolorgroup(QDataStream &s, QColorGroup &g) | 
|---|
| 89 | { | 
|---|
| 90 | if(s.version() == 1) {         // Qt 1.x | 
|---|
| 91 | QColor fg, bg, light, dark, mid, text, base; | 
|---|
| 92 | s >> fg >> bg >> light >> dark >> mid >> text >> base; | 
|---|
| 93 | QPalette p(bg); | 
|---|
| 94 | p.setColor(QPalette::Active, QPalette::Foreground, fg); | 
|---|
| 95 | p.setColor(QPalette::Active, QPalette::Light, light); | 
|---|
| 96 | p.setColor(QPalette::Active, QPalette::Dark, dark); | 
|---|
| 97 | p.setColor(QPalette::Active, QPalette::Mid, mid); | 
|---|
| 98 | p.setColor(QPalette::Active, QPalette::Text, text); | 
|---|
| 99 | p.setColor(QPalette::Active, QPalette::Base, base); | 
|---|
| 100 | g = p; | 
|---|
| 101 | g.setCurrentColorGroup(QPalette::Active); | 
|---|
| 102 | } else { | 
|---|
| 103 | int max = QPalette::NColorRoles; | 
|---|
| 104 | if (s.version() <= QDataStream::Qt_2_1) | 
|---|
| 105 | max = QPalette::HighlightedText + 1; | 
|---|
| 106 | else if (s.version() <= QDataStream::Qt_3_0) | 
|---|
| 107 | max = QPalette::LinkVisited + 1; | 
|---|
| 108 | else if (s.version() <= QDataStream::Qt_4_3) | 
|---|
| 109 | max = QPalette::AlternateBase + 1; | 
|---|
| 110 | QBrush tmp; | 
|---|
| 111 | for(int r = 0 ; r < max; r++) { | 
|---|
| 112 | s >> tmp; | 
|---|
| 113 | g.setBrush((QPalette::ColorRole)r, tmp); | 
|---|
| 114 | } | 
|---|
| 115 | } | 
|---|
| 116 | return s; | 
|---|
| 117 | } | 
|---|
| 118 |  | 
|---|
| 119 | QDataStream &operator<<(QDataStream &s, const QColorGroup &g) | 
|---|
| 120 | { | 
|---|
| 121 | return qt_stream_out_qcolorgroup(s, g); | 
|---|
| 122 | } | 
|---|
| 123 |  | 
|---|
| 124 | QDataStream &operator>>(QDataStream &s, QColorGroup &g) | 
|---|
| 125 | { | 
|---|
| 126 | return qt_stream_in_qcolorgroup(s, g); | 
|---|
| 127 | } | 
|---|
| 128 | #endif // QT_NO_DATASTREAM | 
|---|
| 129 |  | 
|---|
| 130 | /*! | 
|---|
| 131 | Constructs a palette with the specified \a active, \a disabled and | 
|---|
| 132 | \a inactive color groups. | 
|---|
| 133 | */ | 
|---|
| 134 | QPalette::QPalette(const QColorGroup &active, const QColorGroup &disabled, | 
|---|
| 135 | const QColorGroup &inactive) | 
|---|
| 136 | { | 
|---|
| 137 | Q_ASSERT(QPalette::NColorRoles == QPalette::ToolTipText + 1); | 
|---|
| 138 | init(); | 
|---|
| 139 | setColorGroup(Active, active); | 
|---|
| 140 | setColorGroup(Disabled, disabled); | 
|---|
| 141 | setColorGroup(Inactive, inactive); | 
|---|
| 142 | } | 
|---|
| 143 |  | 
|---|
| 144 | QColorGroup QPalette::createColorGroup(ColorGroup cr) const | 
|---|
| 145 | { | 
|---|
| 146 | QColorGroup ret(*this); | 
|---|
| 147 | ret.setCurrentColorGroup(cr); | 
|---|
| 148 | return ret; | 
|---|
| 149 | } | 
|---|
| 150 |  | 
|---|
| 151 | void QPalette::setColorGroup(ColorGroup cg, const QColorGroup &g) | 
|---|
| 152 | { | 
|---|
| 153 | setColorGroup(cg, g.brush(WindowText), g.brush(Button), g.brush(Light), | 
|---|
| 154 | g.brush(Dark), g.brush(Mid), g.brush(Text), g.brush(BrightText), | 
|---|
| 155 | g.brush(Base), g.brush(AlternateBase), g.brush(Window), | 
|---|
| 156 | g.brush(Midlight), g.brush(ButtonText), g.brush(Shadow), | 
|---|
| 157 | g.brush(Highlight), g.brush(HighlightedText), g.brush(Link), | 
|---|
| 158 | g.brush(LinkVisited), g.brush(ToolTipBase), g.brush(ToolTipText)); | 
|---|
| 159 | } | 
|---|
| 160 |  | 
|---|
| 161 | #endif // QT3_SUPPORT | 
|---|
| 162 |  | 
|---|
| 163 | /*! | 
|---|
| 164 | \fn const QColor &QPalette::color(ColorRole role) const | 
|---|
| 165 |  | 
|---|
| 166 | \overload | 
|---|
| 167 |  | 
|---|
| 168 | Returns the color that has been set for the given color \a role in | 
|---|
| 169 | the current ColorGroup. | 
|---|
| 170 |  | 
|---|
| 171 | \sa brush() ColorRole | 
|---|
| 172 | */ | 
|---|
| 173 |  | 
|---|
| 174 | /*! | 
|---|
| 175 | \fn const QBrush &QPalette::brush(ColorRole role) const | 
|---|
| 176 |  | 
|---|
| 177 | \overload | 
|---|
| 178 |  | 
|---|
| 179 | Returns the brush that has been set for the given color \a role in | 
|---|
| 180 | the current ColorGroup. | 
|---|
| 181 |  | 
|---|
| 182 | \sa color() setBrush() ColorRole | 
|---|
| 183 | */ | 
|---|
| 184 |  | 
|---|
| 185 | /*! | 
|---|
| 186 | \fn void QPalette::setColor(ColorRole role, const QColor &color) | 
|---|
| 187 |  | 
|---|
| 188 | \overload | 
|---|
| 189 |  | 
|---|
| 190 | Sets the color used for the given color \a role, in all color | 
|---|
| 191 | groups, to the specified solid \a color. | 
|---|
| 192 |  | 
|---|
| 193 | \sa brush() setColor() ColorRole | 
|---|
| 194 | */ | 
|---|
| 195 |  | 
|---|
| 196 | /*! | 
|---|
| 197 | \fn void QPalette::setBrush(ColorRole role, const QBrush &brush) | 
|---|
| 198 |  | 
|---|
| 199 | Sets the brush for the given color \a role to the specified \a | 
|---|
| 200 | brush for all groups in the palette. | 
|---|
| 201 |  | 
|---|
| 202 | \sa brush() setColor() ColorRole | 
|---|
| 203 | */ | 
|---|
| 204 |  | 
|---|
| 205 | /*! | 
|---|
| 206 | \fn const QBrush & QPalette::foreground() const | 
|---|
| 207 | \obsolete | 
|---|
| 208 |  | 
|---|
| 209 | Use windowText() instead. | 
|---|
| 210 | */ | 
|---|
| 211 |  | 
|---|
| 212 | /*! | 
|---|
| 213 | \fn const QBrush & QPalette::windowText() const | 
|---|
| 214 |  | 
|---|
| 215 | Returns the window text (general foreground) brush of the | 
|---|
| 216 | current color group. | 
|---|
| 217 |  | 
|---|
| 218 | \sa ColorRole brush() | 
|---|
| 219 | */ | 
|---|
| 220 |  | 
|---|
| 221 | /*! | 
|---|
| 222 | \fn const QBrush & QPalette::button() const | 
|---|
| 223 |  | 
|---|
| 224 | Returns the button brush of the current color group. | 
|---|
| 225 |  | 
|---|
| 226 | \sa ColorRole brush() | 
|---|
| 227 | */ | 
|---|
| 228 |  | 
|---|
| 229 | /*! | 
|---|
| 230 | \fn const QBrush & QPalette::light() const | 
|---|
| 231 |  | 
|---|
| 232 | Returns the light brush of the current color group. | 
|---|
| 233 |  | 
|---|
| 234 | \sa ColorRole brush() | 
|---|
| 235 | */ | 
|---|
| 236 |  | 
|---|
| 237 | /*! | 
|---|
| 238 | \fn const QBrush& QPalette::midlight() const | 
|---|
| 239 |  | 
|---|
| 240 | Returns the midlight brush of the current color group. | 
|---|
| 241 |  | 
|---|
| 242 | \sa ColorRole brush() | 
|---|
| 243 | */ | 
|---|
| 244 |  | 
|---|
| 245 | /*! | 
|---|
| 246 | \fn const QBrush & QPalette::dark() const | 
|---|
| 247 |  | 
|---|
| 248 | Returns the dark brush of the current color group. | 
|---|
| 249 |  | 
|---|
| 250 | \sa ColorRole brush() | 
|---|
| 251 | */ | 
|---|
| 252 |  | 
|---|
| 253 | /*! | 
|---|
| 254 | \fn const QBrush & QPalette::mid() const | 
|---|
| 255 |  | 
|---|
| 256 | Returns the mid brush of the current color group. | 
|---|
| 257 |  | 
|---|
| 258 | \sa ColorRole brush() | 
|---|
| 259 | */ | 
|---|
| 260 |  | 
|---|
| 261 | /*! | 
|---|
| 262 | \fn const QBrush & QPalette::text() const | 
|---|
| 263 |  | 
|---|
| 264 | Returns the text foreground brush of the current color group. | 
|---|
| 265 |  | 
|---|
| 266 | \sa ColorRole brush() | 
|---|
| 267 | */ | 
|---|
| 268 |  | 
|---|
| 269 | /*! | 
|---|
| 270 | \fn const QBrush & QPalette::brightText() const | 
|---|
| 271 |  | 
|---|
| 272 | Returns the bright text foreground brush of the current color group. | 
|---|
| 273 |  | 
|---|
| 274 | \sa ColorRole brush() | 
|---|
| 275 | */ | 
|---|
| 276 |  | 
|---|
| 277 | /*! | 
|---|
| 278 | \fn const QBrush & QPalette::buttonText() const | 
|---|
| 279 |  | 
|---|
| 280 | Returns the button text foreground brush of the current color group. | 
|---|
| 281 |  | 
|---|
| 282 | \sa ColorRole brush() | 
|---|
| 283 | */ | 
|---|
| 284 |  | 
|---|
| 285 | /*! | 
|---|
| 286 | \fn const QBrush & QPalette::base() const | 
|---|
| 287 |  | 
|---|
| 288 | Returns the base brush of the current color group. | 
|---|
| 289 |  | 
|---|
| 290 | \sa ColorRole brush() | 
|---|
| 291 | */ | 
|---|
| 292 |  | 
|---|
| 293 | /*! | 
|---|
| 294 | \fn const QBrush & QPalette::alternateBase() const | 
|---|
| 295 |  | 
|---|
| 296 | Returns the alternate base brush of the current color group. | 
|---|
| 297 |  | 
|---|
| 298 | \sa ColorRole brush() | 
|---|
| 299 | */ | 
|---|
| 300 |  | 
|---|
| 301 | /*! | 
|---|
| 302 | \fn const QBrush & QPalette::toolTipBase() const | 
|---|
| 303 | \since 4.4 | 
|---|
| 304 |  | 
|---|
| 305 | Returns the tool tip base brush of the current color group. This brush is | 
|---|
| 306 | used by QToolTip and QWhatsThis. | 
|---|
| 307 |  | 
|---|
| 308 | \note Tool tips use the Inactive color group of QPalette, because tool | 
|---|
| 309 | tips are not active windows. | 
|---|
| 310 |  | 
|---|
| 311 | \sa ColorRole brush() | 
|---|
| 312 | */ | 
|---|
| 313 |  | 
|---|
| 314 | /*! | 
|---|
| 315 | \fn const QBrush & QPalette::toolTipText() const | 
|---|
| 316 | \since 4.4 | 
|---|
| 317 |  | 
|---|
| 318 | Returns the tool tip text brush of the current color group. This brush is | 
|---|
| 319 | used by QToolTip and QWhatsThis. | 
|---|
| 320 |  | 
|---|
| 321 | \note Tool tips use the Inactive color group of QPalette, because tool | 
|---|
| 322 | tips are not active windows. | 
|---|
| 323 |  | 
|---|
| 324 | \sa ColorRole brush() | 
|---|
| 325 | */ | 
|---|
| 326 |  | 
|---|
| 327 | /*! | 
|---|
| 328 | \fn const QBrush & QPalette::background() const | 
|---|
| 329 | \obsolete | 
|---|
| 330 |  | 
|---|
| 331 | Use window() instead. | 
|---|
| 332 | */ | 
|---|
| 333 |  | 
|---|
| 334 | /*! | 
|---|
| 335 | \fn const QBrush & QPalette::window() const | 
|---|
| 336 |  | 
|---|
| 337 | Returns the window (general background) brush of the current | 
|---|
| 338 | color group. | 
|---|
| 339 |  | 
|---|
| 340 | \sa ColorRole brush() | 
|---|
| 341 | */ | 
|---|
| 342 |  | 
|---|
| 343 | /*! | 
|---|
| 344 | \fn const QBrush & QPalette::shadow() const | 
|---|
| 345 |  | 
|---|
| 346 | Returns the shadow brush of the current color group. | 
|---|
| 347 |  | 
|---|
| 348 | \sa ColorRole brush() | 
|---|
| 349 | */ | 
|---|
| 350 |  | 
|---|
| 351 | /*! | 
|---|
| 352 | \fn const QBrush & QPalette::highlight() const | 
|---|
| 353 |  | 
|---|
| 354 | Returns the highlight brush of the current color group. | 
|---|
| 355 |  | 
|---|
| 356 | \sa ColorRole brush() | 
|---|
| 357 | */ | 
|---|
| 358 |  | 
|---|
| 359 | /*! | 
|---|
| 360 | \fn const QBrush & QPalette::highlightedText() const | 
|---|
| 361 |  | 
|---|
| 362 | Returns the highlighted text brush of the current color group. | 
|---|
| 363 |  | 
|---|
| 364 | \sa ColorRole brush() | 
|---|
| 365 | */ | 
|---|
| 366 |  | 
|---|
| 367 | /*! | 
|---|
| 368 | \fn const QBrush & QPalette::link() const | 
|---|
| 369 |  | 
|---|
| 370 | Returns the unvisited link text brush of the current color group. | 
|---|
| 371 |  | 
|---|
| 372 | \sa ColorRole brush() | 
|---|
| 373 | */ | 
|---|
| 374 |  | 
|---|
| 375 | /*! | 
|---|
| 376 | \fn const QBrush & QPalette::linkVisited() const | 
|---|
| 377 |  | 
|---|
| 378 | Returns the visited link text brush of the current color group. | 
|---|
| 379 |  | 
|---|
| 380 | \sa ColorRole brush() | 
|---|
| 381 | */ | 
|---|
| 382 |  | 
|---|
| 383 | /*! | 
|---|
| 384 | \fn ColorGroup QPalette::currentColorGroup() const | 
|---|
| 385 |  | 
|---|
| 386 | Returns the palette's current color group. | 
|---|
| 387 | */ | 
|---|
| 388 |  | 
|---|
| 389 | /*! | 
|---|
| 390 | \fn void QPalette::setCurrentColorGroup(ColorGroup cg) | 
|---|
| 391 |  | 
|---|
| 392 | Set the palette's current color group to \a cg. | 
|---|
| 393 | */ | 
|---|
| 394 |  | 
|---|
| 395 | /*! | 
|---|
| 396 | \class QPalette | 
|---|
| 397 |  | 
|---|
| 398 | \brief The QPalette class contains color groups for each widget state. | 
|---|
| 399 |  | 
|---|
| 400 | \ingroup appearance | 
|---|
| 401 | \ingroup shared | 
|---|
| 402 | \ingroup painting | 
|---|
| 403 |  | 
|---|
| 404 |  | 
|---|
| 405 | A palette consists of three color groups: \e Active, \e Disabled, | 
|---|
| 406 | and \e Inactive. All widgets in Qt contain a palette and | 
|---|
| 407 | use their palette to draw themselves. This makes the user | 
|---|
| 408 | interface easily configurable and easier to keep consistent. | 
|---|
| 409 |  | 
|---|
| 410 |  | 
|---|
| 411 | If you create a new widget we strongly recommend that you use the | 
|---|
| 412 | colors in the palette rather than hard-coding specific colors. | 
|---|
| 413 |  | 
|---|
| 414 | The color groups: | 
|---|
| 415 | \list | 
|---|
| 416 | \i The Active group is used for the window that has keyboard focus. | 
|---|
| 417 | \i The Inactive group is used for other windows. | 
|---|
| 418 | \i The Disabled group is used for widgets (not windows) that are | 
|---|
| 419 | disabled for some reason. | 
|---|
| 420 | \endlist | 
|---|
| 421 |  | 
|---|
| 422 | Both active and inactive windows can contain disabled widgets. | 
|---|
| 423 | (Disabled widgets are often called \e inaccessible or \e{grayed | 
|---|
| 424 | out}.) | 
|---|
| 425 |  | 
|---|
| 426 | In most styles, Active and Inactive look the same. | 
|---|
| 427 |  | 
|---|
| 428 | Colors and brushes can be set for particular roles in any of a palette's | 
|---|
| 429 | color groups with setColor() and setBrush().  A color group contains a | 
|---|
| 430 | group of colors used by widgets for drawing themselves. We recommend that | 
|---|
| 431 | widgets use color group roles from the palette such as "foreground" and | 
|---|
| 432 | "base" rather than literal colors like "red" or "turquoise". The color | 
|---|
| 433 | roles are enumerated and defined in the \l ColorRole documentation. | 
|---|
| 434 |  | 
|---|
| 435 | We strongly recommend that you use the default palette of the | 
|---|
| 436 | current style (returned by QApplication::palette()) and | 
|---|
| 437 | modify that as necessary. This is done by Qt's widgets when they | 
|---|
| 438 | are drawn. | 
|---|
| 439 |  | 
|---|
| 440 | To modify a color group you call the functions | 
|---|
| 441 | setColor() and setBrush(), depending on whether you want a pure | 
|---|
| 442 | color or a pixmap pattern. | 
|---|
| 443 |  | 
|---|
| 444 | There are also corresponding color() and brush() getters, and a | 
|---|
| 445 | commonly used convenience function to get the ColorRole for the current ColorGroup: | 
|---|
| 446 | window(), windowText(), base(), etc. | 
|---|
| 447 |  | 
|---|
| 448 |  | 
|---|
| 449 | You can copy a palette using the copy constructor and test to see | 
|---|
| 450 | if two palettes are \e identical using isCopyOf(). | 
|---|
| 451 |  | 
|---|
| 452 | QPalette is optimized by the use of \l{implicit sharing}, | 
|---|
| 453 | so it is very efficient to pass QPalette objects as arguments. | 
|---|
| 454 |  | 
|---|
| 455 | \warning Some styles do not use the palette for all drawing, for | 
|---|
| 456 | instance, if they make use of native theme engines. This is the | 
|---|
| 457 | case for both the Windows XP, Windows Vista, and the Mac OS X | 
|---|
| 458 | styles. | 
|---|
| 459 |  | 
|---|
| 460 | \sa QApplication::setPalette(), QWidget::setPalette(), QColor | 
|---|
| 461 | */ | 
|---|
| 462 |  | 
|---|
| 463 | /*! | 
|---|
| 464 | \enum QPalette::ColorGroup | 
|---|
| 465 |  | 
|---|
| 466 | \value Disabled | 
|---|
| 467 | \value Active | 
|---|
| 468 | \value Inactive | 
|---|
| 469 | \value Normal synonym for Active | 
|---|
| 470 |  | 
|---|
| 471 | \omitvalue All | 
|---|
| 472 | \omitvalue NColorGroups | 
|---|
| 473 | \omitvalue Current | 
|---|
| 474 | */ | 
|---|
| 475 |  | 
|---|
| 476 | /*! | 
|---|
| 477 | \enum QPalette::ColorRole | 
|---|
| 478 |  | 
|---|
| 479 | \img palette.png Color Roles | 
|---|
| 480 |  | 
|---|
| 481 | The ColorRole enum defines the different symbolic color roles used | 
|---|
| 482 | in current GUIs. | 
|---|
| 483 |  | 
|---|
| 484 | The central roles are: | 
|---|
| 485 |  | 
|---|
| 486 | \value Window  A general background color. | 
|---|
| 487 |  | 
|---|
| 488 | \value Background  This value is obsolete. Use Window instead. | 
|---|
| 489 |  | 
|---|
| 490 | \value WindowText  A general foreground color. | 
|---|
| 491 |  | 
|---|
| 492 | \value Foreground  This value is obsolete. Use WindowText instead. | 
|---|
| 493 |  | 
|---|
| 494 | \value Base  Used mostly as the background color for text entry widgets, | 
|---|
| 495 | but can also be used for other painting - such as the | 
|---|
| 496 | background of combobox drop down lists and toolbar handles. | 
|---|
| 497 | It is usually white or another light color. | 
|---|
| 498 |  | 
|---|
| 499 | \value AlternateBase  Used as the alternate background color in views with | 
|---|
| 500 | alternating row colors (see | 
|---|
| 501 | QAbstractItemView::setAlternatingRowColors()). | 
|---|
| 502 |  | 
|---|
| 503 | \value ToolTipBase Used as the background color for QToolTip and | 
|---|
| 504 | QWhatsThis. Tool tips use the Inactive color group | 
|---|
| 505 | of QPalette, because tool tips are not active | 
|---|
| 506 | windows. | 
|---|
| 507 |  | 
|---|
| 508 | \value ToolTipText Used as the foreground color for QToolTip and | 
|---|
| 509 | QWhatsThis. Tool tips use the Inactive color group | 
|---|
| 510 | of QPalette, because tool tips are not active | 
|---|
| 511 | windows. | 
|---|
| 512 |  | 
|---|
| 513 | \value Text  The foreground color used with \c Base. This is usually | 
|---|
| 514 | the same as the \c WindowText, in which case it must provide | 
|---|
| 515 | good contrast with \c Window and \c Base. | 
|---|
| 516 |  | 
|---|
| 517 | \value Button The general button background color. This background can be different from | 
|---|
| 518 | \c Window as some styles require a different background color for buttons. | 
|---|
| 519 |  | 
|---|
| 520 | \value ButtonText  A foreground color used with the \c Button color. | 
|---|
| 521 |  | 
|---|
| 522 | \value BrightText  A text color that is very different from | 
|---|
| 523 | \c WindowText, and contrasts well with e.g. \c | 
|---|
| 524 | Dark. Typically used for text that needs to be | 
|---|
| 525 | drawn where \c Text or \c WindowText would give | 
|---|
| 526 | poor contrast, such as on pressed push buttons. | 
|---|
| 527 | Note that text colors can be used for things | 
|---|
| 528 | other than just words; text colors are \e | 
|---|
| 529 | usually used for text, but it's quite common to | 
|---|
| 530 | use the text color roles for lines, icons, etc. | 
|---|
| 531 |  | 
|---|
| 532 |  | 
|---|
| 533 | There are some color roles used mostly for 3D bevel and shadow effects. | 
|---|
| 534 | All of these are normally derived from \c Window, and used in ways that | 
|---|
| 535 | depend on that relationship. For example, buttons depend on it to make the | 
|---|
| 536 | bevels look attractive, and Motif scroll bars depend on \c Mid to be | 
|---|
| 537 | slightly different from \c Window. | 
|---|
| 538 |  | 
|---|
| 539 | \value Light  Lighter than \c Button color. | 
|---|
| 540 |  | 
|---|
| 541 | \value Midlight  Between \c Button and \c Light. | 
|---|
| 542 |  | 
|---|
| 543 | \value Dark  Darker than \c Button. | 
|---|
| 544 |  | 
|---|
| 545 | \value Mid  Between \c Button and \c Dark. | 
|---|
| 546 |  | 
|---|
| 547 | \value Shadow  A very dark color. By default, the shadow color is | 
|---|
| 548 | Qt::black. | 
|---|
| 549 |  | 
|---|
| 550 |  | 
|---|
| 551 | Selected (marked) items have two roles: | 
|---|
| 552 |  | 
|---|
| 553 | \value Highlight   A color to indicate a selected item or the current | 
|---|
| 554 | item. By default, the highlight color is | 
|---|
| 555 | Qt::darkBlue. | 
|---|
| 556 |  | 
|---|
| 557 | \value HighlightedText  A text color that contrasts with \c Highlight. | 
|---|
| 558 | By default, the highlighted text color is Qt::white. | 
|---|
| 559 |  | 
|---|
| 560 | There are two color roles related to hyperlinks: | 
|---|
| 561 |  | 
|---|
| 562 | \value Link  A text color used for unvisited hyperlinks. | 
|---|
| 563 | By default, the link color is Qt::blue. | 
|---|
| 564 |  | 
|---|
| 565 | \value LinkVisited  A text color used for already visited hyperlinks. | 
|---|
| 566 | By default, the linkvisited color is Qt::magenta. | 
|---|
| 567 |  | 
|---|
| 568 | Note that we do not use the \c Link and \c LinkVisited roles when | 
|---|
| 569 | rendering rich text in Qt, and that we recommend that you use CSS | 
|---|
| 570 | and the QTextDocument::setDefaultStyleSheet() function to alter | 
|---|
| 571 | the appearance of links. For example: | 
|---|
| 572 |  | 
|---|
| 573 | \snippet doc/src/snippets/textdocument-css/main.cpp 0 | 
|---|
| 574 |  | 
|---|
| 575 | \value NoRole No role; this special role is often used to indicate that a | 
|---|
| 576 | role has not been assigned. | 
|---|
| 577 |  | 
|---|
| 578 | \omitvalue NColorRoles | 
|---|
| 579 | */ | 
|---|
| 580 |  | 
|---|
| 581 | /*! | 
|---|
| 582 | Constructs a palette object that uses the application's default palette. | 
|---|
| 583 |  | 
|---|
| 584 | \sa QApplication::setPalette(), QApplication::palette() | 
|---|
| 585 | */ | 
|---|
| 586 | QPalette::QPalette() | 
|---|
| 587 | : d(QApplication::palette().d), | 
|---|
| 588 | current_group(Active), | 
|---|
| 589 | resolve_mask(0) | 
|---|
| 590 | { | 
|---|
| 591 | d->ref.ref(); | 
|---|
| 592 | } | 
|---|
| 593 |  | 
|---|
| 594 | static void qt_palette_from_color(QPalette &pal, const QColor & button) | 
|---|
| 595 | { | 
|---|
| 596 | QColor bg = button, | 
|---|
| 597 | btn = button, | 
|---|
| 598 | fg, base; | 
|---|
| 599 | int h, s, v; | 
|---|
| 600 | bg.getHsv(&h, &s, &v); | 
|---|
| 601 | if(v > 128) { | 
|---|
| 602 | fg   = Qt::black; | 
|---|
| 603 | base = Qt::white; | 
|---|
| 604 | } else { | 
|---|
| 605 | fg   = Qt::white; | 
|---|
| 606 | base = Qt::black; | 
|---|
| 607 | } | 
|---|
| 608 | //inactive and active are the same.. | 
|---|
| 609 | pal.setColorGroup(QPalette::Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), | 
|---|
| 610 | QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), | 
|---|
| 611 | QBrush(base), QBrush(bg)); | 
|---|
| 612 | pal.setColorGroup(QPalette::Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), | 
|---|
| 613 | QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), | 
|---|
| 614 | QBrush(base), QBrush(bg)); | 
|---|
| 615 | pal.setColorGroup(QPalette::Disabled, QBrush(btn.darker()), QBrush(btn), QBrush(btn.lighter(150)), | 
|---|
| 616 | QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(btn.darker()), | 
|---|
| 617 | QBrush(Qt::white), QBrush(bg), QBrush(bg)); | 
|---|
| 618 | } | 
|---|
| 619 |  | 
|---|
| 620 |  | 
|---|
| 621 | /*! | 
|---|
| 622 | Constructs a palette from the \a button color. The other colors are | 
|---|
| 623 | automatically calculated, based on this color. \c Window will be | 
|---|
| 624 | the button color as well. | 
|---|
| 625 | */ | 
|---|
| 626 | QPalette::QPalette(const QColor &button) | 
|---|
| 627 | { | 
|---|
| 628 | init(); | 
|---|
| 629 | qt_palette_from_color(*this, button); | 
|---|
| 630 | } | 
|---|
| 631 |  | 
|---|
| 632 | /*! | 
|---|
| 633 | Constructs a palette from the \a button color. The other colors are | 
|---|
| 634 | automatically calculated, based on this color. \c Window will be | 
|---|
| 635 | the button color as well. | 
|---|
| 636 | */ | 
|---|
| 637 | QPalette::QPalette(Qt::GlobalColor button) | 
|---|
| 638 | { | 
|---|
| 639 | init(); | 
|---|
| 640 | qt_palette_from_color(*this, button); | 
|---|
| 641 | } | 
|---|
| 642 |  | 
|---|
| 643 | /*! | 
|---|
| 644 | Constructs a palette. You can pass either brushes, pixmaps or | 
|---|
| 645 | plain colors for \a windowText, \a button, \a light, \a dark, \a | 
|---|
| 646 | mid, \a text, \a bright_text, \a base and \a window. | 
|---|
| 647 |  | 
|---|
| 648 | \sa QBrush | 
|---|
| 649 | */ | 
|---|
| 650 | QPalette::QPalette(const QBrush &windowText, const QBrush &button, | 
|---|
| 651 | const QBrush &light, const QBrush &dark, | 
|---|
| 652 | const QBrush &mid, const QBrush &text, | 
|---|
| 653 | const QBrush &bright_text, const QBrush &base, | 
|---|
| 654 | const QBrush &window) | 
|---|
| 655 | { | 
|---|
| 656 | init(); | 
|---|
| 657 | setColorGroup(All, windowText, button, light, dark, mid, text, bright_text, | 
|---|
| 658 | base, window); | 
|---|
| 659 | } | 
|---|
| 660 |  | 
|---|
| 661 |  | 
|---|
| 662 | /*!\obsolete | 
|---|
| 663 |  | 
|---|
| 664 | Constructs a palette with the specified \a windowText, \a | 
|---|
| 665 | window, \a light, \a dark, \a mid, \a text, and \a base colors. | 
|---|
| 666 | The button color will be set to the window color. | 
|---|
| 667 | */ | 
|---|
| 668 | QPalette::QPalette(const QColor &windowText, const QColor &window, | 
|---|
| 669 | const QColor &light, const QColor &dark, const QColor &mid, | 
|---|
| 670 | const QColor &text, const QColor &base) | 
|---|
| 671 | { | 
|---|
| 672 | init(); | 
|---|
| 673 | setColorGroup(All, QBrush(windowText), QBrush(window), QBrush(light), | 
|---|
| 674 | QBrush(dark), QBrush(mid), QBrush(text), QBrush(light), | 
|---|
| 675 | QBrush(base), QBrush(window)); | 
|---|
| 676 | } | 
|---|
| 677 |  | 
|---|
| 678 | /*! | 
|---|
| 679 | Constructs a palette from a \a button color and a \a window. | 
|---|
| 680 | The other colors are automatically calculated, based on these | 
|---|
| 681 | colors. | 
|---|
| 682 | */ | 
|---|
| 683 | QPalette::QPalette(const QColor &button, const QColor &window) | 
|---|
| 684 | { | 
|---|
| 685 | init(); | 
|---|
| 686 | QColor bg = window, btn = button, fg, base, disfg; | 
|---|
| 687 | int h, s, v; | 
|---|
| 688 | bg.getHsv(&h, &s, &v); | 
|---|
| 689 | if(v > 128) { | 
|---|
| 690 | fg   = Qt::black; | 
|---|
| 691 | base = Qt::white; | 
|---|
| 692 | disfg = Qt::darkGray; | 
|---|
| 693 | } else { | 
|---|
| 694 | fg   = Qt::white; | 
|---|
| 695 | base = Qt::black; | 
|---|
| 696 | disfg = Qt::darkGray; | 
|---|
| 697 | } | 
|---|
| 698 | //inactive and active are identical | 
|---|
| 699 | setColorGroup(Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), QBrush(btn.darker()), | 
|---|
| 700 | QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), QBrush(base), | 
|---|
| 701 | QBrush(bg)); | 
|---|
| 702 | setColorGroup(Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), QBrush(btn.darker()), | 
|---|
| 703 | QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), QBrush(base), | 
|---|
| 704 | QBrush(bg)); | 
|---|
| 705 | setColorGroup(Disabled, QBrush(disfg), QBrush(btn), QBrush(btn.lighter(150)), | 
|---|
| 706 | QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(disfg), | 
|---|
| 707 | QBrush(Qt::white), QBrush(base), QBrush(bg)); | 
|---|
| 708 | } | 
|---|
| 709 |  | 
|---|
| 710 | /*! | 
|---|
| 711 | Constructs a copy of \a p. | 
|---|
| 712 |  | 
|---|
| 713 | This constructor is fast thanks to \l{implicit sharing}. | 
|---|
| 714 | */ | 
|---|
| 715 | QPalette::QPalette(const QPalette &p) | 
|---|
| 716 | { | 
|---|
| 717 | d = p.d; | 
|---|
| 718 | d->ref.ref(); | 
|---|
| 719 | resolve_mask = p.resolve_mask; | 
|---|
| 720 | current_group = p.current_group; | 
|---|
| 721 | } | 
|---|
| 722 |  | 
|---|
| 723 | /*! | 
|---|
| 724 | Destroys the palette. | 
|---|
| 725 | */ | 
|---|
| 726 | QPalette::~QPalette() | 
|---|
| 727 | { | 
|---|
| 728 | if(!d->ref.deref()) | 
|---|
| 729 | delete d; | 
|---|
| 730 | } | 
|---|
| 731 |  | 
|---|
| 732 | /*!\internal*/ | 
|---|
| 733 | void QPalette::init() { | 
|---|
| 734 | d = new QPalettePrivate; | 
|---|
| 735 | resolve_mask = 0; | 
|---|
| 736 | current_group = Active; //as a default.. | 
|---|
| 737 | } | 
|---|
| 738 |  | 
|---|
| 739 | /*! | 
|---|
| 740 | Assigns \a p to this palette and returns a reference to this | 
|---|
| 741 | palette. | 
|---|
| 742 |  | 
|---|
| 743 | This operation is fast thanks to \l{implicit sharing}. | 
|---|
| 744 | */ | 
|---|
| 745 | QPalette &QPalette::operator=(const QPalette &p) | 
|---|
| 746 | { | 
|---|
| 747 | p.d->ref.ref(); | 
|---|
| 748 | resolve_mask = p.resolve_mask; | 
|---|
| 749 | current_group = p.current_group; | 
|---|
| 750 | if(!d->ref.deref()) | 
|---|
| 751 | delete d; | 
|---|
| 752 | d = p.d; | 
|---|
| 753 | return *this; | 
|---|
| 754 | } | 
|---|
| 755 |  | 
|---|
| 756 | /*! | 
|---|
| 757 | Returns the palette as a QVariant | 
|---|
| 758 | */ | 
|---|
| 759 | QPalette::operator QVariant() const | 
|---|
| 760 | { | 
|---|
| 761 | return QVariant(QVariant::Palette, this); | 
|---|
| 762 | } | 
|---|
| 763 |  | 
|---|
| 764 | /*! | 
|---|
| 765 | \fn const QColor &QPalette::color(ColorGroup group, ColorRole role) const | 
|---|
| 766 |  | 
|---|
| 767 | Returns the color in the specified color \a group, used for the | 
|---|
| 768 | given color \a role. | 
|---|
| 769 |  | 
|---|
| 770 | \sa brush() setColor() ColorRole | 
|---|
| 771 | */ | 
|---|
| 772 |  | 
|---|
| 773 | /*! | 
|---|
| 774 | \fn const QBrush &QPalette::brush(ColorGroup group, ColorRole role) const | 
|---|
| 775 |  | 
|---|
| 776 | Returns the brush in the specified color \a group, used for the | 
|---|
| 777 | given color \a role. | 
|---|
| 778 |  | 
|---|
| 779 | \sa color() setBrush() ColorRole | 
|---|
| 780 | */ | 
|---|
| 781 | const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const | 
|---|
| 782 | { | 
|---|
| 783 | Q_ASSERT(cr < NColorRoles); | 
|---|
| 784 | if(gr >= (int)NColorGroups) { | 
|---|
| 785 | if(gr == Current) { | 
|---|
| 786 | gr = (ColorGroup)current_group; | 
|---|
| 787 | } else { | 
|---|
| 788 | qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr); | 
|---|
| 789 | gr = Active; | 
|---|
| 790 | } | 
|---|
| 791 | } | 
|---|
| 792 | return d->br[gr][cr]; | 
|---|
| 793 | } | 
|---|
| 794 |  | 
|---|
| 795 | /*! | 
|---|
| 796 | \fn void QPalette::setColor(ColorGroup group, ColorRole role, const QColor &color) | 
|---|
| 797 |  | 
|---|
| 798 | Sets the color in the specified color \a group, used for the given | 
|---|
| 799 | color \a role, to the specified solid \a color. | 
|---|
| 800 |  | 
|---|
| 801 | \sa setBrush() color() ColorRole | 
|---|
| 802 | */ | 
|---|
| 803 |  | 
|---|
| 804 | /*! | 
|---|
| 805 | \fn void QPalette::setBrush(ColorGroup group, ColorRole role, const QBrush &brush) | 
|---|
| 806 | \overload | 
|---|
| 807 |  | 
|---|
| 808 | Sets the brush in the specified color \a group, used for the given | 
|---|
| 809 | color \a role, to \a brush. | 
|---|
| 810 |  | 
|---|
| 811 | \sa brush() setColor() ColorRole | 
|---|
| 812 | */ | 
|---|
| 813 | void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) | 
|---|
| 814 | { | 
|---|
| 815 | Q_ASSERT(cr < NColorRoles); | 
|---|
| 816 | detach(); | 
|---|
| 817 | if(cg >= (int)NColorGroups) { | 
|---|
| 818 | if(cg == All) { | 
|---|
| 819 | for(int i = 0; i < (int)NColorGroups; i++) | 
|---|
| 820 | d->br[i][cr] = b; | 
|---|
| 821 | resolve_mask |= (1<<cr); | 
|---|
| 822 | return; | 
|---|
| 823 | } else if(cg == Current) { | 
|---|
| 824 | cg = (ColorGroup)current_group; | 
|---|
| 825 | } else { | 
|---|
| 826 | qWarning("QPalette::setBrush: Unknown ColorGroup: %d", (int)cg); | 
|---|
| 827 | cg = Active; | 
|---|
| 828 | } | 
|---|
| 829 | } | 
|---|
| 830 | d->br[cg][cr] = b; | 
|---|
| 831 | resolve_mask |= (1<<cr); | 
|---|
| 832 | } | 
|---|
| 833 |  | 
|---|
| 834 | /*! | 
|---|
| 835 | \since 4.2 | 
|---|
| 836 |  | 
|---|
| 837 | Returns true if the ColorGroup \a cg and ColorRole \a cr has been | 
|---|
| 838 | set previously on this palette; otherwise returns false. | 
|---|
| 839 |  | 
|---|
| 840 | \sa setBrush() | 
|---|
| 841 | */ | 
|---|
| 842 | bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const | 
|---|
| 843 | { | 
|---|
| 844 | Q_UNUSED(cg); | 
|---|
| 845 | return (resolve_mask & (1<<cr)); | 
|---|
| 846 | } | 
|---|
| 847 |  | 
|---|
| 848 | /*! | 
|---|
| 849 | \internal | 
|---|
| 850 | */ | 
|---|
| 851 | void QPalette::detach() | 
|---|
| 852 | { | 
|---|
| 853 | if (d->ref != 1) { | 
|---|
| 854 | QPalettePrivate *x = new QPalettePrivate; | 
|---|
| 855 | for(int grp = 0; grp < (int)NColorGroups; grp++) { | 
|---|
| 856 | for(int role = 0; role < (int)NColorRoles; role++) | 
|---|
| 857 | x->br[grp][role] = d->br[grp][role]; | 
|---|
| 858 | } | 
|---|
| 859 | if(!d->ref.deref()) | 
|---|
| 860 | delete d; | 
|---|
| 861 | d = x; | 
|---|
| 862 | } | 
|---|
| 863 | ++d->detach_no; | 
|---|
| 864 | } | 
|---|
| 865 |  | 
|---|
| 866 | /*! | 
|---|
| 867 | \fn bool QPalette::operator!=(const QPalette &p) const | 
|---|
| 868 |  | 
|---|
| 869 | Returns true (slowly) if this palette is different from \a p; | 
|---|
| 870 | otherwise returns false (usually quickly). | 
|---|
| 871 |  | 
|---|
| 872 | \note The current ColorGroup is not taken into account when | 
|---|
| 873 | comparing palettes | 
|---|
| 874 |  | 
|---|
| 875 | \sa operator==() | 
|---|
| 876 | */ | 
|---|
| 877 |  | 
|---|
| 878 | /*! | 
|---|
| 879 | Returns true (usually quickly) if this palette is equal to \a p; | 
|---|
| 880 | otherwise returns false (slowly). | 
|---|
| 881 |  | 
|---|
| 882 | \note The current ColorGroup is not taken into account when | 
|---|
| 883 | comparing palettes | 
|---|
| 884 |  | 
|---|
| 885 | \sa operator!=() | 
|---|
| 886 | */ | 
|---|
| 887 | bool QPalette::operator==(const QPalette &p) const | 
|---|
| 888 | { | 
|---|
| 889 | if (isCopyOf(p)) | 
|---|
| 890 | return true; | 
|---|
| 891 | for(int grp = 0; grp < (int)NColorGroups; grp++) { | 
|---|
| 892 | for(int role = 0; role < (int)NColorRoles; role++) { | 
|---|
| 893 | if(d->br[grp][role] != p.d->br[grp][role]) | 
|---|
| 894 | return false; | 
|---|
| 895 | } | 
|---|
| 896 | } | 
|---|
| 897 | return true; | 
|---|
| 898 | } | 
|---|
| 899 |  | 
|---|
| 900 | #ifdef QT3_SUPPORT | 
|---|
| 901 | bool QColorGroup::operator==(const QColorGroup &other) const | 
|---|
| 902 | { | 
|---|
| 903 | if (isCopyOf(other)) | 
|---|
| 904 | return true; | 
|---|
| 905 | for (int role = 0; role < int(NColorRoles); role++) { | 
|---|
| 906 | if(d->br[current_group][role] != other.d->br[other.current_group][role]) | 
|---|
| 907 | return false; | 
|---|
| 908 | } | 
|---|
| 909 | return true; | 
|---|
| 910 | } | 
|---|
| 911 |  | 
|---|
| 912 | /*! | 
|---|
| 913 | Returns the color group as a QVariant | 
|---|
| 914 | */ | 
|---|
| 915 | QColorGroup::operator QVariant() const | 
|---|
| 916 | { | 
|---|
| 917 | return QVariant(QVariant::ColorGroup, this); | 
|---|
| 918 | } | 
|---|
| 919 | #endif | 
|---|
| 920 |  | 
|---|
| 921 | /*! | 
|---|
| 922 | \fn bool QPalette::isEqual(ColorGroup cg1, ColorGroup cg2) const | 
|---|
| 923 |  | 
|---|
| 924 | Returns true (usually quickly) if color group \a cg1 is equal to | 
|---|
| 925 | \a cg2; otherwise returns false. | 
|---|
| 926 | */ | 
|---|
| 927 | bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) const | 
|---|
| 928 | { | 
|---|
| 929 | if(group1 >= (int)NColorGroups) { | 
|---|
| 930 | if(group1 == Current) { | 
|---|
| 931 | group1 = (ColorGroup)current_group; | 
|---|
| 932 | } else { | 
|---|
| 933 | qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1); | 
|---|
| 934 | group1 = Active; | 
|---|
| 935 | } | 
|---|
| 936 | } | 
|---|
| 937 | if(group2 >= (int)NColorGroups) { | 
|---|
| 938 | if(group2 == Current) { | 
|---|
| 939 | group2 = (ColorGroup)current_group; | 
|---|
| 940 | } else { | 
|---|
| 941 | qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2); | 
|---|
| 942 | group2 = Active; | 
|---|
| 943 | } | 
|---|
| 944 | } | 
|---|
| 945 | if(group1 == group2) | 
|---|
| 946 | return true; | 
|---|
| 947 | for(int role = 0; role < (int)NColorRoles; role++) { | 
|---|
| 948 | if(d->br[group1][role] != d->br[group2][role]) | 
|---|
| 949 | return false; | 
|---|
| 950 | } | 
|---|
| 951 | return true; | 
|---|
| 952 | } | 
|---|
| 953 |  | 
|---|
| 954 | /*! \obsolete | 
|---|
| 955 |  | 
|---|
| 956 | Returns a number that identifies the contents of this QPalette | 
|---|
| 957 | object. Distinct QPalette objects can only have the same serial | 
|---|
| 958 | number if they refer to the same contents (but they don't have | 
|---|
| 959 | to). Also, the serial number of a QPalette may change during the | 
|---|
| 960 | lifetime of the object. | 
|---|
| 961 |  | 
|---|
| 962 | Use cacheKey() instead. | 
|---|
| 963 |  | 
|---|
| 964 | \warning The serial number doesn't necessarily change when the | 
|---|
| 965 | palette is altered. This means that it may be dangerous to use it | 
|---|
| 966 | as a cache key. | 
|---|
| 967 |  | 
|---|
| 968 | \sa operator==() | 
|---|
| 969 | */ | 
|---|
| 970 | int QPalette::serialNumber() const | 
|---|
| 971 | { | 
|---|
| 972 | return d->ser_no; | 
|---|
| 973 | } | 
|---|
| 974 |  | 
|---|
| 975 | /*! | 
|---|
| 976 | Returns a number that identifies the contents of this QPalette | 
|---|
| 977 | object. Distinct QPalette objects can have the same key if | 
|---|
| 978 | they refer to the same contents. | 
|---|
| 979 |  | 
|---|
| 980 | The cacheKey() will change when the palette is altered. | 
|---|
| 981 | */ | 
|---|
| 982 | qint64 QPalette::cacheKey() const | 
|---|
| 983 | { | 
|---|
| 984 | return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no)); | 
|---|
| 985 | } | 
|---|
| 986 |  | 
|---|
| 987 | /*! | 
|---|
| 988 | Returns a new QPalette that has attributes copied from \a other. | 
|---|
| 989 | */ | 
|---|
| 990 | QPalette QPalette::resolve(const QPalette &other) const | 
|---|
| 991 | { | 
|---|
| 992 | if ((*this == other && resolve_mask == other.resolve_mask) | 
|---|
| 993 | || resolve_mask == 0) { | 
|---|
| 994 | QPalette o = other; | 
|---|
| 995 | o.resolve_mask = resolve_mask; | 
|---|
| 996 | return o; | 
|---|
| 997 | } | 
|---|
| 998 |  | 
|---|
| 999 | QPalette palette(*this); | 
|---|
| 1000 | palette.detach(); | 
|---|
| 1001 |  | 
|---|
| 1002 | for(int role = 0; role < (int)NColorRoles; role++) | 
|---|
| 1003 | if (!(resolve_mask & (1<<role))) | 
|---|
| 1004 | for(int grp = 0; grp < (int)NColorGroups; grp++) | 
|---|
| 1005 | palette.d->br[grp][role] = other.d->br[grp][role]; | 
|---|
| 1006 |  | 
|---|
| 1007 | return palette; | 
|---|
| 1008 | } | 
|---|
| 1009 |  | 
|---|
| 1010 | /*! | 
|---|
| 1011 | \fn uint QPalette::resolve() const | 
|---|
| 1012 | \internal | 
|---|
| 1013 | */ | 
|---|
| 1014 |  | 
|---|
| 1015 | /*! | 
|---|
| 1016 | \fn void QPalette::resolve(uint mask) | 
|---|
| 1017 | \internal | 
|---|
| 1018 | */ | 
|---|
| 1019 |  | 
|---|
| 1020 |  | 
|---|
| 1021 | /***************************************************************************** | 
|---|
| 1022 | QPalette stream functions | 
|---|
| 1023 | *****************************************************************************/ | 
|---|
| 1024 |  | 
|---|
| 1025 | #ifndef QT_NO_DATASTREAM | 
|---|
| 1026 |  | 
|---|
| 1027 | static const int NumOldRoles = 7; | 
|---|
| 1028 | static const int oldRoles[7] = { QPalette::Foreground, QPalette::Background, QPalette::Light, | 
|---|
| 1029 | QPalette::Dark, QPalette::Mid, QPalette::Text, QPalette::Base }; | 
|---|
| 1030 |  | 
|---|
| 1031 | /*! | 
|---|
| 1032 | \relates QPalette | 
|---|
| 1033 |  | 
|---|
| 1034 | Writes the palette, \a p to the stream \a s and returns a | 
|---|
| 1035 | reference to the stream. | 
|---|
| 1036 |  | 
|---|
| 1037 | \sa \link datastreamformat.html Format of the QDataStream operators \endlink | 
|---|
| 1038 | */ | 
|---|
| 1039 |  | 
|---|
| 1040 | QDataStream &operator<<(QDataStream &s, const QPalette &p) | 
|---|
| 1041 | { | 
|---|
| 1042 | for (int grp = 0; grp < (int)QPalette::NColorGroups; grp++) { | 
|---|
| 1043 | if (s.version() == 1) { | 
|---|
| 1044 | // Qt 1.x | 
|---|
| 1045 | for (int i = 0; i < NumOldRoles; ++i) | 
|---|
| 1046 | s << p.d->br[grp][oldRoles[i]].color(); | 
|---|
| 1047 | } else { | 
|---|
| 1048 | int max = QPalette::ToolTipText + 1; | 
|---|
| 1049 | if (s.version() <= QDataStream::Qt_2_1) | 
|---|
| 1050 | max = QPalette::HighlightedText + 1; | 
|---|
| 1051 | else if (s.version() <= QDataStream::Qt_4_3) | 
|---|
| 1052 | max = QPalette::AlternateBase + 1; | 
|---|
| 1053 | for (int r = 0; r < max; r++) | 
|---|
| 1054 | s << p.d->br[grp][r]; | 
|---|
| 1055 | } | 
|---|
| 1056 | } | 
|---|
| 1057 | return s; | 
|---|
| 1058 | } | 
|---|
| 1059 |  | 
|---|
| 1060 | static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup grp) | 
|---|
| 1061 | { | 
|---|
| 1062 | for (int i = 0; i < NumOldRoles; ++i) { | 
|---|
| 1063 | QColor col; | 
|---|
| 1064 | s >> col; | 
|---|
| 1065 | pal.setColor(grp, (QPalette::ColorRole)oldRoles[i], col); | 
|---|
| 1066 | } | 
|---|
| 1067 | } | 
|---|
| 1068 |  | 
|---|
| 1069 | /*! | 
|---|
| 1070 | \relates QPalette | 
|---|
| 1071 |  | 
|---|
| 1072 | Reads a palette from the stream, \a s into the palette \a p, and | 
|---|
| 1073 | returns a reference to the stream. | 
|---|
| 1074 |  | 
|---|
| 1075 | \sa \link datastreamformat.html Format of the QDataStream operators \endlink | 
|---|
| 1076 | */ | 
|---|
| 1077 |  | 
|---|
| 1078 | QDataStream &operator>>(QDataStream &s, QPalette &p) | 
|---|
| 1079 | { | 
|---|
| 1080 | if(s.version() == 1) { | 
|---|
| 1081 | p = QPalette(); | 
|---|
| 1082 | readV1ColorGroup(s, p, QPalette::Active); | 
|---|
| 1083 | readV1ColorGroup(s, p, QPalette::Disabled); | 
|---|
| 1084 | readV1ColorGroup(s, p, QPalette::Inactive); | 
|---|
| 1085 | } else { | 
|---|
| 1086 | int max = QPalette::NColorRoles; | 
|---|
| 1087 | if (s.version() <= QDataStream::Qt_2_1) { | 
|---|
| 1088 | p = QPalette(); | 
|---|
| 1089 | max = QPalette::HighlightedText + 1; | 
|---|
| 1090 | } else if (s.version() <= QDataStream::Qt_4_3) { | 
|---|
| 1091 | p = QPalette(); | 
|---|
| 1092 | max = QPalette::AlternateBase + 1; | 
|---|
| 1093 | } | 
|---|
| 1094 |  | 
|---|
| 1095 | QBrush tmp; | 
|---|
| 1096 | for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) { | 
|---|
| 1097 | for(int role = 0; role < max; ++role) { | 
|---|
| 1098 | s >> tmp; | 
|---|
| 1099 | p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp); | 
|---|
| 1100 | } | 
|---|
| 1101 | } | 
|---|
| 1102 | } | 
|---|
| 1103 | return s; | 
|---|
| 1104 | } | 
|---|
| 1105 | #endif //QT_NO_DATASTREAM | 
|---|
| 1106 |  | 
|---|
| 1107 | /*! | 
|---|
| 1108 | Returns true if this palette and \a p are copies of each other, | 
|---|
| 1109 | i.e. one of them was created as a copy of the other and neither | 
|---|
| 1110 | was subsequently modified; otherwise returns false. This is much | 
|---|
| 1111 | stricter than equality. | 
|---|
| 1112 |  | 
|---|
| 1113 | \sa operator=() operator==() | 
|---|
| 1114 | */ | 
|---|
| 1115 |  | 
|---|
| 1116 | bool QPalette::isCopyOf(const QPalette &p) const | 
|---|
| 1117 | { | 
|---|
| 1118 | return d == p.d; | 
|---|
| 1119 | } | 
|---|
| 1120 |  | 
|---|
| 1121 | /*! | 
|---|
| 1122 |  | 
|---|
| 1123 | Sets a the group at \a cg. You can pass either brushes, pixmaps or | 
|---|
| 1124 | plain colors for \a windowText, \a button, \a light, \a dark, \a | 
|---|
| 1125 | mid, \a text, \a bright_text, \a base and \a window. | 
|---|
| 1126 |  | 
|---|
| 1127 | \sa QBrush | 
|---|
| 1128 | */ | 
|---|
| 1129 | void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBrush &button, | 
|---|
| 1130 | const QBrush &light, const QBrush &dark, const QBrush &mid, | 
|---|
| 1131 | const QBrush &text, const QBrush &bright_text, const QBrush &base, | 
|---|
| 1132 | const QBrush &window) | 
|---|
| 1133 | { | 
|---|
| 1134 | QBrush alt_base = QBrush(qt_mix_colors(base.color(), button.color())); | 
|---|
| 1135 | QBrush mid_light = QBrush(qt_mix_colors(button.color(), light.color())); | 
|---|
| 1136 | QColor toolTipBase(255, 255, 220); | 
|---|
| 1137 | QColor toolTipText(0, 0, 0); | 
|---|
| 1138 |  | 
|---|
| 1139 | setColorGroup(cg, windowText, button, light, dark, mid, text, bright_text, base, | 
|---|
| 1140 | alt_base, window, mid_light, text, | 
|---|
| 1141 | QBrush(Qt::black), QBrush(Qt::darkBlue), QBrush(Qt::white), | 
|---|
| 1142 | QBrush(Qt::blue), QBrush(Qt::magenta), QBrush(toolTipBase), | 
|---|
| 1143 | QBrush(toolTipText)); | 
|---|
| 1144 |  | 
|---|
| 1145 | resolve_mask &= ~(1 << Highlight); | 
|---|
| 1146 | resolve_mask &= ~(1 << HighlightedText); | 
|---|
| 1147 | resolve_mask &= ~(1 << LinkVisited); | 
|---|
| 1148 | resolve_mask &= ~(1 << Link); | 
|---|
| 1149 | } | 
|---|
| 1150 |  | 
|---|
| 1151 |  | 
|---|
| 1152 | /*!\internal*/ | 
|---|
| 1153 | void | 
|---|
| 1154 | QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button, | 
|---|
| 1155 | const QBrush &light, const QBrush &dark, const QBrush &mid, | 
|---|
| 1156 | const QBrush &text, const QBrush &bright_text, | 
|---|
| 1157 | const QBrush &base, const QBrush &alternate_base, | 
|---|
| 1158 | const QBrush &background, const QBrush &midlight, | 
|---|
| 1159 | const QBrush &button_text, const QBrush &shadow, | 
|---|
| 1160 | const QBrush &highlight, const QBrush &highlighted_text, | 
|---|
| 1161 | const QBrush &link, const QBrush &link_visited) | 
|---|
| 1162 | { | 
|---|
| 1163 | setColorGroup(cg, foreground, button, light, dark, mid, | 
|---|
| 1164 | text, bright_text, base, alternate_base, background, | 
|---|
| 1165 | midlight, button_text, shadow, highlight, highlighted_text, | 
|---|
| 1166 | link, link_visited, background, foreground); | 
|---|
| 1167 | } | 
|---|
| 1168 |  | 
|---|
| 1169 | /*!\internal*/ | 
|---|
| 1170 | void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button, | 
|---|
| 1171 | const QBrush &light, const QBrush &dark, const QBrush &mid, | 
|---|
| 1172 | const QBrush &text, const QBrush &bright_text, | 
|---|
| 1173 | const QBrush &base, const QBrush &alternate_base, | 
|---|
| 1174 | const QBrush &background, const QBrush &midlight, | 
|---|
| 1175 | const QBrush &button_text, const QBrush &shadow, | 
|---|
| 1176 | const QBrush &highlight, const QBrush &highlighted_text, | 
|---|
| 1177 | const QBrush &link, const QBrush &link_visited, | 
|---|
| 1178 | const QBrush &toolTipBase, const QBrush &toolTipText) | 
|---|
| 1179 | { | 
|---|
| 1180 | detach(); | 
|---|
| 1181 | setBrush(cg, WindowText, foreground); | 
|---|
| 1182 | setBrush(cg, Button, button); | 
|---|
| 1183 | setBrush(cg, Light, light); | 
|---|
| 1184 | setBrush(cg, Dark, dark); | 
|---|
| 1185 | setBrush(cg, Mid, mid); | 
|---|
| 1186 | setBrush(cg, Text, text); | 
|---|
| 1187 | setBrush(cg, BrightText, bright_text); | 
|---|
| 1188 | setBrush(cg, Base, base); | 
|---|
| 1189 | setBrush(cg, AlternateBase, alternate_base); | 
|---|
| 1190 | setBrush(cg, Window, background); | 
|---|
| 1191 | setBrush(cg, Midlight, midlight); | 
|---|
| 1192 | setBrush(cg, ButtonText, button_text); | 
|---|
| 1193 | setBrush(cg, Shadow, shadow); | 
|---|
| 1194 | setBrush(cg, Highlight, highlight); | 
|---|
| 1195 | setBrush(cg, HighlightedText, highlighted_text); | 
|---|
| 1196 | setBrush(cg, Link, link); | 
|---|
| 1197 | setBrush(cg, LinkVisited, link_visited); | 
|---|
| 1198 | setBrush(cg, ToolTipBase, toolTipBase); | 
|---|
| 1199 | setBrush(cg, ToolTipText, toolTipText); | 
|---|
| 1200 | } | 
|---|
| 1201 |  | 
|---|
| 1202 | /*! | 
|---|
| 1203 | \fn QPalette QPalette::copy() const | 
|---|
| 1204 |  | 
|---|
| 1205 | Use simple assignment instead. | 
|---|
| 1206 | */ | 
|---|
| 1207 |  | 
|---|
| 1208 | /*! | 
|---|
| 1209 | \fn QColorGroup QPalette::normal() const | 
|---|
| 1210 | \obsolete | 
|---|
| 1211 |  | 
|---|
| 1212 | Returns the active color group. Use active() instead. | 
|---|
| 1213 |  | 
|---|
| 1214 | Use createColorGroup(Active) instead. | 
|---|
| 1215 | */ | 
|---|
| 1216 |  | 
|---|
| 1217 | /*! | 
|---|
| 1218 | \fn void QPalette::setNormal(const QColorGroup &colorGroup) | 
|---|
| 1219 |  | 
|---|
| 1220 | Sets the normal color group to \a colorGroup. | 
|---|
| 1221 |  | 
|---|
| 1222 | \sa QColorGroup | 
|---|
| 1223 | */ | 
|---|
| 1224 |  | 
|---|
| 1225 | /*! | 
|---|
| 1226 | \fn QColorGroup QPalette::active() const | 
|---|
| 1227 |  | 
|---|
| 1228 | Returns the active color group. | 
|---|
| 1229 | \sa QColorGroup | 
|---|
| 1230 | */ | 
|---|
| 1231 |  | 
|---|
| 1232 | /*! | 
|---|
| 1233 | \fn QColorGroup QPalette::disabled() const | 
|---|
| 1234 |  | 
|---|
| 1235 | Returns the disabled color group. | 
|---|
| 1236 | \sa QColorGroup | 
|---|
| 1237 | */ | 
|---|
| 1238 |  | 
|---|
| 1239 | /*! | 
|---|
| 1240 | \fn QColorGroup QPalette::inactive() const | 
|---|
| 1241 |  | 
|---|
| 1242 | Returns the inactive color group. | 
|---|
| 1243 | \sa QColorGroup | 
|---|
| 1244 | */ | 
|---|
| 1245 |  | 
|---|
| 1246 | /*! | 
|---|
| 1247 | \fn void QPalette::setActive(const QColorGroup &colorGroup) | 
|---|
| 1248 |  | 
|---|
| 1249 | Sets the active color group to \a colorGroup. | 
|---|
| 1250 | \sa QColorGroup | 
|---|
| 1251 | */ | 
|---|
| 1252 |  | 
|---|
| 1253 | /*! | 
|---|
| 1254 | \fn void QPalette::setDisabled(const QColorGroup &colorGroup) | 
|---|
| 1255 |  | 
|---|
| 1256 | Sets the disabled color group to \a colorGroup. | 
|---|
| 1257 | \sa QColorGroup | 
|---|
| 1258 | */ | 
|---|
| 1259 |  | 
|---|
| 1260 | /*! | 
|---|
| 1261 | \fn void QPalette::setInactive(const QColorGroup &colorGroup) | 
|---|
| 1262 |  | 
|---|
| 1263 | Sets the inactive color group. | 
|---|
| 1264 | \sa QColorGroup | 
|---|
| 1265 | */ | 
|---|
| 1266 |  | 
|---|
| 1267 | /*! \class QColorGroup | 
|---|
| 1268 | \brief The QColorGroup class contains color groups for each widget state. | 
|---|
| 1269 | \compat | 
|---|
| 1270 | */ | 
|---|
| 1271 |  | 
|---|
| 1272 | /*! \fn QColorGroup::QColorGroup() | 
|---|
| 1273 |  | 
|---|
| 1274 | Use QPalette() instead. | 
|---|
| 1275 | */ | 
|---|
| 1276 |  | 
|---|
| 1277 | /*! \fn QColorGroup::QColorGroup(const QBrush &foreground, const QBrush &button, \ | 
|---|
| 1278 | const QBrush &light, const QBrush &dark, const QBrush &mid, \ | 
|---|
| 1279 | const QBrush &text, const QBrush &bright_text, | 
|---|
| 1280 | const QBrush &base, const QBrush &background) | 
|---|
| 1281 |  | 
|---|
| 1282 | Use QPalette(\a foreground, \a button, \a light, \a dark, \a mid, | 
|---|
| 1283 | \a text, \a bright_text, \a base, \a background) instead. | 
|---|
| 1284 | */ | 
|---|
| 1285 |  | 
|---|
| 1286 | /*! \fn QColorGroup::QColorGroup(const QColor &foreground, const QColor &background, \ | 
|---|
| 1287 | const QColor &light, const QColor &dark, const QColor &mid, \ | 
|---|
| 1288 | const QColor &text, const QColor &base) | 
|---|
| 1289 |  | 
|---|
| 1290 | Use QColorGroup(\a foreground, \a background, \a light, \a dark, | 
|---|
| 1291 | \a mid, \a text, \a base) instead. | 
|---|
| 1292 | */ | 
|---|
| 1293 |  | 
|---|
| 1294 | /*! \fn QColorGroup::QColorGroup(const QColorGroup &other) | 
|---|
| 1295 |  | 
|---|
| 1296 | Use QPalette(\a other) instead. | 
|---|
| 1297 | */ | 
|---|
| 1298 |  | 
|---|
| 1299 | /*! \fn QColorGroup::QColorGroup(const QPalette &pal) | 
|---|
| 1300 |  | 
|---|
| 1301 | Use QPalette(\a pal) instead. | 
|---|
| 1302 | */ | 
|---|
| 1303 |  | 
|---|
| 1304 | /*! \fn const QColor &QColorGroup::foreground() const | 
|---|
| 1305 |  | 
|---|
| 1306 | Use QPalette::windowText().color() instead. | 
|---|
| 1307 | */ | 
|---|
| 1308 |  | 
|---|
| 1309 | /*! \fn const QColor &QColorGroup::button() const | 
|---|
| 1310 |  | 
|---|
| 1311 | Use QPalette::button().color() instead. | 
|---|
| 1312 | */ | 
|---|
| 1313 |  | 
|---|
| 1314 | /*! \fn const QColor &QColorGroup::light() const | 
|---|
| 1315 |  | 
|---|
| 1316 | Use QPalette::light().color() instead. | 
|---|
| 1317 | */ | 
|---|
| 1318 |  | 
|---|
| 1319 | /*! \fn const QColor &QColorGroup::dark() const | 
|---|
| 1320 |  | 
|---|
| 1321 | Use QPalette::dark().color() instead. | 
|---|
| 1322 | */ | 
|---|
| 1323 |  | 
|---|
| 1324 | /*! \fn const QColor &QColorGroup::mid() const | 
|---|
| 1325 |  | 
|---|
| 1326 | Use QPalette::mid().color() instead. | 
|---|
| 1327 | */ | 
|---|
| 1328 |  | 
|---|
| 1329 | /*! \fn const QColor &QColorGroup::text() const | 
|---|
| 1330 |  | 
|---|
| 1331 | Use QPalette::text().color() instead. | 
|---|
| 1332 | */ | 
|---|
| 1333 |  | 
|---|
| 1334 | /*! \fn const QColor &QColorGroup::base() const | 
|---|
| 1335 |  | 
|---|
| 1336 | Use QPalette::base().color() instead. | 
|---|
| 1337 | */ | 
|---|
| 1338 |  | 
|---|
| 1339 | /*! \fn const QColor &QColorGroup::background() const | 
|---|
| 1340 |  | 
|---|
| 1341 | Use QPalette::window().color() instead. | 
|---|
| 1342 | */ | 
|---|
| 1343 |  | 
|---|
| 1344 | /*! \fn const QColor &QColorGroup::midlight() const | 
|---|
| 1345 |  | 
|---|
| 1346 | Use QPalette::midlight().color() instead. | 
|---|
| 1347 | */ | 
|---|
| 1348 |  | 
|---|
| 1349 | /*! \fn const QColor &QColorGroup::brightText() const | 
|---|
| 1350 |  | 
|---|
| 1351 | Use QPalette::brightText().color() instead. | 
|---|
| 1352 | */ | 
|---|
| 1353 |  | 
|---|
| 1354 | /*! \fn const QColor &QColorGroup::buttonText() const | 
|---|
| 1355 |  | 
|---|
| 1356 | Use QPalette::buttonText().color() instead. | 
|---|
| 1357 | */ | 
|---|
| 1358 |  | 
|---|
| 1359 | /*! \fn const QColor &QColorGroup::shadow() const | 
|---|
| 1360 |  | 
|---|
| 1361 | Use QPalette::shadow().color() instead. | 
|---|
| 1362 | */ | 
|---|
| 1363 |  | 
|---|
| 1364 | /*! \fn const QColor &QColorGroup::highlight() const | 
|---|
| 1365 |  | 
|---|
| 1366 | Use QPalette::highlight().color() instead. | 
|---|
| 1367 | */ | 
|---|
| 1368 |  | 
|---|
| 1369 | /*! \fn const QColor &QColorGroup::highlightedText() const | 
|---|
| 1370 |  | 
|---|
| 1371 | Use QPalette::highlightedText().color() instead. | 
|---|
| 1372 | */ | 
|---|
| 1373 |  | 
|---|
| 1374 | /*! \fn const QColor &QColorGroup::link() const | 
|---|
| 1375 |  | 
|---|
| 1376 | Use QPalette::link().color() instead. | 
|---|
| 1377 | */ | 
|---|
| 1378 |  | 
|---|
| 1379 | /*! \fn const QColor &QColorGroup::linkVisited() const | 
|---|
| 1380 |  | 
|---|
| 1381 | Use QPalette::linkVisited().color() instead. | 
|---|
| 1382 | */ | 
|---|
| 1383 |  | 
|---|
| 1384 | /*! \fn QDataStream &operator<<(QDataStream &ds, const QColorGroup &colorGroup) | 
|---|
| 1385 | \relates QColorGroup | 
|---|
| 1386 | \compat | 
|---|
| 1387 | */ | 
|---|
| 1388 |  | 
|---|
| 1389 | /*! \fn QDataStream &operator>>(QDataStream &ds, QColorGroup &colorGroup) | 
|---|
| 1390 | \relates QColorGroup | 
|---|
| 1391 | \compat | 
|---|
| 1392 | */ | 
|---|
| 1393 |  | 
|---|
| 1394 | /*! \fn bool QColorGroup::operator==(const QColorGroup &other) const | 
|---|
| 1395 |  | 
|---|
| 1396 | Returns true if this color group is equal to \a other; otherwise | 
|---|
| 1397 | returns false. | 
|---|
| 1398 | */ | 
|---|
| 1399 |  | 
|---|
| 1400 | /*! \fn bool QColorGroup::operator!=(const QColorGroup &other) const | 
|---|
| 1401 |  | 
|---|
| 1402 | Returns true if this color group is not equal to \a other; | 
|---|
| 1403 | otherwise returns false. | 
|---|
| 1404 | */ | 
|---|
| 1405 |  | 
|---|
| 1406 | QT_END_NAMESPACE | 
|---|