Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowsthemedata.cpp
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// Qt-Security score:significant reason:default
4
7
8/* \internal
9 Returns \c true if the QWindowsThemeData is valid for use.
10*/
11bool QWindowsThemeData::isValid()
12{
13 return QWindowsVistaStylePrivate::useVista() && theme >= 0 && handle();
14}
15
16/* \internal
17 Returns the theme engine handle to the specific class.
18 If the handle hasn't been opened before, it opens the data, and
19 adds it to a static map, for caching.
20*/
21HTHEME QWindowsThemeData::handle()
22{
24 return nullptr;
25
26 if (!htheme)
27 htheme = QWindowsVistaStylePrivate::createTheme(theme, widget);
28 return htheme;
29}
30
31/* \internal
32 Converts a QRect to the native RECT structure.
33*/
34RECT QWindowsThemeData::toRECT(const QRect &qr)
35{
36 RECT r;
37 r.left = qr.x();
38 r.right = qr.x() + qr.width();
39 r.top = qr.y();
40 r.bottom = qr.y() + qr.height();
41 return r;
42}
43
44/* \internal
45 Returns the native region of a part, if the part is considered
46 transparent. The region is scaled to the parts size (rect).
47*/
48HRGN QWindowsThemeData::mask(QWidget *widget)
49{
50 if (!IsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
51 return nullptr;
52
53 HRGN hrgn;
54 HDC dc = nullptr;
55 if (widget)
56 dc = QWindowsVistaStylePrivate::hdcForWidgetBackingStore(widget);
57 RECT nativeRect = toRECT(rect);
58 GetThemeBackgroundRegion(handle(), dc, partId, stateId, &nativeRect, &hrgn);
59 return hrgn;
60}
friend class QWidget
Definition qpainter.h:431
static bool useVista(bool update=false)