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
qwindowsthemedata_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QWINDOWSTHEMEDATA_P_H
5#define QWINDOWSTHEMEDATA_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 <qwidget.h>
19#include <qt_windows.h>
20#include <uxtheme.h>
21#include <vssym32.h>
22#include <limits.h>
23
24
25// TMT_TEXTSHADOWCOLOR is wrongly defined in mingw
26#if TMT_TEXTSHADOWCOLOR != 3818
27#undef TMT_TEXTSHADOWCOLOR
28#define TMT_TEXTSHADOWCOLOR 3818
29#endif
30#ifndef TST_NONE
31# define TST_NONE 0
32#endif
33
34// These defines are missing from the tmschema, but still exist as
35// states for their parts
36#ifndef MINBS_INACTIVE
37#define MINBS_INACTIVE 5
38#endif
39#ifndef MAXBS_INACTIVE
40#define MAXBS_INACTIVE 5
41#endif
42#ifndef RBS_INACTIVE
43#define RBS_INACTIVE 5
44#endif
45#ifndef HBS_INACTIVE
46#define HBS_INACTIVE 5
47#endif
48#ifndef CBS_INACTIVE
49#define CBS_INACTIVE 5
50#endif
51
52// Declarations -----------------------------------------------------------------------------------
54{
55public:
56 explicit QWindowsThemeData(const QWidget *w = nullptr, QPainter *p = nullptr, int themeIn = -1,
57 int part = 0, int state = 0, const QRect &r = QRect())
58 : widget(w), painter(p), theme(themeIn), partId(part), stateId(state),
61 {}
62
63 HRGN mask(QWidget *widget);
64 HTHEME handle();
65 bool isValid();
66 QSizeF size();
67
68 static QSizeF themeSize(const QWidget *w = nullptr, QPainter *p = nullptr,
69 int themeIn = -1, int part = 0, int state = 0);
70 static RECT toRECT(const QRect &qr);
71
72 QMarginsF margins(const QRect &rect, int propId = TMT_CONTENTMARGINS);
74
77
78 int theme;
79 HTHEME htheme = nullptr;
80 int partId;
82
90};
91
93 int theme = 0;
94 int partId = -1;
95 int stateId = -1;
96 bool noBorder = false;
97 bool noContent = false;
98
99 ThemeMapKey() = default;
103
104};
105
106inline size_t qHash(const ThemeMapKey &key)
107{ return key.theme ^ key.partId ^ key.stateId; }
108
109inline bool operator==(const ThemeMapKey &k1, const ThemeMapKey &k2)
110{
111 return k1.theme == k2.theme
112 && k1.partId == k2.partId
113 && k1.stateId == k2.stateId;
114}
115
117 UnknownAlpha = -1, // Alpha of part & state not yet known
118 NoAlpha, // Totally opaque, no need to touch alpha (RGB)
119 MaskAlpha, // Alpha channel must be fixed (ARGB)
120 RealAlpha // Proper alpha values from Windows (ARGB_Premultiplied)
122
124 AlphaChannelType alphaType = UnknownAlpha; // Which type of alpha on part & state
125
126 bool dataValid : 1; // Only used to detect if hash value is ok
128 bool hasAlphaChannel : 1; // True = part & state has real Alpha
129 bool wasAlphaSwapped : 1; // True = alpha channel needs to be swapped
130 bool hadInvalidAlpha : 1; // True = alpha channel contained invalid alpha values
131
134};
135
136
137#ifndef QT_NO_DEBUG_STREAM
141#endif
142
144{
145 QSizeF result(0, 0);
146 if (isValid()) {
147 SIZE size;
148 if (SUCCEEDED(GetThemePartSize(handle(), nullptr, partId, stateId, nullptr, TS_TRUE, &size)))
149 result = QSize(size.cx, size.cy);
150 }
151 return result;
152}
153
154inline QSizeF QWindowsThemeData::themeSize(const QWidget *w, QPainter *p, int themeIn, int part, int state)
155{
156 QWindowsThemeData theme(w, p, themeIn, part, state);
157 return theme.size();
158}
159
160inline QMarginsF QWindowsThemeData::margins(const QRect &qRect, int propId)
161{
162 QMarginsF result(0, 0, 0 ,0);
163 if (isValid()) {
164 MARGINS margins;
165 RECT rect = QWindowsThemeData::toRECT(qRect);
166 if (SUCCEEDED(GetThemeMargins(handle(), nullptr, partId, stateId, propId, &rect, &margins)))
167 result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
168 }
169 return result;
170}
171
173{
174 QMarginsF result(0, 0, 0 ,0);
175 if (isValid()) {
176 MARGINS margins;
177 if (SUCCEEDED(GetThemeMargins(handle(), nullptr, partId, stateId, propId, nullptr, &margins)))
178 result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
179 }
180 return result;
181}
182
183#endif // QWINDOWSTHEMEDATA_P_H
\inmodule QtCore
\inmodule QtCore
Definition qmargins.h:270
\inmodule QtCore
Definition qmargins.h:24
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QWindowsThemeData(const QWidget *w=nullptr, QPainter *p=nullptr, int themeIn=-1, int part=0, int state=0, const QRect &r=QRect())
QMarginsF margins(const QRect &rect, int propId=TMT_CONTENTMARGINS)
const QWidget * widget
static RECT toRECT(const QRect &qr)
static QSizeF themeSize(const QWidget *w=nullptr, QPainter *p=nullptr, int themeIn=-1, int part=0, int state=0)
else opt state
[0]
#define SIZE(large, small, mini)
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
#define k1
unsigned int uint
Definition qtypes.h:34
QDebug operator<<(QDebug d, const QWindowsThemeData &t)
bool operator==(const ThemeMapKey &k1, const ThemeMapKey &k2)
@ UnknownAlpha
size_t qHash(const ThemeMapKey &key)
#define TMT_CONTENTMARGINS
AlphaChannelType alphaType
ThemeMapKey(const QWindowsThemeData &data)
ThemeMapKey()=default