Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qmacstyle_mac_p_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
5#ifndef QMACSTYLE_MAC_P_P_H
6#define QMACSTYLE_MAC_P_P_H
7
8#include "qmacstyle_mac_p.h"
9
10#include <QtCore/qdebug.h>
11#include <QtCore/qhash.h>
12#include <QtCore/qlist.h>
13#include <QtCore/qmap.h>
14#include <QtCore/qmath.h>
15#include <QtCore/qpair.h>
16#include <QtCore/qpointer.h>
17#include <QtCore/qtextstream.h>
18
19#include <QtGui/private/qpainter_p.h>
20
21#include <QtGui/qbitmap.h>
22#include <QtGui/qevent.h>
23#include <QtGui/qpaintdevice.h>
24#include <QtGui/qpainter.h>
25#include <QtGui/qpixmapcache.h>
26
27#include <QtWidgets/private/qapplication_p.h>
28#include <QtWidgets/private/qcommonstyle_p.h>
29#include <QtWidgets/private/qstylehelper_p.h>
30
31#include <QtWidgets/qapplication.h>
32#include <QtWidgets/qfocusframe.h>
33#include <QtWidgets/qformlayout.h>
34#include <QtWidgets/qlayout.h>
35#include <QtWidgets/qstyleoption.h>
36#include <QtWidgets/qtextedit.h>
37
38#if QT_CONFIG(checkbox)
39#include <QtWidgets/qcheckbox.h>
40#endif
41#if QT_CONFIG(combobox)
42#include <QtWidgets/private/qcombobox_p.h>
43#include <QtWidgets/qcombobox.h>
44#endif
45#if QT_CONFIG(datetimeedit)
46#include <QtWidgets/qdatetimeedit.h>
47#endif
48#if QT_CONFIG(dialogbuttonbox)
49#include <QtWidgets/qdialogbuttonbox.h>
50#endif
51#if QT_CONFIG(dockwidget)
52#include <QtWidgets/qdockwidget.h>
53#endif
54#if QT_CONFIG(graphicsview)
55#include <QtWidgets/qgraphicsproxywidget.h>
56#include <QtWidgets/qgraphicsview.h>
57#endif
58#if QT_CONFIG(groupbox)
59#include <QtWidgets/qgroupbox.h>
60#endif
61#if QT_CONFIG(itemviews)
62#include <QtWidgets/qheaderview.h>
63#endif
64#if QT_CONFIG(lineedit)
65#include <QtWidgets/qlineedit.h>
66#endif
67#if QT_CONFIG(listview)
68#include <QtWidgets/qlistview.h>
69#endif
70#if QT_CONFIG(mainwindow)
71#include <QtWidgets/qmainwindow.h>
72#endif
73#if QT_CONFIG(menubar)
74#include <QtWidgets/qmenubar.h>
75#endif
76#if QT_CONFIG(progressbar)
77#include <QtWidgets/qprogressbar.h>
78#endif
79#if QT_CONFIG(pushbutton)
80#include <QtWidgets/qpushbutton.h>
81#endif
82#include <QtWidgets/qradiobutton.h>
83#if QT_CONFIG(rubberband)
84#include <QtWidgets/qrubberband.h>
85#endif
86#if QT_CONFIG(sizegrip)
87#include <QtWidgets/qsizegrip.h>
88#endif
89#if QT_CONFIG(spinbox)
90#include <QtWidgets/qspinbox.h>
91#endif
92#if QT_CONFIG(splitter)
93#include <QtWidgets/qsplitter.h>
94#endif
95#if QT_CONFIG(tableview)
96#include <QtWidgets/qtableview.h>
97#endif
98#if QT_CONFIG(toolbar)
99#include <QtWidgets/qtoolbar.h>
100#endif
101#if QT_CONFIG(toolbutton)
102#include <QtWidgets/qtoolbutton.h>
103#endif
104#if QT_CONFIG(treeview)
105#include <QtWidgets/qtreeview.h>
106#endif
107
108//
109// W A R N I N G
110// -------------
111//
112// This file is not part of the Qt API. It exists purely as an
113// implementation detail. This header file may change from version to
114// version without notice, or even be removed.
115//
116// We mean it.
117//
118
120
123
125
126/*
127 AHIG:
128 macOS Human Interface Guidelines
129 https://developer.apple.com/macos/human-interface-guidelines/overview/themes/
130
131 Builder:
132 Interface Builder in Xcode 8 or later
133*/
134
135// this works as long as we have at most 16 different control types
136#define CT1(c) CT2(c, c)
137#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))
138
139#define SIZE(large, small, mini) \
140 (controlSize == QStyleHelper::SizeLarge ? (large) : controlSize == QStyleHelper::SizeSmall ? (small) : (mini))
141
142// same as return SIZE(...) but optimized
143#define return_SIZE(large, small, mini) \
144 do { \
145 static const int sizes[] = { (large), (small), (mini) }; \
146 return sizes[controlSize]; \
147 } while (false)
148
150{
151 Q_DECLARE_PUBLIC(QMacStyle)
152public:
155 };
156
158 NoControl, // For when there's no such a control in Cocoa
159 Box, // QGroupBox
160 Box_Dark, // FIXME See render code in drawPrimitive(PE_FrameTabWidget)
162 Button_Disclosure, // Disclosure triangle, like in QTreeView
163 Button_PopupButton, // Non-editable QComboBox
164 Button_PullDown, // QPushButton with menu
165 Button_PushButton, // Plain QPushButton and QTabBar buttons
167 Button_SquareButton, // Oversized QPushButton
171 ComboBox, // Editable QComboBox
176 SegmentedControl_First, // QTabBar buttons focus ring
184 Stepper, // QSpinBox buttons
186 };
187
189 CocoaControl();
191
194
195 bool operator==(const CocoaControl &other) const;
196
197 QSizeF defaultFrameSize() const;
199 QMarginsF titleMargins() const;
200
201 bool getCocoaButtonTypeAndBezelStyle(NSButtonType *buttonType, NSBezelStyle *bezelStyle) const;
202 };
203
204
205 typedef void (^DrawRectBlock)(CGContextRef, const CGRect &);
206
209
210 // Ideally these wouldn't exist, but since they already exist we need some accessors.
211 static const int PushButtonLeftOffset;
212 static const int PushButtonRightOffset;
213 static const int PushButtonContentPadding;
214
218 QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
221 QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
222 inline int animateSpeed(Animates) const { return 33; }
223
224 // Utility functions
225 static CGRect comboboxInnerBounds(const CGRect &outterBounds, const CocoaControl &cocoaWidget);
226
227 static QRectF comboboxEditBounds(const QRectF &outterBounds, const CocoaControl &cw);
228
230
231 NSView *cocoaControl(CocoaControl widget) const;
232 NSCell *cocoaCell(CocoaControl widget) const;
233
234 void setupNSGraphicsContext(CGContextRef cg, bool flipped) const;
236
237 void setupVerticalInvertedXform(CGContextRef cg, bool reverse, bool vertical, const CGRect &rect) const;
238
239 void drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, __attribute__((noescape)) DrawRectBlock drawRectBlock = nil) const;
241
242 void drawFocusRing(QPainter *p, const QRectF &targetRect, int hMargin, int vMargin, const CocoaControl &cw) const;
243
244 void drawToolbarButtonArrow(const QStyleOption *opt, QPainter *p) const;
245
246 QPainterPath windowPanelPath(const QRectF &r) const;
247
249
250#if QT_CONFIG(tabbar)
251 void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const override;
252 static Direction tabDirection(QTabBar::Shape shape);
253 static bool verticalTabs(QMacStylePrivate::Direction tabDirection);
254#endif
255
256public:
259
261 mutable NSView *backingStoreNSView;
264
265 std::optional<QFont> smallSystemFont;
266
268};
269
271
272#endif // QMACSTYLE_MAC_P_P_H
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
void drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, __attribute__((noescape)) DrawRectBlock drawRectBlock=nil) const
static const int PushButtonRightOffset
QHash< CocoaControl, NSCell * > cocoaCells
void drawFocusRing(QPainter *p, const QRectF &targetRect, int hMargin, int vMargin, const CocoaControl &cw) const
CocoaControlType windowButtonCocoaControl(QStyle::SubControl sc) const
std::optional< QFont > smallSystemFont
void resolveCurrentNSView(QWindow *window) const
NSView * cocoaControl(CocoaControl widget) const
QHash< CocoaControl, NSView * > cocoaControls
void drawToolbarButtonArrow(const QStyleOption *opt, QPainter *p) const
QMacKeyValueObserver appearanceObserver
NSCell * cocoaCell(CocoaControl widget) const
void(^ DrawRectBlock)(CGContextRef, const CGRect &)
void setAutoDefaultButton(QObject *button) const
static CGRect comboboxInnerBounds(const CGRect &outterBounds, const CocoaControl &cocoaWidget)
static QList< QPointer< QObject > > scrollBars
int animateSpeed(Animates) const
void setupNSGraphicsContext(CGContextRef cg, bool flipped) const
QPainterPath windowPanelPath(const QRectF &r) const
QPointer< QFocusFrame > focusWidget
static const int PushButtonLeftOffset
QPointer< QObject > autoDefaultButton
static const int PushButtonContentPadding
static QRectF comboboxEditBounds(const QRectF &outterBounds, const CocoaControl &cw)
QStyleHelper::WidgetSizePolicy effectiveAquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
void restoreNSGraphicsContext(CGContextRef cg) const
QStyleHelper::WidgetSizePolicy aquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
void setupVerticalInvertedXform(CGContextRef cg, bool reverse, bool vertical, const CGRect &rect) const
\inmodule QtCore
Definition qmargins.h:274
\inmodule QtCore
Definition qobject.h:90
\inmodule QtGui
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:207
\inmodule QtCore
Definition qsize.h:25
The QStyleOption class stores the parameters used by QStyle functions.
ContentsType
This enum describes the available contents types.
Definition qstyle.h:544
@ CT_CustomBase
Definition qstyle.h:569
SubControl
This enum describes the available sub controls.
Definition qstyle.h:347
Shape
This enum type lists the built-in shapes supported by QTabBar.
Definition qtabbar.h:42
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
\inmodule QtGui
Definition qwindow.h:63
QOpenGLWidget * widget
[1]
QPushButton * button
[2]
rect
[4]
QStyleOptionButton opt
QRect textRect
Combined button and popup list for selecting options.
#define Q_FORWARD_DECLARE_OBJC_CLASS(classname)
#define Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(type)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
GLboolean r
[2]
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
GLuint GLenum option
struct CGContext * CGContextRef
static const struct TessellationWindingOrderTab cw[]
constexpr bool verticalTabs(QTabBar::Shape shape) noexcept
Definition qtabbar_p.h:248
static const int hMargin
static const int vMargin
QSharedPointer< T > other(t)
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QQuickView * view
[0]
QRectF adjustedControlFrame(const QRectF &rect) const
bool operator==(const CocoaControl &other) const
bool getCocoaButtonTypeAndBezelStyle(NSButtonType *buttonType, NSBezelStyle *bezelStyle) const
QStyleHelper::WidgetSizePolicy size