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
qmacstyle_p.h
Go to the documentation of this file.
1
// Copyright (C) 2025 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
QMACSTYLE_P_H
5
#
define
QMACSTYLE_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
<
QtGui
/
qtguiglobal
.
h
>
19
20
#
if
defined
(
QT_WIDGETS_LIB
)
&&
defined
(
QT_QUICK_LIB
)
21
#
error
"Cannot use QtGui Mac style with both Widgets and Quick"
22
#
endif
23
24
#
if
defined
(
QT_WIDGETS_LIB
)
25
#
define
OPTIONAL_WIDGET_ARGUMENT
,
const
QWidget
*
w
=
nullptr
26
#
define
FORWARD_OPTIONAL_WIDGET_ARGUMENT
,
w
27
#
else
28
#
define
OPTIONAL_WIDGET_ARGUMENT
29
#
define
FORWARD_OPTIONAL_WIDGET_ARGUMENT
30
#
endif
31
32
#
include
<
AppKit
/
NSApplication
.
h
>
33
34
QT_BEGIN_NAMESPACE
35
36
/*
37
Helper class to ensure that the Mac style in Widgets and Quick
38
draw their NSViews and NSCells with the correct appearance,
39
as the native controls use NSAppearance.currentDrawingAppearance
40
instead of NSApp.effectiveAppearance when drawing.
41
42
Due to the duplicated class hierarchies between Widgets and Quick
43
for the styles, with the Quick styles missing the QWidget pointer
44
in the function parameters, we have to opt for an awkward macro
45
to solve this.
46
*/
47
template
<
typename
Style>
48
class
QMacApperanceStyle :
public
Style
49
{
50
public
:
51
void
drawPrimitive(
typename
Style::PrimitiveElement pe,
const
QStyleOption *opt, QPainter *p
52
OPTIONAL_WIDGET_ARGUMENT
)
const
override
53
{
54
[NSApp.effectiveAppearance performAsCurrentDrawingAppearance:^{
55
Style::drawPrimitive(pe, opt, p
56
FORWARD_OPTIONAL_WIDGET_ARGUMENT
);
57
}];
58
}
59
60
void
drawControl(
typename
Style::ControlElement element,
const
QStyleOption *opt, QPainter *p
61
OPTIONAL_WIDGET_ARGUMENT
)
const
override
62
{
63
[NSApp.effectiveAppearance performAsCurrentDrawingAppearance:^{
64
Style::drawControl(element, opt, p
65
FORWARD_OPTIONAL_WIDGET_ARGUMENT
);
66
}];
67
}
68
69
void
drawComplexControl(
typename
Style::ComplexControl cc,
const
QStyleOptionComplex *opt, QPainter *p
70
OPTIONAL_WIDGET_ARGUMENT
)
const
override
71
{
72
[NSApp.effectiveAppearance performAsCurrentDrawingAppearance:^{
73
Style::drawComplexControl(cc, opt, p
74
FORWARD_OPTIONAL_WIDGET_ARGUMENT
);
75
}];
76
}
77
};
78
79
QT_END_NAMESPACE
80
81
#
endif
// QMACSTYLE_P_H
OPTIONAL_WIDGET_ARGUMENT
#define OPTIONAL_WIDGET_ARGUMENT
Definition
qmacstyle_p.h:28
FORWARD_OPTIONAL_WIDGET_ARGUMENT
#define FORWARD_OPTIONAL_WIDGET_ARGUMENT
Definition
qmacstyle_p.h:29
qtbase
src
gui
platform
macos
qmacstyle_p.h
Generated on
for Qt by
1.14.0