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
qquickmacstyle_mac_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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
10#include "qquickstylehelper_p.h"
11
12#include <QtCore/qdebug.h>
13#include <QtCore/qhash.h>
14#include <QtCore/qmap.h>
15#include <QtCore/qmath.h>
16#include <QtCore/qpair.h>
17#include <QtCore/qpointer.h>
18#include <QtCore/qtextstream.h>
19#include <QtCore/qvector.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 <QtQuick/qquickitem.h>
28
29#include <QtCore/private/qcore_mac_p.h>
30#include <QtGui/private/qpainter_p.h>
31
32//
33// W A R N I N G
34// -------------
35//
36// This file is not part of the Qt API. It exists purely as an
37// implementation detail. This header file may change from version to
38// version without notice, or even be removed.
39//
40// We mean it.
41//
42
44
47
49
50namespace QQC2 {
51
52/*
53 AHIG:
54 macOS Human Interface Guidelines
55 https://developer.apple.com/macos/human-interface-guidelines/overview/themes/
56
57 Builder:
58 Interface Builder in Xcode 8 or later
59*/
60
61// this works as long as we have at most 16 different control types
62#define CT1(c) CT2(c, c)
63#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))
64
65#define SIZE(large, small, mini) \
66 (controlSize == QStyleHelper::SizeLarge ? (large) : controlSize == QStyleHelper::SizeSmall ? (small) : (mini))
67
68// same as return SIZE(...) but optimized
69#define return_SIZE(large, small, mini) \
70 do { \
71 static const int sizes[] = { (large), (small), (mini) }; \
72 return sizes[controlSize]; \
73 } while (false)
74
76{
77 Q_DECLARE_PUBLIC(QMacStyle)
78
79public:
83
85 NoControl, // For when there's no such a control in Cocoa
86 Box, // QGroupBox
87 Box_Dark, // FIXME See render code in drawPrimitive(PE_FrameTabWidget)
89 Button_Disclosure, // Disclosure triangle, like in QTreeView
90 Button_PopupButton, // Non-editable QComboBox
91 Button_PullDown, // QPushButton with menu
92 Button_PushButton, // Plain QPushButton and QTabBar buttons
94 Button_SquareButton, // Oversized QPushButton
98 ComboBox, // Editable QComboBox
103 SegmentedControl_First, // QTabBar buttons focus ring
111 Stepper, // QSpinBox buttons
113 };
114
130
131 typedef void (^DrawRectBlock)(CGContextRef, const CGRect &);
132
135
136 // Ideally these wouldn't exist, but since they already exist we need some accessors.
137 static const int PushButtonLeftOffset;
138 static const int PushButtonRightOffset;
139 static const int PushButtonContentPadding;
140
144 QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
147 QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
148 inline int animateSpeed(Animates) const { return 33; }
149
150 // Utility functions
151 static CGRect comboboxInnerBounds(const CGRect &outterBounds, const CocoaControl &cocoaWidget);
152
153 static QRectF comboboxEditBounds(const QRectF &outterBounds, const CocoaControl &cw);
154
156
159
160 void setupNSGraphicsContext(CGContextRef cg, bool flipped) const;
162
163 void setupVerticalInvertedXform(CGContextRef cg, bool reverse, bool vertical, const CGRect &rect) const;
164
165 void drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, DrawRectBlock drawRectBlock = nil) const;
167
169
171
173
174 void tabLayout(const QStyleOptionTab *opt, QRect *textRect, QRect *iconRect) const override;
177
178public:
179 mutable QPointer<QObject> autoDefaultButton;
180 static QVector<QPointer<QObject> > scrollBars;
181
182 mutable QPointer<QQuickItem> focusWidget; // TODO: rename to focusItem
183 mutable NSView *backingStoreNSView;
184 mutable QHash<CocoaControl, NSView *> cocoaControls;
185 mutable QHash<CocoaControl, NSCell *> cocoaCells;
186
189
191};
192
193} // namespace QQC2
194
196
197#endif // QMACSTYLE_MAC_P_P_H
\reentrant
Definition qfont.h:22
\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
void setupNSGraphicsContext(CGContextRef cg, bool flipped) const
static Direction tabDirection(QStyleOptionTab::Shape shape)
static const int PushButtonContentPadding
static CGRect comboboxInnerBounds(const CGRect &outterBounds, const CocoaControl &cocoaWidget)
static bool verticalTabs(QMacStylePrivate::Direction tabDirection)
QMacKeyValueObserver appearanceObserver
static const int PushButtonLeftOffset
QPointer< QQuickItem > focusWidget
void restoreNSGraphicsContext(CGContextRef cg) const
QStyleHelper::WidgetSizePolicy effectiveAquaSizeConstrain(const QStyleOption *option, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
QHash< CocoaControl, NSCell * > cocoaCells
void setAutoDefaultButton(QObject *button) const
QPointer< QObject > autoDefaultButton
static const int PushButtonRightOffset
NSView * cocoaControl(CocoaControl cocoaControl) const
QHash< CocoaControl, NSView * > cocoaControls
QPainterPath windowPanelPath(const QRectF &r) const
void(^ DrawRectBlock)(CGContextRef, const CGRect &)
NSCell * cocoaCell(CocoaControl cocoaControl) const
void resolveCurrentNSView(QWindow *window) const
CocoaControlType windowButtonCocoaControl(QStyle::SubControl sc) const
QStyleHelper::WidgetSizePolicy aquaSizeConstrain(const QStyleOption *option, QStyle::ContentsType ct=QStyle::CT_CustomBase, QSize szHint=QSize(-1, -1), QSize *insz=0) const
static QRectF comboboxEditBounds(const QRectF &outterBounds, const CocoaControl &cw)
void drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, DrawRectBlock drawRectBlock=nil) const
void drawToolbarButtonArrow(const QStyleOption *opt, QPainter *p) const
void tabLayout(const QStyleOptionTab *opt, QRect *textRect, QRect *iconRect) const override
void setupVerticalInvertedXform(CGContextRef cg, bool reverse, bool vertical, const CGRect &rect) const
int animateSpeed(Animates) const
static QVector< QPointer< QObject > > scrollBars
\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
\inmodule QtGui
Definition qwindow.h:63
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[]
QSharedPointer< T > other(t)
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QQuickView * view
[0]
bool operator==(const CocoaControl &other) const
QRectF adjustedControlFrame(const QRectF &rect) const
CocoaControl(CocoaControlType t, QStyleHelper::WidgetSizePolicy s)
bool getCocoaButtonTypeAndBezelStyle(NSButtonType *buttonType, NSBezelStyle *bezelStyle) const