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
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/qpointer.h>
16#include <QtCore/qtextstream.h>
17
18#include <QtGui/private/qpainter_p.h>
19
20#include <QtGui/qbitmap.h>
21#include <QtGui/qevent.h>
22#include <QtGui/qpaintdevice.h>
23#include <QtGui/qpainter.h>
24#include <QtGui/qpixmapcache.h>
25
26#include <QtWidgets/private/qapplication_p.h>
27#include <QtWidgets/private/qcommonstyle_p.h>
28#include <QtWidgets/private/qstylehelper_p.h>
29
30#include <QtWidgets/qapplication.h>
31#include <QtWidgets/qfocusframe.h>
32#include <QtWidgets/qformlayout.h>
33#include <QtWidgets/qlayout.h>
34#include <QtWidgets/qstyleoption.h>
35#include <QtWidgets/qtextedit.h>
36
37#if QT_CONFIG(checkbox)
38#include <QtWidgets/qcheckbox.h>
39#endif
40#if QT_CONFIG(combobox)
41#include <QtWidgets/private/qcombobox_p.h>
42#include <QtWidgets/qcombobox.h>
43#endif
44#if QT_CONFIG(datetimeedit)
45#include <QtWidgets/qdatetimeedit.h>
46#endif
47#if QT_CONFIG(dialogbuttonbox)
48#include <QtWidgets/qdialogbuttonbox.h>
49#endif
50#if QT_CONFIG(dockwidget)
51#include <QtWidgets/qdockwidget.h>
52#endif
53#if QT_CONFIG(graphicsview)
54#include <QtWidgets/qgraphicsproxywidget.h>
55#include <QtWidgets/qgraphicsview.h>
56#endif
57#if QT_CONFIG(groupbox)
58#include <QtWidgets/qgroupbox.h>
59#endif
60#if QT_CONFIG(itemviews)
61#include <QtWidgets/qheaderview.h>
62#endif
63#if QT_CONFIG(lineedit)
64#include <QtWidgets/qlineedit.h>
65#endif
66#if QT_CONFIG(listview)
67#include <QtWidgets/qlistview.h>
68#endif
69#if QT_CONFIG(mainwindow)
70#include <QtWidgets/qmainwindow.h>
71#endif
72#if QT_CONFIG(menubar)
73#include <QtWidgets/qmenubar.h>
74#endif
75#if QT_CONFIG(progressbar)
76#include <QtWidgets/qprogressbar.h>
77#endif
78#if QT_CONFIG(pushbutton)
79#include <QtWidgets/qpushbutton.h>
80#endif
81#include <QtWidgets/qradiobutton.h>
82#if QT_CONFIG(rubberband)
83#include <QtWidgets/qrubberband.h>
84#endif
85#if QT_CONFIG(sizegrip)
86#include <QtWidgets/qsizegrip.h>
87#endif
88#if QT_CONFIG(spinbox)
89#include <QtWidgets/qspinbox.h>
90#endif
91#if QT_CONFIG(splitter)
92#include <QtWidgets/qsplitter.h>
93#endif
94#if QT_CONFIG(tableview)
95#include <QtWidgets/qtableview.h>
96#endif
97#if QT_CONFIG(toolbar)
98#include <QtWidgets/qtoolbar.h>
99#endif
100#if QT_CONFIG(toolbutton)
101#include <QtWidgets/qtoolbutton.h>
102#endif
103#if QT_CONFIG(treeview)
104#include <QtWidgets/qtreeview.h>
105#endif
106
107//
108// W A R N I N G
109// -------------
110//
111// This file is not part of the Qt API. It exists purely as an
112// implementation detail. This header file may change from version to
113// version without notice, or even be removed.
114//
115// We mean it.
116//
117
119
122
124
125/*
126 AHIG:
127 macOS Human Interface Guidelines
128 https://developer.apple.com/macos/human-interface-guidelines/overview/themes/
129
130 Builder:
131 Interface Builder in Xcode 8 or later
132*/
133
134// this works as long as we have at most 16 different control types
135#define CT1(c) CT2(c, c)
136#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))
137
138#define SIZE(large, small, mini) \
139 (controlSize == QStyleHelper::SizeLarge ? (large) : controlSize == QStyleHelper::SizeSmall ? (small) : (mini))
140
141// same as return SIZE(...) but optimized
142#define return_SIZE(large, small, mini) \
143 do { \
144 static const int sizes[] = { (large), (small), (mini) }; \
145 return sizes[controlSize]; \
146 } while (false)
147
149{
150 Q_DECLARE_PUBLIC(QMacStyle)
151public:
155
157 NoControl, // For when there's no such a control in Cocoa
158 Box, // QGroupBox
159 Box_Dark, // FIXME See render code in drawPrimitive(PE_FrameTabWidget)
161 Button_Disclosure, // Disclosure triangle, like in QTreeView
162 Button_PopupButton, // Non-editable QComboBox
163 Button_PullDown, // QPushButton with menu
164 Button_PushButton, // Plain QPushButton and QTabBar buttons
166 Button_SquareButton, // Oversized QPushButton
170 ComboBox, // Editable QComboBox
175 SegmentedControl_First, // QTabBar buttons focus ring
183 Stepper, // QSpinBox buttons
185 };
186
188 CocoaControl();
190
193
194 bool operator==(const CocoaControl &other) const;
195
196 QSizeF defaultFrameSize() const;
198 QMarginsF titleMargins() const;
199
200 bool getCocoaButtonTypeAndBezelStyle(NSButtonType *buttonType, NSBezelStyle *bezelStyle) const;
201 };
202
203
204 typedef void (^DrawRectBlock)(CGContextRef, const CGRect &);
205
208
209 // Ideally these wouldn't exist, but since they already exist we need some accessors.
210 static const int PushButtonLeftOffset;
211 static const int PushButtonRightOffset;
212 static const int PushButtonContentPadding;
213
217 QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
220 QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
221 inline int animateSpeed(Animates) const { return 33; }
222
223 // Utility functions
224 static CGRect comboboxInnerBounds(const CGRect &outterBounds, const CocoaControl &cocoaWidget);
225
226 static QRectF comboboxEditBounds(const QRectF &outterBounds, const CocoaControl &cw);
227
229
230 NSView *cocoaControl(CocoaControl widget) const;
231 NSCell *cocoaCell(CocoaControl widget) const;
232
233 void setupNSGraphicsContext(CGContextRef cg, bool flipped) const;
235
236 void setupVerticalInvertedXform(CGContextRef cg, bool reverse, bool vertical, const CGRect &rect) const;
237
238 void drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, __attribute__((noescape)) DrawRectBlock drawRectBlock = nil) const;
240
241 void drawFocusRing(QPainter *p, const QRectF &targetRect, int hMargin, int vMargin, const CocoaControl &cw) const;
242
243 void drawToolbarButtonArrow(const QStyleOption *opt, QPainter *p) const;
244
245 QPainterPath windowPanelPath(const QRectF &r) const;
246
248
249#if QT_CONFIG(tabbar)
250 void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const override;
251 static Direction tabDirection(QTabBar::Shape shape);
252 static bool verticalTabs(QMacStylePrivate::Direction tabDirection);
253#endif
254
255public:
256 mutable QPointer<QObject> autoDefaultButton;
257 static QList<QPointer<QObject> > scrollBars;
258
259 mutable QPointer<QFocusFrame> focusWidget;
260 mutable NSView *backingStoreNSView;
261 mutable QHash<CocoaControl, NSView *> cocoaControls;
262 mutable QHash<CocoaControl, NSCell *> cocoaCells;
263
264 std::optional<QFont> smallSystemFont;
265
267};
268
270
271#endif // QMACSTYLE_MAC_P_P_H
struct capHdr __attribute__
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:270
\inmodule QtCore
Definition qobject.h:103
\inmodule QtGui
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:208
\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:546
@ CT_CustomBase
Definition qstyle.h:571
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 s
[6]
Definition qopenglext.h:235
GLdouble GLdouble t
Definition qopenglext.h:243
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