| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QT_MAC_P_H
|
|---|
| 43 | #define QT_MAC_P_H
|
|---|
| 44 |
|
|---|
| 45 | //
|
|---|
| 46 | // W A R N I N G
|
|---|
| 47 | // -------------
|
|---|
| 48 | //
|
|---|
| 49 | // This file is not part of the Qt API. It exists purely as an
|
|---|
| 50 | // implementation detail. This header file may change from version to
|
|---|
| 51 | // version without notice, or even be removed.
|
|---|
| 52 | //
|
|---|
| 53 | // We mean it.
|
|---|
| 54 | //
|
|---|
| 55 |
|
|---|
| 56 | #include "qmacdefines_mac.h"
|
|---|
| 57 |
|
|---|
| 58 | #ifdef __OBJC__
|
|---|
| 59 | #include <Cocoa/Cocoa.h>
|
|---|
| 60 | #ifdef QT_MAC_USE_COCOA
|
|---|
| 61 | #include <objc/runtime.h>
|
|---|
| 62 | #endif // QT_MAC_USE_COCOA
|
|---|
| 63 | #endif
|
|---|
| 64 |
|
|---|
| 65 | #include <CoreServices/CoreServices.h>
|
|---|
| 66 |
|
|---|
| 67 | #include "QtCore/qglobal.h"
|
|---|
| 68 | #include "QtCore/qvariant.h"
|
|---|
| 69 | #include "QtCore/qmimedata.h"
|
|---|
| 70 | #include "QtCore/qpointer.h"
|
|---|
| 71 | #include "private/qcore_mac_p.h"
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | #include "QtGui/qpainter.h"
|
|---|
| 75 |
|
|---|
| 76 | #include <Carbon/Carbon.h>
|
|---|
| 77 |
|
|---|
| 78 | QT_BEGIN_NAMESPACE
|
|---|
| 79 | class QWidget;
|
|---|
| 80 | class QDragMoveEvent;
|
|---|
| 81 |
|
|---|
| 82 | /* Event masks */
|
|---|
| 83 | // internal Qt types
|
|---|
| 84 |
|
|---|
| 85 | // Event class for our own Carbon events.
|
|---|
| 86 | #if defined(QT_NAMESPACE) && defined(QT_NAMESPACE_MAC_CRC)
|
|---|
| 87 | // Take the CRC we generated at configure time. This *may* result in a
|
|---|
| 88 | // collision with another value If that is the case, please change the value
|
|---|
| 89 | // here to something other than 'Cute'.
|
|---|
| 90 | const UInt32 kEventClassQt = QT_NAMESPACE_MAC_CRC;
|
|---|
| 91 | #else
|
|---|
| 92 | const UInt32 kEventClassQt = 'Cute';
|
|---|
| 93 | #endif
|
|---|
| 94 |
|
|---|
| 95 | enum {
|
|---|
| 96 | //AE types
|
|---|
| 97 | typeAEClipboardChanged = 1,
|
|---|
| 98 | //types
|
|---|
| 99 | typeQWidget = 1, /* QWidget * */
|
|---|
| 100 | //params
|
|---|
| 101 | kEventParamQWidget = 'qwid', /* typeQWidget */
|
|---|
| 102 | //events
|
|---|
| 103 | kEventQtRequestContext = 13,
|
|---|
| 104 | kEventQtRequestMenubarUpdate = 14,
|
|---|
| 105 | kEventQtRequestShowSheet = 17,
|
|---|
| 106 | kEventQtRequestActivate = 18,
|
|---|
| 107 | kEventQtRequestWindowChange = 20
|
|---|
| 108 | };
|
|---|
| 109 |
|
|---|
| 110 | // Simple class to manage short-lived regions
|
|---|
| 111 | class QMacSmartQuickDrawRegion
|
|---|
| 112 | {
|
|---|
| 113 | RgnHandle qdRgn;
|
|---|
| 114 | Q_DISABLE_COPY(QMacSmartQuickDrawRegion)
|
|---|
| 115 | public:
|
|---|
| 116 | explicit QMacSmartQuickDrawRegion(RgnHandle rgn) : qdRgn(rgn) {}
|
|---|
| 117 | ~QMacSmartQuickDrawRegion() {
|
|---|
| 118 | extern void qt_mac_dispose_rgn(RgnHandle); // qregion_mac.cpp
|
|---|
| 119 | qt_mac_dispose_rgn(qdRgn);
|
|---|
| 120 | }
|
|---|
| 121 | operator RgnHandle() {
|
|---|
| 122 | return qdRgn;
|
|---|
| 123 | }
|
|---|
| 124 | };
|
|---|
| 125 |
|
|---|
| 126 | // Class for chaining to gether a bunch of fades. It pretty much is only used for qmenu fading.
|
|---|
| 127 | class QMacWindowFader
|
|---|
| 128 | {
|
|---|
| 129 | QWidgetList m_windowsToFade;
|
|---|
| 130 | float m_duration;
|
|---|
| 131 | Q_DISABLE_COPY(QMacWindowFader)
|
|---|
| 132 | public:
|
|---|
| 133 | QMacWindowFader(); // PLEASE DON'T CALL THIS.
|
|---|
| 134 | static QMacWindowFader *currentFader();
|
|---|
| 135 | void registerWindowToFade(QWidget *window);
|
|---|
| 136 | void setFadeDuration(float durationInSecs) { m_duration = durationInSecs; }
|
|---|
| 137 | float fadeDuration() const { return m_duration; }
|
|---|
| 138 | void performFade();
|
|---|
| 139 | };
|
|---|
| 140 |
|
|---|
| 141 | class Q_GUI_EXPORT QMacCocoaAutoReleasePool
|
|---|
| 142 | {
|
|---|
| 143 | private:
|
|---|
| 144 | void *pool;
|
|---|
| 145 | public:
|
|---|
| 146 | QMacCocoaAutoReleasePool();
|
|---|
| 147 | ~QMacCocoaAutoReleasePool();
|
|---|
| 148 |
|
|---|
| 149 | inline void *handle() const { return pool; }
|
|---|
| 150 | };
|
|---|
| 151 |
|
|---|
| 152 | QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp
|
|---|
| 153 |
|
|---|
| 154 | class Q_GUI_EXPORT QMacWindowChangeEvent
|
|---|
| 155 | {
|
|---|
| 156 | private:
|
|---|
| 157 | static QList<QMacWindowChangeEvent*> *change_events;
|
|---|
| 158 | public:
|
|---|
| 159 | QMacWindowChangeEvent() {
|
|---|
| 160 | }
|
|---|
| 161 | virtual ~QMacWindowChangeEvent() {
|
|---|
| 162 | }
|
|---|
| 163 | static inline void exec(bool ) {
|
|---|
| 164 | }
|
|---|
| 165 | protected:
|
|---|
| 166 | virtual void windowChanged() = 0;
|
|---|
| 167 | virtual void flushWindowChanged() = 0;
|
|---|
| 168 | };
|
|---|
| 169 |
|
|---|
| 170 | class QMacCGContext
|
|---|
| 171 | {
|
|---|
| 172 | CGContextRef context;
|
|---|
| 173 | public:
|
|---|
| 174 | QMacCGContext(QPainter *p); //qpaintengine_mac.cpp
|
|---|
| 175 | inline QMacCGContext() { context = 0; }
|
|---|
| 176 | inline QMacCGContext(const QPaintDevice *pdev) {
|
|---|
| 177 | extern CGContextRef qt_mac_cg_context(const QPaintDevice *);
|
|---|
| 178 | context = qt_mac_cg_context(pdev);
|
|---|
| 179 | }
|
|---|
| 180 | inline QMacCGContext(CGContextRef cg, bool takeOwnership=false) {
|
|---|
| 181 | context = cg;
|
|---|
| 182 | if(!takeOwnership)
|
|---|
| 183 | CGContextRetain(context);
|
|---|
| 184 | }
|
|---|
| 185 | inline QMacCGContext(const QMacCGContext ©) : context(0) { *this = copy; }
|
|---|
| 186 | inline ~QMacCGContext() {
|
|---|
| 187 | if(context)
|
|---|
| 188 | CGContextRelease(context);
|
|---|
| 189 | }
|
|---|
| 190 | inline bool isNull() const { return context; }
|
|---|
| 191 | inline operator CGContextRef() { return context; }
|
|---|
| 192 | inline QMacCGContext &operator=(const QMacCGContext ©) {
|
|---|
| 193 | if(context)
|
|---|
| 194 | CGContextRelease(context);
|
|---|
| 195 | context = copy.context;
|
|---|
| 196 | CGContextRetain(context);
|
|---|
| 197 | return *this;
|
|---|
| 198 | }
|
|---|
| 199 | inline QMacCGContext &operator=(CGContextRef cg) {
|
|---|
| 200 | if(context)
|
|---|
| 201 | CGContextRelease(context);
|
|---|
| 202 | context = cg;
|
|---|
| 203 | CGContextRetain(context); //we do not take ownership
|
|---|
| 204 | return *this;
|
|---|
| 205 | }
|
|---|
| 206 | };
|
|---|
| 207 |
|
|---|
| 208 | class QMacPasteboardMime;
|
|---|
| 209 | class QMimeData;
|
|---|
| 210 |
|
|---|
| 211 | class QMacPasteboard
|
|---|
| 212 | {
|
|---|
| 213 | struct Promise {
|
|---|
| 214 | Promise() : itemId(0), convertor(0) { }
|
|---|
| 215 | Promise(int itemId, QMacPasteboardMime *c, QString m, QVariant d, int o=0) : itemId(itemId), offset(o), convertor(c), mime(m), data(d) { }
|
|---|
| 216 | int itemId, offset;
|
|---|
| 217 | QMacPasteboardMime *convertor;
|
|---|
| 218 | QString mime;
|
|---|
| 219 | QVariant data;
|
|---|
| 220 | };
|
|---|
| 221 | QList<Promise> promises;
|
|---|
| 222 |
|
|---|
| 223 | OSPasteboardRef paste;
|
|---|
| 224 | uchar mime_type;
|
|---|
| 225 | mutable QPointer<QMimeData> mime;
|
|---|
| 226 | mutable bool mac_mime_source;
|
|---|
| 227 | static OSStatus promiseKeeper(OSPasteboardRef, PasteboardItemID, CFStringRef, void *);
|
|---|
| 228 | void clear_helper();
|
|---|
| 229 | public:
|
|---|
| 230 | QMacPasteboard(OSPasteboardRef p, uchar mime_type=0);
|
|---|
| 231 | QMacPasteboard(uchar mime_type);
|
|---|
| 232 | QMacPasteboard(CFStringRef name=0, uchar mime_type=0);
|
|---|
| 233 | ~QMacPasteboard();
|
|---|
| 234 |
|
|---|
| 235 | bool hasFlavor(QString flavor) const;
|
|---|
| 236 | bool hasOSType(int c_flavor) const;
|
|---|
| 237 |
|
|---|
| 238 | OSPasteboardRef pasteBoard() const;
|
|---|
| 239 | QMimeData *mimeData() const;
|
|---|
| 240 | void setMimeData(QMimeData *mime);
|
|---|
| 241 |
|
|---|
| 242 | QStringList formats() const;
|
|---|
| 243 | bool hasFormat(const QString &format) const;
|
|---|
| 244 | QVariant retrieveData(const QString &format, QVariant::Type) const;
|
|---|
| 245 |
|
|---|
| 246 | void clear();
|
|---|
| 247 | bool sync() const;
|
|---|
| 248 | };
|
|---|
| 249 |
|
|---|
| 250 | extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp
|
|---|
| 251 |
|
|---|
| 252 | extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm
|
|---|
| 253 | extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm
|
|---|
| 254 | extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm
|
|---|
| 255 |
|
|---|
| 256 | #ifdef check
|
|---|
| 257 | # undef check
|
|---|
| 258 | #endif
|
|---|
| 259 |
|
|---|
| 260 | QFont qfontForThemeFont(ThemeFontID themeID);
|
|---|
| 261 |
|
|---|
| 262 | QColor qcolorForTheme(ThemeBrush brush);
|
|---|
| 263 |
|
|---|
| 264 | QColor qcolorForThemeTextColor(ThemeTextColor themeColor);
|
|---|
| 265 |
|
|---|
| 266 | struct QMacDndAnswerRecord {
|
|---|
| 267 | QRect rect;
|
|---|
| 268 | Qt::KeyboardModifiers modifiers;
|
|---|
| 269 | Qt::MouseButtons buttons;
|
|---|
| 270 | Qt::DropAction lastAction;
|
|---|
| 271 | unsigned int lastOperation;
|
|---|
| 272 | void clear() {
|
|---|
| 273 | rect = QRect();
|
|---|
| 274 | modifiers = Qt::NoModifier;
|
|---|
| 275 | buttons = Qt::NoButton;
|
|---|
| 276 | lastAction = Qt::IgnoreAction;
|
|---|
| 277 | lastOperation = 0;
|
|---|
| 278 | }
|
|---|
| 279 | };
|
|---|
| 280 | extern QMacDndAnswerRecord qt_mac_dnd_answer_rec;
|
|---|
| 281 | void qt_mac_copy_answer_rect(const QDragMoveEvent &event);
|
|---|
| 282 | bool qt_mac_mouse_inside_answer_rect(QPoint mouse);
|
|---|
| 283 |
|
|---|
| 284 | QT_END_NAMESPACE
|
|---|
| 285 |
|
|---|
| 286 | #endif // QT_MAC_P_H
|
|---|