source: trunk/src/gui/kernel/qt_mac_p.h@ 808

Last change on this file since 808 was 651, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.2 sources.

File size: 8.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 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#endif
61
62#include <CoreServices/CoreServices.h>
63
64#include "QtCore/qglobal.h"
65#include "QtCore/qvariant.h"
66#include "QtCore/qmimedata.h"
67#include "QtCore/qpointer.h"
68#include "private/qcore_mac_p.h"
69
70
71#include "QtGui/qpainter.h"
72
73#include <Carbon/Carbon.h>
74
75QT_BEGIN_NAMESPACE
76class QWidget;
77class QDragMoveEvent;
78
79/* Event masks */
80// internal Qt types
81
82 // Event class for our own Carbon events.
83#if defined(QT_NAMESPACE) && defined(QT_NAMESPACE_MAC_CRC)
84// Take the CRC we generated at configure time. This *may* result in a
85// collision with another value If that is the case, please change the value
86// here to something other than 'Cute'.
87const UInt32 kEventClassQt = QT_NAMESPACE_MAC_CRC;
88#else
89const UInt32 kEventClassQt = 'Cute';
90#endif
91
92enum {
93 //AE types
94 typeAEClipboardChanged = 1,
95 //types
96 typeQWidget = 1, /* QWidget * */
97 //params
98 kEventParamQWidget = 'qwid', /* typeQWidget */
99 //events
100 kEventQtRequestContext = 13,
101 kEventQtRequestMenubarUpdate = 14,
102 kEventQtRequestShowSheet = 17,
103 kEventQtRequestActivate = 18,
104 kEventQtRequestWindowChange = 20
105};
106
107// Simple class to manage short-lived regions
108class QMacSmartQuickDrawRegion
109{
110 RgnHandle qdRgn;
111 Q_DISABLE_COPY(QMacSmartQuickDrawRegion)
112public:
113 explicit QMacSmartQuickDrawRegion(RgnHandle rgn) : qdRgn(rgn) {}
114 ~QMacSmartQuickDrawRegion() {
115 extern void qt_mac_dispose_rgn(RgnHandle); // qregion_mac.cpp
116 qt_mac_dispose_rgn(qdRgn);
117 }
118 operator RgnHandle() {
119 return qdRgn;
120 }
121};
122
123// Class for chaining to gether a bunch of fades. It pretty much is only used for qmenu fading.
124class QMacWindowFader
125{
126 QWidgetList m_windowsToFade;
127 float m_duration;
128 Q_DISABLE_COPY(QMacWindowFader)
129public:
130 QMacWindowFader(); // PLEASE DON'T CALL THIS.
131 static QMacWindowFader *currentFader();
132 void registerWindowToFade(QWidget *window);
133 void setFadeDuration(float durationInSecs) { m_duration = durationInSecs; }
134 float fadeDuration() const { return m_duration; }
135 void performFade();
136};
137
138class Q_GUI_EXPORT QMacCocoaAutoReleasePool
139{
140private:
141 void *pool;
142public:
143 QMacCocoaAutoReleasePool();
144 ~QMacCocoaAutoReleasePool();
145
146 inline void *handle() const { return pool; }
147};
148
149QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp
150
151class Q_GUI_EXPORT QMacWindowChangeEvent
152{
153private:
154 static QList<QMacWindowChangeEvent*> *change_events;
155public:
156 QMacWindowChangeEvent() {
157 }
158 virtual ~QMacWindowChangeEvent() {
159 }
160 static inline void exec(bool ) {
161 }
162protected:
163 virtual void windowChanged() = 0;
164 virtual void flushWindowChanged() = 0;
165};
166
167class QMacCGContext
168{
169 CGContextRef context;
170public:
171 QMacCGContext(QPainter *p); //qpaintengine_mac.cpp
172 inline QMacCGContext() { context = 0; }
173 inline QMacCGContext(const QPaintDevice *pdev) {
174 extern CGContextRef qt_mac_cg_context(const QPaintDevice *);
175 context = qt_mac_cg_context(pdev);
176 }
177 inline QMacCGContext(CGContextRef cg, bool takeOwnership=false) {
178 context = cg;
179 if(!takeOwnership)
180 CGContextRetain(context);
181 }
182 inline QMacCGContext(const QMacCGContext &copy) : context(0) { *this = copy; }
183 inline ~QMacCGContext() {
184 if(context)
185 CGContextRelease(context);
186 }
187 inline bool isNull() const { return context; }
188 inline operator CGContextRef() { return context; }
189 inline QMacCGContext &operator=(const QMacCGContext &copy) {
190 if(context)
191 CGContextRelease(context);
192 context = copy.context;
193 CGContextRetain(context);
194 return *this;
195 }
196 inline QMacCGContext &operator=(CGContextRef cg) {
197 if(context)
198 CGContextRelease(context);
199 context = cg;
200 CGContextRetain(context); //we do not take ownership
201 return *this;
202 }
203};
204
205class QMacPasteboardMime;
206class QMimeData;
207
208class QMacPasteboard
209{
210 struct Promise {
211 Promise() : itemId(0), convertor(0) { }
212 Promise(int itemId, QMacPasteboardMime *c, QString m, QVariant d, int o=0) : itemId(itemId), offset(o), convertor(c), mime(m), data(d) { }
213 int itemId, offset;
214 QMacPasteboardMime *convertor;
215 QString mime;
216 QVariant data;
217 };
218 QList<Promise> promises;
219
220 OSPasteboardRef paste;
221 uchar mime_type;
222 mutable QPointer<QMimeData> mime;
223 mutable bool mac_mime_source;
224 static OSStatus promiseKeeper(OSPasteboardRef, PasteboardItemID, CFStringRef, void *);
225 void clear_helper();
226public:
227 QMacPasteboard(OSPasteboardRef p, uchar mime_type=0);
228 QMacPasteboard(uchar mime_type);
229 QMacPasteboard(CFStringRef name=0, uchar mime_type=0);
230 ~QMacPasteboard();
231
232 bool hasFlavor(QString flavor) const;
233 bool hasOSType(int c_flavor) const;
234
235 OSPasteboardRef pasteBoard() const;
236 QMimeData *mimeData() const;
237 void setMimeData(QMimeData *mime);
238
239 QStringList formats() const;
240 bool hasFormat(const QString &format) const;
241 QVariant retrieveData(const QString &format, QVariant::Type) const;
242
243 void clear();
244 bool sync() const;
245};
246
247extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp
248
249extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm
250extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm
251extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm
252
253#ifdef check
254# undef check
255#endif
256
257QFont qfontForThemeFont(ThemeFontID themeID);
258
259QColor qcolorForTheme(ThemeBrush brush);
260
261QColor qcolorForThemeTextColor(ThemeTextColor themeColor);
262
263struct QMacDndAnswerRecord {
264 QRect rect;
265 Qt::KeyboardModifiers modifiers;
266 Qt::MouseButtons buttons;
267 Qt::DropAction lastAction;
268 unsigned int lastOperation;
269 void clear() {
270 rect = QRect();
271 modifiers = Qt::NoModifier;
272 buttons = Qt::NoButton;
273 lastAction = Qt::IgnoreAction;
274 lastOperation = 0;
275 }
276};
277extern QMacDndAnswerRecord qt_mac_dnd_answer_rec;
278void qt_mac_copy_answer_rect(const QDragMoveEvent &event);
279bool qt_mac_mouse_inside_answer_rect(QPoint mouse);
280
281QT_END_NAMESPACE
282
283#endif // QT_MAC_P_H
Note: See TracBrowser for help on using the repository browser.