Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:27:36

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QPALETTE_H
0005 #define QPALETTE_H
0006 
0007 #include <QtGui/qtguiglobal.h>
0008 #include <QtGui/qwindowdefs.h>
0009 #include <QtGui/qcolor.h>
0010 #include <QtGui/qbrush.h>
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 
0015 class QPalettePrivate;
0016 class QVariant;
0017 
0018 class Q_GUI_EXPORT QPalette
0019 {
0020     Q_GADGET
0021 public:
0022     QPalette();
0023     QPalette(const QColor &button);
0024     QPalette(Qt::GlobalColor button);
0025     QPalette(const QColor &button, const QColor &window);
0026     QPalette(const QBrush &windowText, const QBrush &button, const QBrush &light,
0027              const QBrush &dark, const QBrush &mid, const QBrush &text,
0028              const QBrush &bright_text, const QBrush &base, const QBrush &window);
0029     QPalette(const QColor &windowText, const QColor &window, const QColor &light,
0030              const QColor &dark, const QColor &mid, const QColor &text, const QColor &base);
0031     QPalette(const QPalette &palette);
0032     ~QPalette();
0033     QPalette &operator=(const QPalette &palette);
0034     QPalette(QPalette &&other) noexcept
0035         : d(std::exchange(other.d, nullptr)), currentGroup(other.currentGroup)
0036     {}
0037     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPalette)
0038 
0039     void swap(QPalette &other) noexcept
0040     {
0041         std::swap(currentGroup, other.currentGroup);
0042         qt_ptr_swap(d, other.d);
0043     }
0044 
0045     operator QVariant() const;
0046 
0047     // Do not change the order, the serialization format depends on it
0048     // Ensure these values are kept in sync with QQuickColorGroup's properties
0049     // and QCss::KnownValue!
0050     enum ColorGroup { Active, Disabled, Inactive, NColorGroups, Current, All, Normal = Active };
0051     Q_ENUM(ColorGroup)
0052     enum ColorRole { WindowText, Button, Light, Midlight, Dark, Mid,
0053                      Text, BrightText, ButtonText, Base, Window, Shadow,
0054                      Highlight, HighlightedText,
0055                      Link, LinkVisited,
0056                      AlternateBase,
0057                      NoRole,
0058                      ToolTipBase, ToolTipText,
0059                      PlaceholderText,
0060                      Accent,
0061                      NColorRoles = Accent + 1,
0062                    };
0063     Q_ENUM(ColorRole)
0064 
0065     inline ColorGroup currentColorGroup() const { return currentGroup; }
0066     inline void setCurrentColorGroup(ColorGroup cg) { currentGroup = cg; }
0067 
0068     inline const QColor &color(ColorGroup cg, ColorRole cr) const
0069     { return brush(cg, cr).color(); }
0070     const QBrush &brush(ColorGroup cg, ColorRole cr) const;
0071     inline void setColor(ColorGroup cg, ColorRole cr, const QColor &color);
0072     inline void setColor(ColorRole cr, const QColor &color);
0073     inline void setBrush(ColorRole cr, const QBrush &brush);
0074     bool isBrushSet(ColorGroup cg, ColorRole cr) const;
0075     void setBrush(ColorGroup cg, ColorRole cr, const QBrush &brush);
0076     void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
0077                        const QBrush &light, const QBrush &dark, const QBrush &mid,
0078                        const QBrush &text, const QBrush &bright_text, const QBrush &base,
0079                        const QBrush &window);
0080     bool isEqual(ColorGroup cr1, ColorGroup cr2) const;
0081 
0082     inline const QColor &color(ColorRole cr) const { return color(Current, cr); }
0083     inline const QBrush &brush(ColorRole cr) const { return brush(Current, cr); }
0084     inline const QBrush &windowText() const { return brush(WindowText); }
0085     inline const QBrush &button() const { return brush(Button); }
0086     inline const QBrush &light() const { return brush(Light); }
0087     inline const QBrush &dark() const { return brush(Dark); }
0088     inline const QBrush &mid() const { return brush(Mid); }
0089     inline const QBrush &text() const { return brush(Text); }
0090     inline const QBrush &base() const { return brush(Base); }
0091     inline const QBrush &alternateBase() const { return brush(AlternateBase); }
0092     inline const QBrush &toolTipBase() const { return brush(ToolTipBase); }
0093     inline const QBrush &toolTipText() const { return brush(ToolTipText); }
0094     inline const QBrush &window() const { return brush(Window); }
0095     inline const QBrush &midlight() const { return brush(Midlight); }
0096     inline const QBrush &brightText() const { return brush(BrightText); }
0097     inline const QBrush &buttonText() const { return brush(ButtonText); }
0098     inline const QBrush &shadow() const { return brush(Shadow); }
0099     inline const QBrush &highlight() const { return brush(Highlight); }
0100     inline const QBrush &highlightedText() const { return brush(HighlightedText); }
0101     inline const QBrush &link() const { return brush(Link); }
0102     inline const QBrush &linkVisited() const { return brush(LinkVisited); }
0103     inline const QBrush &placeholderText() const { return brush(PlaceholderText); }
0104     inline const QBrush &accent() const { return brush(Accent); }
0105 
0106     bool operator==(const QPalette &p) const;
0107     inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
0108     bool isCopyOf(const QPalette &p) const;
0109 
0110     qint64 cacheKey() const;
0111 
0112     QPalette resolve(const QPalette &other) const;
0113 
0114     using ResolveMask = quint64;
0115     ResolveMask resolveMask() const;
0116     void setResolveMask(ResolveMask mask);
0117 
0118 private:
0119     void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
0120                        const QBrush &light, const QBrush &dark, const QBrush &mid,
0121                        const QBrush &text, const QBrush &bright_text,
0122                        const QBrush &base, const QBrush &alternate_base,
0123                        const QBrush &window, const QBrush &midlight,
0124                        const QBrush &button_text, const QBrush &shadow,
0125                        const QBrush &highlight, const QBrush &highlighted_text,
0126                        const QBrush &link, const QBrush &link_visited);
0127     void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
0128                        const QBrush &light, const QBrush &dark, const QBrush &mid,
0129                        const QBrush &text, const QBrush &bright_text,
0130                        const QBrush &base, const QBrush &alternate_base,
0131                        const QBrush &window, const QBrush &midlight,
0132                        const QBrush &button_text, const QBrush &shadow,
0133                        const QBrush &highlight, const QBrush &highlighted_text,
0134                        const QBrush &link, const QBrush &link_visited,
0135                        const QBrush &toolTipBase, const QBrush &toolTipText);
0136     void init();
0137     void detach();
0138 
0139     QPalettePrivate *d;
0140     ColorGroup currentGroup{Active};
0141 
0142     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
0143 };
0144 
0145 Q_DECLARE_SHARED(QPalette)
0146 
0147 inline void QPalette::setColor(ColorGroup acg, ColorRole acr,
0148                                const QColor &acolor)
0149 { setBrush(acg, acr, QBrush(acolor)); }
0150 inline void QPalette::setColor(ColorRole acr, const QColor &acolor)
0151 { setColor(All, acr, acolor); }
0152 inline void QPalette::setBrush(ColorRole acr, const QBrush &abrush)
0153 { setBrush(All, acr, abrush); }
0154 
0155 /*****************************************************************************
0156   QPalette stream functions
0157  *****************************************************************************/
0158 #ifndef QT_NO_DATASTREAM
0159 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const QPalette &p);
0160 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &ds, QPalette &p);
0161 #endif // QT_NO_DATASTREAM
0162 
0163 #ifndef QT_NO_DEBUG_STREAM
0164 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPalette &);
0165 #endif
0166 
0167 QT_END_NAMESPACE
0168 
0169 #endif // QPALETTE_H