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

Last change on this file since 134 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 7.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department 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
123class Q_GUI_EXPORT QMacCocoaAutoReleasePool
124{
125private:
126 void *pool;
127public:
128 QMacCocoaAutoReleasePool();
129 ~QMacCocoaAutoReleasePool();
130
131 inline void *handle() const { return pool; }
132};
133
134QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp
135
136class Q_GUI_EXPORT QMacWindowChangeEvent
137{
138private:
139 static QList<QMacWindowChangeEvent*> *change_events;
140public:
141 QMacWindowChangeEvent() {
142 }
143 virtual ~QMacWindowChangeEvent() {
144 }
145 static inline void exec(bool ) {
146 }
147protected:
148 virtual void windowChanged() = 0;
149 virtual void flushWindowChanged() = 0;
150};
151
152class QMacCGContext
153{
154 CGContextRef context;
155public:
156 QMacCGContext(QPainter *p); //qpaintengine_mac.cpp
157 inline QMacCGContext() { context = 0; }
158 inline QMacCGContext(const QPaintDevice *pdev) {
159 extern CGContextRef qt_mac_cg_context(const QPaintDevice *);
160 context = qt_mac_cg_context(pdev);
161 }
162 inline QMacCGContext(CGContextRef cg, bool takeOwnership=false) {
163 context = cg;
164 if(!takeOwnership)
165 CGContextRetain(context);
166 }
167 inline QMacCGContext(const QMacCGContext &copy) : context(0) { *this = copy; }
168 inline ~QMacCGContext() {
169 if(context)
170 CGContextRelease(context);
171 }
172 inline bool isNull() const { return context; }
173 inline operator CGContextRef() { return context; }
174 inline QMacCGContext &operator=(const QMacCGContext &copy) {
175 if(context)
176 CGContextRelease(context);
177 context = copy.context;
178 CGContextRetain(context);
179 return *this;
180 }
181 inline QMacCGContext &operator=(CGContextRef cg) {
182 if(context)
183 CGContextRelease(context);
184 context = cg;
185 CGContextRetain(context); //we do not take ownership
186 return *this;
187 }
188};
189
190class QMacPasteboardMime;
191class QMimeData;
192
193class QMacPasteboard
194{
195 struct Promise {
196 Promise() : itemId(0), convertor(0) { }
197 Promise(int itemId, QMacPasteboardMime *c, QString m, QVariant d, int o=0) : itemId(itemId), offset(o), convertor(c), mime(m), data(d) { }
198 int itemId, offset;
199 QMacPasteboardMime *convertor;
200 QString mime;
201 QVariant data;
202 };
203 QList<Promise> promises;
204
205 OSPasteboardRef paste;
206 uchar mime_type;
207 mutable QPointer<QMimeData> mime;
208 mutable bool mac_mime_source;
209 static OSStatus promiseKeeper(OSPasteboardRef, PasteboardItemID, CFStringRef, void *);
210 void clear_helper();
211public:
212 QMacPasteboard(OSPasteboardRef p, uchar mime_type=0);
213 QMacPasteboard(uchar mime_type);
214 QMacPasteboard(CFStringRef name=0, uchar mime_type=0);
215 ~QMacPasteboard();
216
217 bool hasFlavor(QString flavor) const;
218 bool hasOSType(int c_flavor) const;
219
220 OSPasteboardRef pasteBoard() const;
221 QMimeData *mimeData() const;
222 void setMimeData(QMimeData *mime);
223
224 QStringList formats() const;
225 bool hasFormat(const QString &format) const;
226 QVariant retrieveData(const QString &format, QVariant::Type) const;
227
228 void clear();
229 bool sync() const;
230};
231
232extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp
233
234extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm
235extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm
236extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm
237
238#ifdef check
239# undef check
240#endif
241
242QFont qfontForThemeFont(ThemeFontID themeID);
243
244QColor qcolorForTheme(ThemeBrush brush);
245
246QColor qcolorForThemeTextColor(ThemeTextColor themeColor);
247
248struct QMacDndAnswerRecord {
249 QRect rect;
250 Qt::KeyboardModifiers modifiers;
251 Qt::MouseButtons buttons;
252 Qt::DropAction lastAction;
253 unsigned int lastOperation;
254 void clear() {
255 rect = QRect();
256 modifiers = Qt::NoModifier;
257 buttons = Qt::NoButton;
258 lastAction = Qt::IgnoreAction;
259 lastOperation = 0;
260 }
261};
262extern QMacDndAnswerRecord qt_mac_dnd_answer_rec;
263void qt_mac_copy_answer_rect(const QDragMoveEvent &event);
264bool qt_mac_mouse_inside_answer_rect(QPoint mouse);
265
266QT_END_NAMESPACE
267
268#endif // QT_MAC_P_H
Note: See TracBrowser for help on using the repository browser.