Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtGui/qpalette.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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     enum ColorGroup { Active, Disabled, Inactive, NColorGroups, Current, All, Normal = Active };
0050     Q_ENUM(ColorGroup)
0051     enum ColorRole { WindowText, Button, Light, Midlight, Dark, Mid,
0052                      Text, BrightText, ButtonText, Base, Window, Shadow,
0053                      Highlight, HighlightedText,
0054                      Link, LinkVisited,
0055                      AlternateBase,
0056                      NoRole,
0057                      ToolTipBase, ToolTipText,
0058                      PlaceholderText,
0059                      Accent,
0060                      NColorRoles = Accent + 1,
0061                    };
0062     Q_ENUM(ColorRole)
0063 
0064     inline ColorGroup currentColorGroup() const { return currentGroup; }
0065     inline void setCurrentColorGroup(ColorGroup cg) { currentGroup = cg; }
0066 
0067     inline const QColor &color(ColorGroup cg, ColorRole cr) const
0068     { return brush(cg, cr).color(); }
0069     const QBrush &brush(ColorGroup cg, ColorRole cr) const;
0070     inline void setColor(ColorGroup cg, ColorRole cr, const QColor &color);
0071     inline void setColor(ColorRole cr, const QColor &color);
0072     inline void setBrush(ColorRole cr, const QBrush &brush);
0073     bool isBrushSet(ColorGroup cg, ColorRole cr) const;
0074     void setBrush(ColorGroup cg, ColorRole cr, const QBrush &brush);
0075     void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
0076                        const QBrush &light, const QBrush &dark, const QBrush &mid,
0077                        const QBrush &text, const QBrush &bright_text, const QBrush &base,
0078                        const QBrush &window);
0079     bool isEqual(ColorGroup cr1, ColorGroup cr2) const;
0080 
0081     inline const QColor &color(ColorRole cr) const { return color(Current, cr); }
0082     inline const QBrush &brush(ColorRole cr) const { return brush(Current, cr); }
0083     inline const QBrush &windowText() const { return brush(WindowText); }
0084     inline const QBrush &button() const { return brush(Button); }
0085     inline const QBrush &light() const { return brush(Light); }
0086     inline const QBrush &dark() const { return brush(Dark); }
0087     inline const QBrush &mid() const { return brush(Mid); }
0088     inline const QBrush &text() const { return brush(Text); }
0089     inline const QBrush &base() const { return brush(Base); }
0090     inline const QBrush &alternateBase() const { return brush(AlternateBase); }
0091     inline const QBrush &toolTipBase() const { return brush(ToolTipBase); }
0092     inline const QBrush &toolTipText() const { return brush(ToolTipText); }
0093     inline const QBrush &window() const { return brush(Window); }
0094     inline const QBrush &midlight() const { return brush(Midlight); }
0095     inline const QBrush &brightText() const { return brush(BrightText); }
0096     inline const QBrush &buttonText() const { return brush(ButtonText); }
0097     inline const QBrush &shadow() const { return brush(Shadow); }
0098     inline const QBrush &highlight() const { return brush(Highlight); }
0099     inline const QBrush &highlightedText() const { return brush(HighlightedText); }
0100     inline const QBrush &link() const { return brush(Link); }
0101     inline const QBrush &linkVisited() const { return brush(LinkVisited); }
0102     inline const QBrush &placeholderText() const { return brush(PlaceholderText); }
0103     inline const QBrush &accent() const { return brush(Accent); }
0104 
0105     bool operator==(const QPalette &p) const;
0106     inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
0107     bool isCopyOf(const QPalette &p) const;
0108 
0109     qint64 cacheKey() const;
0110 
0111     QPalette resolve(const QPalette &other) const;
0112 
0113     using ResolveMask = quint64;
0114     ResolveMask resolveMask() const;
0115     void setResolveMask(ResolveMask mask);
0116 
0117 private:
0118     void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
0119                        const QBrush &light, const QBrush &dark, const QBrush &mid,
0120                        const QBrush &text, const QBrush &bright_text,
0121                        const QBrush &base, const QBrush &alternate_base,
0122                        const QBrush &window, const QBrush &midlight,
0123                        const QBrush &button_text, const QBrush &shadow,
0124                        const QBrush &highlight, const QBrush &highlighted_text,
0125                        const QBrush &link, const QBrush &link_visited);
0126     void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
0127                        const QBrush &light, const QBrush &dark, const QBrush &mid,
0128                        const QBrush &text, const QBrush &bright_text,
0129                        const QBrush &base, const QBrush &alternate_base,
0130                        const QBrush &window, const QBrush &midlight,
0131                        const QBrush &button_text, const QBrush &shadow,
0132                        const QBrush &highlight, const QBrush &highlighted_text,
0133                        const QBrush &link, const QBrush &link_visited,
0134                        const QBrush &toolTipBase, const QBrush &toolTipText);
0135     void init();
0136     void detach();
0137 
0138     QPalettePrivate *d;
0139     ColorGroup currentGroup{Active};
0140 
0141     friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
0142 };
0143 
0144 Q_DECLARE_SHARED(QPalette)
0145 
0146 inline void QPalette::setColor(ColorGroup acg, ColorRole acr,
0147                                const QColor &acolor)
0148 { setBrush(acg, acr, QBrush(acolor)); }
0149 inline void QPalette::setColor(ColorRole acr, const QColor &acolor)
0150 { setColor(All, acr, acolor); }
0151 inline void QPalette::setBrush(ColorRole acr, const QBrush &abrush)
0152 { setBrush(All, acr, abrush); }
0153 
0154 /*****************************************************************************
0155   QPalette stream functions
0156  *****************************************************************************/
0157 #ifndef QT_NO_DATASTREAM
0158 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const QPalette &p);
0159 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &ds, QPalette &p);
0160 #endif // QT_NO_DATASTREAM
0161 
0162 #ifndef QT_NO_DEBUG_STREAM
0163 Q_GUI_EXPORT QDebug operator<<(QDebug, const QPalette &);
0164 #endif
0165 
0166 QT_END_NAMESPACE
0167 
0168 #endif // QPALETTE_H