| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qpalette.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Definition of QColorGroup and QPalette classes
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 950323
|
|---|
| 7 | **
|
|---|
| 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|---|
| 9 | **
|
|---|
| 10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
|---|
| 11 | **
|
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License
|
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file.
|
|---|
| 15 | **
|
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the
|
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 19 | ** packaging of this file.
|
|---|
| 20 | **
|
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
|
|---|
| 23 | ** Agreement provided with the Software.
|
|---|
| 24 | **
|
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 27 | **
|
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|---|
| 29 | ** information about Qt Commercial License Agreements.
|
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|---|
| 32 | **
|
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
|---|
| 34 | ** not clear to you.
|
|---|
| 35 | **
|
|---|
| 36 | **********************************************************************/
|
|---|
| 37 |
|
|---|
| 38 | #ifndef QPALETTE_H
|
|---|
| 39 | #define QPALETTE_H
|
|---|
| 40 |
|
|---|
| 41 | #ifndef QT_H
|
|---|
| 42 | #include "qwindowdefs.h"
|
|---|
| 43 | #include "qcolor.h"
|
|---|
| 44 | #include "qshared.h"
|
|---|
| 45 | #include "qbrush.h" // QColor->QBrush conversion
|
|---|
| 46 | #endif // QT_H
|
|---|
| 47 |
|
|---|
| 48 | #ifndef QT_NO_PALETTE
|
|---|
| 49 |
|
|---|
| 50 | class QColorGroupPrivate;
|
|---|
| 51 |
|
|---|
| 52 | class Q_EXPORT QColorGroup
|
|---|
| 53 | {
|
|---|
| 54 | public:
|
|---|
| 55 | QColorGroup();
|
|---|
| 56 | QColorGroup( const QColor &foreground, const QColor &button,
|
|---|
| 57 | const QColor &light, const QColor &dark, const QColor &mid,
|
|---|
| 58 | const QColor &text, const QColor &base );
|
|---|
| 59 | QColorGroup( const QBrush &foreground, const QBrush &button,
|
|---|
| 60 | const QBrush &light, const QBrush &dark, const QBrush &mid,
|
|---|
| 61 | const QBrush &text, const QBrush &bright_text,
|
|---|
| 62 | const QBrush &base, const QBrush &background);
|
|---|
| 63 | QColorGroup( const QColorGroup & );
|
|---|
| 64 |
|
|---|
| 65 | ~QColorGroup();
|
|---|
| 66 |
|
|---|
| 67 | QColorGroup& operator =(const QColorGroup&);
|
|---|
| 68 |
|
|---|
| 69 | // Do not change the order, the serialization format depends on it
|
|---|
| 70 | enum ColorRole { Foreground, Button, Light, Midlight, Dark, Mid,
|
|---|
| 71 | Text, BrightText, ButtonText, Base, Background, Shadow,
|
|---|
| 72 | Highlight, HighlightedText, Link, LinkVisited,
|
|---|
| 73 | NColorRoles };
|
|---|
| 74 |
|
|---|
| 75 | const QColor &color( ColorRole ) const;
|
|---|
| 76 | const QBrush &brush( ColorRole ) const;
|
|---|
| 77 | void setColor( ColorRole, const QColor & );
|
|---|
| 78 | void setBrush( ColorRole, const QBrush & );
|
|---|
| 79 |
|
|---|
| 80 | const QColor &foreground() const { return br[Foreground].color(); }
|
|---|
| 81 | const QColor &button() const { return br[Button].color(); }
|
|---|
| 82 | const QColor &light() const { return br[Light].color(); }
|
|---|
| 83 | const QColor &dark() const { return br[Dark].color(); }
|
|---|
| 84 | const QColor &mid() const { return br[Mid].color(); }
|
|---|
| 85 | const QColor &text() const { return br[Text].color(); }
|
|---|
| 86 | const QColor &base() const { return br[Base].color(); }
|
|---|
| 87 | const QColor &background() const { return br[Background].color(); }
|
|---|
| 88 |
|
|---|
| 89 | const QColor &midlight() const { return br[Midlight].color(); }
|
|---|
| 90 | const QColor &brightText() const { return br[BrightText].color(); }
|
|---|
| 91 | const QColor &buttonText() const { return br[ButtonText].color(); }
|
|---|
| 92 | const QColor &shadow() const { return br[Shadow].color(); }
|
|---|
| 93 | const QColor &highlight() const { return br[Highlight].color(); }
|
|---|
| 94 | const QColor &highlightedText() const{return br[HighlightedText].color(); }
|
|---|
| 95 | const QColor &link() const { return br[Link].color(); }
|
|---|
| 96 | const QColor &linkVisited() const { return br[LinkVisited].color(); }
|
|---|
| 97 |
|
|---|
| 98 | bool operator==( const QColorGroup &g ) const;
|
|---|
| 99 | bool operator!=( const QColorGroup &g ) const
|
|---|
| 100 | { return !(operator==(g)); }
|
|---|
| 101 |
|
|---|
| 102 | private:
|
|---|
| 103 | QBrush *br;
|
|---|
| 104 | QColorGroupPrivate * d;
|
|---|
| 105 |
|
|---|
| 106 | friend class QPalette;
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 | class Q_EXPORT QPalette
|
|---|
| 111 | {
|
|---|
| 112 | public:
|
|---|
| 113 | QPalette();
|
|---|
| 114 | QPalette( const QColor &button );
|
|---|
| 115 | QPalette( const QColor &button, const QColor &background );
|
|---|
| 116 | QPalette( const QColorGroup &active, const QColorGroup &disabled,
|
|---|
| 117 | const QColorGroup &inactive );
|
|---|
| 118 | QPalette( const QPalette & );
|
|---|
| 119 | ~QPalette();
|
|---|
| 120 | QPalette &operator=( const QPalette & );
|
|---|
| 121 |
|
|---|
| 122 | enum ColorGroup { Disabled, Active, Inactive, NColorGroups, Normal=Active };
|
|---|
| 123 |
|
|---|
| 124 | const QColor &color( ColorGroup, QColorGroup::ColorRole ) const;
|
|---|
| 125 | const QBrush &brush( ColorGroup, QColorGroup::ColorRole ) const;
|
|---|
| 126 | void setColor( ColorGroup, QColorGroup::ColorRole, const QColor & );
|
|---|
| 127 | void setBrush( ColorGroup, QColorGroup::ColorRole, const QBrush & );
|
|---|
| 128 |
|
|---|
| 129 | void setColor( QColorGroup::ColorRole, const QColor & );
|
|---|
| 130 | void setBrush( QColorGroup::ColorRole, const QBrush & );
|
|---|
| 131 |
|
|---|
| 132 | QPalette copy() const;
|
|---|
| 133 |
|
|---|
| 134 | const QColorGroup &active() const { return data->active; }
|
|---|
| 135 | const QColorGroup &disabled() const { return data->disabled; }
|
|---|
| 136 | const QColorGroup &inactive() const { return data->inactive; }
|
|---|
| 137 | #ifndef QT_NO_COMPAT
|
|---|
| 138 | const QColorGroup &normal() const { return active(); }
|
|---|
| 139 | #endif
|
|---|
| 140 |
|
|---|
| 141 | void setActive( const QColorGroup & );
|
|---|
| 142 | void setDisabled( const QColorGroup & );
|
|---|
| 143 | void setInactive( const QColorGroup & );
|
|---|
| 144 | #ifndef QT_NO_COMPAT
|
|---|
| 145 | void setNormal( const QColorGroup & cg ) { setActive(cg); }
|
|---|
| 146 | #endif
|
|---|
| 147 |
|
|---|
| 148 | bool operator==( const QPalette &p ) const;
|
|---|
| 149 | bool operator!=( const QPalette &p ) const
|
|---|
| 150 | { return !(operator==(p)); }
|
|---|
| 151 | bool isCopyOf( const QPalette & );
|
|---|
| 152 |
|
|---|
| 153 | int serialNumber() const { return data->ser_no; }
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 | static QColorGroup::ColorRole foregroundRoleFromMode( Qt::BackgroundMode mode );
|
|---|
| 157 | static QColorGroup::ColorRole backgroundRoleFromMode( Qt::BackgroundMode mode);
|
|---|
| 158 |
|
|---|
| 159 | private:
|
|---|
| 160 | void detach();
|
|---|
| 161 | const QBrush &directBrush( ColorGroup, QColorGroup::ColorRole ) const;
|
|---|
| 162 | void directSetBrush( ColorGroup, QColorGroup::ColorRole, const QBrush& );
|
|---|
| 163 |
|
|---|
| 164 | struct QPalData : public QShared {
|
|---|
| 165 | QColorGroup disabled;
|
|---|
| 166 | QColorGroup active;
|
|---|
| 167 | int ser_no;
|
|---|
| 168 | QColorGroup inactive;
|
|---|
| 169 | } *data;
|
|---|
| 170 | };
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 | /*****************************************************************************
|
|---|
| 174 | QColorGroup/QPalette stream functions
|
|---|
| 175 | *****************************************************************************/
|
|---|
| 176 |
|
|---|
| 177 | #ifndef QT_NO_DATASTREAM
|
|---|
| 178 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QColorGroup & );
|
|---|
| 179 | Q_EXPORT QDataStream &operator>>( QDataStream &, QColorGroup & );
|
|---|
| 180 |
|
|---|
| 181 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QPalette & );
|
|---|
| 182 | Q_EXPORT QDataStream &operator>>( QDataStream &, QPalette & );
|
|---|
| 183 | #endif // QT_NO_DATASTREAM
|
|---|
| 184 |
|
|---|
| 185 | #endif // QT_NO_PALETTE
|
|---|
| 186 | #endif // QPALETTE_H
|
|---|