Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpalette_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPALETTE_P_H
5#define QPALETTE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qpalette.h"
19
21
22class Q_GUI_EXPORT QPalettePrivate
23{
24public:
25 class Data : public QSharedData {
26 public:
27 // Every instance of Data has to have a unique serial number, even
28 // if it gets created by copying another - we wouldn't create a copy
29 // in the first place if the serial number should be the same!
30 Data(const Data &other)
32 {
33 for (int grp = 0; grp < int(QPalette::NColorGroups); grp++) {
34 for (int role = 0; role < int(QPalette::NColorRoles); role++)
35 br[grp][role] = other.br[grp][role];
36 }
37 }
38 Data() = default;
39
41 const int ser_no = qt_palette_count++;
42 };
43
44 QPalettePrivate(const QExplicitlySharedDataPointer<Data> &data)
45 : ref(1), data(data)
46 { }
50
52 {
53 // Exclude NoRole; that bit is used for Accent
54 return (qToUnderlying(QPalette::NColorRoles) - 1) * qToUnderlying(colorGroup);
55 }
56
58 QPalette::ColorRole colorRole)
59 {
60 // Map Accent into NoRole for resolving purposes
61 if (colorRole == QPalette::Accent)
62 colorRole = QPalette::NoRole;
63
64 return colorRole + colorRoleOffset(colorGroup);
65 }
66
68 QPalette::ResolveMask resolveMask = {0};
69 static inline int qt_palette_count = 0;
70 static inline int qt_palette_private_count = 0;
71 int detach_no = ++qt_palette_private_count;
72 QExplicitlySharedDataPointer<Data> data;
73};
74
76
77#endif // QPALETTE_P_H
\inmodule QtCore
Definition qatomic.h:112
\inmodule QtGui
Definition qbrush.h:30
Data(const Data &other)
Definition qpalette_p.h:30
static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup, QPalette::ColorRole colorRole)
Definition qpalette_p.h:57
QPalettePrivate(const QExplicitlySharedDataPointer< Data > &data)
Definition qpalette_p.h:44
QExplicitlySharedDataPointer< Data > data
Definition qpalette_p.h:72
static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup)
Definition qpalette_p.h:51
QAtomicInt ref
Definition qpalette_p.h:67
quint64 ResolveMask
Definition qpalette.h:113
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
Definition qpalette.h:49
@ NColorGroups
Definition qpalette.h:49
@ NColorRoles
Definition qpalette.h:60
\inmodule QtCore
Definition qshareddata.h:19
Combined button and popup list for selecting options.
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint ref
QT_BEGIN_NAMESPACE constexpr std::underlying_type_t< Enum > qToUnderlying(Enum e) noexcept
QSharedPointer< T > other(t)
[5]