Warning: That file was not part of the compilation database. It may have many parsing errors.
1 | /**************************************************************************** |
---|---|
2 | ** |
3 | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/legal |
5 | ** |
6 | ** This file is part of the QtGui module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and Digia. For licensing terms and |
14 | ** conditions see http://qt.digia.com/licensing. For further information |
15 | ** use the contact form at http://qt.digia.com/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 2.1 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
24 | ** |
25 | ** In addition, as a special exception, Digia gives you certain additional |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
28 | ** |
29 | ** GNU General Public License Usage |
30 | ** Alternatively, this file may be used under the terms of the GNU |
31 | ** General Public License version 3.0 as published by the Free Software |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the |
33 | ** packaging of this file. Please review the following information to |
34 | ** ensure the GNU General Public License version 3.0 requirements will be |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. |
36 | ** |
37 | ** |
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 | #if !defined(QT_MAC_USE_COCOA) && defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 |
79 | // Some deprecated functions have been removed from the the 10.7 SDK, but the symbols are |
80 | // still exported by the 32-bit QD.framework (a subframework of ApplicationServices). |
81 | extern "C"{ |
82 | // from QuickdrawAPI.h |
83 | // https://developer.apple.com/legacy/library/documentation/Carbon/reference/QuickDraw_Ref/QuickDraw_Ref.pdf |
84 | void CopyBits(const BitMap *srcBits, const BitMap *dstBits, const Rect *srcRect, const Rect *dstRect, short mode, RgnHandle maskRgn); |
85 | void CopyRgn(RgnHandle srcRgn, RgnHandle dstRgn); |
86 | void DisposeRgn(RgnHandle rgn); |
87 | GDHandle GetMainDevice(void); |
88 | const BitMap *GetPortBitMapForCopyBits(CGrafPtr port); |
89 | Rect *GetRegionBounds(RgnHandle region, Rect *bounds); |
90 | RgnHandle NewRgn(void); |
91 | OSStatus QDRegionToRects(RgnHandle rgn, QDRegionParseDirection dir, RegionToRectsUPP proc, void *userData); |
92 | void SetEmptyRgn(RgnHandle rgn); |
93 | void SetRect(Rect* r, short left, short top, short right, short bottom); |
94 | void SetRectRgn(RgnHandle rgn, short left, short top, short right, short bottom); |
95 | void UnionRgn(RgnHandle srcRgnA, RgnHandle srcRgnB, RgnHandle dstRgn); |
96 | enum { |
97 | kQDRegionToRectsMsgInit = 1, |
98 | kQDRegionToRectsMsgParse = 2, |
99 | kQDRegionToRectsMsgTerminate = 3 |
100 | }; |
101 | enum { |
102 | kQDParseRegionFromTop = (1 << 0), |
103 | kQDParseRegionFromBottom = (1 << 1), |
104 | kQDParseRegionFromLeft = (1 << 2), |
105 | kQDParseRegionFromRight = (1 << 3), |
106 | kQDParseRegionFromTopLeft = kQDParseRegionFromTop | kQDParseRegionFromLeft, |
107 | kQDParseRegionFromBottomRight = kQDParseRegionFromBottom | kQDParseRegionFromRight |
108 | }; |
109 | |
110 | // from Fonts.h |
111 | // https://developer.apple.com/legacy/library/documentation/Carbon/reference/Font_Manager/fm_reference.pdf |
112 | OSStatus FMCreateFontIterator(const FMFilter *iFilter, void *iRefCon, OptionBits iOptions, FMFontIterator *ioIterator); |
113 | OSStatus FMDisposeFontIterator(FMFontIterator *ioIterator); |
114 | ATSFontFamilyRef FMGetATSFontFamilyRefFromFont(FMFontFamily iFamily); |
115 | ATSFontFamilyRef FMGetATSFontFamilyRefFromFontFamily(FMFontFamily iFamily); |
116 | ATSFontRef FMGetATSFontRefFromFont(FMFont iFont); |
117 | OSStatus FMGetFontFamilyInstanceFromFont(FMFont iFont, FMFontFamily *oFontFamily, FMFontStyle *oStyle); |
118 | FMFontFamily FMGetFontFamilyFromATSFontFamilyRef(ATSFontFamilyRef iFamily); |
119 | FMFont FMGetFontFromATSFontRef(ATSFontRef iFont); |
120 | OSStatus FMGetFontFromFontFamilyInstance(FMFontFamily iFontFamily, FMFontStyle iStyle, FMFont *oFont, FMFontStyle *oIntrinsicStyle); |
121 | OSStatus FMGetNextFont(FMFontIterator *ioIterator, FMFont *oFont); |
122 | enum { |
123 | kFMUseGlobalScopeOption = 0x00000001 |
124 | }; |
125 | enum { |
126 | commandMark = 17, |
127 | checkMark = 18, |
128 | diamondMark = 19, |
129 | appleMark = 20 |
130 | }; |
131 | } |
132 | #endif |
133 | |
134 | QT_BEGIN_NAMESPACE |
135 | class QWidget; |
136 | class QDragMoveEvent; |
137 | |
138 | /* Event masks */ |
139 | // internal Qt types |
140 | |
141 | // Event class for our own Carbon events. |
142 | #if defined(QT_NAMESPACE) && defined(QT_NAMESPACE_MAC_CRC) |
143 | // Take the CRC we generated at configure time. This *may* result in a |
144 | // collision with another value If that is the case, please change the value |
145 | // here to something other than 'Cute'. |
146 | const UInt32 kEventClassQt = QT_NAMESPACE_MAC_CRC; |
147 | #else |
148 | const UInt32 kEventClassQt = |
149 | #endif |
150 | |
151 | enum { |
152 | //AE types |
153 | typeAEClipboardChanged = 1, |
154 | //types |
155 | typeQWidget = 1, /* QWidget * */ |
156 | //params |
157 | kEventParamQWidget = |
158 | //events |
159 | kEventQtRequestContext = 13, |
160 | kEventQtRequestMenubarUpdate = 14, |
161 | kEventQtRequestShowSheet = 17, |
162 | kEventQtRequestActivate = 18, |
163 | kEventQtRequestWindowChange = 20 |
164 | }; |
165 | |
166 | // Simple class to manage short-lived regions |
167 | class QMacSmartQuickDrawRegion |
168 | { |
169 | RgnHandle qdRgn; |
170 | Q_DISABLE_COPY(QMacSmartQuickDrawRegion) |
171 | public: |
172 | explicit QMacSmartQuickDrawRegion(RgnHandle rgn) : qdRgn(rgn) {} |
173 | ~QMacSmartQuickDrawRegion() { |
174 | extern void qt_mac_dispose_rgn(RgnHandle); // qregion_mac.cpp |
175 | qt_mac_dispose_rgn(qdRgn); |
176 | } |
177 | operator RgnHandle() { |
178 | return qdRgn; |
179 | } |
180 | }; |
181 | |
182 | // Class for chaining to gether a bunch of fades. It pretty much is only used for qmenu fading. |
183 | class QMacWindowFader |
184 | { |
185 | QWidgetList m_windowsToFade; |
186 | float m_duration; |
187 | Q_DISABLE_COPY(QMacWindowFader) |
188 | public: |
189 | QMacWindowFader(); // PLEASE DON'T CALL THIS. |
190 | static QMacWindowFader *currentFader(); |
191 | void registerWindowToFade(QWidget *window); |
192 | void setFadeDuration(float durationInSecs) { m_duration = durationInSecs; } |
193 | float fadeDuration() const { return m_duration; } |
194 | void performFade(); |
195 | }; |
196 | |
197 | class Q_GUI_EXPORT QMacCocoaAutoReleasePool |
198 | { |
199 | private: |
200 | void *pool; |
201 | public: |
202 | QMacCocoaAutoReleasePool(); |
203 | ~QMacCocoaAutoReleasePool(); |
204 | |
205 | inline void *handle() const { return pool; } |
206 | }; |
207 | |
208 | QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp |
209 | |
210 | class Q_GUI_EXPORT QMacWindowChangeEvent |
211 | { |
212 | private: |
213 | static QList<QMacWindowChangeEvent*> *change_events; |
214 | public: |
215 | QMacWindowChangeEvent() { |
216 | } |
217 | virtual ~QMacWindowChangeEvent() { |
218 | } |
219 | static inline void exec(bool ) { |
220 | } |
221 | protected: |
222 | virtual void windowChanged() = 0; |
223 | virtual void flushWindowChanged() = 0; |
224 | }; |
225 | |
226 | class QMacCGContext |
227 | { |
228 | CGContextRef context; |
229 | public: |
230 | QMacCGContext(QPainter *p); //qpaintengine_mac.cpp |
231 | inline QMacCGContext() { context = 0; } |
232 | inline QMacCGContext(const QPaintDevice *pdev) { |
233 | extern CGContextRef qt_mac_cg_context(const QPaintDevice *); |
234 | context = qt_mac_cg_context(pdev); |
235 | } |
236 | inline QMacCGContext(CGContextRef cg, bool takeOwnership=false) { |
237 | context = cg; |
238 | if(!takeOwnership) |
239 | CGContextRetain(context); |
240 | } |
241 | inline QMacCGContext(const QMacCGContext ©) : context(0) { *this = copy; } |
242 | inline ~QMacCGContext() { |
243 | if(context) |
244 | CGContextRelease(context); |
245 | } |
246 | inline bool isNull() const { return context; } |
247 | inline operator CGContextRef() { return context; } |
248 | inline QMacCGContext &operator=(const QMacCGContext ©) { |
249 | if(context) |
250 | CGContextRelease(context); |
251 | context = copy.context; |
252 | CGContextRetain(context); |
253 | return *this; |
254 | } |
255 | inline QMacCGContext &operator=(CGContextRef cg) { |
256 | if(context) |
257 | CGContextRelease(context); |
258 | context = cg; |
259 | CGContextRetain(context); //we do not take ownership |
260 | return *this; |
261 | } |
262 | }; |
263 | |
264 | class QMacPasteboardMime; |
265 | class QMimeData; |
266 | |
267 | class QMacPasteboard |
268 | { |
269 | struct Promise { |
270 | Promise() : itemId(0), convertor(0) { } |
271 | Promise(int itemId, QMacPasteboardMime *c, QString m, QVariant d, int o=0) : itemId(itemId), offset(o), convertor(c), mime(m), data(d) { } |
272 | int itemId, offset; |
273 | QMacPasteboardMime *convertor; |
274 | QString mime; |
275 | QVariant data; |
276 | }; |
277 | QList<Promise> promises; |
278 | |
279 | OSPasteboardRef paste; |
280 | uchar mime_type; |
281 | mutable QPointer<QMimeData> mime; |
282 | mutable bool mac_mime_source; |
283 | static OSStatus promiseKeeper(OSPasteboardRef, PasteboardItemID, CFStringRef, void *); |
284 | void clear_helper(); |
285 | public: |
286 | QMacPasteboard(OSPasteboardRef p, uchar mime_type=0); |
287 | QMacPasteboard(uchar mime_type); |
288 | QMacPasteboard(CFStringRef name=0, uchar mime_type=0); |
289 | ~QMacPasteboard(); |
290 | |
291 | bool hasFlavor(QString flavor) const; |
292 | bool hasOSType(int c_flavor) const; |
293 | |
294 | OSPasteboardRef pasteBoard() const; |
295 | QMimeData *mimeData() const; |
296 | void setMimeData(QMimeData *mime); |
297 | |
298 | QStringList formats() const; |
299 | bool hasFormat(const QString &format) const; |
300 | QVariant retrieveData(const QString &format, QVariant::Type) const; |
301 | |
302 | void clear(); |
303 | bool sync() const; |
304 | }; |
305 | |
306 | extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp |
307 | |
308 | extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm |
309 | extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm |
310 | extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm |
311 | |
312 | #ifdef check |
313 | # undef check |
314 | #endif |
315 | |
316 | QFont qfontForThemeFont(ThemeFontID themeID); |
317 | |
318 | QColor qcolorForTheme(ThemeBrush brush); |
319 | |
320 | QColor qcolorForThemeTextColor(ThemeTextColor themeColor); |
321 | |
322 | struct QMacDndAnswerRecord { |
323 | QRect rect; |
324 | Qt::KeyboardModifiers modifiers; |
325 | Qt::MouseButtons buttons; |
326 | Qt::DropAction lastAction; |
327 | unsigned int lastOperation; |
328 | void clear() { |
329 | rect = QRect(); |
330 | modifiers = Qt::NoModifier; |
331 | buttons = Qt::NoButton; |
332 | lastAction = Qt::IgnoreAction; |
333 | lastOperation = 0; |
334 | } |
335 | }; |
336 | extern QMacDndAnswerRecord qt_mac_dnd_answer_rec; |
337 | void qt_mac_copy_answer_rect(const QDragMoveEvent &event); |
338 | bool qt_mac_mouse_inside_answer_rect(QPoint mouse); |
339 | |
340 | QT_END_NAMESPACE |
341 | |
342 | #endif // QT_MAC_P_H |
343 |
Warning: That file was not part of the compilation database. It may have many parsing errors.