Qt 4.8
qt-4.8.6
src
corelib
kernel
qcore_mac_p.h
Go to the documentation of this file.
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 QtCore 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 QCORE_MAC_P_H
43
#define QCORE_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 for the convenience
50
// of other Qt classes. This header file may change from version to
51
// version without notice, or even be removed.
52
//
53
// We mean it.
54
//
55
56
#ifndef __IMAGECAPTURE__
57
# define __IMAGECAPTURE__
58
#endif
59
60
#undef OLD_DEBUG
61
#ifdef DEBUG
62
# define OLD_DEBUG DEBUG
63
# undef DEBUG
64
#endif
65
#define DEBUG 0
66
#ifdef qDebug
67
# define old_qDebug qDebug
68
# undef qDebug
69
#endif
70
71
#if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED)
72
#include <ApplicationServices/ApplicationServices.h>
73
#else
74
#include <CoreFoundation/CoreFoundation.h>
75
#endif
76
77
#if !defined(Q_OS_IOS)
78
#include <CoreServices/CoreServices.h>
79
#endif
80
81
#undef DEBUG
82
#ifdef OLD_DEBUG
83
# define DEBUG OLD_DEBUG
84
# undef OLD_DEBUG
85
#endif
86
87
#ifdef old_qDebug
88
# undef qDebug
89
# define qDebug QT_NO_QDEBUG_MACRO
90
# undef old_qDebug
91
#endif
92
93
#include "
qstring.h
"
94
95
QT_BEGIN_NAMESPACE
96
97
/*
98
Helper class that automates refernce counting for CFtypes.
99
After constructing the QCFType object, it can be copied like a
100
value-based type.
101
102
Note that you must own the object you are wrapping.
103
This is typically the case if you get the object from a Core
104
Foundation function with the word "Create" or "Copy" in it. If
105
you got the object from a "Get" function, either retain it or use
106
constructFromGet(). One exception to this rule is the
107
HIThemeGet*Shape functions, which in reality are "Copy" functions.
108
*/
109
template
<
typename
T>
110
class
Q_CORE_EXPORT
QCFType
111
{
112
public
:
113
inline
QCFType
(
const
T &t = 0) :
type
(t) {}
114
inline
QCFType
(
const
QCFType
&helper) :
type
(helper.
type
) {
if
(
type
) CFRetain(
type
); }
115
inline
~QCFType
() {
if
(
type
) CFRelease(
type
); }
116
inline
operator
T() {
return
type
; }
117
inline
QCFType
operator =(
const
QCFType
&helper)
118
{
119
if
(helper.
type
)
120
CFRetain(helper.
type
);
121
CFTypeRef
type2 =
type
;
122
type
= helper.
type
;
123
if
(type2)
124
CFRelease(type2);
125
return
*
this
;
126
}
127
inline
T *
operator&
() {
return
&
type
; }
128
template
<
typename
X> X
as
()
const
{
return
reinterpret_cast<
X
>
(
type
); }
129
static
QCFType
constructFromGet
(
const
T &t)
130
{
131
CFRetain(t);
132
return
QCFType<T>
(t);
133
}
134
protected
:
135
T
type
;
136
};
137
138
class
Q_CORE_EXPORT
QCFString
:
public
QCFType
<CFStringRef>
139
{
140
public
:
141
inline
QCFString
(
const
QString
&str) :
QCFType
<
CFStringRef
>(0), string(str) {}
142
inline
QCFString
(
const
CFStringRef
cfstr = 0) :
QCFType
<
CFStringRef
>(cfstr) {}
143
inline
QCFString
(
const
QCFType<CFStringRef>
&other) :
QCFType
<
CFStringRef
>(other) {}
144
operator
QString
()
const
;
145
operator
CFStringRef
()
const
;
146
static
QString
toQString(
CFStringRef
cfstr);
147
static
CFStringRef
toCFStringRef(
const
QString
&str);
148
private
:
149
QString
string
;
150
};
151
152
153
#if !defined(Q_OS_IOS)
154
Q_CORE_EXPORT
void
qt_mac_to_pascal_string
(
const
QString
&s, Str255 str, TextEncoding encoding = 0,
int
len = -1);
155
Q_CORE_EXPORT
QString
qt_mac_from_pascal_string
(
const
Str255 pstr);
156
157
Q_CORE_EXPORT
OSErr
qt_mac_create_fsref
(
const
QString
&file, FSRef *fsref);
158
// Don't use this function, it won't work in 10.5 (Leopard) and up
159
Q_CORE_EXPORT
OSErr
qt_mac_create_fsspec
(
const
QString
&file, FSSpec *spec);
160
#endif // !defined(Q_OS_IOS)
161
162
QT_END_NAMESPACE
163
164
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
165
#ifndef __LP64__
166
typedef
float
CGFloat
;
167
typedef
int
NSInteger;
168
typedef
unsigned
int
NSUInteger;
169
#define SRefCon SInt32
170
#define URefCon UInt32
171
#endif
172
#endif
173
174
#endif // QCORE_MAC_P_H
QCFType::QCFType
QCFType(const T &t=0)
Definition:
qcore_mac_p.h:113
QCFType::QCFType
QCFType(const QCFType &helper)
Definition:
qcore_mac_p.h:114
CFStringRef
const struct __CFString * CFStringRef
Definition:
qmainwindowlayout_p.h:86
type
int type
Definition:
qmetatype.cpp:239
QCFString::QCFString
QCFString(const QCFType< CFStringRef > &other)
Definition:
qcore_mac_p.h:143
QT_END_NAMESPACE
#define QT_END_NAMESPACE
This macro expands to.
Definition:
qglobal.h:90
QCFType::as
X as() const
Definition:
qcore_mac_p.h:128
QString
The QString class provides a Unicode character string.
Definition:
qstring.h:83
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition:
qglobal.h:89
QCFType::constructFromGet
static QCFType constructFromGet(const T &t)
Definition:
qcore_mac_p.h:129
qt_mac_from_pascal_string
Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr)
Definition:
qcore_mac.cpp:120
QCFString
Definition:
qcore_mac_p.h:138
CFTypeRef
const void * CFTypeRef
Definition:
qmainwindowlayout_p.h:85
QCFString::QCFString
QCFString(const QString &str)
Definition:
qcore_mac_p.h:141
Q_CORE_EXPORT
#define Q_CORE_EXPORT
Definition:
qglobal.h:1449
qt_mac_to_pascal_string
Q_CORE_EXPORT void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding=0, int len=-1)
Definition:
qcore_mac.cpp:91
QCFString::string
QString string
Definition:
qcore_mac_p.h:149
qt_mac_create_fsref
Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref)
Definition:
qcore_mac.cpp:125
qstring.h
QCFType
Definition:
qcore_mac_p.h:110
QCFType::type
T type
Definition:
qcore_mac_p.h:135
QCFString::QCFString
QCFString(const CFStringRef cfstr=0)
Definition:
qcore_mac_p.h:142
QCFType::operator &
T * operator &()
Definition:
qcore_mac_p.h:127
QCFType::~QCFType
~QCFType()
Definition:
qcore_mac_p.h:115
qt_mac_create_fsspec
Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec)
Definition:
qcore_mac.cpp:131
CGFloat
float CGFloat
Definition:
qcolordialog_mac.mm:55
Qt 4.8 Source Code Browser