Delete src/widgets/platforms/mac
This looks like the mac port but isn't any more, remove it to prevent confusion. Change-Id: I498f536d77d1a3c53e687f696ca6992539a1a90b Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
parent
82340ea5cd
commit
bc02ef882b
@ -51,8 +51,8 @@
|
||||
#include <qapplication.h>
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qfiledialog_p.h>
|
||||
#include <private/qt_mac_p.h>
|
||||
#include <private/qt_cocoa_helpers_mac_p.h>
|
||||
#include "qt_mac_p.h"
|
||||
#include "qcocoahelpers.h"
|
||||
#include <qregexp.h>
|
||||
#include <qbuffer.h>
|
||||
#include <qdebug.h>
|
||||
|
@ -52,8 +52,7 @@
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <private/qt_mac_p.h>
|
||||
#include "qt_mac_p.h"
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <QtGui/qscreen.h>
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qt_mac_p.h>
|
||||
#include "qt_mac_p.h"
|
||||
#include <QtCore/qpointer.h>
|
||||
#include <QtWidgets/qmenu.h>
|
||||
#include <QtWidgets/qmenubar.h>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,632 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qclipboard.h"
|
||||
#include "qapplication.h"
|
||||
#include "qbitmap.h"
|
||||
#include "qdatetime.h"
|
||||
#include "qdebug.h"
|
||||
#include "qapplication_p.h"
|
||||
#include <private/qt_mac_p.h>
|
||||
#include "qevent.h"
|
||||
#include "qurl.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "qt_cocoa_helpers_mac_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
/*****************************************************************************
|
||||
QClipboard debug facilities
|
||||
*****************************************************************************/
|
||||
//#define DEBUG_PASTEBOARD
|
||||
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
|
||||
/*****************************************************************************
|
||||
QClipboard member functions for mac.
|
||||
*****************************************************************************/
|
||||
|
||||
static QMacPasteboard *qt_mac_pasteboards[2] = {0, 0};
|
||||
|
||||
static inline QMacPasteboard *qt_mac_pasteboard(QClipboard::Mode mode)
|
||||
{
|
||||
Q_ASSERT(mode == QClipboard::Clipboard || mode == QClipboard::FindBuffer);
|
||||
if (mode == QClipboard::Clipboard)
|
||||
return qt_mac_pasteboards[0];
|
||||
else
|
||||
return qt_mac_pasteboards[1];
|
||||
}
|
||||
|
||||
static void qt_mac_cleanupPasteboard() {
|
||||
delete qt_mac_pasteboards[0];
|
||||
delete qt_mac_pasteboards[1];
|
||||
qt_mac_pasteboards[0] = 0;
|
||||
qt_mac_pasteboards[1] = 0;
|
||||
}
|
||||
|
||||
static bool qt_mac_updateScrap(QClipboard::Mode mode)
|
||||
{
|
||||
if(!qt_mac_pasteboards[0]) {
|
||||
qt_mac_pasteboards[0] = new QMacPasteboard(kPasteboardClipboard, QMacPasteboardMime::MIME_CLIP);
|
||||
qt_mac_pasteboards[1] = new QMacPasteboard(kPasteboardFind, QMacPasteboardMime::MIME_CLIP);
|
||||
qAddPostRoutine(qt_mac_cleanupPasteboard);
|
||||
return true;
|
||||
}
|
||||
return qt_mac_pasteboard(mode)->sync();
|
||||
}
|
||||
|
||||
void QClipboard::clear(Mode mode)
|
||||
{
|
||||
if (!supportsMode(mode))
|
||||
return;
|
||||
qt_mac_updateScrap(mode);
|
||||
qt_mac_pasteboard(mode)->clear();
|
||||
setMimeData(0, mode);
|
||||
}
|
||||
|
||||
void QClipboard::ownerDestroyed()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void QClipboard::connectNotify(const char *signal)
|
||||
{
|
||||
Q_UNUSED(signal);
|
||||
}
|
||||
|
||||
bool QClipboard::event(QEvent *e)
|
||||
{
|
||||
if(e->type() != QEvent::Clipboard)
|
||||
return QObject::event(e);
|
||||
|
||||
if (qt_mac_updateScrap(QClipboard::Clipboard)) {
|
||||
emitChanged(QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
if (qt_mac_updateScrap(QClipboard::FindBuffer)) {
|
||||
emitChanged(QClipboard::FindBuffer);
|
||||
}
|
||||
|
||||
return QObject::event(e);
|
||||
}
|
||||
|
||||
const QMimeData *QClipboard::mimeData(Mode mode) const
|
||||
{
|
||||
if (!supportsMode(mode))
|
||||
return 0;
|
||||
qt_mac_updateScrap(mode);
|
||||
return qt_mac_pasteboard(mode)->mimeData();
|
||||
}
|
||||
|
||||
void QClipboard::setMimeData(QMimeData *src, Mode mode)
|
||||
{
|
||||
if (!supportsMode(mode))
|
||||
return;
|
||||
qt_mac_updateScrap(mode);
|
||||
qt_mac_pasteboard(mode)->setMimeData(src);
|
||||
emitChanged(mode);
|
||||
}
|
||||
|
||||
bool QClipboard::supportsMode(Mode mode) const
|
||||
{
|
||||
return (mode == Clipboard || mode == FindBuffer);
|
||||
}
|
||||
|
||||
bool QClipboard::ownsMode(Mode mode) const
|
||||
{
|
||||
Q_UNUSED(mode);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // QT_NO_CLIPBOARD
|
||||
|
||||
/*****************************************************************************
|
||||
QMacPasteboard code
|
||||
*****************************************************************************/
|
||||
|
||||
QMacPasteboard::QMacPasteboard(PasteboardRef p, uchar mt)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
mime_type = mt ? mt : uchar(QMacPasteboardMime::MIME_ALL);
|
||||
paste = p;
|
||||
CFRetain(paste);
|
||||
}
|
||||
|
||||
QMacPasteboard::QMacPasteboard(uchar mt)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
mime_type = mt ? mt : uchar(QMacPasteboardMime::MIME_ALL);
|
||||
paste = 0;
|
||||
OSStatus err = PasteboardCreate(0, &paste);
|
||||
if(err == noErr) {
|
||||
PasteboardSetPromiseKeeper(paste, promiseKeeper, this);
|
||||
} else {
|
||||
qDebug("PasteBoard: Error creating pasteboard: [%d]", (int)err);
|
||||
}
|
||||
}
|
||||
|
||||
QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
mime_type = mt ? mt : uchar(QMacPasteboardMime::MIME_ALL);
|
||||
paste = 0;
|
||||
OSStatus err = PasteboardCreate(name, &paste);
|
||||
if(err == noErr) {
|
||||
PasteboardSetPromiseKeeper(paste, promiseKeeper, this);
|
||||
} else {
|
||||
qDebug("PasteBoard: Error creating pasteboard: %s [%d]", QCFString::toQString(name).toLatin1().constData(), (int)err);
|
||||
}
|
||||
}
|
||||
|
||||
QMacPasteboard::~QMacPasteboard()
|
||||
{
|
||||
// commit all promises for paste after exit close
|
||||
for (int i = 0; i < promises.count(); ++i) {
|
||||
const Promise &promise = promises.at(i);
|
||||
QCFString flavor = QCFString(promise.convertor->flavorFor(promise.mime));
|
||||
promiseKeeper(paste, (PasteboardItemID)promise.itemId, flavor, this);
|
||||
}
|
||||
|
||||
if(paste)
|
||||
CFRelease(paste);
|
||||
}
|
||||
|
||||
PasteboardRef
|
||||
QMacPasteboard::pasteBoard() const
|
||||
{
|
||||
return paste;
|
||||
}
|
||||
|
||||
OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id, CFStringRef flavor, void *_qpaste)
|
||||
{
|
||||
QMacPasteboard *qpaste = (QMacPasteboard*)_qpaste;
|
||||
const long promise_id = (long)id;
|
||||
|
||||
// Find the kept promise
|
||||
const QString flavorAsQString = QCFString::toQString(flavor);
|
||||
QMacPasteboard::Promise promise;
|
||||
for (int i = 0; i < qpaste->promises.size(); i++){
|
||||
QMacPasteboard::Promise tmp = qpaste->promises[i];
|
||||
if (tmp.itemId == promise_id && tmp.convertor->canConvert(tmp.mime, flavorAsQString)){
|
||||
promise = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!promise.itemId && flavorAsQString == QLatin1String("com.trolltech.qt.MimeTypeName")) {
|
||||
// we have promised this data, but wont be able to convert, so return null data.
|
||||
// This helps in making the application/x-qt-mime-type-name hidden from normal use.
|
||||
QByteArray ba;
|
||||
QCFType<CFDataRef> data = CFDataCreate(0, (UInt8*)ba.constData(), ba.size());
|
||||
PasteboardPutItemFlavor(paste, id, flavor, data, kPasteboardFlavorNoFlags);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
if (!promise.itemId) {
|
||||
// There was no promise that could deliver data for the
|
||||
// given id and flavor. This should not happend.
|
||||
qDebug("Pasteboard: %d: Request for %ld, %s, but no promise found!", __LINE__, promise_id, qPrintable(flavorAsQString));
|
||||
return cantGetFlavorErr;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug("PasteBoard: Calling in promise for %s[%ld] [%s] (%s) [%d]", qPrintable(promise.mime), promise_id,
|
||||
qPrintable(flavorAsQString), qPrintable(promise.convertor->convertorName()), promise.offset);
|
||||
#endif
|
||||
|
||||
QList<QByteArray> md = promise.convertor->convertFromMime(promise.mime, promise.data, flavorAsQString);
|
||||
if (md.size() <= promise.offset)
|
||||
return cantGetFlavorErr;
|
||||
const QByteArray &ba = md[promise.offset];
|
||||
QCFType<CFDataRef> data = CFDataCreate(0, (UInt8*)ba.constData(), ba.size());
|
||||
PasteboardPutItemFlavor(paste, id, flavor, data, kPasteboardFlavorNoFlags);
|
||||
return noErr;
|
||||
}
|
||||
|
||||
bool
|
||||
QMacPasteboard::hasOSType(int c_flavor) const
|
||||
{
|
||||
if (!paste)
|
||||
return false;
|
||||
|
||||
sync();
|
||||
|
||||
ItemCount cnt = 0;
|
||||
if(PasteboardGetItemCount(paste, &cnt) || !cnt)
|
||||
return false;
|
||||
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug("PasteBoard: hasOSType [%c%c%c%c]", (c_flavor>>24)&0xFF, (c_flavor>>16)&0xFF,
|
||||
(c_flavor>>8)&0xFF, (c_flavor>>0)&0xFF);
|
||||
#endif
|
||||
for(uint index = 1; index <= cnt; ++index) {
|
||||
|
||||
PasteboardItemID id;
|
||||
if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
|
||||
return false;
|
||||
|
||||
QCFType<CFArrayRef> types;
|
||||
if(PasteboardCopyItemFlavors(paste, id, &types ) != noErr)
|
||||
return false;
|
||||
|
||||
const int type_count = CFArrayGetCount(types);
|
||||
for(int i = 0; i < type_count; ++i) {
|
||||
CFStringRef flavor = (CFStringRef)CFArrayGetValueAtIndex(types, i);
|
||||
const int os_flavor = UTGetOSTypeFromString(UTTypeCopyPreferredTagWithClass(flavor, kUTTagClassOSType));
|
||||
if(os_flavor == c_flavor) {
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" - Found!");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" - NotFound!");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
QMacPasteboard::hasFlavor(QString c_flavor) const
|
||||
{
|
||||
if (!paste)
|
||||
return false;
|
||||
|
||||
sync();
|
||||
|
||||
ItemCount cnt = 0;
|
||||
if(PasteboardGetItemCount(paste, &cnt) || !cnt)
|
||||
return false;
|
||||
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug("PasteBoard: hasFlavor [%s]", qPrintable(c_flavor));
|
||||
#endif
|
||||
for(uint index = 1; index <= cnt; ++index) {
|
||||
|
||||
PasteboardItemID id;
|
||||
if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
|
||||
return false;
|
||||
|
||||
PasteboardFlavorFlags flags;
|
||||
if(PasteboardGetItemFlavorFlags(paste, id, QCFString(c_flavor), &flags) == noErr) {
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" - Found!");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" - NotFound!");
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeSource : public QMimeData {
|
||||
const QMacPasteboard *paste;
|
||||
public:
|
||||
QMacPasteboardMimeSource(const QMacPasteboard *p) : QMimeData(), paste(p) { }
|
||||
~QMacPasteboardMimeSource() { }
|
||||
virtual QStringList formats() const { return paste->formats(); }
|
||||
virtual QVariant retrieveData(const QString &format, QVariant::Type type) const { return paste->retrieveData(format, type); }
|
||||
};
|
||||
|
||||
QMimeData
|
||||
*QMacPasteboard::mimeData() const
|
||||
{
|
||||
if(!mime) {
|
||||
mac_mime_source = true;
|
||||
mime = new QMacPasteboardMimeSource(this);
|
||||
|
||||
}
|
||||
return mime;
|
||||
}
|
||||
|
||||
class QMacMimeData : public QMimeData
|
||||
{
|
||||
public:
|
||||
QVariant variantData(const QString &mime) { return retrieveData(mime, QVariant::Invalid); }
|
||||
private:
|
||||
QMacMimeData();
|
||||
};
|
||||
|
||||
void
|
||||
QMacPasteboard::setMimeData(QMimeData *mime_src)
|
||||
{
|
||||
if (!paste)
|
||||
return;
|
||||
|
||||
if (mime == mime_src || (!mime_src && mime && mac_mime_source))
|
||||
return;
|
||||
mac_mime_source = false;
|
||||
delete mime;
|
||||
mime = mime_src;
|
||||
|
||||
QList<QMacPasteboardMime*> availableConverters = QMacPasteboardMime::all(mime_type);
|
||||
if (mime != 0) {
|
||||
clear_helper();
|
||||
QStringList formats = mime_src->formats();
|
||||
|
||||
// QMimeData sub classes reimplementing the formats() might not expose the
|
||||
// temporary "application/x-qt-mime-type-name" mimetype. So check the existence
|
||||
// of this mime type while doing drag and drop.
|
||||
QString dummyMimeType(QLatin1String("application/x-qt-mime-type-name"));
|
||||
if (!formats.contains(dummyMimeType)) {
|
||||
QByteArray dummyType = mime_src->data(dummyMimeType);
|
||||
if (!dummyType.isEmpty()) {
|
||||
formats.append(dummyMimeType);
|
||||
}
|
||||
}
|
||||
for(int f = 0; f < formats.size(); ++f) {
|
||||
QString mimeType = formats.at(f);
|
||||
for (QList<QMacPasteboardMime *>::Iterator it = availableConverters.begin(); it != availableConverters.end(); ++it) {
|
||||
QMacPasteboardMime *c = (*it);
|
||||
QString flavor(c->flavorFor(mimeType));
|
||||
if(!flavor.isEmpty()) {
|
||||
QVariant mimeData = static_cast<QMacMimeData*>(mime_src)->variantData(mimeType);
|
||||
#if 0
|
||||
//### Grrr, why didn't I put in a virtual int QMacPasteboardMime::count()? --Sam
|
||||
const int numItems = c->convertFromMime(mimeType, mimeData, flavor).size();
|
||||
#else
|
||||
int numItems = 1; //this is a hack but it is much faster than allowing conversion above
|
||||
if(c->convertorName() == QLatin1String("FileURL"))
|
||||
numItems = mime_src->urls().count();
|
||||
#endif
|
||||
for(int item = 0; item < numItems; ++item) {
|
||||
const int itemID = item+1; //id starts at 1
|
||||
promises.append(QMacPasteboard::Promise(itemID, c, mimeType, mimeData, item));
|
||||
PasteboardPutItemFlavor(paste, (PasteboardItemID)itemID, QCFString(flavor), 0, kPasteboardFlavorNoFlags);
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" - adding %d %s [%s] <%s> [%d]",
|
||||
itemID, qPrintable(mimeType), qPrintable(flavor), qPrintable(c->convertorName()), item);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList
|
||||
QMacPasteboard::formats() const
|
||||
{
|
||||
if (!paste)
|
||||
return QStringList();
|
||||
|
||||
sync();
|
||||
|
||||
QStringList ret;
|
||||
ItemCount cnt = 0;
|
||||
if(PasteboardGetItemCount(paste, &cnt) || !cnt)
|
||||
return ret;
|
||||
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug("PasteBoard: Formats [%d]", (int)cnt);
|
||||
#endif
|
||||
for(uint index = 1; index <= cnt; ++index) {
|
||||
|
||||
PasteboardItemID id;
|
||||
if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
|
||||
continue;
|
||||
|
||||
QCFType<CFArrayRef> types;
|
||||
if(PasteboardCopyItemFlavors(paste, id, &types ) != noErr)
|
||||
continue;
|
||||
|
||||
const int type_count = CFArrayGetCount(types);
|
||||
for(int i = 0; i < type_count; ++i) {
|
||||
const QString flavor = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(types, i));
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" -%s", qPrintable(QString(flavor)));
|
||||
#endif
|
||||
QString mimeType = QMacPasteboardMime::flavorToMime(mime_type, flavor);
|
||||
if(!mimeType.isEmpty() && !ret.contains(mimeType)) {
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" -<%d> %s [%s]", ret.size(), qPrintable(mimeType), qPrintable(QString(flavor)));
|
||||
#endif
|
||||
ret << mimeType;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
QMacPasteboard::hasFormat(const QString &format) const
|
||||
{
|
||||
if (!paste)
|
||||
return false;
|
||||
|
||||
sync();
|
||||
|
||||
ItemCount cnt = 0;
|
||||
if(PasteboardGetItemCount(paste, &cnt) || !cnt)
|
||||
return false;
|
||||
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug("PasteBoard: hasFormat [%s]", qPrintable(format));
|
||||
#endif
|
||||
for(uint index = 1; index <= cnt; ++index) {
|
||||
|
||||
PasteboardItemID id;
|
||||
if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
|
||||
continue;
|
||||
|
||||
QCFType<CFArrayRef> types;
|
||||
if(PasteboardCopyItemFlavors(paste, id, &types ) != noErr)
|
||||
continue;
|
||||
|
||||
const int type_count = CFArrayGetCount(types);
|
||||
for(int i = 0; i < type_count; ++i) {
|
||||
const QString flavor = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(types, i));
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" -%s [0x%x]", qPrintable(QString(flavor)), mime_type);
|
||||
#endif
|
||||
QString mimeType = QMacPasteboardMime::flavorToMime(mime_type, flavor);
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
if(!mimeType.isEmpty())
|
||||
qDebug(" - %s", qPrintable(mimeType));
|
||||
#endif
|
||||
if(mimeType == format)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant
|
||||
QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const
|
||||
{
|
||||
if (!paste)
|
||||
return QVariant();
|
||||
|
||||
sync();
|
||||
|
||||
ItemCount cnt = 0;
|
||||
if(PasteboardGetItemCount(paste, &cnt) || !cnt)
|
||||
return QByteArray();
|
||||
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug("Pasteboard: retrieveData [%s]", qPrintable(format));
|
||||
#endif
|
||||
const QList<QMacPasteboardMime *> mimes = QMacPasteboardMime::all(mime_type);
|
||||
for(int mime = 0; mime < mimes.size(); ++mime) {
|
||||
QMacPasteboardMime *c = mimes.at(mime);
|
||||
QString c_flavor = c->flavorFor(format);
|
||||
if(!c_flavor.isEmpty()) {
|
||||
// Handle text/plain a little differently. Try handling Unicode first.
|
||||
bool checkForUtf16 = (c_flavor == QLatin1String("com.apple.traditional-mac-plain-text")
|
||||
|| c_flavor == QLatin1String("public.utf8-plain-text"));
|
||||
if (checkForUtf16 || c_flavor == QLatin1String("public.utf16-plain-text")) {
|
||||
// Try to get the NSStringPboardType from NSPasteboard, newlines are mapped
|
||||
// correctly (as '\n') in this data. The 'public.utf16-plain-text' type
|
||||
// usually maps newlines to '\r' instead.
|
||||
QString str = qt_mac_get_pasteboardString(paste);
|
||||
if (!str.isEmpty())
|
||||
return str;
|
||||
}
|
||||
if (checkForUtf16 && hasFlavor(QLatin1String("public.utf16-plain-text")))
|
||||
c_flavor = QLatin1String("public.utf16-plain-text");
|
||||
|
||||
QVariant ret;
|
||||
QList<QByteArray> retList;
|
||||
for(uint index = 1; index <= cnt; ++index) {
|
||||
PasteboardItemID id;
|
||||
if(PasteboardGetItemIdentifier(paste, index, &id) != noErr)
|
||||
continue;
|
||||
|
||||
QCFType<CFArrayRef> types;
|
||||
if(PasteboardCopyItemFlavors(paste, id, &types ) != noErr)
|
||||
continue;
|
||||
|
||||
const int type_count = CFArrayGetCount(types);
|
||||
for(int i = 0; i < type_count; ++i) {
|
||||
CFStringRef flavor = static_cast<CFStringRef>(CFArrayGetValueAtIndex(types, i));
|
||||
if(c_flavor == QCFString::toQString(flavor)) {
|
||||
QCFType<CFDataRef> macBuffer;
|
||||
if(PasteboardCopyItemFlavorData(paste, id, flavor, &macBuffer) == noErr) {
|
||||
QByteArray buffer((const char *)CFDataGetBytePtr(macBuffer), CFDataGetLength(macBuffer));
|
||||
if(!buffer.isEmpty()) {
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" - %s [%s] (%s)", qPrintable(format), qPrintable(QCFString::toQString(flavor)), qPrintable(c->convertorName()));
|
||||
#endif
|
||||
buffer.detach(); //detach since we release the macBuffer
|
||||
retList.append(buffer);
|
||||
break; //skip to next element
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug(" - NoMatch %s [%s] (%s)", qPrintable(c_flavor), qPrintable(QCFString::toQString(flavor)), qPrintable(c->convertorName()));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!retList.isEmpty()) {
|
||||
ret = c->convertToMime(format, retList, c_flavor);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void QMacPasteboard::clear_helper()
|
||||
{
|
||||
if (paste)
|
||||
PasteboardClear(paste);
|
||||
promises.clear();
|
||||
}
|
||||
|
||||
void
|
||||
QMacPasteboard::clear()
|
||||
{
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
qDebug("PasteBoard: clear!");
|
||||
#endif
|
||||
clear_helper();
|
||||
}
|
||||
|
||||
bool
|
||||
QMacPasteboard::sync() const
|
||||
{
|
||||
if (!paste)
|
||||
return false;
|
||||
const bool fromGlobal = PasteboardSynchronize(paste) & kPasteboardModified;
|
||||
|
||||
if (fromGlobal)
|
||||
const_cast<QMacPasteboard *>(this)->setMimeData(0);
|
||||
|
||||
#ifdef DEBUG_PASTEBOARD
|
||||
if(fromGlobal)
|
||||
qDebug("Pasteboard: Synchronize!");
|
||||
#endif
|
||||
return fromGlobal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,119 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2007-2008, Apple, Inc.
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
**
|
||||
** * Redistributions in binary form must reproduce the above copyright notice,
|
||||
** this list of conditions and the following disclaimer in the documentation
|
||||
** and/or other materials provided with the distribution.
|
||||
**
|
||||
** * Neither the name of Apple, Inc. nor the names of its contributors
|
||||
** may be used to endorse or promote products derived from this software
|
||||
** without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qcocoaintrospection_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
|
||||
{
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
// The following code replaces the _implementation_ for the selector we want to hack
|
||||
// (originalSel) with the implementation found in proxyClass. Then it creates
|
||||
// a new 'backup' method inside baseClass containing the old, original,
|
||||
// implementation (fakeSel). You can let the proxy implementation of originalSel
|
||||
// call fakeSel if needed (similar approach to calling a super class implementation).
|
||||
// fakeSel must also be implemented in proxyClass, as the signature is used
|
||||
// as template for the method one we add into baseClass.
|
||||
// NB: You will typically never create any instances of proxyClass; we use it
|
||||
// only for stealing its contents and put it into baseClass.
|
||||
if (!replacementSel)
|
||||
replacementSel = originalSel;
|
||||
|
||||
Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
|
||||
Method replacementMethod = class_getInstanceMethod(proxyClass, replacementSel);
|
||||
IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(replacementMethod));
|
||||
|
||||
if (backupSel) {
|
||||
Method backupMethod = class_getInstanceMethod(proxyClass, backupSel);
|
||||
class_addMethod(baseClass, backupSel, originalImp, method_getTypeEncoding(backupMethod));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel)
|
||||
{
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
|
||||
Method backupMethodInBaseClass = class_getInstanceMethod(baseClass, backupSel);
|
||||
method_setImplementation(originalMethod, method_getImplementation(backupMethodInBaseClass));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,84 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2007-2008, Apple, Inc.
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
**
|
||||
** * Redistributions in binary form must reproduce the above copyright notice,
|
||||
** this list of conditions and the following disclaimer in the documentation
|
||||
** and/or other materials provided with the distribution.
|
||||
**
|
||||
** * Neither the name of Apple, Inc. nor the names of its contributors
|
||||
** may be used to endorse or promote products derived from this software
|
||||
** without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qglobal.h>
|
||||
#import <objc/objc-class.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel = 0, SEL backupSel = 0);
|
||||
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel);
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,68 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#import <private/qcocoapanel_mac_p.h>
|
||||
#import <private/qt_cocoa_helpers_mac_p.h>
|
||||
#import <private/qcocoawindow_mac_p.h>
|
||||
#import <private/qcocoawindowdelegate_mac_p.h>
|
||||
#import <private/qcocoaview_mac_p.h>
|
||||
#import <private/qcocoawindowcustomthemeframe_mac_p.h>
|
||||
#import <private/qcocoaapplication_mac_p.h>
|
||||
#import <private/qmultitouch_mac_p.h>
|
||||
#import <private/qapplication_p.h>
|
||||
#import <private/qbackingstore_p.h>
|
||||
#import <private/qdnd_p.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget);
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
@implementation QT_MANGLE_NAMESPACE(QCocoaPanel)
|
||||
|
||||
/***********************************************************************
|
||||
Copy and Paste between QCocoaWindow and QCocoaPanel
|
||||
This is a bit unfortunate, but thanks to the dynamic dispatch we
|
||||
have to duplicate this code or resort to really silly forwarding methods
|
||||
**************************************************************************/
|
||||
#include "qcocoasharedwindowmethods_mac_p.h"
|
||||
|
||||
@end
|
@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#ifndef QCOCOAPANEL_MAC_P
|
||||
#define QCOCOAPANEL_MAC_P
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QStringList);
|
||||
QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
|
||||
|
||||
@interface NSPanel (QtIntegration)
|
||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
|
||||
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
|
||||
- (void)draggingExited:(id <NSDraggingInfo>)sender;
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
|
||||
@end
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(QCocoaPanel) : NSPanel {
|
||||
QStringList *currentCustomDragTypes;
|
||||
QCocoaDropData *dropData;
|
||||
NSInteger dragEnterSequence;
|
||||
}
|
||||
|
||||
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask;
|
||||
- (void)registerDragTypes;
|
||||
- (void)drawRectOriginal:(NSRect)rect;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
@ -1,610 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
NB: This is not a header file, dispite the file name suffix. This file is
|
||||
included directly into the source code of qcocoawindow_mac.mm and
|
||||
qcocoapanel_mac.mm to avoid manually doing copy and paste of the exact
|
||||
same code needed at both places. This solution makes it more difficult
|
||||
to e.g fix a bug in qcocoawindow_mac.mm, but forget to do the same in
|
||||
qcocoapanel_mac.mm.
|
||||
The reason we need to do copy and paste in the first place, rather than
|
||||
resolve to method overriding, is that QCocoaPanel needs to inherit from
|
||||
NSPanel, while QCocoaWindow needs to inherit NSWindow rather than NSPanel).
|
||||
****************************************************************************/
|
||||
|
||||
// WARNING: Don't include any header files from within this file. Put them
|
||||
// directly into qcocoawindow_mac_p.h and qcocoapanel_mac_p.h
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
|
||||
extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
|
||||
extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp
|
||||
extern void qt_event_request_window_change(QWidget *); // qapplication_mac.mm
|
||||
extern void qt_mac_send_posted_gl_updates(QWidget *widget); // qapplication_mac.mm
|
||||
|
||||
Q_GLOBAL_STATIC(QPointer<QWidget>, currentDragTarget);
|
||||
QT_END_NAMESPACE
|
||||
|
||||
- (id)initWithContentRect:(NSRect)contentRect
|
||||
styleMask:(NSUInteger)windowStyle
|
||||
backing:(NSBackingStoreType)bufferingType
|
||||
defer:(BOOL)deferCreation
|
||||
{
|
||||
self = [super initWithContentRect:contentRect styleMask:windowStyle
|
||||
backing:bufferingType defer:deferCreation];
|
||||
if (self) {
|
||||
currentCustomDragTypes = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
delete currentCustomDragTypes;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeKeyWindow
|
||||
{
|
||||
QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)];
|
||||
if (!widget)
|
||||
return NO; // This should happen only for qt_root_win
|
||||
if (QApplicationPrivate::isBlockedByModal(widget))
|
||||
return NO;
|
||||
|
||||
bool isToolTip = (widget->windowType() == Qt::ToolTip);
|
||||
bool isPopup = (widget->windowType() == Qt::Popup);
|
||||
return !(isPopup || isToolTip);
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeMainWindow
|
||||
{
|
||||
QWidget *widget = [self QT_MANGLE_NAMESPACE(qt_qwidget)];
|
||||
if (!widget)
|
||||
return NO; // This should happen only for qt_root_win
|
||||
if ([self isSheet])
|
||||
return NO;
|
||||
|
||||
bool isToolTip = (widget->windowType() == Qt::ToolTip);
|
||||
bool isPopup = (widget->windowType() == Qt::Popup);
|
||||
bool isTool = (widget->windowType() == Qt::Tool);
|
||||
return !(isPopup || isToolTip || isTool);
|
||||
}
|
||||
|
||||
- (void)becomeMainWindow
|
||||
{
|
||||
[super becomeMainWindow];
|
||||
// Cocoa sometimes tell a hidden window to become the
|
||||
// main window (and as such, show it). This can e.g
|
||||
// happend when the application gets activated. If
|
||||
// this is the case, we tell it to hide again:
|
||||
if (![self isVisible])
|
||||
[self orderOut:self];
|
||||
}
|
||||
|
||||
- (void)toggleToolbarShown:(id)sender
|
||||
{
|
||||
macSendToolbarChangeEvent([self QT_MANGLE_NAMESPACE(qt_qwidget)]);
|
||||
[super toggleToolbarShown:sender];
|
||||
}
|
||||
|
||||
- (void)flagsChanged:(NSEvent *)theEvent
|
||||
{
|
||||
qt_dispatchModifiersChanged(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
|
||||
[super flagsChanged:theEvent];
|
||||
}
|
||||
|
||||
|
||||
- (void)tabletProximity:(NSEvent *)tabletEvent
|
||||
{
|
||||
qt_dispatchTabletProximityEvent(tabletEvent);
|
||||
}
|
||||
|
||||
- (void)terminate:(id)sender
|
||||
{
|
||||
// This function is called from the quit item in the menubar when this window
|
||||
// is in the first responder chain (see also qtDispatcherToQAction above)
|
||||
[NSApp terminate:sender];
|
||||
}
|
||||
|
||||
- (void)setLevel:(NSInteger)windowLevel
|
||||
{
|
||||
// Cocoa will upon activating/deactivating applications level modal
|
||||
// windows up and down, regardsless of any explicit set window level.
|
||||
// To ensure that modal stays-on-top dialogs actually stays on top after
|
||||
// the application is activated (and therefore stacks in front of
|
||||
// other stays-on-top windows), we need to add this little special-case override:
|
||||
QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
|
||||
if (widget && widget->isModal() && (widget->windowFlags() & Qt::WindowStaysOnTopHint))
|
||||
[super setLevel:NSPopUpMenuWindowLevel];
|
||||
else
|
||||
[super setLevel:windowLevel];
|
||||
}
|
||||
|
||||
- (void)sendEvent:(NSEvent *)event
|
||||
{
|
||||
[self retain];
|
||||
|
||||
bool handled = false;
|
||||
switch([event type]) {
|
||||
case NSMouseMoved:
|
||||
// Cocoa sends move events to a parent and all its children under the mouse, much
|
||||
// like Qt handles hover events. But we only want to handle the move event once, so
|
||||
// to optimize a bit (since we subscribe for move event for all views), we handle it
|
||||
// here before this logic happends. Note: it might be tempting to do this shortcut for
|
||||
// all mouse events. The problem is that Cocoa does more than just find the correct view
|
||||
// when sending the event, like raising windows etc. So avoid it as much as possible:
|
||||
handled = qt_mac_handleMouseEvent(event, QEvent::MouseMove, Qt::NoButton, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!handled) {
|
||||
[super sendEvent:event];
|
||||
qt_mac_handleNonClientAreaMouseEvent(self, event);
|
||||
}
|
||||
[self release];
|
||||
}
|
||||
|
||||
- (void)setInitialFirstResponder:(NSView *)view
|
||||
{
|
||||
// This method is called the first time the window is placed on screen and
|
||||
// is the earliest point in time we can connect OpenGL contexts to NSViews.
|
||||
QWidget *qwidget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
|
||||
if (qwidget) {
|
||||
qt_event_request_window_change(qwidget);
|
||||
qt_mac_send_posted_gl_updates(qwidget);
|
||||
}
|
||||
|
||||
[super setInitialFirstResponder:view];
|
||||
}
|
||||
|
||||
- (BOOL)makeFirstResponder:(NSResponder *)responder
|
||||
{
|
||||
// For some reason Cocoa wants to flip the first responder
|
||||
// when Qt doesn't want to, sorry, but "No" :-)
|
||||
if (responder == nil && qApp->focusWidget())
|
||||
return NO;
|
||||
return [super makeFirstResponder:responder];
|
||||
}
|
||||
|
||||
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
|
||||
{
|
||||
if (styleMask & QtMacCustomizeWindow)
|
||||
return [QT_MANGLE_NAMESPACE(QCocoaWindowCustomThemeFrame) class];
|
||||
return [super frameViewClassForStyleMask:styleMask];
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
- (void)touchesBeganWithEvent:(NSEvent *)event;
|
||||
{
|
||||
QPoint qlocal, qglobal;
|
||||
QWidget *widgetToGetTouch = 0;
|
||||
qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch);
|
||||
if (!widgetToGetTouch)
|
||||
return;
|
||||
|
||||
bool all = widgetToGetTouch->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
|
||||
qt_translateRawTouchEvent(widgetToGetTouch, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
|
||||
}
|
||||
|
||||
- (void)touchesMovedWithEvent:(NSEvent *)event;
|
||||
{
|
||||
QPoint qlocal, qglobal;
|
||||
QWidget *widgetToGetTouch = 0;
|
||||
qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch);
|
||||
if (!widgetToGetTouch)
|
||||
return;
|
||||
|
||||
bool all = widgetToGetTouch->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
|
||||
qt_translateRawTouchEvent(widgetToGetTouch, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
|
||||
}
|
||||
|
||||
- (void)touchesEndedWithEvent:(NSEvent *)event;
|
||||
{
|
||||
QPoint qlocal, qglobal;
|
||||
QWidget *widgetToGetTouch = 0;
|
||||
qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch);
|
||||
if (!widgetToGetTouch)
|
||||
return;
|
||||
|
||||
bool all = widgetToGetTouch->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
|
||||
qt_translateRawTouchEvent(widgetToGetTouch, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
|
||||
}
|
||||
|
||||
- (void)touchesCancelledWithEvent:(NSEvent *)event;
|
||||
{
|
||||
QPoint qlocal, qglobal;
|
||||
QWidget *widgetToGetTouch = 0;
|
||||
qt_mac_getTargetForMouseEvent(event, QEvent::Gesture, qlocal, qglobal, 0, &widgetToGetTouch);
|
||||
if (!widgetToGetTouch)
|
||||
return;
|
||||
|
||||
bool all = widgetToGetTouch->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
|
||||
qt_translateRawTouchEvent(widgetToGetTouch, QTouchEvent::TouchPad, QCocoaTouch::getCurrentTouchPointList(event, all));
|
||||
}
|
||||
#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
|
||||
-(void)registerDragTypes
|
||||
{
|
||||
// Calling registerForDraggedTypes below is slow, so only do
|
||||
// it once for each window, or when the custom types change.
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
const QStringList& customTypes = qEnabledDraggedTypes();
|
||||
if (currentCustomDragTypes == 0 || *currentCustomDragTypes != customTypes) {
|
||||
if (currentCustomDragTypes == 0)
|
||||
currentCustomDragTypes = new QStringList();
|
||||
*currentCustomDragTypes = customTypes;
|
||||
const NSString* mimeTypeGeneric = @"com.trolltech.qt.MimeTypeName";
|
||||
NSMutableArray *supportedTypes = [NSMutableArray arrayWithObjects:NSColorPboardType,
|
||||
NSFilenamesPboardType, NSStringPboardType,
|
||||
NSFilenamesPboardType, NSPostScriptPboardType, NSTIFFPboardType,
|
||||
NSRTFPboardType, NSTabularTextPboardType, NSFontPboardType,
|
||||
NSRulerPboardType, NSFileContentsPboardType, NSColorPboardType,
|
||||
NSRTFDPboardType, NSHTMLPboardType, NSPICTPboardType,
|
||||
NSURLPboardType, NSPDFPboardType, NSVCardPboardType,
|
||||
NSFilesPromisePboardType, NSInkTextPboardType,
|
||||
NSMultipleTextSelectionPboardType, mimeTypeGeneric, nil];
|
||||
// Add custom types supported by the application.
|
||||
for (int i = 0; i < customTypes.size(); i++) {
|
||||
[supportedTypes addObject:qt_mac_QStringToNSString(customTypes[i])];
|
||||
}
|
||||
[self registerForDraggedTypes:supportedTypes];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeDropData
|
||||
{
|
||||
if (dropData) {
|
||||
delete dropData;
|
||||
dropData = 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addDropData:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
[self removeDropData];
|
||||
CFStringRef dropPasteboard = (CFStringRef) [[sender draggingPasteboard] name];
|
||||
dropData = new QCocoaDropData(dropPasteboard);
|
||||
}
|
||||
|
||||
- (void)changeDraggingCursor:(NSDragOperation)newOperation
|
||||
{
|
||||
static SEL action = nil;
|
||||
static bool operationSupported = false;
|
||||
if (action == nil) {
|
||||
action = NSSelectorFromString(@"operationNotAllowedCursor");
|
||||
if ([NSCursor respondsToSelector:action]) {
|
||||
operationSupported = true;
|
||||
}
|
||||
}
|
||||
if (operationSupported) {
|
||||
NSCursor *notAllowedCursor = [NSCursor performSelector:action];
|
||||
bool isNotAllowedCursor = ([NSCursor currentCursor] == notAllowedCursor);
|
||||
if (newOperation == NSDragOperationNone && !isNotAllowedCursor) {
|
||||
[notAllowedCursor push];
|
||||
} else if (newOperation != NSDragOperationNone && isNotAllowedCursor) {
|
||||
[notAllowedCursor pop];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
// The user dragged something into the window. Send a draggingEntered message
|
||||
// to the QWidget under the mouse. As the drag moves over the window, and over
|
||||
// different widgets, we will handle enter and leave events from within
|
||||
// draggingUpdated below. The reason why we handle this ourselves rather than
|
||||
// subscribing for drag events directly in QCocoaView is that calling
|
||||
// registerForDraggedTypes on the views will severly degrade initialization time
|
||||
// for an application that uses a lot of drag subscribing widgets.
|
||||
|
||||
NSPoint nswindowPoint = [sender draggingLocation];
|
||||
NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
|
||||
QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
|
||||
|
||||
QWidget *qwidget = QApplication::widgetAt(globalPoint);
|
||||
*currentDragTarget() = qwidget;
|
||||
if (!qwidget)
|
||||
return [super draggingEntered:sender];
|
||||
if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false)
|
||||
return NSDragOperationNone;
|
||||
|
||||
[self addDropData:sender];
|
||||
|
||||
QMimeData *mimeData = dropData;
|
||||
if (QDragManager::self()->source())
|
||||
mimeData = QDragManager::self()->dragPrivate()->data;
|
||||
|
||||
NSDragOperation nsActions = [sender draggingSourceOperationMask];
|
||||
Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
|
||||
QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier;
|
||||
|
||||
if ([sender draggingSource] != nil) {
|
||||
// modifier flags might have changed, update it here since we don't send any input events.
|
||||
QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
|
||||
modifiers = QApplication::keyboardModifiers();
|
||||
} else {
|
||||
// when the source is from another application the above technique will not work.
|
||||
modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
|
||||
}
|
||||
|
||||
// send the drag enter event to the widget.
|
||||
QPoint localPoint(qwidget->mapFromGlobal(globalPoint));
|
||||
QDragEnterEvent qDEEvent(localPoint, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
|
||||
QApplication::sendEvent(qwidget, &qDEEvent);
|
||||
|
||||
if (!qDEEvent.isAccepted()) {
|
||||
// The enter event was not accepted. We mark this by removing
|
||||
// the drop data so we don't send subsequent drag move events:
|
||||
[self removeDropData];
|
||||
[self changeDraggingCursor:NSDragOperationNone];
|
||||
return NSDragOperationNone;
|
||||
} else {
|
||||
// Send a drag move event immediately after a drag enter event (as per documentation).
|
||||
QDragMoveEvent qDMEvent(localPoint, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
|
||||
qDMEvent.setDropAction(qDEEvent.dropAction());
|
||||
qDMEvent.accept(); // accept by default, since enter event was accepted.
|
||||
QApplication::sendEvent(qwidget, &qDMEvent);
|
||||
|
||||
if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
|
||||
// Since we accepted the drag enter event, the widget expects
|
||||
// future drage move events.
|
||||
nsActions = NSDragOperationNone;
|
||||
// Save as ignored in the answer rect.
|
||||
qDMEvent.setDropAction(Qt::IgnoreAction);
|
||||
} else {
|
||||
nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction());
|
||||
}
|
||||
|
||||
QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent);
|
||||
[self changeDraggingCursor:nsActions];
|
||||
return nsActions;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPoint nswindowPoint = [sender draggingLocation];
|
||||
NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
|
||||
QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
|
||||
|
||||
QWidget *qwidget = QApplication::widgetAt(globalPoint);
|
||||
if (!qwidget)
|
||||
return [super draggingEntered:sender];
|
||||
|
||||
// First, check if the widget under the mouse has changed since the
|
||||
// last drag move events. If so, we need to change target, and dispatch
|
||||
// syntetic drag enter/leave events:
|
||||
if (qwidget != *currentDragTarget()) {
|
||||
if (*currentDragTarget() && dropData) {
|
||||
QDragLeaveEvent de;
|
||||
QApplication::sendEvent(*currentDragTarget(), &de);
|
||||
[self removeDropData];
|
||||
}
|
||||
return [self draggingEntered:sender];
|
||||
}
|
||||
|
||||
if (qwidget->testAttribute(Qt::WA_DropSiteRegistered) == false)
|
||||
return NSDragOperationNone;
|
||||
|
||||
// If we have no drop data (which will be assigned inside draggingEntered), it means
|
||||
// that the current drag target did not accept the enter event. If so, we ignore
|
||||
// subsequent move events as well:
|
||||
if (dropData == 0) {
|
||||
[self changeDraggingCursor:NSDragOperationNone];
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
// If the mouse is still within the accepted rect (provided by
|
||||
// the application on a previous event), we follow the optimization
|
||||
// and just return the answer given at that point:
|
||||
NSDragOperation nsActions = [sender draggingSourceOperationMask];
|
||||
QPoint localPoint(qwidget->mapFromGlobal(globalPoint));
|
||||
if (qt_mac_mouse_inside_answer_rect(localPoint)
|
||||
&& QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions) {
|
||||
NSDragOperation operation = QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction));
|
||||
[self changeDraggingCursor:operation];
|
||||
return operation;
|
||||
}
|
||||
|
||||
QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
|
||||
Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions);
|
||||
Qt::KeyboardModifiers modifiers = Qt::NoModifier;
|
||||
|
||||
// Update modifiers:
|
||||
if ([sender draggingSource] != nil) {
|
||||
QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
|
||||
modifiers = QApplication::keyboardModifiers();
|
||||
} else {
|
||||
modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
|
||||
}
|
||||
|
||||
QMimeData *mimeData = dropData;
|
||||
if (QDragManager::self()->source())
|
||||
mimeData = QDragManager::self()->dragPrivate()->data;
|
||||
|
||||
// Insert the same drop action on the event according to
|
||||
// what the application told us it should be on the previous event:
|
||||
QDragMoveEvent qDMEvent(localPoint, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
|
||||
if (QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction != Qt::IgnoreAction
|
||||
&& QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).buttons == qDMEvent.mouseButtons()
|
||||
&& QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).modifiers == qDMEvent.keyboardModifiers())
|
||||
qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction);
|
||||
|
||||
// Now, end the drag move event to the widget:
|
||||
qDMEvent.accept();
|
||||
QApplication::sendEvent(qwidget, &qDMEvent);
|
||||
|
||||
NSDragOperation operation = qt_mac_mapDropAction(qDMEvent.dropAction());
|
||||
if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
|
||||
// Ignore this event (we will still receive further
|
||||
// notifications), save as ignored in the answer rect:
|
||||
operation = NSDragOperationNone;
|
||||
qDMEvent.setDropAction(Qt::IgnoreAction);
|
||||
}
|
||||
|
||||
qt_mac_copy_answer_rect(qDMEvent);
|
||||
[self changeDraggingCursor:operation];
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
||||
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPoint nswindowPoint = [sender draggingLocation];
|
||||
NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
|
||||
QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
|
||||
|
||||
QWidget *qwidget = *currentDragTarget();
|
||||
if (!qwidget)
|
||||
return [super draggingExited:sender];
|
||||
|
||||
if (dropData) {
|
||||
QDragLeaveEvent de;
|
||||
QApplication::sendEvent(qwidget, &de);
|
||||
[self removeDropData];
|
||||
}
|
||||
|
||||
// Clean-up:
|
||||
[self removeDropData];
|
||||
*currentDragTarget() = 0;
|
||||
[self changeDraggingCursor:NSDragOperationEvery];
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
QWidget *qwidget = *currentDragTarget();
|
||||
if (!qwidget)
|
||||
return NO;
|
||||
|
||||
*currentDragTarget() = 0;
|
||||
NSPoint nswindowPoint = [sender draggingLocation];
|
||||
NSPoint nsglobalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:nswindowPoint];
|
||||
QPoint globalPoint = flipPoint(nsglobalPoint).toPoint();
|
||||
|
||||
[self addDropData:sender];
|
||||
|
||||
NSDragOperation nsActions = [sender draggingSourceOperationMask];
|
||||
Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
|
||||
QMimeData *mimeData = dropData;
|
||||
|
||||
if (QDragManager::self()->source())
|
||||
mimeData = QDragManager::self()->dragPrivate()->data;
|
||||
if (QDragManager::self()->object)
|
||||
QDragManager::self()->dragPrivate()->target = qwidget;
|
||||
|
||||
QPoint localPoint(qwidget->mapFromGlobal(globalPoint));
|
||||
QDropEvent de(localPoint, qtAllowed, mimeData,
|
||||
QApplication::mouseButtons(), QApplication::keyboardModifiers());
|
||||
QApplication::sendEvent(qwidget, &de);
|
||||
|
||||
if (QDragManager::self()->object)
|
||||
QDragManager::self()->dragPrivate()->executed_action = de.dropAction();
|
||||
|
||||
return de.isAccepted();
|
||||
}
|
||||
|
||||
// This is a hack and it should be removed once we find the real cause for
|
||||
// the painting problems.
|
||||
// We have a static variable that signals if we have been called before or not.
|
||||
static bool firstDrawingInvocation = true;
|
||||
|
||||
// The method below exists only as a workaround to draw/not draw the baseline
|
||||
// in the title bar. This is to support unifiedToolbar look.
|
||||
|
||||
// This method is very special. To begin with, it is a
|
||||
// method that will get called only if we enable documentMode.
|
||||
// Furthermore, it won't get called as a normal method, we swap
|
||||
// this method with the normal implementation of drawRect in
|
||||
// _NSThemeFrame. When this method is active, its mission is to
|
||||
// first call the original drawRect implementation so the widget
|
||||
// gets proper painting. After that, it needs to detect if there
|
||||
// is a toolbar or not, in order to decide how to handle the unified
|
||||
// look. The distinction is important since the presence and
|
||||
// visibility of a toolbar change the way we enter into unified mode.
|
||||
// When there is a toolbar and that toolbar is visible, the problem
|
||||
// is as simple as to tell the toolbar not to draw its baseline.
|
||||
// However when there is not toolbar or the toolbar is not visible,
|
||||
// we need to draw a line on top of the baseline, because the baseline
|
||||
// in that case will belong to the title. For this case we need to draw
|
||||
// a line on top of the baseline.
|
||||
// As usual, there is a special case. When we first are called, we might
|
||||
// need to repaint ourselves one more time. We only need that if we
|
||||
// didn't get the activation, i.e. when we are launched via the command
|
||||
// line. And this only if the toolbar is visible from the beginning,
|
||||
// so we have a special flag that signals if we need to repaint or not.
|
||||
- (void)drawRectSpecial:(NSRect)rect
|
||||
{
|
||||
// Call the original drawing method.
|
||||
[id(self) drawRectOriginal:rect];
|
||||
NSWindow *window = [id(self) window];
|
||||
NSToolbar *toolbar = [window toolbar];
|
||||
if(!toolbar) {
|
||||
// There is no toolbar, we have to draw a line on top of the line drawn by Cocoa.
|
||||
macDrawRectOnTop((void *)window);
|
||||
} else {
|
||||
if([toolbar isVisible]) {
|
||||
// We tell Cocoa to avoid drawing the line at the end.
|
||||
if(firstDrawingInvocation) {
|
||||
firstDrawingInvocation = false;
|
||||
macSyncDrawingOnFirstInvocation((void *)window);
|
||||
} else
|
||||
[toolbar setShowsBaselineSeparator:NO];
|
||||
} else {
|
||||
// There is a toolbar but it is not visible so
|
||||
// we have to draw a line on top of the line drawn by Cocoa.
|
||||
macDrawRectOnTop((void *)window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)drawRectOriginal:(NSRect)rect
|
||||
{
|
||||
Q_UNUSED(rect)
|
||||
// This method implementation is here to silenct the compiler.
|
||||
// See drawRectSpecial for information.
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <qevent.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class QT_MANGLE_NAMESPACE(QCocoaView);
|
||||
QT_FORWARD_DECLARE_CLASS(QWidgetPrivate);
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget);
|
||||
QT_FORWARD_DECLARE_CLASS(QEvent);
|
||||
QT_FORWARD_DECLARE_CLASS(QString);
|
||||
QT_FORWARD_DECLARE_CLASS(QStringList);
|
||||
|
||||
Q_WIDGETS_EXPORT
|
||||
@interface QT_MANGLE_NAMESPACE(QCocoaView) : NSControl <NSTextInput> {
|
||||
QWidget *qwidget;
|
||||
QWidgetPrivate *qwidgetprivate;
|
||||
NSDragOperation supportedActions;
|
||||
bool composing;
|
||||
int composingLength;
|
||||
bool sendKeyEvents;
|
||||
bool fromKeyDownEvent;
|
||||
QString *composingText;
|
||||
@public int alienTouchCount;
|
||||
}
|
||||
- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
|
||||
- (void) finishInitWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
|
||||
- (void)frameDidChange:(NSNotification *)note;
|
||||
- (void)setSupportedActions:(NSDragOperation)actions;
|
||||
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
|
||||
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation;
|
||||
- (BOOL)isComposing;
|
||||
- (QWidget *)qt_qwidget;
|
||||
- (void) qt_clearQWidget;
|
||||
|
||||
@end
|
@ -1,88 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
#import <private/qcocoawindow_mac_p.h>
|
||||
#import <private/qcocoawindowdelegate_mac_p.h>
|
||||
#import <private/qcocoaview_mac_p.h>
|
||||
#import <private/qt_cocoa_helpers_mac_p.h>
|
||||
#import <private/qcocoawindowcustomthemeframe_mac_p.h>
|
||||
#import <private/qcocoaapplication_mac_p.h>
|
||||
#import <private/qdnd_p.h>
|
||||
#import <private/qmultitouch_mac_p.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget);
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
@implementation NSWindow (QT_MANGLE_NAMESPACE(QWidgetIntegration))
|
||||
|
||||
- (id)QT_MANGLE_NAMESPACE(qt_initWithQWidget):(QWidget*)widget contentRect:(NSRect)rect styleMask:(NSUInteger)mask
|
||||
{
|
||||
self = [self initWithContentRect:rect styleMask:mask backing:NSBackingStoreBuffered defer:YES];
|
||||
if (self) {
|
||||
[[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] becomeDelegteForWindow:self widget:widget];
|
||||
[self setReleasedWhenClosed:NO];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (QWidget *)QT_MANGLE_NAMESPACE(qt_qwidget)
|
||||
{
|
||||
QWidget *widget = 0;
|
||||
if ([self delegate] == [QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate])
|
||||
widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
|
||||
return widget;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation QT_MANGLE_NAMESPACE(QCocoaWindow)
|
||||
|
||||
/***********************************************************************
|
||||
Copy and Paste between QCocoaWindow and QCocoaPanel
|
||||
This is a bit unfortunate, but thanks to the dynamic dispatch we
|
||||
have to duplicate this code or resort to really silly forwarding methods
|
||||
**************************************************************************/
|
||||
#include "qcocoasharedwindowmethods_mac_p.h"
|
||||
|
||||
@end
|
@ -1,95 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#ifndef QCOCOAWINDOW_MAC_P
|
||||
#define QCOCOAWINDOW_MAC_P
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qbackingstore_p.h>
|
||||
|
||||
enum { QtMacCustomizeWindow = 1 << 21 }; // This will one day be run over by
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget);
|
||||
QT_FORWARD_DECLARE_CLASS(QStringList);
|
||||
QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
|
||||
|
||||
@interface NSWindow (QtCoverForHackWithCategory)
|
||||
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask;
|
||||
@end
|
||||
|
||||
@interface NSWindow (QT_MANGLE_NAMESPACE(QWidgetIntegration))
|
||||
- (id)QT_MANGLE_NAMESPACE(qt_initWithQWidget):(QWidget *)widget contentRect:(NSRect)rect styleMask:(NSUInteger)mask;
|
||||
- (QWidget *)QT_MANGLE_NAMESPACE(qt_qwidget);
|
||||
@end
|
||||
|
||||
@interface NSWindow (QtIntegration)
|
||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
|
||||
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
|
||||
- (void)draggingExited:(id <NSDraggingInfo>)sender;
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
|
||||
@end
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(QCocoaWindow) : NSWindow {
|
||||
QStringList *currentCustomDragTypes;
|
||||
QCocoaDropData *dropData;
|
||||
NSInteger dragEnterSequence;
|
||||
}
|
||||
|
||||
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask;
|
||||
- (void)registerDragTypes;
|
||||
- (void)drawRectOriginal:(NSRect)rect;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
@ -1,60 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
|
||||
|
||||
#import "private/qcocoawindowcustomthemeframe_mac_p.h"
|
||||
#import "private/qcocoawindow_mac_p.h"
|
||||
#include "private/qt_cocoa_helpers_mac_p.h"
|
||||
#include "qwidget.h"
|
||||
|
||||
@implementation QT_MANGLE_NAMESPACE(QCocoaWindowCustomThemeFrame)
|
||||
|
||||
- (void)_updateButtons
|
||||
{
|
||||
[super _updateButtons];
|
||||
NSWindow *window = [self window];
|
||||
qt_syncCocoaTitleBarButtons(window, [window QT_MANGLE_NAMESPACE(qt_qwidget)]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -1,61 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
|
||||
// and many other. This header file may change from version to version
|
||||
// without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "qmacdefines_mac.h"
|
||||
#import "qnsthemeframe_mac_p.h"
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(QCocoaWindowCustomThemeFrame) : NSThemeFrame
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
@ -1,437 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#import "private/qcocoawindowdelegate_mac_p.h"
|
||||
#include <private/qwidget_p.h>
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qt_cocoa_helpers_mac_p.h>
|
||||
#include <qevent.h>
|
||||
#include <qlayout.h>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qmenubar.h>
|
||||
#include <QMainWindow>
|
||||
#include <QToolBar>
|
||||
#include <private/qmainwindowlayout_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
extern QWidgetData *qt_qwidget_data(QWidget *); // qwidget.cpp
|
||||
extern void onApplicationWindowChangedActivation(QWidget *, bool); //qapplication_mac.mm
|
||||
extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); // qapplication.cpp
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
static QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) *sharedCocoaWindowDelegate = nil;
|
||||
|
||||
// This is a singleton, but unlike most Cocoa singletons, it lives in a library and could be
|
||||
// pontentially loaded and unloaded. This means we should at least attempt to do the
|
||||
// memory management correctly.
|
||||
|
||||
static void cleanupCocoaWindowDelegate()
|
||||
{
|
||||
[sharedCocoaWindowDelegate release];
|
||||
}
|
||||
|
||||
@implementation QT_MANGLE_NAMESPACE(QCocoaWindowDelegate)
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
m_windowHash = new QHash<NSWindow *, QWidget *>();
|
||||
m_drawerHash = new QHash<NSDrawer *, QWidget *>();
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
sharedCocoaWindowDelegate = nil;
|
||||
QHash<NSWindow *, QWidget *>::const_iterator windowIt = m_windowHash->constBegin();
|
||||
while (windowIt != m_windowHash->constEnd()) {
|
||||
[windowIt.key() setDelegate:nil];
|
||||
++windowIt;
|
||||
}
|
||||
delete m_windowHash;
|
||||
QHash<NSDrawer *, QWidget *>::const_iterator drawerIt = m_drawerHash->constBegin();
|
||||
while (drawerIt != m_drawerHash->constEnd()) {
|
||||
[drawerIt.key() setDelegate:nil];
|
||||
++drawerIt;
|
||||
}
|
||||
delete m_drawerHash;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
+ (id)allocWithZone:(NSZone *)zone
|
||||
{
|
||||
@synchronized(self) {
|
||||
if (sharedCocoaWindowDelegate == nil) {
|
||||
sharedCocoaWindowDelegate = [super allocWithZone:zone];
|
||||
return sharedCocoaWindowDelegate;
|
||||
qAddPostRoutine(cleanupCocoaWindowDelegate);
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (QT_MANGLE_NAMESPACE(QCocoaWindowDelegate)*)sharedDelegate
|
||||
{
|
||||
@synchronized(self) {
|
||||
if (sharedCocoaWindowDelegate == nil)
|
||||
[[self alloc] init];
|
||||
}
|
||||
return [[sharedCocoaWindowDelegate retain] autorelease];
|
||||
}
|
||||
|
||||
-(void)syncSizeForWidget:(QWidget *)qwidget toSize:(const QSize &)newSize fromSize:(const QSize &)oldSize
|
||||
{
|
||||
qt_qwidget_data(qwidget)->crect.setSize(newSize);
|
||||
// ### static contents optimization needs to go here
|
||||
const OSViewRef view = qt_mac_nativeview_for(qwidget);
|
||||
[view setFrameSize:NSMakeSize(newSize.width(), newSize.height())];
|
||||
if (!qwidget->isVisible()) {
|
||||
qwidget->setAttribute(Qt::WA_PendingResizeEvent, true);
|
||||
} else {
|
||||
QResizeEvent qre(newSize, oldSize);
|
||||
if (qwidget->testAttribute(Qt::WA_PendingResizeEvent)) {
|
||||
qwidget->setAttribute(Qt::WA_PendingResizeEvent, false);
|
||||
QApplication::sendEvent(qwidget, &qre);
|
||||
} else {
|
||||
qt_sendSpontaneousEvent(qwidget, &qre);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dumpMaximizedStateforWidget:(QWidget*)qwidget window:(NSWindow *)window
|
||||
{
|
||||
if (!window)
|
||||
return; // Nothing to do.
|
||||
QWidgetData *widgetData = qt_qwidget_data(qwidget);
|
||||
if ((widgetData->window_state & Qt::WindowMaximized) && ![window isZoomed]) {
|
||||
widgetData->window_state &= ~Qt::WindowMaximized;
|
||||
QWindowStateChangeEvent e(Qt::WindowState(widgetData->window_state | Qt::WindowMaximized));
|
||||
qt_sendSpontaneousEvent(qwidget, &e);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSSize)closestAcceptableSizeForWidget:(QWidget *)qwidget window:(NSWindow *)window
|
||||
withNewSize:(NSSize)proposedSize
|
||||
{
|
||||
[self dumpMaximizedStateforWidget:qwidget window:window];
|
||||
QSize newSize = QLayout::closestAcceptableSize(qwidget,
|
||||
QSize(proposedSize.width, proposedSize.height));
|
||||
return [NSWindow frameRectForContentRect:
|
||||
NSMakeRect(0., 0., newSize.width(), newSize.height())
|
||||
styleMask:[window styleMask]].size;
|
||||
}
|
||||
|
||||
- (NSSize)windowWillResize:(NSWindow *)windowToResize toSize:(NSSize)proposedFrameSize
|
||||
{
|
||||
QWidget *qwidget = m_windowHash->value(windowToResize);
|
||||
return [self closestAcceptableSizeForWidget:qwidget window:windowToResize
|
||||
withNewSize:[NSWindow contentRectForFrameRect:
|
||||
NSMakeRect(0, 0,
|
||||
proposedFrameSize.width,
|
||||
proposedFrameSize.height)
|
||||
styleMask:[windowToResize styleMask]].size];
|
||||
}
|
||||
|
||||
- (NSSize)drawerWillResizeContents:(NSDrawer *)sender toSize:(NSSize)contentSize
|
||||
{
|
||||
QWidget *qwidget = m_drawerHash->value(sender);
|
||||
return [self closestAcceptableSizeForWidget:qwidget window:nil withNewSize:contentSize];
|
||||
}
|
||||
|
||||
-(void)windowDidMiniaturize:(NSNotification*)notification
|
||||
{
|
||||
QWidget *qwidget = m_windowHash->value([notification object]);
|
||||
if (!qwidget->isMinimized()) {
|
||||
QWidgetData *widgetData = qt_qwidget_data(qwidget);
|
||||
widgetData->window_state = widgetData->window_state | Qt::WindowMinimized;
|
||||
QWindowStateChangeEvent e(Qt::WindowStates(widgetData->window_state & ~Qt::WindowMinimized));
|
||||
qt_sendSpontaneousEvent(qwidget, &e);
|
||||
}
|
||||
// Send hide to match Qt on X11 and Windows
|
||||
QEvent e(QEvent::Hide);
|
||||
qt_sendSpontaneousEvent(qwidget, &e);
|
||||
}
|
||||
|
||||
- (void)windowDidResize:(NSNotification *)notification
|
||||
{
|
||||
NSWindow *window = [notification object];
|
||||
QWidget *qwidget = m_windowHash->value(window);
|
||||
QWidgetData *widgetData = qt_qwidget_data(qwidget);
|
||||
if (!(qwidget->windowState() & (Qt::WindowMaximized | Qt::WindowFullScreen)) && [window isZoomed]) {
|
||||
widgetData->window_state = widgetData->window_state | Qt::WindowMaximized;
|
||||
QWindowStateChangeEvent e(Qt::WindowStates(widgetData->window_state
|
||||
& ~Qt::WindowMaximized));
|
||||
qt_sendSpontaneousEvent(qwidget, &e);
|
||||
} else {
|
||||
widgetData->window_state = widgetData->window_state & ~Qt::WindowMaximized;
|
||||
QWindowStateChangeEvent e(Qt::WindowStates(widgetData->window_state
|
||||
| Qt::WindowMaximized));
|
||||
qt_sendSpontaneousEvent(qwidget, &e);
|
||||
}
|
||||
NSRect rect = [[window contentView] frame];
|
||||
const QSize newSize(rect.size.width, rect.size.height);
|
||||
const QSize &oldSize = widgetData->crect.size();
|
||||
if (newSize != oldSize) {
|
||||
QWidgetPrivate::qt_mac_update_sizer(qwidget);
|
||||
[self syncSizeForWidget:qwidget toSize:newSize fromSize:oldSize];
|
||||
}
|
||||
|
||||
// We force the repaint to be synchronized with the resize of the window.
|
||||
// Otherwise, the resize looks sluggish because we paint one event loop later.
|
||||
if ([[window contentView] inLiveResize]) {
|
||||
qwidget->repaint();
|
||||
|
||||
// We need to repaint the toolbar as well.
|
||||
QMainWindow* mWindow = qobject_cast<QMainWindow*>(qwidget->window());
|
||||
if (mWindow) {
|
||||
QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
|
||||
QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList;
|
||||
|
||||
for (int i = 0; i < toolbarList.size(); ++i) {
|
||||
QToolBar* toolbar = toolbarList.at(i);
|
||||
toolbar->repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowDidMove:(NSNotification *)notification
|
||||
{
|
||||
// The code underneath needs to translate the window location
|
||||
// from bottom left (which is the origin used by Cocoa) to
|
||||
// upper left (which is the origin used by Qt):
|
||||
NSWindow *window = [notification object];
|
||||
NSRect newRect = [window frame];
|
||||
QWidget *qwidget = m_windowHash->value(window);
|
||||
QPoint qtPoint = flipPoint(NSMakePoint(newRect.origin.x,
|
||||
newRect.origin.y + newRect.size.height)).toPoint();
|
||||
const QRect &oldRect = qwidget->frameGeometry();
|
||||
|
||||
if (qtPoint.x() != oldRect.x() || qtPoint.y() != oldRect.y()) {
|
||||
QWidgetData *widgetData = qt_qwidget_data(qwidget);
|
||||
QRect oldCRect = widgetData->crect;
|
||||
QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget);
|
||||
const QRect &fStrut = widgetPrivate->frameStrut();
|
||||
widgetData->crect.moveTo(qtPoint.x() + fStrut.left(), qtPoint.y() + fStrut.top());
|
||||
if (!qwidget->isVisible()) {
|
||||
qwidget->setAttribute(Qt::WA_PendingMoveEvent, true);
|
||||
} else {
|
||||
QMoveEvent qme(qtPoint, oldRect.topLeft());
|
||||
qt_sendSpontaneousEvent(qwidget, &qme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(BOOL)windowShouldClose:(id)windowThatWantsToClose
|
||||
{
|
||||
QWidget *qwidget = m_windowHash->value(windowThatWantsToClose);
|
||||
QScopedLoopLevelCounter counter(qt_widget_private(qwidget)->threadData);
|
||||
return qt_widget_private(qwidget)->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
|
||||
}
|
||||
|
||||
-(void)windowDidDeminiaturize:(NSNotification *)notification
|
||||
{
|
||||
QWidget *qwidget = m_windowHash->value([notification object]);
|
||||
QWidgetData *widgetData = qt_qwidget_data(qwidget);
|
||||
Qt::WindowStates currState = Qt::WindowStates(widgetData->window_state);
|
||||
Qt::WindowStates newState = currState;
|
||||
if (currState & Qt::WindowMinimized)
|
||||
newState &= ~Qt::WindowMinimized;
|
||||
if (!(currState & Qt::WindowActive))
|
||||
newState |= Qt::WindowActive;
|
||||
if (newState != currState) {
|
||||
widgetData->window_state = newState;
|
||||
QWindowStateChangeEvent e(currState);
|
||||
qt_sendSpontaneousEvent(qwidget, &e);
|
||||
}
|
||||
QShowEvent qse;
|
||||
qt_sendSpontaneousEvent(qwidget, &qse);
|
||||
}
|
||||
|
||||
-(void)windowDidBecomeMain:(NSNotification*)notification
|
||||
{
|
||||
QWidget *qwidget = m_windowHash->value([notification object]);
|
||||
Q_ASSERT(qwidget);
|
||||
onApplicationWindowChangedActivation(qwidget, true);
|
||||
}
|
||||
|
||||
-(void)windowDidResignMain:(NSNotification*)notification
|
||||
{
|
||||
QWidget *qwidget = m_windowHash->value([notification object]);
|
||||
Q_ASSERT(qwidget);
|
||||
onApplicationWindowChangedActivation(qwidget, false);
|
||||
}
|
||||
|
||||
// These are the same as main, but they are probably better to keep separate since there is a
|
||||
// tiny difference between main and key windows.
|
||||
-(void)windowDidBecomeKey:(NSNotification*)notification
|
||||
{
|
||||
QWidget *qwidget = m_windowHash->value([notification object]);
|
||||
Q_ASSERT(qwidget);
|
||||
onApplicationWindowChangedActivation(qwidget, true);
|
||||
}
|
||||
|
||||
-(void)windowDidResignKey:(NSNotification*)notification
|
||||
{
|
||||
QWidget *qwidget = m_windowHash->value([notification object]);
|
||||
Q_ASSERT(qwidget);
|
||||
onApplicationWindowChangedActivation(qwidget, false);
|
||||
}
|
||||
|
||||
-(QWidget *)qt_qwidgetForWindow:(NSWindow *)window
|
||||
{
|
||||
return m_windowHash->value(window);
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame
|
||||
{
|
||||
Q_UNUSED(newFrame);
|
||||
// saving the current window geometry before the window is maximized
|
||||
QWidget *qwidget = m_windowHash->value(window);
|
||||
QWidgetPrivate *widgetPrivate = qt_widget_private(qwidget);
|
||||
if (qwidget->isWindow()) {
|
||||
if(qwidget->windowState() & Qt::WindowMaximized) {
|
||||
// Restoring
|
||||
widgetPrivate->topData()->wasMaximized = false;
|
||||
} else {
|
||||
// Maximizing
|
||||
widgetPrivate->topData()->normalGeometry = qwidget->geometry();
|
||||
// If the window was maximized we need to update the coordinates since now it will start at 0,0.
|
||||
// We do this in a special field that is only used when not restoring but manually resizing the window.
|
||||
// Since the coordinates are fixed we just set a boolean flag.
|
||||
widgetPrivate->topData()->wasMaximized = true;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame
|
||||
{
|
||||
NSRect frameToReturn = defaultFrame;
|
||||
QWidget *qwidget = m_windowHash->value(window);
|
||||
QSizeF size = qwidget->maximumSize();
|
||||
NSRect windowFrameRect = [window frame];
|
||||
NSRect viewFrameRect = [[window contentView] frame];
|
||||
// consider additional size required for titlebar & frame
|
||||
frameToReturn.size.width = qMin<CGFloat>(frameToReturn.size.width,
|
||||
size.width()+(windowFrameRect.size.width - viewFrameRect.size.width));
|
||||
frameToReturn.size.height = qMin<CGFloat>(frameToReturn.size.height,
|
||||
size.height()+(windowFrameRect.size.height - viewFrameRect.size.height));
|
||||
return frameToReturn;
|
||||
}
|
||||
|
||||
- (void)becomeDelegteForWindow:(NSWindow *)window widget:(QWidget *)widget
|
||||
{
|
||||
m_windowHash->insert(window, widget);
|
||||
[window setDelegate:self];
|
||||
}
|
||||
|
||||
- (void)resignDelegateForWindow:(NSWindow *)window
|
||||
{
|
||||
[window setDelegate:nil];
|
||||
m_windowHash->remove(window);
|
||||
}
|
||||
|
||||
- (void)becomeDelegateForDrawer:(NSDrawer *)drawer widget:(QWidget *)widget
|
||||
{
|
||||
m_drawerHash->insert(drawer, widget);
|
||||
[drawer setDelegate:self];
|
||||
NSWindow *window = [[drawer contentView] window];
|
||||
[self becomeDelegteForWindow:window widget:widget];
|
||||
}
|
||||
|
||||
- (void)resignDelegateForDrawer:(NSDrawer *)drawer
|
||||
{
|
||||
QWidget *widget = m_drawerHash->value(drawer);
|
||||
[drawer setDelegate:nil];
|
||||
if (widget)
|
||||
[self resignDelegateForWindow:[[drawer contentView] window]];
|
||||
m_drawerHash->remove(drawer);
|
||||
}
|
||||
|
||||
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
|
||||
{
|
||||
Q_UNUSED(menu);
|
||||
QWidget *qwidget = m_windowHash->value(window);
|
||||
if (qwidget && !qwidget->windowFilePath().isEmpty()) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event
|
||||
from:(NSPoint)dragImageLocation
|
||||
withPasteboard:(NSPasteboard *)pasteboard
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
Q_UNUSED(dragImageLocation);
|
||||
Q_UNUSED(pasteboard);
|
||||
QWidget *qwidget = m_windowHash->value(window);
|
||||
if (qwidget && !qwidget->windowFilePath().isEmpty()) {
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)syncContentViewFrame: (NSNotification *)notification
|
||||
{
|
||||
NSView *cView = [notification object];
|
||||
if (cView) {
|
||||
NSWindow *window = [cView window];
|
||||
QWidget *qwidget = m_windowHash->value(window);
|
||||
if (qwidget) {
|
||||
QWidgetData *widgetData = qt_qwidget_data(qwidget);
|
||||
NSRect rect = [cView frame];
|
||||
const QSize newSize(rect.size.width, rect.size.height);
|
||||
const QSize &oldSize = widgetData->crect.size();
|
||||
if (newSize != oldSize) {
|
||||
[self syncSizeForWidget:qwidget toSize:newSize fromSize:oldSize];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
@ -1,108 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qmacdefines_mac.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
template <class Key, class T> class QHash;
|
||||
QT_END_NAMESPACE
|
||||
using QT_PREPEND_NAMESPACE(QHash);
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QSize)
|
||||
QT_FORWARD_DECLARE_CLASS(QWidgetData)
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5
|
||||
@protocol NSWindowDelegate <NSObject>
|
||||
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize;
|
||||
- (void)windowDidMiniaturize:(NSNotification*)notification;
|
||||
- (void)windowDidResize:(NSNotification *)notification;
|
||||
- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame;
|
||||
- (void)windowDidMove:(NSNotification *)notification;
|
||||
- (BOOL)windowShouldClose:(id)window;
|
||||
- (void)windowDidDeminiaturize:(NSNotification *)notification;
|
||||
- (void)windowDidBecomeMain:(NSNotification*)notification;
|
||||
- (void)windowDidResignMain:(NSNotification*)notification;
|
||||
- (void)windowDidBecomeKey:(NSNotification*)notification;
|
||||
- (void)windowDidResignKey:(NSNotification*)notification;
|
||||
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu;
|
||||
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard;
|
||||
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
|
||||
@end
|
||||
|
||||
@protocol NSDrawerDelegate <NSObject>
|
||||
- (NSSize)drawerWillResizeContents:(NSDrawer *)sender toSize:(NSSize)contentSize;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) : NSObject<NSWindowDelegate, NSDrawerDelegate> {
|
||||
QHash<NSWindow *, QWidget *> *m_windowHash;
|
||||
QHash<NSDrawer *, QWidget *> *m_drawerHash;
|
||||
}
|
||||
+ (QT_MANGLE_NAMESPACE(QCocoaWindowDelegate)*)sharedDelegate;
|
||||
- (void)becomeDelegteForWindow:(NSWindow *)window widget:(QWidget *)widget;
|
||||
- (void)resignDelegateForWindow:(NSWindow *)window;
|
||||
- (void)becomeDelegateForDrawer:(NSDrawer *)drawer widget:(QWidget *)widget;
|
||||
- (void)resignDelegateForDrawer:(NSDrawer *)drawer;
|
||||
- (void)dumpMaximizedStateforWidget:(QWidget*)qwidget window:(NSWindow *)window;
|
||||
- (void)syncSizeForWidget:(QWidget *)qwidget
|
||||
toSize:(const QSize &)newSize
|
||||
fromSize:(const QSize &)oldSize;
|
||||
- (NSSize)closestAcceptableSizeForWidget:(QWidget *)qwidget
|
||||
window:(NSWindow *)window withNewSize:(NSSize)proposedSize;
|
||||
- (QWidget *)qt_qwidgetForWindow:(NSWindow *)window;
|
||||
- (void)syncContentViewFrame: (NSNotification *)notification;
|
||||
@end
|
@ -1,111 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcolormap.h"
|
||||
#include "qcolor.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QColormapPrivate
|
||||
{
|
||||
public:
|
||||
inline QColormapPrivate()
|
||||
: ref(1)
|
||||
{ }
|
||||
|
||||
QAtomicInt ref;
|
||||
};
|
||||
static QColormap *qt_mac_global_map = 0;
|
||||
|
||||
void QColormap::initialize()
|
||||
{
|
||||
qt_mac_global_map = new QColormap;
|
||||
}
|
||||
|
||||
void QColormap::cleanup()
|
||||
{
|
||||
delete qt_mac_global_map;
|
||||
qt_mac_global_map = 0;
|
||||
}
|
||||
|
||||
QColormap QColormap::instance(int)
|
||||
{
|
||||
return *qt_mac_global_map;
|
||||
}
|
||||
|
||||
QColormap::QColormap() : d(new QColormapPrivate)
|
||||
{}
|
||||
|
||||
QColormap::QColormap(const QColormap &colormap) :d (colormap.d)
|
||||
{ d->ref.ref(); }
|
||||
|
||||
QColormap::~QColormap()
|
||||
{
|
||||
if (!d->ref.deref())
|
||||
delete d;
|
||||
}
|
||||
|
||||
QColormap::Mode QColormap::mode() const
|
||||
{ return QColormap::Direct; }
|
||||
|
||||
int QColormap::depth() const
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
int QColormap::size() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint QColormap::pixel(const QColor &color) const
|
||||
{ return color.rgba(); }
|
||||
|
||||
const QColor QColormap::colorAt(uint pixel) const
|
||||
{ return QColor(pixel); }
|
||||
|
||||
const QVector<QColor> QColormap::colormap() const
|
||||
{ return QVector<QColor>(); }
|
||||
|
||||
QColormap &QColormap::operator=(const QColormap &colormap)
|
||||
{ qAtomicAssign(d, colormap.d); return *this; }
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,257 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2007-2008, Apple, Inc.
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
**
|
||||
** * Redistributions in binary form must reproduce the above copyright notice,
|
||||
** this list of conditions and the following disclaimer in the documentation
|
||||
** and/or other materials provided with the distribution.
|
||||
**
|
||||
** * Neither the name of Apple, Inc. nor the names of its contributors
|
||||
** may be used to endorse or promote products derived from this software
|
||||
** without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "qapplication.h"
|
||||
#include "qdesktopwidget.h"
|
||||
#include <private/qt_mac_p.h>
|
||||
#include "qwidget_p.h"
|
||||
#include <private/qt_cocoa_helpers_mac_p.h>
|
||||
#include <private/qdesktopwidget_mac_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
/*****************************************************************************
|
||||
Externals
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
QDesktopWidget member functions
|
||||
*****************************************************************************/
|
||||
|
||||
Q_GLOBAL_STATIC(QDesktopWidgetImplementation, qdesktopWidgetImplementation)
|
||||
|
||||
QDesktopWidgetImplementation::QDesktopWidgetImplementation()
|
||||
: appScreen(0)
|
||||
{
|
||||
onResize();
|
||||
}
|
||||
|
||||
QDesktopWidgetImplementation::~QDesktopWidgetImplementation()
|
||||
{
|
||||
}
|
||||
|
||||
QDesktopWidgetImplementation *QDesktopWidgetImplementation::instance()
|
||||
{
|
||||
return qdesktopWidgetImplementation();
|
||||
}
|
||||
|
||||
QRect QDesktopWidgetImplementation::availableRect(int screenIndex) const
|
||||
{
|
||||
if (screenIndex < 0 || screenIndex >= screenCount)
|
||||
screenIndex = appScreen;
|
||||
|
||||
return availableRects[screenIndex].toRect();
|
||||
}
|
||||
|
||||
QRect QDesktopWidgetImplementation::screenRect(int screenIndex) const
|
||||
{
|
||||
if (screenIndex < 0 || screenIndex >= screenCount)
|
||||
screenIndex = appScreen;
|
||||
|
||||
return screenRects[screenIndex].toRect();
|
||||
}
|
||||
|
||||
void QDesktopWidgetImplementation::onResize()
|
||||
{
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
NSArray *displays = [NSScreen screens];
|
||||
screenCount = [displays count];
|
||||
|
||||
screenRects.clear();
|
||||
availableRects.clear();
|
||||
NSRect primaryRect = [[displays objectAtIndex:0] frame];
|
||||
for (int i = 0; i<screenCount; i++) {
|
||||
NSRect r = [[displays objectAtIndex:i] frame];
|
||||
int flippedY = - r.origin.y + // account for position offset and
|
||||
primaryRect.size.height - r.size.height; // height difference.
|
||||
screenRects.append(QRectF(r.origin.x, flippedY,
|
||||
r.size.width, r.size.height));
|
||||
|
||||
r = [[displays objectAtIndex:i] visibleFrame];
|
||||
flippedY = - r.origin.y + // account for position offset and
|
||||
primaryRect.size.height - r.size.height; // height difference.
|
||||
availableRects.append(QRectF(r.origin.x, flippedY,
|
||||
r.size.width, r.size.height));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
QDesktopWidget::QDesktopWidget()
|
||||
: QWidget(0, Qt::Desktop)
|
||||
{
|
||||
setObjectName(QLatin1String("desktop"));
|
||||
setAttribute(Qt::WA_WState_Visible);
|
||||
}
|
||||
|
||||
QDesktopWidget::~QDesktopWidget()
|
||||
{
|
||||
}
|
||||
|
||||
bool QDesktopWidget::isVirtualDesktop() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int QDesktopWidget::primaryScreen() const
|
||||
{
|
||||
return qdesktopWidgetImplementation()->appScreen;
|
||||
}
|
||||
|
||||
int QDesktopWidget::numScreens() const
|
||||
{
|
||||
return qdesktopWidgetImplementation()->screenCount;
|
||||
}
|
||||
|
||||
QWidget *QDesktopWidget::screen(int)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
const QRect QDesktopWidget::availableGeometry(int screen) const
|
||||
{
|
||||
return qdesktopWidgetImplementation()->availableRect(screen);
|
||||
}
|
||||
|
||||
const QRect QDesktopWidget::screenGeometry(int screen) const
|
||||
{
|
||||
return qdesktopWidgetImplementation()->screenRect(screen);
|
||||
}
|
||||
|
||||
int QDesktopWidget::screenNumber(const QWidget *widget) const
|
||||
{
|
||||
QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
|
||||
if (!widget)
|
||||
return d->appScreen;
|
||||
QRect frame = widget->frameGeometry();
|
||||
if (!widget->isWindow())
|
||||
frame.moveTopLeft(widget->mapToGlobal(QPoint(0,0)));
|
||||
int maxSize = -1, maxScreen = -1;
|
||||
for (int i = 0; i < d->screenCount; ++i) {
|
||||
QRect rr = d->screenRect(i);
|
||||
QRect sect = rr.intersected(frame);
|
||||
int size = sect.width() * sect.height();
|
||||
if (size > maxSize && sect.width() > 0 && sect.height() > 0) {
|
||||
maxSize = size;
|
||||
maxScreen = i;
|
||||
}
|
||||
}
|
||||
return maxScreen;
|
||||
}
|
||||
|
||||
int QDesktopWidget::screenNumber(const QPoint &point) const
|
||||
{
|
||||
QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
|
||||
int closestScreen = -1;
|
||||
int shortestDistance = INT_MAX;
|
||||
for (int i = 0; i < d->screenCount; ++i) {
|
||||
QRect rr = d->screenRect(i);
|
||||
int thisDistance = QWidgetPrivate::pointToRect(point, rr);
|
||||
if (thisDistance < shortestDistance) {
|
||||
shortestDistance = thisDistance;
|
||||
closestScreen = i;
|
||||
}
|
||||
}
|
||||
return closestScreen;
|
||||
}
|
||||
|
||||
void QDesktopWidget::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QDesktopWidgetImplementation *d = qdesktopWidgetImplementation();
|
||||
|
||||
const int oldScreenCount = d->screenCount;
|
||||
const QVector<QRectF> oldRects(d->screenRects);
|
||||
const QVector<QRectF> oldWorks(d->availableRects);
|
||||
|
||||
d->onResize();
|
||||
|
||||
for (int i = 0; i < qMin(oldScreenCount, d->screenCount); ++i) {
|
||||
if (oldRects.at(i) != d->screenRects.at(i))
|
||||
emit resized(i);
|
||||
}
|
||||
for (int i = 0; i < qMin(oldScreenCount, d->screenCount); ++i) {
|
||||
if (oldWorks.at(i) != d->availableRects.at(i))
|
||||
emit workAreaResized(i);
|
||||
}
|
||||
|
||||
if (oldScreenCount != d->screenCount)
|
||||
emit screenCountChanged(d->screenCount);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,75 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <qrect.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDesktopWidgetImplementation
|
||||
{
|
||||
public:
|
||||
QDesktopWidgetImplementation();
|
||||
~QDesktopWidgetImplementation();
|
||||
static QDesktopWidgetImplementation *instance();
|
||||
|
||||
int appScreen;
|
||||
int screenCount;
|
||||
|
||||
QVector<QRectF> availableRects;
|
||||
QVector<QRectF> screenRects;
|
||||
|
||||
QRect availableRect(int screenIndex) const;
|
||||
QRect screenRect(int screenIndex) const;
|
||||
void onResize();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,261 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qapplication.h"
|
||||
#ifndef QT_NO_DRAGANDDROP
|
||||
#include "qbitmap.h"
|
||||
#include "qcursor.h"
|
||||
#include "qevent.h"
|
||||
#include "qpainter.h"
|
||||
#include "qurl.h"
|
||||
#include "qwidget.h"
|
||||
#include "qfile.h"
|
||||
#include "qfileinfo.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
# include "qaccessible.h"
|
||||
#endif
|
||||
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qwidget_p.h>
|
||||
#include <private/qdnd_p.h>
|
||||
#include <private/qt_mac_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
QMacDndAnswerRecord qt_mac_dnd_answer_rec;
|
||||
|
||||
/*****************************************************************************
|
||||
QDnD debug facilities
|
||||
*****************************************************************************/
|
||||
//#define DEBUG_DRAG_EVENTS
|
||||
//#define DEBUG_DRAG_PROMISES
|
||||
|
||||
/*****************************************************************************
|
||||
QDnD globals
|
||||
*****************************************************************************/
|
||||
bool qt_mac_in_drag = false;
|
||||
|
||||
/*****************************************************************************
|
||||
Externals
|
||||
*****************************************************************************/
|
||||
extern void qt_mac_send_modifiers_changed(quint32, QObject *); //qapplication_mac.cpp
|
||||
extern uint qGlobalPostedEventsCount(); //qapplication.cpp
|
||||
extern RgnHandle qt_mac_get_rgn(); // qregion_mac.cpp
|
||||
extern void qt_mac_dispose_rgn(RgnHandle); // qregion_mac.cpp
|
||||
/*****************************************************************************
|
||||
QDnD utility functions
|
||||
*****************************************************************************/
|
||||
|
||||
//action management
|
||||
#ifdef DEBUG_DRAG_EVENTS
|
||||
# define MAP_MAC_ENUM(x) x, #x
|
||||
#else
|
||||
# define MAP_MAC_ENUM(x) x
|
||||
#endif
|
||||
struct mac_enum_mapper
|
||||
{
|
||||
int mac_code;
|
||||
int qt_code;
|
||||
#ifdef DEBUG_DRAG_EVENTS
|
||||
char *qt_desc;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
DnD functions
|
||||
*****************************************************************************/
|
||||
bool QDropData::hasFormat_sys(const QString &mime) const
|
||||
{
|
||||
Q_UNUSED(mime);
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant QDropData::retrieveData_sys(const QString &mime, QVariant::Type type) const
|
||||
{
|
||||
Q_UNUSED(mime);
|
||||
Q_UNUSED(type);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QStringList QDropData::formats_sys() const
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
void QDragManager::timerEvent(QTimerEvent*)
|
||||
{
|
||||
}
|
||||
|
||||
bool QDragManager::eventFilter(QObject *, QEvent *)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void QDragManager::updateCursor()
|
||||
{
|
||||
}
|
||||
|
||||
void QDragManager::cancel(bool)
|
||||
{
|
||||
if(object) {
|
||||
beingCancelled = true;
|
||||
object = 0;
|
||||
}
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
QAccessible::updateAccessibility(this, 0, QAccessible::DragDropEnd);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QDragManager::move(const QPoint &)
|
||||
{
|
||||
}
|
||||
|
||||
void QDragManager::drop()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
If a drop action is already set on the carbon event
|
||||
(from e.g. an earlier enter event), we insert the same
|
||||
action on the new Qt event that has yet to be sendt.
|
||||
*/
|
||||
static inline bool qt_mac_set_existing_drop_action(const DragRef &dragRef, QDropEvent &event)
|
||||
{
|
||||
Q_UNUSED(dragRef);
|
||||
Q_UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
If an answer rect has been set on the event (after being sent
|
||||
to the global event processor), we store that rect so we can
|
||||
check if the mouse is in the same area upon next drag move event.
|
||||
*/
|
||||
void qt_mac_copy_answer_rect(const QDragMoveEvent &event)
|
||||
{
|
||||
if (!event.answerRect().isEmpty()) {
|
||||
qt_mac_dnd_answer_rec.rect = event.answerRect();
|
||||
qt_mac_dnd_answer_rec.buttons = event.mouseButtons();
|
||||
qt_mac_dnd_answer_rec.modifiers = event.keyboardModifiers();
|
||||
qt_mac_dnd_answer_rec.lastAction = event.dropAction();
|
||||
}
|
||||
}
|
||||
|
||||
bool qt_mac_mouse_inside_answer_rect(QPoint mouse)
|
||||
{
|
||||
if (!qt_mac_dnd_answer_rec.rect.isEmpty()
|
||||
&& qt_mac_dnd_answer_rec.rect.contains(mouse)
|
||||
&& QApplication::mouseButtons() == qt_mac_dnd_answer_rec.buttons
|
||||
&& QApplication::keyboardModifiers() == qt_mac_dnd_answer_rec.modifiers)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QWidgetPrivate::qt_mac_dnd_event(uint kind, DragRef dragRef)
|
||||
{
|
||||
Q_UNUSED(kind);
|
||||
Q_UNUSED(dragRef);
|
||||
return false;
|
||||
}
|
||||
|
||||
void QDragManager::updatePixmap()
|
||||
{
|
||||
}
|
||||
|
||||
QCocoaDropData::QCocoaDropData(CFStringRef pasteboard)
|
||||
: QInternalMimeData()
|
||||
{
|
||||
NSString* pasteboardName = (NSString*)pasteboard;
|
||||
[pasteboardName retain];
|
||||
dropPasteboard = pasteboard;
|
||||
}
|
||||
|
||||
QCocoaDropData::~QCocoaDropData()
|
||||
{
|
||||
NSString* pasteboardName = (NSString*)dropPasteboard;
|
||||
[pasteboardName release];
|
||||
}
|
||||
|
||||
QStringList QCocoaDropData::formats_sys() const
|
||||
{
|
||||
QStringList formats;
|
||||
OSPasteboardRef board;
|
||||
if (PasteboardCreate(dropPasteboard, &board) != noErr) {
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return formats;
|
||||
}
|
||||
formats = QMacPasteboard(board, QMacPasteboardMime::MIME_DND).formats();
|
||||
return formats;
|
||||
}
|
||||
|
||||
QVariant QCocoaDropData::retrieveData_sys(const QString &mimeType, QVariant::Type type) const
|
||||
{
|
||||
QVariant data;
|
||||
OSPasteboardRef board;
|
||||
if (PasteboardCreate(dropPasteboard, &board) != noErr) {
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return data;
|
||||
}
|
||||
data = QMacPasteboard(board, QMacPasteboardMime::MIME_DND).retrieveData(mimeType, type);
|
||||
CFRelease(board);
|
||||
return data;
|
||||
}
|
||||
|
||||
bool QCocoaDropData::hasFormat_sys(const QString &mimeType) const
|
||||
{
|
||||
bool has = false;
|
||||
OSPasteboardRef board;
|
||||
if (PasteboardCreate(dropPasteboard, &board) != noErr) {
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return has;
|
||||
}
|
||||
has = QMacPasteboard(board, QMacPasteboardMime::MIME_DND).hasFormat(mimeType);
|
||||
CFRelease(board);
|
||||
return has;
|
||||
}
|
||||
|
||||
#endif // QT_NO_DRAGANDDROP
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
@ -1,218 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2007-2008, Apple, Inc.
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
**
|
||||
** * Redistributions in binary form must reproduce the above copyright notice,
|
||||
** this list of conditions and the following disclaimer in the documentation
|
||||
** and/or other materials provided with the distribution.
|
||||
**
|
||||
** * Neither the name of Apple, Inc. nor the names of its contributors
|
||||
** may be used to endorse or promote products derived from this software
|
||||
** without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QEVENTDISPATCHER_MAC_P_H
|
||||
#define QEVENTDISPATCHER_MAC_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtGui/qwindowdefs.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qstack.h>
|
||||
#include "private/qabstracteventdispatcher_p.h"
|
||||
#include "private/qt_mac_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef struct _NSModalSession *NSModalSession;
|
||||
typedef struct _QCocoaModalSessionInfo {
|
||||
QPointer<QWidget> widget;
|
||||
NSModalSession session;
|
||||
void *nswindow;
|
||||
} QCocoaModalSessionInfo;
|
||||
|
||||
class QEventDispatcherMacPrivate;
|
||||
|
||||
class QEventDispatcherMac : public QAbstractEventDispatcher
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QEventDispatcherMac)
|
||||
|
||||
public:
|
||||
explicit QEventDispatcherMac(QObject *parent = 0);
|
||||
~QEventDispatcherMac();
|
||||
|
||||
bool processEvents(QEventLoop::ProcessEventsFlags flags);
|
||||
bool hasPendingEvents();
|
||||
|
||||
void registerSocketNotifier(QSocketNotifier *notifier);
|
||||
void unregisterSocketNotifier(QSocketNotifier *notifier);
|
||||
|
||||
void registerTimer(int timerId, int interval, QObject *object);
|
||||
bool unregisterTimer(int timerId);
|
||||
bool unregisterTimers(QObject *object);
|
||||
QList<TimerInfo> registeredTimers(QObject *object) const;
|
||||
|
||||
void wakeUp();
|
||||
void flush();
|
||||
void interrupt();
|
||||
|
||||
private:
|
||||
friend void qt_mac_select_timer_callbk(__EventLoopTimer*, void*);
|
||||
friend class QApplicationPrivate;
|
||||
};
|
||||
|
||||
struct MacTimerInfo {
|
||||
int id;
|
||||
int interval;
|
||||
QObject *obj;
|
||||
bool pending;
|
||||
CFRunLoopTimerRef runLoopTimer;
|
||||
bool operator==(const MacTimerInfo &other) const
|
||||
{
|
||||
return (id == other.id);
|
||||
}
|
||||
};
|
||||
typedef QHash<int, MacTimerInfo *> MacTimerHash;
|
||||
|
||||
struct MacSocketInfo {
|
||||
MacSocketInfo() : socket(0), runloop(0), readNotifier(0), writeNotifier(0) {}
|
||||
CFSocketRef socket;
|
||||
CFRunLoopSourceRef runloop;
|
||||
QObject *readNotifier;
|
||||
QObject *writeNotifier;
|
||||
};
|
||||
typedef QHash<int, MacSocketInfo *> MacSocketHash;
|
||||
|
||||
class QEventDispatcherMacPrivate : public QAbstractEventDispatcherPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QEventDispatcherMac)
|
||||
|
||||
public:
|
||||
QEventDispatcherMacPrivate();
|
||||
|
||||
static MacTimerHash macTimerHash;
|
||||
// Set 'blockSendPostedEvents' to true if you _really_ need
|
||||
// to make sure that qt events are not posted while calling
|
||||
// low-level cocoa functions (like beginModalForWindow). And
|
||||
// use a QBoolBlocker to be safe:
|
||||
static bool blockSendPostedEvents;
|
||||
// The following variables help organizing modal sessions:
|
||||
static QStack<QCocoaModalSessionInfo> cocoaModalSessionStack;
|
||||
static bool currentExecIsNSAppRun;
|
||||
static bool nsAppRunCalledByQt;
|
||||
static bool cleanupModalSessionsNeeded;
|
||||
static NSModalSession currentModalSessionCached;
|
||||
static NSModalSession currentModalSession();
|
||||
static void updateChildrenWorksWhenModal();
|
||||
static void temporarilyStopAllModalSessions();
|
||||
static void beginModalSession(QWidget *widget);
|
||||
static void endModalSession(QWidget *widget);
|
||||
static void cancelWaitForMoreEvents();
|
||||
static void cleanupModalSessions();
|
||||
static void ensureNSAppInitialized();
|
||||
|
||||
MacSocketHash macSockets;
|
||||
QList<void *> queuedUserInputEvents; // List of EventRef in Carbon, and NSEvent * in Cocoa
|
||||
CFRunLoopSourceRef postedEventsSource;
|
||||
CFRunLoopObserverRef waitingObserver;
|
||||
CFRunLoopObserverRef firstTimeObserver;
|
||||
QAtomicInt serialNumber;
|
||||
int lastSerial;
|
||||
static bool interrupt;
|
||||
private:
|
||||
static Boolean postedEventSourceEqualCallback(const void *info1, const void *info2);
|
||||
static void postedEventsSourcePerformCallback(void *info);
|
||||
static void activateTimer(CFRunLoopTimerRef, void *info);
|
||||
static void waitingObserverCallback(CFRunLoopObserverRef observer,
|
||||
CFRunLoopActivity activity, void *info);
|
||||
static void firstLoopEntry(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info);
|
||||
};
|
||||
|
||||
class QtMacInterruptDispatcherHelp : public QObject
|
||||
{
|
||||
static QtMacInterruptDispatcherHelp *instance;
|
||||
bool cancelled;
|
||||
|
||||
QtMacInterruptDispatcherHelp();
|
||||
~QtMacInterruptDispatcherHelp();
|
||||
|
||||
public:
|
||||
static void interruptLater();
|
||||
static void cancelInterruptLater();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QEVENTDISPATCHER_MAC_P_H
|
@ -1,963 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qt_mac_p.h>
|
||||
#include <qdebug.h>
|
||||
#include <qevent.h>
|
||||
#include <private/qevent_p.h>
|
||||
#include <qtextcodec.h>
|
||||
#include <qapplication.h>
|
||||
#include <qinputcontext.h>
|
||||
#include <private/qkeymapper_p.h>
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qmacinputcontext_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
/*****************************************************************************
|
||||
QKeyMapper debug facilities
|
||||
*****************************************************************************/
|
||||
//#define DEBUG_KEY_BINDINGS
|
||||
//#define DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
//#define DEBUG_KEY_MAPS
|
||||
|
||||
/*****************************************************************************
|
||||
Internal variables and functions
|
||||
*****************************************************************************/
|
||||
bool qt_mac_eat_unicode_key = false;
|
||||
extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); //qapplication_mac.cpp
|
||||
|
||||
Q_WIDGETS_EXPORT void qt_mac_secure_keyboard(bool b)
|
||||
{
|
||||
static bool secure = false;
|
||||
if (b != secure){
|
||||
b ? EnableSecureEventInput() : DisableSecureEventInput();
|
||||
secure = b;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
\internal
|
||||
A Mac KeyboardLayoutItem has 8 possible states:
|
||||
1. Unmodified
|
||||
2. Shift
|
||||
3. Control
|
||||
4. Control + Shift
|
||||
5. Alt
|
||||
6. Alt + Shift
|
||||
7. Alt + Control
|
||||
8. Alt + Control + Shift
|
||||
9. Meta
|
||||
10. Meta + Shift
|
||||
11. Meta + Control
|
||||
12. Meta + Control + Shift
|
||||
13. Meta + Alt
|
||||
14. Meta + Alt + Shift
|
||||
15. Meta + Alt + Control
|
||||
16. Meta + Alt + Control + Shift
|
||||
*/
|
||||
struct KeyboardLayoutItem {
|
||||
bool dirty;
|
||||
quint32 qtKey[16]; // Can by any Qt::Key_<foo>, or unicode character
|
||||
};
|
||||
|
||||
// Possible modifier states.
|
||||
// NOTE: The order of these states match the order in QKeyMapperPrivate::updatePossibleKeyCodes()!
|
||||
static const Qt::KeyboardModifiers ModsTbl[] = {
|
||||
Qt::NoModifier, // 0
|
||||
Qt::ShiftModifier, // 1
|
||||
Qt::ControlModifier, // 2
|
||||
Qt::ControlModifier | Qt::ShiftModifier, // 3
|
||||
Qt::AltModifier, // 4
|
||||
Qt::AltModifier | Qt::ShiftModifier, // 5
|
||||
Qt::AltModifier | Qt::ControlModifier, // 6
|
||||
Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier, // 7
|
||||
Qt::MetaModifier, // 8
|
||||
Qt::MetaModifier | Qt::ShiftModifier, // 9
|
||||
Qt::MetaModifier | Qt::ControlModifier, // 10
|
||||
Qt::MetaModifier | Qt::ControlModifier | Qt::ShiftModifier,// 11
|
||||
Qt::MetaModifier | Qt::AltModifier, // 12
|
||||
Qt::MetaModifier | Qt::AltModifier | Qt::ShiftModifier, // 13
|
||||
Qt::MetaModifier | Qt::AltModifier | Qt::ControlModifier, // 14
|
||||
Qt::MetaModifier | Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier, // 15
|
||||
};
|
||||
|
||||
/* key maps */
|
||||
struct qt_mac_enum_mapper
|
||||
{
|
||||
int mac_code;
|
||||
int qt_code;
|
||||
#if defined(DEBUG_KEY_BINDINGS)
|
||||
# define QT_MAC_MAP_ENUM(x) x, #x
|
||||
const char *desc;
|
||||
#else
|
||||
# define QT_MAC_MAP_ENUM(x) x
|
||||
#endif
|
||||
};
|
||||
|
||||
//modifiers
|
||||
static qt_mac_enum_mapper qt_mac_modifier_symbols[] = {
|
||||
{ shiftKey, QT_MAC_MAP_ENUM(Qt::ShiftModifier) },
|
||||
{ rightShiftKey, QT_MAC_MAP_ENUM(Qt::ShiftModifier) },
|
||||
{ controlKey, QT_MAC_MAP_ENUM(Qt::MetaModifier) },
|
||||
{ rightControlKey, QT_MAC_MAP_ENUM(Qt::MetaModifier) },
|
||||
{ cmdKey, QT_MAC_MAP_ENUM(Qt::ControlModifier) },
|
||||
{ optionKey, QT_MAC_MAP_ENUM(Qt::AltModifier) },
|
||||
{ rightOptionKey, QT_MAC_MAP_ENUM(Qt::AltModifier) },
|
||||
{ kEventKeyModifierNumLockMask, QT_MAC_MAP_ENUM(Qt::KeypadModifier) },
|
||||
{ 0, QT_MAC_MAP_ENUM(0) }
|
||||
};
|
||||
Qt::KeyboardModifiers qt_mac_get_modifiers(int keys)
|
||||
{
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("Qt: internal: **Mapping modifiers: %d (0x%04x)", keys, keys);
|
||||
#endif
|
||||
Qt::KeyboardModifiers ret = Qt::NoModifier;
|
||||
for (int i = 0; qt_mac_modifier_symbols[i].qt_code; i++) {
|
||||
if (keys & qt_mac_modifier_symbols[i].mac_code) {
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("Qt: internal: got modifier: %s", qt_mac_modifier_symbols[i].desc);
|
||||
#endif
|
||||
ret |= Qt::KeyboardModifier(qt_mac_modifier_symbols[i].qt_code);
|
||||
}
|
||||
}
|
||||
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
|
||||
Qt::KeyboardModifiers oldModifiers = ret;
|
||||
ret &= ~(Qt::MetaModifier | Qt::ControlModifier);
|
||||
if (oldModifiers & Qt::ControlModifier)
|
||||
ret |= Qt::MetaModifier;
|
||||
if (oldModifiers & Qt::MetaModifier)
|
||||
ret |= Qt::ControlModifier;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
static int qt_mac_get_mac_modifiers(Qt::KeyboardModifiers keys)
|
||||
{
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("Qt: internal: **Mapping modifiers: %d (0x%04x)", (int)keys, (int)keys);
|
||||
#endif
|
||||
int ret = 0;
|
||||
for (int i = 0; qt_mac_modifier_symbols[i].qt_code; i++) {
|
||||
if (keys & qt_mac_modifier_symbols[i].qt_code) {
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("Qt: internal: got modifier: %s", qt_mac_modifier_symbols[i].desc);
|
||||
#endif
|
||||
ret |= qt_mac_modifier_symbols[i].mac_code;
|
||||
}
|
||||
}
|
||||
|
||||
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
|
||||
int oldModifiers = ret;
|
||||
ret &= ~(controlKeyBit | cmdKeyBit);
|
||||
if (oldModifiers & controlKeyBit)
|
||||
ret |= cmdKeyBit;
|
||||
if (oldModifiers & cmdKeyBit)
|
||||
ret |= controlKeyBit;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object)
|
||||
{
|
||||
static quint32 cachedModifiers = 0;
|
||||
quint32 lastModifiers = cachedModifiers,
|
||||
changedModifiers = lastModifiers ^ modifiers;
|
||||
cachedModifiers = modifiers;
|
||||
|
||||
//check the bits
|
||||
static qt_mac_enum_mapper modifier_key_symbols[] = {
|
||||
{ shiftKeyBit, QT_MAC_MAP_ENUM(Qt::Key_Shift) },
|
||||
{ rightShiftKeyBit, QT_MAC_MAP_ENUM(Qt::Key_Shift) }, //???
|
||||
{ controlKeyBit, QT_MAC_MAP_ENUM(Qt::Key_Meta) },
|
||||
{ rightControlKeyBit, QT_MAC_MAP_ENUM(Qt::Key_Meta) }, //???
|
||||
{ cmdKeyBit, QT_MAC_MAP_ENUM(Qt::Key_Control) },
|
||||
{ optionKeyBit, QT_MAC_MAP_ENUM(Qt::Key_Alt) },
|
||||
{ rightOptionKeyBit, QT_MAC_MAP_ENUM(Qt::Key_Alt) }, //???
|
||||
{ alphaLockBit, QT_MAC_MAP_ENUM(Qt::Key_CapsLock) },
|
||||
{ kEventKeyModifierNumLockBit, QT_MAC_MAP_ENUM(Qt::Key_NumLock) },
|
||||
{ 0, QT_MAC_MAP_ENUM(0) } };
|
||||
for (int i = 0; i <= 32; i++) { //just check each bit
|
||||
if (!(changedModifiers & (1 << i)))
|
||||
continue;
|
||||
QEvent::Type etype = QEvent::KeyPress;
|
||||
if (lastModifiers & (1 << i))
|
||||
etype = QEvent::KeyRelease;
|
||||
int key = 0;
|
||||
for (uint x = 0; modifier_key_symbols[x].mac_code; x++) {
|
||||
if (modifier_key_symbols[x].mac_code == i) {
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("got modifier changed: %s", modifier_key_symbols[x].desc);
|
||||
#endif
|
||||
key = modifier_key_symbols[x].qt_code;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!key) {
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("could not get modifier changed: %d", i);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("KeyEvent (modif): Sending %s to %s::%s: %d - 0x%08x",
|
||||
etype == QEvent::KeyRelease ? "KeyRelease" : "KeyPress",
|
||||
object ? object->metaObject()->className() : "none",
|
||||
object ? object->objectName().toLatin1().constData() : "",
|
||||
key, (int)modifiers);
|
||||
#endif
|
||||
QKeyEvent ke(etype, key, qt_mac_get_modifiers(modifiers ^ (1 << i)), QLatin1String(""));
|
||||
qt_sendSpontaneousEvent(object, &ke);
|
||||
}
|
||||
}
|
||||
|
||||
//keyboard keys (non-modifiers)
|
||||
static qt_mac_enum_mapper qt_mac_keyboard_symbols[] = {
|
||||
{ kHomeCharCode, QT_MAC_MAP_ENUM(Qt::Key_Home) },
|
||||
{ kEnterCharCode, QT_MAC_MAP_ENUM(Qt::Key_Enter) },
|
||||
{ kEndCharCode, QT_MAC_MAP_ENUM(Qt::Key_End) },
|
||||
{ kBackspaceCharCode, QT_MAC_MAP_ENUM(Qt::Key_Backspace) },
|
||||
{ kTabCharCode, QT_MAC_MAP_ENUM(Qt::Key_Tab) },
|
||||
{ kPageUpCharCode, QT_MAC_MAP_ENUM(Qt::Key_PageUp) },
|
||||
{ kPageDownCharCode, QT_MAC_MAP_ENUM(Qt::Key_PageDown) },
|
||||
{ kReturnCharCode, QT_MAC_MAP_ENUM(Qt::Key_Return) },
|
||||
{ kEscapeCharCode, QT_MAC_MAP_ENUM(Qt::Key_Escape) },
|
||||
{ kLeftArrowCharCode, QT_MAC_MAP_ENUM(Qt::Key_Left) },
|
||||
{ kRightArrowCharCode, QT_MAC_MAP_ENUM(Qt::Key_Right) },
|
||||
{ kUpArrowCharCode, QT_MAC_MAP_ENUM(Qt::Key_Up) },
|
||||
{ kDownArrowCharCode, QT_MAC_MAP_ENUM(Qt::Key_Down) },
|
||||
{ kHelpCharCode, QT_MAC_MAP_ENUM(Qt::Key_Help) },
|
||||
{ kDeleteCharCode, QT_MAC_MAP_ENUM(Qt::Key_Delete) },
|
||||
//ascii maps, for debug
|
||||
{ ':', QT_MAC_MAP_ENUM(Qt::Key_Colon) },
|
||||
{ ';', QT_MAC_MAP_ENUM(Qt::Key_Semicolon) },
|
||||
{ '<', QT_MAC_MAP_ENUM(Qt::Key_Less) },
|
||||
{ '=', QT_MAC_MAP_ENUM(Qt::Key_Equal) },
|
||||
{ '>', QT_MAC_MAP_ENUM(Qt::Key_Greater) },
|
||||
{ '?', QT_MAC_MAP_ENUM(Qt::Key_Question) },
|
||||
{ '@', QT_MAC_MAP_ENUM(Qt::Key_At) },
|
||||
{ ' ', QT_MAC_MAP_ENUM(Qt::Key_Space) },
|
||||
{ '!', QT_MAC_MAP_ENUM(Qt::Key_Exclam) },
|
||||
{ '"', QT_MAC_MAP_ENUM(Qt::Key_QuoteDbl) },
|
||||
{ '#', QT_MAC_MAP_ENUM(Qt::Key_NumberSign) },
|
||||
{ '$', QT_MAC_MAP_ENUM(Qt::Key_Dollar) },
|
||||
{ '%', QT_MAC_MAP_ENUM(Qt::Key_Percent) },
|
||||
{ '&', QT_MAC_MAP_ENUM(Qt::Key_Ampersand) },
|
||||
{ '\'', QT_MAC_MAP_ENUM(Qt::Key_Apostrophe) },
|
||||
{ '(', QT_MAC_MAP_ENUM(Qt::Key_ParenLeft) },
|
||||
{ ')', QT_MAC_MAP_ENUM(Qt::Key_ParenRight) },
|
||||
{ '*', QT_MAC_MAP_ENUM(Qt::Key_Asterisk) },
|
||||
{ '+', QT_MAC_MAP_ENUM(Qt::Key_Plus) },
|
||||
{ ',', QT_MAC_MAP_ENUM(Qt::Key_Comma) },
|
||||
{ '-', QT_MAC_MAP_ENUM(Qt::Key_Minus) },
|
||||
{ '.', QT_MAC_MAP_ENUM(Qt::Key_Period) },
|
||||
{ '/', QT_MAC_MAP_ENUM(Qt::Key_Slash) },
|
||||
{ '[', QT_MAC_MAP_ENUM(Qt::Key_BracketLeft) },
|
||||
{ ']', QT_MAC_MAP_ENUM(Qt::Key_BracketRight) },
|
||||
{ '\\', QT_MAC_MAP_ENUM(Qt::Key_Backslash) },
|
||||
{ '_', QT_MAC_MAP_ENUM(Qt::Key_Underscore) },
|
||||
{ '`', QT_MAC_MAP_ENUM(Qt::Key_QuoteLeft) },
|
||||
{ '{', QT_MAC_MAP_ENUM(Qt::Key_BraceLeft) },
|
||||
{ '}', QT_MAC_MAP_ENUM(Qt::Key_BraceRight) },
|
||||
{ '|', QT_MAC_MAP_ENUM(Qt::Key_Bar) },
|
||||
{ '~', QT_MAC_MAP_ENUM(Qt::Key_AsciiTilde) },
|
||||
{ '^', QT_MAC_MAP_ENUM(Qt::Key_AsciiCircum) },
|
||||
{ 0, QT_MAC_MAP_ENUM(0) }
|
||||
};
|
||||
|
||||
static qt_mac_enum_mapper qt_mac_keyvkey_symbols[] = { //real scan codes
|
||||
{ 122, QT_MAC_MAP_ENUM(Qt::Key_F1) },
|
||||
{ 120, QT_MAC_MAP_ENUM(Qt::Key_F2) },
|
||||
{ 99, QT_MAC_MAP_ENUM(Qt::Key_F3) },
|
||||
{ 118, QT_MAC_MAP_ENUM(Qt::Key_F4) },
|
||||
{ 96, QT_MAC_MAP_ENUM(Qt::Key_F5) },
|
||||
{ 97, QT_MAC_MAP_ENUM(Qt::Key_F6) },
|
||||
{ 98, QT_MAC_MAP_ENUM(Qt::Key_F7) },
|
||||
{ 100, QT_MAC_MAP_ENUM(Qt::Key_F8) },
|
||||
{ 101, QT_MAC_MAP_ENUM(Qt::Key_F9) },
|
||||
{ 109, QT_MAC_MAP_ENUM(Qt::Key_F10) },
|
||||
{ 103, QT_MAC_MAP_ENUM(Qt::Key_F11) },
|
||||
{ 111, QT_MAC_MAP_ENUM(Qt::Key_F12) },
|
||||
{ 105, QT_MAC_MAP_ENUM(Qt::Key_F13) },
|
||||
{ 107, QT_MAC_MAP_ENUM(Qt::Key_F14) },
|
||||
{ 113, QT_MAC_MAP_ENUM(Qt::Key_F15) },
|
||||
{ 106, QT_MAC_MAP_ENUM(Qt::Key_F16) },
|
||||
{ 0, QT_MAC_MAP_ENUM(0) }
|
||||
};
|
||||
|
||||
static qt_mac_enum_mapper qt_mac_private_unicode[] = {
|
||||
{ 0xF700, QT_MAC_MAP_ENUM(Qt::Key_Up) }, //NSUpArrowFunctionKey
|
||||
{ 0xF701, QT_MAC_MAP_ENUM(Qt::Key_Down) }, //NSDownArrowFunctionKey
|
||||
{ 0xF702, QT_MAC_MAP_ENUM(Qt::Key_Left) }, //NSLeftArrowFunctionKey
|
||||
{ 0xF703, QT_MAC_MAP_ENUM(Qt::Key_Right) }, //NSRightArrowFunctionKey
|
||||
{ 0xF727, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertFunctionKey
|
||||
{ 0xF728, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteFunctionKey
|
||||
{ 0xF729, QT_MAC_MAP_ENUM(Qt::Key_Home) }, //NSHomeFunctionKey
|
||||
{ 0xF72B, QT_MAC_MAP_ENUM(Qt::Key_End) }, //NSEndFunctionKey
|
||||
{ 0xF72C, QT_MAC_MAP_ENUM(Qt::Key_PageUp) }, //NSPageUpFunctionKey
|
||||
{ 0xF72D, QT_MAC_MAP_ENUM(Qt::Key_PageDown) }, //NSPageDownFunctionKey
|
||||
{ 0xF72F, QT_MAC_MAP_ENUM(Qt::Key_ScrollLock) }, //NSScrollLockFunctionKey
|
||||
{ 0xF730, QT_MAC_MAP_ENUM(Qt::Key_Pause) }, //NSPauseFunctionKey
|
||||
{ 0xF731, QT_MAC_MAP_ENUM(Qt::Key_SysReq) }, //NSSysReqFunctionKey
|
||||
{ 0xF735, QT_MAC_MAP_ENUM(Qt::Key_Menu) }, //NSMenuFunctionKey
|
||||
{ 0xF738, QT_MAC_MAP_ENUM(Qt::Key_Print) }, //NSPrintFunctionKey
|
||||
{ 0xF73A, QT_MAC_MAP_ENUM(Qt::Key_Clear) }, //NSClearDisplayFunctionKey
|
||||
{ 0xF73D, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertCharFunctionKey
|
||||
{ 0xF73E, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteCharFunctionKey
|
||||
{ 0xF741, QT_MAC_MAP_ENUM(Qt::Key_Select) }, //NSSelectFunctionKey
|
||||
{ 0xF742, QT_MAC_MAP_ENUM(Qt::Key_Execute) }, //NSExecuteFunctionKey
|
||||
{ 0xF746, QT_MAC_MAP_ENUM(Qt::Key_Help) }, //NSHelpFunctionKey
|
||||
{ 0xF747, QT_MAC_MAP_ENUM(Qt::Key_Mode_switch) }, //NSModeSwitchFunctionKey
|
||||
{ 0, QT_MAC_MAP_ENUM(0) }
|
||||
};
|
||||
|
||||
static int qt_mac_get_key(int modif, const QChar &key, int virtualKey)
|
||||
{
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("**Mapping key: %d (0x%04x) - %d (0x%04x)", key.unicode(), key.unicode(), virtualKey, virtualKey);
|
||||
#endif
|
||||
|
||||
if (key == kClearCharCode && virtualKey == 0x47)
|
||||
return Qt::Key_Clear;
|
||||
|
||||
if (key.isDigit()) {
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("%d: got key: %d", __LINE__, key.digitValue());
|
||||
#endif
|
||||
return key.digitValue() + Qt::Key_0;
|
||||
}
|
||||
|
||||
if (key.isLetter()) {
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("%d: got key: %d", __LINE__, (key.toUpper().unicode() - 'A'));
|
||||
#endif
|
||||
return (key.toUpper().unicode() - 'A') + Qt::Key_A;
|
||||
}
|
||||
if (key.isSymbol()) {
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("%d: got key: %d", __LINE__, (key.unicode()));
|
||||
#endif
|
||||
return key.unicode();
|
||||
}
|
||||
|
||||
for (int i = 0; qt_mac_keyboard_symbols[i].qt_code; i++) {
|
||||
if (qt_mac_keyboard_symbols[i].mac_code == key) {
|
||||
/* To work like Qt for X11 we issue Backtab when Shift + Tab are pressed */
|
||||
if (qt_mac_keyboard_symbols[i].qt_code == Qt::Key_Tab && (modif & Qt::ShiftModifier)) {
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("%d: got key: Qt::Key_Backtab", __LINE__);
|
||||
#endif
|
||||
return Qt::Key_Backtab;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("%d: got key: %s", __LINE__, qt_mac_keyboard_symbols[i].desc);
|
||||
#endif
|
||||
return qt_mac_keyboard_symbols[i].qt_code;
|
||||
}
|
||||
}
|
||||
|
||||
//last ditch try to match the scan code
|
||||
for (int i = 0; qt_mac_keyvkey_symbols[i].qt_code; i++) {
|
||||
if (qt_mac_keyvkey_symbols[i].mac_code == virtualKey) {
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("%d: got key: %s", __LINE__, qt_mac_keyvkey_symbols[i].desc);
|
||||
#endif
|
||||
return qt_mac_keyvkey_symbols[i].qt_code;
|
||||
}
|
||||
}
|
||||
|
||||
// check if they belong to key codes in private unicode range
|
||||
if (key >= 0xf700 && key <= 0xf747) {
|
||||
if (key >= 0xf704 && key <= 0xf726) {
|
||||
return Qt::Key_F1 + (key.unicode() - 0xf704) ;
|
||||
}
|
||||
for (int i = 0; qt_mac_private_unicode[i].qt_code; i++) {
|
||||
if (qt_mac_private_unicode[i].mac_code == key) {
|
||||
return qt_mac_private_unicode[i].qt_code;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//oh well
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("Unknown case.. %s:%d %d[%d] %d", __FILE__, __LINE__, key.unicode(), key.toLatin1(), virtualKey);
|
||||
#endif
|
||||
return Qt::Key_unknown;
|
||||
}
|
||||
|
||||
static Boolean qt_KeyEventComparatorProc(EventRef inEvent, void *data)
|
||||
{
|
||||
UInt32 ekind = GetEventKind(inEvent),
|
||||
eclass = GetEventClass(inEvent);
|
||||
return (eclass == kEventClassKeyboard && (void *)ekind == data);
|
||||
}
|
||||
|
||||
static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent, int *qtKey,
|
||||
QChar *outChar, Qt::KeyboardModifiers *outModifiers, bool *outHandled)
|
||||
{
|
||||
const UInt32 ekind = GetEventKind(keyEvent);
|
||||
{
|
||||
UInt32 mac_modifiers = 0;
|
||||
GetEventParameter(keyEvent, kEventParamKeyModifiers, typeUInt32, 0,
|
||||
sizeof(mac_modifiers), 0, &mac_modifiers);
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("************ Mapping modifiers and key ***********");
|
||||
#endif
|
||||
*outModifiers = qt_mac_get_modifiers(mac_modifiers);
|
||||
#ifdef DEBUG_KEY_BINDINGS_MODIFIERS
|
||||
qDebug("------------ Mapping modifiers and key -----------");
|
||||
#endif
|
||||
}
|
||||
|
||||
//get keycode
|
||||
UInt32 keyCode = 0;
|
||||
GetEventParameter(keyEvent, kEventParamKeyCode, typeUInt32, 0, sizeof(keyCode), 0, &keyCode);
|
||||
|
||||
//get mac mapping
|
||||
static UInt32 tmp_unused_state = 0L;
|
||||
const UCKeyboardLayout *uchrData = 0;
|
||||
#if defined(Q_OS_MAC32)
|
||||
KeyboardLayoutRef keyLayoutRef = 0;
|
||||
KLGetCurrentKeyboardLayout(&keyLayoutRef);
|
||||
OSStatus err;
|
||||
if (keyLayoutRef != 0) {
|
||||
err = KLGetKeyboardLayoutProperty(keyLayoutRef, kKLuchrData,
|
||||
(reinterpret_cast<const void **>(&uchrData)));
|
||||
if (err != noErr) {
|
||||
qWarning("Qt::internal::unable to get keyboardlayout %ld %s:%d",
|
||||
long(err), __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
#else
|
||||
QCFType<TISInputSourceRef> inputSource = TISCopyCurrentKeyboardInputSource();
|
||||
Q_ASSERT(inputSource != 0);
|
||||
CFDataRef data = static_cast<CFDataRef>(TISGetInputSourceProperty(inputSource,
|
||||
kTISPropertyUnicodeKeyLayoutData));
|
||||
uchrData = data ? reinterpret_cast<const UCKeyboardLayout *>(CFDataGetBytePtr(data)) : 0;
|
||||
#endif
|
||||
*qtKey = Qt::Key_unknown;
|
||||
if (uchrData) {
|
||||
// The easy stuff; use the unicode stuff!
|
||||
UniChar string[4];
|
||||
UniCharCount actualLength;
|
||||
UInt32 currentModifiers = GetCurrentEventKeyModifiers();
|
||||
UInt32 currentModifiersWOAltOrControl = currentModifiers & ~(controlKey | optionKey);
|
||||
int keyAction;
|
||||
switch (ekind) {
|
||||
default:
|
||||
case kEventRawKeyDown:
|
||||
keyAction = kUCKeyActionDown;
|
||||
break;
|
||||
case kEventRawKeyUp:
|
||||
keyAction = kUCKeyActionUp;
|
||||
break;
|
||||
case kEventRawKeyRepeat:
|
||||
keyAction = kUCKeyActionAutoKey;
|
||||
break;
|
||||
}
|
||||
OSStatus err = UCKeyTranslate(uchrData, keyCode, keyAction,
|
||||
((currentModifiersWOAltOrControl >> 8) & 0xff), LMGetKbdType(),
|
||||
kUCKeyTranslateNoDeadKeysMask, &tmp_unused_state, 4, &actualLength,
|
||||
string);
|
||||
if (err == noErr) {
|
||||
*outChar = QChar(string[0]);
|
||||
*qtKey = qt_mac_get_key(*outModifiers, *outChar, keyCode);
|
||||
if (currentModifiersWOAltOrControl != currentModifiers) {
|
||||
// Now get the real char.
|
||||
err = UCKeyTranslate(uchrData, keyCode, keyAction,
|
||||
((currentModifiers >> 8) & 0xff), LMGetKbdType(),
|
||||
kUCKeyTranslateNoDeadKeysMask, &tmp_unused_state, 4, &actualLength,
|
||||
string);
|
||||
if (err == noErr)
|
||||
*outChar = QChar(string[0]);
|
||||
}
|
||||
} else {
|
||||
qWarning("Qt::internal::UCKeyTranslate is returnining %ld %s:%d",
|
||||
long(err), __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
#ifdef Q_OS_MAC32
|
||||
else {
|
||||
// The road less travelled; use KeyTranslate
|
||||
const void *keyboard_layout;
|
||||
KeyboardLayoutRef keyLayoutRef = 0;
|
||||
KLGetCurrentKeyboardLayout(&keyLayoutRef);
|
||||
err = KLGetKeyboardLayoutProperty(keyLayoutRef, kKLKCHRData,
|
||||
reinterpret_cast<const void **>(&keyboard_layout));
|
||||
|
||||
int translatedChar = KeyTranslate(keyboard_layout, (GetCurrentEventKeyModifiers() &
|
||||
(kEventKeyModifierNumLockMask|shiftKey|cmdKey|
|
||||
rightShiftKey|alphaLock)) | keyCode,
|
||||
&tmp_unused_state);
|
||||
if (!translatedChar) {
|
||||
if (outHandled) {
|
||||
qt_mac_eat_unicode_key = false;
|
||||
if (er)
|
||||
CallNextEventHandler(er, keyEvent);
|
||||
*outHandled = qt_mac_eat_unicode_key;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//map it into qt keys
|
||||
*qtKey = qt_mac_get_key(*outModifiers, QChar(translatedChar), keyCode);
|
||||
if (*outModifiers & (Qt::AltModifier | Qt::ControlModifier)) {
|
||||
if (translatedChar & (1 << 7)) //high ascii
|
||||
translatedChar = 0;
|
||||
} else { //now get the real ascii value
|
||||
UInt32 tmp_mod = 0L;
|
||||
static UInt32 tmp_state = 0L;
|
||||
if (*outModifiers & Qt::ShiftModifier)
|
||||
tmp_mod |= shiftKey;
|
||||
if (*outModifiers & Qt::MetaModifier)
|
||||
tmp_mod |= controlKey;
|
||||
if (*outModifiers & Qt::ControlModifier)
|
||||
tmp_mod |= cmdKey;
|
||||
if (GetCurrentEventKeyModifiers() & alphaLock) //no Qt mapper
|
||||
tmp_mod |= alphaLock;
|
||||
if (*outModifiers & Qt::AltModifier)
|
||||
tmp_mod |= optionKey;
|
||||
if (*outModifiers & Qt::KeypadModifier)
|
||||
tmp_mod |= kEventKeyModifierNumLockMask;
|
||||
translatedChar = KeyTranslate(keyboard_layout, tmp_mod | keyCode, &tmp_state);
|
||||
}
|
||||
{
|
||||
ByteCount unilen = 0;
|
||||
if (GetEventParameter(keyEvent, kEventParamKeyUnicodes, typeUnicodeText, 0, 0, &unilen, 0)
|
||||
== noErr && unilen == 2) {
|
||||
GetEventParameter(keyEvent, kEventParamKeyUnicodes, typeUnicodeText, 0, unilen, 0, outChar);
|
||||
} else if (translatedChar) {
|
||||
static QTextCodec *c = 0;
|
||||
if (!c)
|
||||
c = QTextCodec::codecForName("Apple Roman");
|
||||
char tmpChar = (char)translatedChar; // **sigh**
|
||||
*outChar = c->toUnicode(&tmpChar, 1).at(0);
|
||||
} else {
|
||||
*qtKey = qt_mac_get_key(*outModifiers, QChar(translatedChar), keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (*qtKey == Qt::Key_unknown)
|
||||
*qtKey = qt_mac_get_key(*outModifiers, *outChar, keyCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
QKeyMapperPrivate::QKeyMapperPrivate()
|
||||
{
|
||||
memset(keyLayout, 0, sizeof(keyLayout));
|
||||
keyboard_layout_format.unicode = 0;
|
||||
#ifdef Q_OS_MAC32
|
||||
keyboard_mode = NullMode;
|
||||
#else
|
||||
currentInputSource = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
QKeyMapperPrivate::~QKeyMapperPrivate()
|
||||
{
|
||||
deleteLayouts();
|
||||
}
|
||||
|
||||
bool
|
||||
QKeyMapperPrivate::updateKeyboard()
|
||||
{
|
||||
const UCKeyboardLayout *uchrData = 0;
|
||||
#ifdef Q_OS_MAC32
|
||||
KeyboardLayoutRef keyLayoutRef = 0;
|
||||
KLGetCurrentKeyboardLayout(&keyLayoutRef);
|
||||
|
||||
if (keyboard_mode != NullMode && currentKeyboardLayout == keyLayoutRef)
|
||||
return false;
|
||||
|
||||
OSStatus err;
|
||||
if (keyLayoutRef != 0) {
|
||||
err = KLGetKeyboardLayoutProperty(keyLayoutRef, kKLuchrData,
|
||||
const_cast<const void **>(reinterpret_cast<const void **>(&uchrData)));
|
||||
if (err != noErr) {
|
||||
qWarning("Qt::internal::unable to get unicode keyboardlayout %ld %s:%d",
|
||||
long(err), __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
#else
|
||||
QCFType<TISInputSourceRef> source = TISCopyCurrentKeyboardInputSource();
|
||||
if (keyboard_mode != NullMode && source == currentInputSource) {
|
||||
return false;
|
||||
}
|
||||
Q_ASSERT(source != 0);
|
||||
CFDataRef data = static_cast<CFDataRef>(TISGetInputSourceProperty(source,
|
||||
kTISPropertyUnicodeKeyLayoutData));
|
||||
uchrData = data ? reinterpret_cast<const UCKeyboardLayout *>(CFDataGetBytePtr(data)) : 0;
|
||||
#endif
|
||||
|
||||
keyboard_kind = LMGetKbdType();
|
||||
if (uchrData) {
|
||||
keyboard_layout_format.unicode = uchrData;
|
||||
keyboard_mode = UnicodeMode;
|
||||
}
|
||||
#ifdef Q_OS_MAC32
|
||||
else {
|
||||
void *happy;
|
||||
err = KLGetKeyboardLayoutProperty(keyLayoutRef, kKLKCHRData,
|
||||
const_cast<const void **>(reinterpret_cast<void **>(&happy)));
|
||||
if (err != noErr) {
|
||||
qFatal("Qt::internal::unable to get non-unicode layout, cannot procede %ld %s:%d",
|
||||
long(err), __FILE__, __LINE__);
|
||||
}
|
||||
keyboard_layout_format.other = happy;
|
||||
keyboard_mode = OtherMode;
|
||||
}
|
||||
|
||||
currentKeyboardLayout = keyLayoutRef;
|
||||
#else
|
||||
currentInputSource = source;
|
||||
#endif
|
||||
keyboard_dead = 0;
|
||||
CFStringRef iso639Code;
|
||||
#ifdef Q_OS_MAC32
|
||||
# ifndef kKLLanguageCode
|
||||
# define kKLLanguageCode 9
|
||||
# endif
|
||||
KLGetKeyboardLayoutProperty(currentKeyboardLayout, kKLLanguageCode,
|
||||
reinterpret_cast<const void **>(&iso639Code));
|
||||
#else
|
||||
CFArrayRef array = static_cast<CFArrayRef>(TISGetInputSourceProperty(currentInputSource, kTISPropertyInputSourceLanguages));
|
||||
iso639Code = static_cast<CFStringRef>(CFArrayGetValueAtIndex(array, 0)); // Actually a RFC3066bis, but it's close enough
|
||||
#endif
|
||||
if (iso639Code) {
|
||||
keyboardInputLocale = QLocale(QCFString::toQString(iso639Code));
|
||||
keyboardInputDirection = keyboardInputLocale.textDirection();
|
||||
} else {
|
||||
keyboardInputLocale = QLocale::c();
|
||||
keyboardInputDirection = Qt::LeftToRight;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
QKeyMapperPrivate::deleteLayouts()
|
||||
{
|
||||
keyboard_mode = NullMode;
|
||||
for (int i = 0; i < 255; ++i) {
|
||||
if (keyLayout[i]) {
|
||||
delete keyLayout[i];
|
||||
keyLayout[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
QKeyMapperPrivate::clearMappings()
|
||||
{
|
||||
deleteLayouts();
|
||||
updateKeyboard();
|
||||
}
|
||||
|
||||
QList<int>
|
||||
QKeyMapperPrivate::possibleKeys(QKeyEvent *e)
|
||||
{
|
||||
QList<int> ret;
|
||||
|
||||
KeyboardLayoutItem *kbItem = keyLayout[e->nativeVirtualKey()];
|
||||
if (!kbItem) // Key is not in any keyboard layout (e.g. eisu-key on Japanese keyboard)
|
||||
return ret;
|
||||
|
||||
int baseKey = kbItem->qtKey[0];
|
||||
Qt::KeyboardModifiers keyMods = e->modifiers();
|
||||
ret << int(baseKey + keyMods); // The base key is _always_ valid, of course
|
||||
|
||||
for (int i = 1; i < 8; ++i) {
|
||||
Qt::KeyboardModifiers neededMods = ModsTbl[i];
|
||||
int key = kbItem->qtKey[i];
|
||||
if (key && key != baseKey && ((keyMods & neededMods) == neededMods))
|
||||
ret << int(key + (keyMods & ~neededMods));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef er, EventRef event,
|
||||
void *info, bool grab)
|
||||
{
|
||||
Q_ASSERT(GetEventClass(event) == kEventClassKeyboard);
|
||||
bool handled_event=true;
|
||||
UInt32 ekind = GetEventKind(event);
|
||||
|
||||
// unfortunately modifiers changed event looks quite different, so I have a separate
|
||||
// code path
|
||||
if (ekind == kEventRawKeyModifiersChanged) {
|
||||
//figure out changed modifiers, wish Apple would just send a delta
|
||||
UInt32 modifiers = 0;
|
||||
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
|
||||
sizeof(modifiers), 0, &modifiers);
|
||||
qt_mac_send_modifiers_changed(modifiers, widget);
|
||||
return true;
|
||||
}
|
||||
|
||||
QInputContext *currentContext = qApp->inputContext();
|
||||
if (currentContext && currentContext->isComposing()) {
|
||||
if (ekind == kEventRawKeyDown) {
|
||||
QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext);
|
||||
if (context)
|
||||
context->setLastKeydownEvent(event);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Once we process the key down , we don't need to send the saved event again from
|
||||
// kEventTextInputUnicodeForKeyEvent, so clear it.
|
||||
if (currentContext && ekind == kEventRawKeyDown) {
|
||||
QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext);
|
||||
if (context)
|
||||
context->setLastKeydownEvent(0);
|
||||
}
|
||||
|
||||
//get modifiers
|
||||
Qt::KeyboardModifiers modifiers;
|
||||
int qtKey;
|
||||
QChar ourChar;
|
||||
if (translateKeyEventInternal(er, event, &qtKey, &ourChar, &modifiers,
|
||||
&handled_event) == false)
|
||||
return handled_event;
|
||||
QString text(ourChar);
|
||||
/* This is actually wrong - but unfortunately it is the best that can be
|
||||
done for now because of the Control/Meta mapping problems */
|
||||
if (modifiers & (Qt::ControlModifier | Qt::MetaModifier)
|
||||
&& !qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
|
||||
text = QString();
|
||||
}
|
||||
|
||||
|
||||
if (widget) {
|
||||
// Try to compress key events.
|
||||
if (!text.isEmpty() && widget->testAttribute(Qt::WA_KeyCompression)) {
|
||||
EventTime lastTime = GetEventTime(event);
|
||||
for (;;) {
|
||||
EventRef releaseEvent = FindSpecificEventInQueue(GetMainEventQueue(),
|
||||
qt_KeyEventComparatorProc,
|
||||
(void*)kEventRawKeyUp);
|
||||
if (!releaseEvent)
|
||||
break;
|
||||
const EventTime releaseTime = GetEventTime(releaseEvent);
|
||||
if (releaseTime < lastTime)
|
||||
break;
|
||||
lastTime = releaseTime;
|
||||
|
||||
EventRef pressEvent = FindSpecificEventInQueue(GetMainEventQueue(),
|
||||
qt_KeyEventComparatorProc,
|
||||
(void*)kEventRawKeyDown);
|
||||
if (!pressEvent)
|
||||
break;
|
||||
const EventTime pressTime = GetEventTime(pressEvent);
|
||||
if (pressTime < lastTime)
|
||||
break;
|
||||
lastTime = pressTime;
|
||||
|
||||
Qt::KeyboardModifiers compressMod;
|
||||
int compressQtKey = 0;
|
||||
QChar compressChar;
|
||||
if (translateKeyEventInternal(er, pressEvent,
|
||||
&compressQtKey, &compressChar, &compressMod, 0)
|
||||
== false) {
|
||||
break;
|
||||
}
|
||||
// Copied from qapplication_x11.cpp (change both).
|
||||
|
||||
bool stopCompression =
|
||||
// 1) misc keys
|
||||
(compressQtKey >= Qt::Key_Escape && compressQtKey <= Qt::Key_SysReq)
|
||||
// 2) cursor movement
|
||||
|| (compressQtKey >= Qt::Key_Home && compressQtKey <= Qt::Key_PageDown)
|
||||
// 3) extra keys
|
||||
|| (compressQtKey >= Qt::Key_Super_L && compressQtKey <= Qt::Key_Direction_R)
|
||||
// 4) something that a) doesn't translate to text or b) translates
|
||||
// to newline text
|
||||
|| (compressQtKey == 0)
|
||||
|| (compressChar == QLatin1Char('\n'))
|
||||
|| (compressQtKey == Qt::Key_unknown);
|
||||
|
||||
if (compressMod == modifiers && !compressChar.isNull() && !stopCompression) {
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("compressing away %c", compressChar.toLatin1());
|
||||
#endif
|
||||
text += compressChar;
|
||||
// Clean up
|
||||
RemoveEventFromQueue(GetMainEventQueue(), releaseEvent);
|
||||
RemoveEventFromQueue(GetMainEventQueue(), pressEvent);
|
||||
} else {
|
||||
#ifdef DEBUG_KEY_BINDINGS
|
||||
qDebug("stoping compression..");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// There is no way to get the scan code from carbon. But we cannot use the value 0, since
|
||||
// it indicates that the event originates from somewhere else than the keyboard
|
||||
UInt32 macScanCode = 1;
|
||||
UInt32 macVirtualKey = 0;
|
||||
GetEventParameter(event, kEventParamKeyCode, typeUInt32, 0, sizeof(macVirtualKey), 0, &macVirtualKey);
|
||||
UInt32 macModifiers = 0;
|
||||
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
|
||||
sizeof(macModifiers), 0, &macModifiers);
|
||||
// The unicode characters in the range 0xF700-0xF747 are reserved
|
||||
// by Mac OS X for transient use as keyboard function keys. We
|
||||
// wont send 'text' for such key events. This is done to match
|
||||
// behavior on other platforms.
|
||||
unsigned int *unicodeKey = (unsigned int*)info;
|
||||
if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747)
|
||||
text = QString();
|
||||
bool isAccepted;
|
||||
handled_event = QKeyMapper::sendKeyEvent(widget, grab,
|
||||
(ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress,
|
||||
qtKey, modifiers, text, ekind == kEventRawKeyRepeat, 0,
|
||||
macScanCode, macVirtualKey, macModifiers
|
||||
,&isAccepted
|
||||
);
|
||||
*unicodeKey = (unsigned int)isAccepted;
|
||||
}
|
||||
return handled_event;
|
||||
}
|
||||
|
||||
void
|
||||
QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *
|
||||
unicodeKey // unicode character from NSEvent (modifiers applied)
|
||||
)
|
||||
{
|
||||
UInt32 macVirtualKey = 0;
|
||||
GetEventParameter(event, kEventParamKeyCode, typeUInt32, 0, sizeof(macVirtualKey), 0, &macVirtualKey);
|
||||
if (updateKeyboard())
|
||||
QKeyMapper::changeKeyboard();
|
||||
else if (keyLayout[macVirtualKey])
|
||||
return;
|
||||
|
||||
UniCharCount buffer_size = 10;
|
||||
UniChar buffer[buffer_size];
|
||||
keyLayout[macVirtualKey] = new KeyboardLayoutItem;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
UniCharCount out_buffer_size = 0;
|
||||
keyLayout[macVirtualKey]->qtKey[i] = 0;
|
||||
#ifdef Q_WS_MAC32
|
||||
if (keyboard_mode == UnicodeMode) {
|
||||
#endif
|
||||
const UInt32 keyModifier = ((qt_mac_get_mac_modifiers(ModsTbl[i]) >> 8) & 0xFF);
|
||||
OSStatus err = UCKeyTranslate(keyboard_layout_format.unicode, macVirtualKey, kUCKeyActionDown, keyModifier,
|
||||
keyboard_kind, 0, &keyboard_dead, buffer_size, &out_buffer_size, buffer);
|
||||
if (err == noErr && out_buffer_size) {
|
||||
const QChar unicode(buffer[0]);
|
||||
int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey);
|
||||
if (qtkey == Qt::Key_unknown)
|
||||
qtkey = unicode.unicode();
|
||||
keyLayout[macVirtualKey]->qtKey[i] = qtkey;
|
||||
}
|
||||
#ifndef Q_WS_MAC32
|
||||
else {
|
||||
const QChar unicode(*((UniChar *)unicodeKey));
|
||||
int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey);
|
||||
if (qtkey == Qt::Key_unknown)
|
||||
qtkey = unicode.unicode();
|
||||
keyLayout[macVirtualKey]->qtKey[i] = qtkey;
|
||||
}
|
||||
#endif
|
||||
#ifdef Q_WS_MAC32
|
||||
} else {
|
||||
const UInt32 keyModifier = (qt_mac_get_mac_modifiers(ModsTbl[i]));
|
||||
|
||||
uchar translatedChar = KeyTranslate(keyboard_layout_format.other, keyModifier | macVirtualKey, &keyboard_dead);
|
||||
if (translatedChar) {
|
||||
static QTextCodec *c = 0;
|
||||
if (!c)
|
||||
c = QTextCodec::codecForName("Apple Roman");
|
||||
const QChar unicode(c->toUnicode((const char *)&translatedChar, 1).at(0));
|
||||
int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey);
|
||||
if (qtkey == Qt::Key_unknown)
|
||||
qtkey = unicode.unicode();
|
||||
keyLayout[macVirtualKey]->qtKey[i] = qtkey;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG_KEY_MAPS
|
||||
qDebug("updateKeyMap for virtual key = 0x%02x!", (uint)macVirtualKey);
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
qDebug(" [%d] (%d,0x%02x,'%c')", i,
|
||||
keyLayout[macVirtualKey]->qtKey[i],
|
||||
keyLayout[macVirtualKey]->qtKey[i],
|
||||
keyLayout[macVirtualKey]->qtKey[i]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
QKeyMapper::sendKeyEvent(QWidget *widget, bool grab,
|
||||
QEvent::Type type, int code, Qt::KeyboardModifiers modifiers,
|
||||
const QString &text, bool autorepeat, int count,
|
||||
quint32 nativeScanCode, quint32 nativeVirtualKey,
|
||||
quint32 nativeModifiers, bool *isAccepted)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(grab);
|
||||
|
||||
if (widget && widget->isEnabled()) {
|
||||
bool key_event = true;
|
||||
if (key_event) {
|
||||
#if defined(DEBUG_KEY_BINDINGS) || defined(DEBUG_KEY_BINDINGS_MODIFIERS)
|
||||
qDebug("KeyEvent: Sending %s to %s::%s: %s 0x%08x%s",
|
||||
type == QEvent::KeyRelease ? "KeyRelease" : "KeyPress",
|
||||
widget ? widget->metaObject()->className() : "none",
|
||||
widget ? widget->objectName().toLatin1().constData() : "",
|
||||
text.toLatin1().constData(), int(modifiers),
|
||||
autorepeat ? " Repeat" : "");
|
||||
#endif
|
||||
QKeyEventEx ke(type, code, modifiers, text, autorepeat, qMax(1, text.length()),
|
||||
nativeScanCode, nativeVirtualKey, nativeModifiers);
|
||||
bool retMe = qt_sendSpontaneousEvent(widget,&ke);
|
||||
if (isAccepted)
|
||||
*isAccepted = ke.isAccepted();
|
||||
return retMe;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,270 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmacgesturerecognizer_mac_p.h"
|
||||
#include "qgesture.h"
|
||||
#include "qgesture_p.h"
|
||||
#include "qevent.h"
|
||||
#include "qevent_p.h"
|
||||
#include "qwidget.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
#ifndef QT_NO_GESTURES
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QMacSwipeGestureRecognizer::QMacSwipeGestureRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
QGesture *QMacSwipeGestureRecognizer::create(QObject * /*target*/)
|
||||
{
|
||||
return new QSwipeGesture;
|
||||
}
|
||||
|
||||
QGestureRecognizer::Result
|
||||
QMacSwipeGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::NativeGesture && obj->isWidgetType()) {
|
||||
QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
|
||||
switch (ev->gestureType) {
|
||||
case QNativeGestureEvent::Swipe: {
|
||||
QSwipeGesture *g = static_cast<QSwipeGesture *>(gesture);
|
||||
g->setSwipeAngle(ev->angle);
|
||||
g->setHotSpot(ev->position);
|
||||
return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
|
||||
break; }
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return QGestureRecognizer::Ignore;
|
||||
}
|
||||
|
||||
void QMacSwipeGestureRecognizer::reset(QGesture *gesture)
|
||||
{
|
||||
QSwipeGesture *g = static_cast<QSwipeGesture *>(gesture);
|
||||
g->setSwipeAngle(0);
|
||||
QGestureRecognizer::reset(gesture);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QMacPinchGestureRecognizer::QMacPinchGestureRecognizer()
|
||||
{
|
||||
}
|
||||
|
||||
QGesture *QMacPinchGestureRecognizer::create(QObject * /*target*/)
|
||||
{
|
||||
return new QPinchGesture;
|
||||
}
|
||||
|
||||
QGestureRecognizer::Result
|
||||
QMacPinchGestureRecognizer::recognize(QGesture *gesture, QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::NativeGesture && obj->isWidgetType()) {
|
||||
QPinchGesture *g = static_cast<QPinchGesture *>(gesture);
|
||||
QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
|
||||
switch(ev->gestureType) {
|
||||
case QNativeGestureEvent::GestureBegin:
|
||||
reset(gesture);
|
||||
g->setStartCenterPoint(static_cast<QWidget*>(obj)->mapFromGlobal(ev->position));
|
||||
g->setCenterPoint(g->startCenterPoint());
|
||||
g->setChangeFlags(QPinchGesture::CenterPointChanged);
|
||||
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
|
||||
g->setHotSpot(ev->position);
|
||||
return QGestureRecognizer::MayBeGesture | QGestureRecognizer::ConsumeEventHint;
|
||||
case QNativeGestureEvent::Rotate: {
|
||||
g->setLastScaleFactor(g->scaleFactor());
|
||||
g->setLastRotationAngle(g->rotationAngle());
|
||||
g->setRotationAngle(g->rotationAngle() + ev->percentage);
|
||||
g->setChangeFlags(QPinchGesture::RotationAngleChanged);
|
||||
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
|
||||
g->setHotSpot(ev->position);
|
||||
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
|
||||
}
|
||||
case QNativeGestureEvent::Zoom:
|
||||
g->setLastScaleFactor(g->scaleFactor());
|
||||
g->setLastRotationAngle(g->rotationAngle());
|
||||
g->setScaleFactor(g->scaleFactor() * (1 + ev->percentage));
|
||||
g->setChangeFlags(QPinchGesture::ScaleFactorChanged);
|
||||
g->setTotalChangeFlags(g->totalChangeFlags() | g->changeFlags());
|
||||
g->setHotSpot(ev->position);
|
||||
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
|
||||
case QNativeGestureEvent::GestureEnd:
|
||||
return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return QGestureRecognizer::Ignore;
|
||||
}
|
||||
|
||||
void QMacPinchGestureRecognizer::reset(QGesture *gesture)
|
||||
{
|
||||
QPinchGesture *g = static_cast<QPinchGesture *>(gesture);
|
||||
g->setChangeFlags(0);
|
||||
g->setTotalChangeFlags(0);
|
||||
g->setScaleFactor(1.0f);
|
||||
g->setTotalScaleFactor(1.0f);
|
||||
g->setLastScaleFactor(1.0f);
|
||||
g->setRotationAngle(0.0f);
|
||||
g->setTotalRotationAngle(0.0f);
|
||||
g->setLastRotationAngle(0.0f);
|
||||
g->setCenterPoint(QPointF());
|
||||
g->setStartCenterPoint(QPointF());
|
||||
g->setLastCenterPoint(QPointF());
|
||||
QGestureRecognizer::reset(gesture);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
QMacPanGestureRecognizer::QMacPanGestureRecognizer() : _panCanceled(true)
|
||||
{
|
||||
}
|
||||
|
||||
QGesture *QMacPanGestureRecognizer::create(QObject *target)
|
||||
{
|
||||
if (!target)
|
||||
return new QPanGesture;
|
||||
|
||||
if (QWidget *w = qobject_cast<QWidget *>(target)) {
|
||||
w->setAttribute(Qt::WA_AcceptTouchEvents);
|
||||
w->setAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
|
||||
return new QPanGesture;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QGestureRecognizer::Result
|
||||
QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *event)
|
||||
{
|
||||
const int panBeginDelay = 300;
|
||||
const int panBeginRadius = 3;
|
||||
|
||||
QPanGesture *g = static_cast<QPanGesture *>(gesture);
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::TouchBegin: {
|
||||
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
|
||||
if (ev->touchPoints().size() == 1) {
|
||||
reset(gesture);
|
||||
_startPos = QCursor::pos();
|
||||
_panTimer.start(panBeginDelay, target);
|
||||
_panCanceled = false;
|
||||
return QGestureRecognizer::MayBeGesture;
|
||||
}
|
||||
break;}
|
||||
case QEvent::TouchEnd: {
|
||||
if (_panCanceled)
|
||||
break;
|
||||
|
||||
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
|
||||
if (ev->touchPoints().size() == 1)
|
||||
return QGestureRecognizer::FinishGesture;
|
||||
break;}
|
||||
case QEvent::TouchUpdate: {
|
||||
if (_panCanceled)
|
||||
break;
|
||||
|
||||
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
|
||||
if (ev->touchPoints().size() == 1) {
|
||||
if (_panTimer.isActive()) {
|
||||
// INVARIANT: Still in maybeGesture. Check if the user
|
||||
// moved his finger so much that it makes sense to cancel the pan:
|
||||
const QPointF p = QCursor::pos();
|
||||
if ((p - _startPos).manhattanLength() > panBeginRadius) {
|
||||
_panCanceled = true;
|
||||
_panTimer.stop();
|
||||
return QGestureRecognizer::CancelGesture;
|
||||
}
|
||||
} else {
|
||||
const QPointF p = QCursor::pos();
|
||||
const QPointF posOffset = p - _startPos;
|
||||
g->setLastOffset(g->offset());
|
||||
g->setOffset(QPointF(posOffset.x(), posOffset.y()));
|
||||
g->setHotSpot(_startPos);
|
||||
return QGestureRecognizer::TriggerGesture;
|
||||
}
|
||||
} else if (_panTimer.isActive()) {
|
||||
// I only want to cancel the pan if the user is pressing
|
||||
// more than one finger, and the pan hasn't started yet:
|
||||
_panCanceled = true;
|
||||
_panTimer.stop();
|
||||
return QGestureRecognizer::CancelGesture;
|
||||
}
|
||||
break;}
|
||||
case QEvent::Timer: {
|
||||
QTimerEvent *ev = static_cast<QTimerEvent *>(event);
|
||||
if (ev->timerId() == _panTimer.timerId()) {
|
||||
_panTimer.stop();
|
||||
if (_panCanceled)
|
||||
break;
|
||||
// Begin new pan session!
|
||||
_startPos = QCursor::pos();
|
||||
g->setHotSpot(_startPos);
|
||||
return QGestureRecognizer::TriggerGesture | QGestureRecognizer::ConsumeEventHint;
|
||||
}
|
||||
break; }
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QGestureRecognizer::Ignore;
|
||||
}
|
||||
|
||||
void QMacPanGestureRecognizer::reset(QGesture *gesture)
|
||||
{
|
||||
QPanGesture *g = static_cast<QPanGesture *>(gesture);
|
||||
_startPos = QPointF();
|
||||
_panCanceled = true;
|
||||
g->setOffset(QPointF(0, 0));
|
||||
g->setLastOffset(QPointF(0, 0));
|
||||
g->setAcceleration(qreal(1));
|
||||
QGestureRecognizer::reset(gesture);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_GESTURES
|
@ -1,104 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMACSWIPEGESTURERECOGNIZER_MAC_P_H
|
||||
#define QMACSWIPEGESTURERECOGNIZER_MAC_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qtimer.h"
|
||||
#include "qpoint.h"
|
||||
#include "qgesturerecognizer.h"
|
||||
|
||||
#ifndef QT_NO_GESTURES
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMacSwipeGestureRecognizer : public QGestureRecognizer
|
||||
{
|
||||
public:
|
||||
QMacSwipeGestureRecognizer();
|
||||
|
||||
QGesture *create(QObject *target);
|
||||
QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event);
|
||||
void reset(QGesture *gesture);
|
||||
};
|
||||
|
||||
class QMacPinchGestureRecognizer : public QGestureRecognizer
|
||||
{
|
||||
public:
|
||||
QMacPinchGestureRecognizer();
|
||||
|
||||
QGesture *create(QObject *target);
|
||||
QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event);
|
||||
void reset(QGesture *gesture);
|
||||
};
|
||||
|
||||
|
||||
class QMacPanGestureRecognizer : public QObject, public QGestureRecognizer
|
||||
{
|
||||
public:
|
||||
QMacPanGestureRecognizer();
|
||||
|
||||
QGesture *create(QObject *target);
|
||||
QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event);
|
||||
void reset(QGesture *gesture);
|
||||
private:
|
||||
QPointF _startPos;
|
||||
QBasicTimer _panTimer;
|
||||
bool _panCanceled;
|
||||
};
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_GESTURES
|
||||
|
||||
#endif // QMACSWIPEGESTURERECOGNIZER_MAC_P_H
|
@ -1,124 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qvarlengtharray.h>
|
||||
#include <qwidget.h>
|
||||
#include <private/qmacinputcontext_p.h>
|
||||
#include "qtextformat.h"
|
||||
#include <qdebug.h>
|
||||
#include <private/qapplication_p.h>
|
||||
#include <private/qkeymapper_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
|
||||
# define typeRefCon typeSInt32
|
||||
# define typeByteCount typeSInt32
|
||||
#endif
|
||||
|
||||
QMacInputContext::QMacInputContext(QObject *parent)
|
||||
: QInputContext(parent), composing(false), recursionGuard(false), textDocument(0),
|
||||
keydownEvent(0)
|
||||
{
|
||||
// createTextDocument();
|
||||
}
|
||||
|
||||
QMacInputContext::~QMacInputContext()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
QMacInputContext::createTextDocument()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString QMacInputContext::language()
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
void QMacInputContext::mouseHandler(int pos, QMouseEvent *e)
|
||||
{
|
||||
Q_UNUSED(pos);
|
||||
Q_UNUSED(e);
|
||||
}
|
||||
|
||||
|
||||
void QMacInputContext::setFocusWidget(QWidget *w)
|
||||
{
|
||||
createTextDocument();
|
||||
QInputContext::setFocusWidget(w);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
QMacInputContext::initialize()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
QMacInputContext::cleanup()
|
||||
{
|
||||
}
|
||||
|
||||
void QMacInputContext::setLastKeydownEvent(EventRef event)
|
||||
{
|
||||
EventRef tmpEvent = keydownEvent;
|
||||
keydownEvent = event;
|
||||
if (keydownEvent)
|
||||
RetainEvent(keydownEvent);
|
||||
if (tmpEvent)
|
||||
ReleaseEvent(tmpEvent);
|
||||
}
|
||||
|
||||
OSStatus
|
||||
QMacInputContext::globalEventProcessor(EventHandlerCallRef, EventRef event, void *)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
return noErr; //we eat the event
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,97 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMACINPUTCONTEXT_P_H
|
||||
#define QMACINPUTCONTEXT_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtWidgets/qinputcontext.h"
|
||||
#include "private/qt_mac_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Q_WIDGETS_EXPORT QMacInputContext : public QInputContext
|
||||
{
|
||||
Q_OBJECT
|
||||
//Q_DECLARE_PRIVATE(QMacInputContext)
|
||||
void createTextDocument();
|
||||
public:
|
||||
explicit QMacInputContext(QObject* parent = 0);
|
||||
virtual ~QMacInputContext();
|
||||
|
||||
virtual void setFocusWidget(QWidget *w);
|
||||
virtual QString identifierName() { return QLatin1String("mac"); }
|
||||
virtual QString language();
|
||||
|
||||
virtual void reset();
|
||||
|
||||
virtual bool isComposing() const;
|
||||
|
||||
static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
|
||||
static void initialize();
|
||||
static void cleanup();
|
||||
|
||||
EventRef lastKeydownEvent() { return keydownEvent; }
|
||||
void setLastKeydownEvent(EventRef);
|
||||
|
||||
protected:
|
||||
void mouseHandler(int pos, QMouseEvent *);
|
||||
private:
|
||||
bool composing;
|
||||
bool recursionGuard;
|
||||
TSMDocumentID textDocument;
|
||||
QString currentText;
|
||||
EventRef keydownEvent;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QMACINPUTCONTEXT_P_H
|
File diff suppressed because it is too large
Load Diff
@ -1,154 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
|
||||
// and many other. This header file may change from version to version
|
||||
// without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
// Private AppKit class (dumped from classdump).
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface NSFrameView : NSView
|
||||
{
|
||||
unsigned int styleMask;
|
||||
NSString *_title;
|
||||
NSCell *titleCell;
|
||||
NSButton *closeButton;
|
||||
NSButton *zoomButton;
|
||||
NSButton *minimizeButton;
|
||||
char resizeByIncrement;
|
||||
char frameNeedsDisplay;
|
||||
unsigned char tabViewCount;
|
||||
NSSize resizeParameter;
|
||||
int shadowState;
|
||||
}
|
||||
|
||||
+ (void)initialize;
|
||||
+ (void)initTitleCell:fp8 styleMask:(unsigned int)fp12;
|
||||
+ (struct _NSRect)frameRectForContentRect:(struct _NSRect)fp8 styleMask:(unsigned int)fp24;
|
||||
+ (struct _NSRect)contentRectForFrameRect:(struct _NSRect)fp8 styleMask:(unsigned int)fp24;
|
||||
+ (struct _NSSize)minFrameSizeForMinContentSize:(struct _NSSize)fp8 styleMask:(unsigned int)fp16;
|
||||
+ (struct _NSSize)minContentSizeForMinFrameSize:(struct _NSSize)fp8 styleMask:(unsigned int)fp16;
|
||||
+ (float)minFrameWidthWithTitle:fp8 styleMask:(unsigned int)fp12;
|
||||
+ (unsigned int)_validateStyleMask:(unsigned int)fp8;
|
||||
- initWithFrame:(struct _NSRect)fp8 styleMask:(unsigned int)fp24 owner:fp28;
|
||||
- initWithFrame:(struct _NSRect)fp8;
|
||||
- (void)dealloc;
|
||||
- (void)shapeWindow;
|
||||
- (void)tileAndSetWindowShape:(char)fp8;
|
||||
- (void)tile;
|
||||
- (void)drawRect:(struct _NSRect)fp8;
|
||||
- (void)_drawFrameRects:(struct _NSRect)fp8;
|
||||
- (void)drawFrame:(struct _NSRect)fp8;
|
||||
- (void)drawThemeContentFill:(struct _NSRect)fp8 inView:fp24;
|
||||
- (void)drawWindowBackgroundRect:(struct _NSRect)fp8;
|
||||
- (void)drawWindowBackgroundRegion:(void *)fp8;
|
||||
- (float)contentAlpha;
|
||||
- (void)_windowChangedKeyState;
|
||||
- (void)_updateButtonState;
|
||||
- (char)_isSheet;
|
||||
- (char)_isUtility;
|
||||
- (void)setShadowState:(int)fp8;
|
||||
- (int)shadowState;
|
||||
- (char)_canHaveToolbar;
|
||||
- (char)_toolbarIsInTransition;
|
||||
- (char)_toolbarIsShown;
|
||||
- (char)_toolbarIsHidden;
|
||||
- (void)_showToolbarWithAnimation:(char)fp8;
|
||||
- (void)_hideToolbarWithAnimation:(char)fp8;
|
||||
- (float)_distanceFromToolbarBaseToTitlebar;
|
||||
- (int)_shadowType;
|
||||
- (unsigned int)_shadowFlags;
|
||||
- (void)_setShadowParameters;
|
||||
- (void)_drawFrameShadowAndFlushContext:fp8;
|
||||
- (void)setUpGState;
|
||||
- (void)adjustHalftonePhase;
|
||||
- (void)systemColorsDidChange:fp8;
|
||||
- frameColor;
|
||||
- contentFill;
|
||||
- (void)tabViewAdded;
|
||||
- (void)tabViewRemoved;
|
||||
- title;
|
||||
- (void)setTitle:fp8;
|
||||
- titleCell;
|
||||
- (void)initTitleCell:fp8;
|
||||
- (void)setResizeIncrements:(struct _NSSize)fp8;
|
||||
- (struct _NSSize)resizeIncrements;
|
||||
- (void)setAspectRatio:(struct _NSSize)fp8;
|
||||
- (struct _NSSize)aspectRatio;
|
||||
- (unsigned int)styleMask;
|
||||
- representedFilename;
|
||||
- (void)setRepresentedFilename:fp8;
|
||||
- (void)setDocumentEdited:(char)fp8;
|
||||
- (void)_setFrameNeedsDisplay:(char)fp8;
|
||||
- (char)frameNeedsDisplay;
|
||||
- titleFont;
|
||||
- (struct _NSRect)_maxTitlebarTitleRect;
|
||||
- (struct _NSRect)titlebarRect;
|
||||
- (void)_setUtilityWindow:(char)fp8;
|
||||
- (void)_setNonactivatingPanel:(char)fp8;
|
||||
- (void)setIsClosable:(char)fp8;
|
||||
- (void)setIsResizable:(char)fp8;
|
||||
- closeButton;
|
||||
- minimizeButton;
|
||||
- zoomButton;
|
||||
- (struct _NSSize)miniaturizedSize;
|
||||
- (void)_clearDragMargins;
|
||||
- (void)_resetDragMargins;
|
||||
- (void)setTitle:fp8 andDefeatWrap:(char)fp12;
|
||||
- (struct _NSRect)frameRectForContentRect:(struct _NSRect)fp8 styleMask:(unsigned int)fp24;
|
||||
- (struct _NSRect)contentRectForFrameRect:(struct _NSRect)fp8 styleMask:(unsigned int)fp24;
|
||||
- (struct _NSSize)minFrameSizeForMinContentSize:(struct _NSSize)fp8 styleMask:(unsigned int)fp16;
|
||||
- (struct _NSRect)dragRectForFrameRect:(struct _NSRect)fp8;
|
||||
- (struct _NSRect)contentRect;
|
||||
- (struct _NSSize)minFrameSize;
|
||||
- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(struct _NSRect)fp8 isVisibleRect:(char)fp24 rectIsVisibleRectForView:fp28 topView:(char)fp32;
|
||||
|
||||
@end
|
@ -1,246 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
|
||||
// and many other. This header file may change from version to version
|
||||
// without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
// Private AppKit class (dumped from classdump).
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "qnstitledframe_mac_p.h"
|
||||
|
||||
@interface NSThemeFrame : NSTitledFrame
|
||||
{
|
||||
NSButton *toolbarButton;
|
||||
int toolbarVisibleStatus;
|
||||
NSImage *showToolbarTransitionImage;
|
||||
NSSize showToolbarPreWindowSize;
|
||||
NSButton *modeButton;
|
||||
int leftGroupTrackingTagNum;
|
||||
int rightGroupTrackingTagNum;
|
||||
char mouseInsideLeftGroup;
|
||||
char mouseInsideRightGroup;
|
||||
int widgetState;
|
||||
NSString *displayName;
|
||||
}
|
||||
|
||||
+ (void)initialize;
|
||||
+ (float)_windowBorderThickness:(unsigned int)fp8;
|
||||
+ (float)_minXWindowBorderWidth:(unsigned int)fp8;
|
||||
+ (float)_maxXWindowBorderWidth:(unsigned int)fp8;
|
||||
+ (float)_minYWindowBorderHeight:(unsigned int)fp8;
|
||||
+ (float)_windowTitlebarButtonSpacingWidth:(unsigned int)fp8;
|
||||
+ (float)_windowFileButtonSpacingWidth:(unsigned int)fp8;
|
||||
+ (float)_minXTitlebarWidgetInset:(unsigned int)fp8;
|
||||
+ (float)_maxXTitlebarWidgetInset:(unsigned int)fp8;
|
||||
+ (float)minFrameWidthWithTitle:fp8 styleMask:(unsigned int)fp12;
|
||||
+ (float)_windowSideTitlebarTitleMinWidth:(unsigned int)fp8;
|
||||
+ (float)_windowTitlebarTitleMinHeight:(unsigned int)fp8;
|
||||
+ (float)_sideTitlebarWidth:(unsigned int)fp8;
|
||||
+ (float)_titlebarHeight:(unsigned int)fp8;
|
||||
+ (float)_resizeHeight:(unsigned int)fp8;
|
||||
+ (char)_resizeFromEdge;
|
||||
+ (struct _NSSize)sizeOfTitlebarButtons:(unsigned int)fp8;
|
||||
+ (float)_contentToFrameMinXWidth:(unsigned int)fp8;
|
||||
+ (float)_contentToFrameMaxXWidth:(unsigned int)fp8;
|
||||
+ (float)_contentToFrameMinYHeight:(unsigned int)fp8;
|
||||
+ (float)_contentToFrameMaxYHeight:(unsigned int)fp8;
|
||||
+ (unsigned int)_validateStyleMask:(unsigned int)fp8;
|
||||
- (struct _NSSize)_topCornerSize;
|
||||
- (struct _NSSize)_bottomCornerSize;
|
||||
- (void *)_createWindowOpaqueShape;
|
||||
- (void)shapeWindow;
|
||||
- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)fp8 isVisibleRect:(char)fp24 rectIsVisibleRectForView:fp28 topView:(char)fp32;
|
||||
- (void *)_regionForOpaqueDescendants:(NSRect)fp8 forMove:(char)fp24;
|
||||
- (void)_drawFrameInterior:(NSRect *)fp8 clip:(NSRect)fp12;
|
||||
- (void)_setTextShadow:(char)fp8;
|
||||
- (void)_drawTitleBar:(NSRect)fp8;
|
||||
- (void)_drawResizeIndicators:(NSRect)fp8;
|
||||
- (void)_drawFrameRects:(NSRect)fp8;
|
||||
- (void)drawFrame:(NSRect)fp8;
|
||||
- contentFill;
|
||||
- (void)viewDidEndLiveResize;
|
||||
- (float)contentAlpha;
|
||||
- (void)setThemeFrameWidgetState:(int)fp8;
|
||||
- (char)constrainResizeEdge:(int *)fp8 withDelta:(struct _NSSize)fp12 elapsedTime:(float)fp20;
|
||||
- (void)addFileButton:fp8;
|
||||
- (void)_updateButtons;
|
||||
- (void)_updateButtonState;
|
||||
- newCloseButton;
|
||||
- newZoomButton;
|
||||
- newMiniaturizeButton;
|
||||
- newToolbarButton;
|
||||
- newFileButton;
|
||||
- (void)_resetTitleBarButtons;
|
||||
- (void)setDocumentEdited:(char)fp8;
|
||||
- toolbarButton;
|
||||
- modeButton;
|
||||
- initWithFrame:(NSRect)fp8 styleMask:(unsigned int)fp24 owner:fp28;
|
||||
- (void)dealloc;
|
||||
- (void)setFrameSize:(struct _NSSize)fp8;
|
||||
- (char)_canHaveToolbar;
|
||||
- (char)_toolbarIsInTransition;
|
||||
- (char)_toolbarIsShown;
|
||||
- (char)_toolbarIsHidden;
|
||||
- _toolbarView;
|
||||
- _toolbar;
|
||||
- (float)_distanceFromToolbarBaseToTitlebar;
|
||||
- (unsigned int)_shadowFlags;
|
||||
- (NSRect)frameRectForContentRect:(NSRect)fp8 styleMask:(unsigned int)fp24;
|
||||
- (NSRect)contentRectForFrameRect:(NSRect)fp8 styleMask:(unsigned int)fp24;
|
||||
- (struct _NSSize)minFrameSizeForMinContentSize:(struct _NSSize)fp8 styleMask:(unsigned int)fp16;
|
||||
- (NSRect)contentRect;
|
||||
- (NSRect)_contentRectExcludingToolbar;
|
||||
- (NSRect)_contentRectIncludingToolbarAtHome;
|
||||
- (void)_setToolbarShowHideResizeWeightingOptimizationOn:(char)fp8;
|
||||
- (char)_usingToolbarShowHideWeightingOptimization;
|
||||
- (void)handleSetFrameCommonRedisplay;
|
||||
- (void)_startLiveResizeAsTopLevel;
|
||||
- (void)_endLiveResizeAsTopLevel;
|
||||
- (void)_growContentReshapeContentAndToolbarView:(int)fp8 animate:(char)fp12;
|
||||
- (char)_growWindowReshapeContentAndToolbarView:(int)fp8 animate:(char)fp12;
|
||||
- (void)_reshapeContentAndToolbarView:(int)fp8 resizeWindow:(char)fp12 animate:(char)fp16;
|
||||
- (void)_toolbarFrameSizeChanged:fp8 oldSize:(struct _NSSize)fp12;
|
||||
- (void)_syncToolbarPosition;
|
||||
- (void)_showHideToolbar:(int)fp8 resizeWindow:(char)fp12 animate:(char)fp16;
|
||||
- (void)_showToolbarWithAnimation:(char)fp8;
|
||||
- (void)_hideToolbarWithAnimation:(char)fp8;
|
||||
- (void)_drawToolbarTransitionIfNecessary;
|
||||
- (void)drawRect:(NSRect)fp8;
|
||||
- (void)resetCursorRects;
|
||||
- (char)shouldBeTreatedAsInkEvent:fp8;
|
||||
- (char)_shouldBeTreatedAsInkEventInInactiveWindow:fp8;
|
||||
//- hitTest:(struct _NSPoint)fp8; // collides with hittest in qcocoasharedwindowmethods_mac_p.h
|
||||
- (NSRect)_leftGroupRect;
|
||||
- (NSRect)_rightGroupRect;
|
||||
- (void)_updateWidgets;
|
||||
- (void)_updateMouseTracking;
|
||||
- (void)mouseEntered:fp8;
|
||||
- (void)mouseExited:fp8;
|
||||
- (void)_setMouseEnteredGroup:(char)fp8 entered:(char)fp12;
|
||||
- (char)_mouseInGroup:fp8;
|
||||
- (struct _NSSize)miniaturizedSize;
|
||||
- (float)_minXTitlebarDecorationMinWidth;
|
||||
- (float)_maxXTitlebarDecorationMinWidth;
|
||||
- (struct _NSSize)minFrameSize;
|
||||
- (float)_windowBorderThickness;
|
||||
- (float)_windowTitlebarXResizeBorderThickness;
|
||||
- (float)_windowTitlebarYResizeBorderThickness;
|
||||
- (float)_windowResizeBorderThickness;
|
||||
- (float)_minXWindowBorderWidth;
|
||||
- (float)_maxXWindowBorderWidth;
|
||||
- (float)_minYWindowBorderHeight;
|
||||
- (float)_maxYWindowBorderHeight;
|
||||
- (float)_minYTitlebarButtonsOffset;
|
||||
- (float)_minYTitlebarTitleOffset;
|
||||
- (float)_sideTitlebarWidth;
|
||||
- (float)_titlebarHeight;
|
||||
- (NSRect)_titlebarTitleRect;
|
||||
- (NSRect)titlebarRect;
|
||||
- (float)_windowTitlebarTitleMinHeight;
|
||||
- (struct _NSSize)_sizeOfTitlebarFileButton;
|
||||
- (struct _NSSize)sizeOfTitlebarToolbarButton;
|
||||
- (float)_windowTitlebarButtonSpacingWidth;
|
||||
- (float)_windowFileButtonSpacingWidth;
|
||||
- (float)_minXTitlebarWidgetInset;
|
||||
- (float)_maxXTitlebarWidgetInset;
|
||||
- (float)_minXTitlebarButtonsWidth;
|
||||
- (float)_maxXTitlebarButtonsWidth;
|
||||
- (struct _NSPoint)_closeButtonOrigin;
|
||||
- (struct _NSPoint)_zoomButtonOrigin;
|
||||
- (struct _NSPoint)_collapseButtonOrigin;
|
||||
- (struct _NSPoint)_toolbarButtonOrigin;
|
||||
- (struct _NSPoint)_fileButtonOrigin;
|
||||
- (void)_tileTitlebar;
|
||||
- (NSRect)_commandPopupRect;
|
||||
- (void)_resetDragMargins;
|
||||
- (float)_maxYTitlebarDragHeight;
|
||||
- (float)_minXTitlebarDragWidth;
|
||||
- (float)_maxXTitlebarDragWidth;
|
||||
- (float)_contentToFrameMinXWidth;
|
||||
- (float)_contentToFrameMaxXWidth;
|
||||
- (float)_contentToFrameMinYHeight;
|
||||
- (float)_contentToFrameMaxYHeight;
|
||||
- (float)_windowResizeCornerThickness;
|
||||
- (NSRect)_minYResizeRect;
|
||||
- (NSRect)_minYminXResizeRect;
|
||||
- (NSRect)_minYmaxXResizeRect;
|
||||
- (NSRect)_minXResizeRect;
|
||||
- (NSRect)_minXminYResizeRect;
|
||||
- (NSRect)_minXmaxYResizeRect;
|
||||
- (NSRect)_maxYResizeRect;
|
||||
- (NSRect)_maxYminXResizeRect;
|
||||
- (NSRect)_maxYmaxXResizeRect;
|
||||
- (NSRect)_maxXResizeRect;
|
||||
- (NSRect)_maxXminYResizeRect;
|
||||
- (NSRect)_maxXmaxYResizeRect;
|
||||
- (NSRect)_minXTitlebarResizeRect;
|
||||
- (NSRect)_maxXTitlebarResizeRect;
|
||||
- (NSRect)_minXBorderRect;
|
||||
- (NSRect)_maxXBorderRect;
|
||||
- (NSRect)_maxYBorderRect;
|
||||
- (NSRect)_minYBorderRect;
|
||||
- (void)_setUtilityWindow:(char)fp8;
|
||||
- (char)_isUtility;
|
||||
- (float)_sheetHeightAdjustment;
|
||||
- (void)_setSheet:(char)fp8;
|
||||
- (char)_isSheet;
|
||||
- (char)_isResizable;
|
||||
- (char)_isClosable;
|
||||
- (char)_isMiniaturizable;
|
||||
- (char)_hasToolbar;
|
||||
- (NSRect)_growBoxRect;
|
||||
- (void)_drawGrowBoxWithClip:(NSRect)fp8;
|
||||
- (char)_inactiveButtonsNeedMask;
|
||||
- (void)mouseDown:fp8;
|
||||
- _displayName;
|
||||
- (void)_setDisplayName:fp8;
|
||||
|
||||
@end
|
@ -1,205 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
|
||||
// and many other. This header file may change from version to version
|
||||
// without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
// Private AppKit class (dumped from classdump).
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "qnsframeview_mac_p.h"
|
||||
|
||||
|
||||
@interface NSTitledFrame : NSFrameView
|
||||
{
|
||||
int resizeFlags;
|
||||
id fileButton; /* NSDocumentDragButton* */
|
||||
NSSize titleCellSize;
|
||||
}
|
||||
|
||||
+ (float)_windowBorderThickness:(unsigned int)fp8;
|
||||
+ (float)_minXWindowBorderWidth:(unsigned int)fp8;
|
||||
+ (float)_maxXWindowBorderWidth:(unsigned int)fp8;
|
||||
+ (float)_minYWindowBorderHeight:(unsigned int)fp8;
|
||||
+ (char)_resizeFromEdge;
|
||||
+ (NSRect)frameRectForContentRect:(NSRect)fp8 styleMask:(unsigned int)fp24;
|
||||
+ (NSRect)contentRectForFrameRect:(NSRect)fp8 styleMask:(unsigned int)fp24;
|
||||
+ (struct _NSSize)minFrameSizeForMinContentSize:(struct _NSSize)fp8 styleMask:(unsigned int)fp16;
|
||||
+ (struct _NSSize)minContentSizeForMinFrameSize:(struct _NSSize)fp8 styleMask:(unsigned int)fp16;
|
||||
+ (float)minFrameWidthWithTitle:fp8 styleMask:(unsigned int)fp12;
|
||||
+ (struct _NSSize)_titleCellSizeForTitle:fp8 styleMask:(unsigned int)fp12;
|
||||
+ (float)_titleCellHeight:(unsigned int)fp8;
|
||||
+ (float)_windowTitlebarTitleMinHeight:(unsigned int)fp8;
|
||||
+ (float)_titlebarHeight:(unsigned int)fp8;
|
||||
+ (struct _NSSize)sizeOfTitlebarButtons:(unsigned int)fp8;
|
||||
+ (float)windowTitlebarLinesSpacingWidth:(unsigned int)fp8;
|
||||
+ (float)windowTitlebarTitleLinesSpacingWidth:(unsigned int)fp8;
|
||||
+ (float)_contentToFrameMinXWidth:(unsigned int)fp8;
|
||||
+ (float)_contentToFrameMaxXWidth:(unsigned int)fp8;
|
||||
+ (float)_contentToFrameMinYHeight:(unsigned int)fp8;
|
||||
+ (float)_contentToFrameMaxYHeight:(unsigned int)fp8;
|
||||
- initWithFrame:(NSRect)fp8 styleMask:(unsigned int)fp24 owner:fp28;
|
||||
- (void)dealloc;
|
||||
- (void)setIsClosable:(char)fp8;
|
||||
- (void)setIsResizable:(char)fp8;
|
||||
- (void)_resetTitleFont;
|
||||
- (void)_setUtilityWindow:(char)fp8;
|
||||
- (char)isOpaque;
|
||||
- (char)worksWhenModal;
|
||||
- (void)propagateFrameDirtyRects:(NSRect)fp8;
|
||||
- (void)_showDrawRect:(NSRect)fp8;
|
||||
- (void)_drawFrameInterior:(NSRect *)fp8 clip:(NSRect)fp12;
|
||||
- (void)drawFrame:(NSRect)fp8;
|
||||
- (void)_drawFrameRects:(NSRect)fp8;
|
||||
- (void)_drawTitlebar:(NSRect)fp8;
|
||||
- (void)_drawTitlebarPattern:(int)fp8 inRect:(NSRect)fp12 clippedByRect:(NSRect)fp28 forKey:(char)fp44 alignment:(int)fp48;
|
||||
- (void)_drawTitlebarLines:(int)fp8 inRect:(NSRect)fp12 clippedByRect:(NSRect)fp28;
|
||||
- frameHighlightColor;
|
||||
- frameShadowColor;
|
||||
- (void)setFrameSize:(struct _NSSize)fp8;
|
||||
- (void)setFrameOrigin:(struct _NSPoint)fp8;
|
||||
- (void)tileAndSetWindowShape:(char)fp8;
|
||||
- (void)tile;
|
||||
- (void)_tileTitlebar;
|
||||
- (void)setTitle:fp8;
|
||||
- (char)_shouldRepresentFilename;
|
||||
- (void)setRepresentedFilename:fp8;
|
||||
- (void)_drawTitleStringIn:(NSRect)fp8 withColor:fp24;
|
||||
- titleFont;
|
||||
- (void)_drawResizeIndicators:(NSRect)fp8;
|
||||
- titleButtonOfClass:(Class)fp8;
|
||||
- initTitleButton:fp8;
|
||||
- newCloseButton;
|
||||
- newZoomButton;
|
||||
- newMiniaturizeButton;
|
||||
- newFileButton;
|
||||
- fileButton;
|
||||
- (void)_removeButtons;
|
||||
- (void)_updateButtons;
|
||||
- (char)_eventInTitlebar:fp8;
|
||||
- (char)acceptsFirstMouse:fp8;
|
||||
- (void)mouseDown:fp8;
|
||||
- (void)mouseUp:fp8;
|
||||
- (void)rightMouseDown:fp8;
|
||||
- (void)rightMouseUp:fp8;
|
||||
- (int)resizeEdgeForEvent:fp8;
|
||||
- (struct _NSSize)_resizeDeltaFromPoint:(struct _NSPoint)fp8 toEvent:fp16;
|
||||
- (NSRect)_validFrameForResizeFrame:(NSRect)fp8 fromResizeEdge:(int)fp24;
|
||||
- (NSRect)frame:(NSRect)fp8 resizedFromEdge:(int)fp24 withDelta:(struct _NSSize)fp28;
|
||||
- (char)constrainResizeEdge:(int *)fp8 withDelta:(struct _NSSize)fp12 elapsedTime:(float)fp20;
|
||||
- (void)resizeWithEvent:fp8;
|
||||
- (int)resizeFlags;
|
||||
- (void)resetCursorRects;
|
||||
- (void)setDocumentEdited:(char)fp8;
|
||||
- (struct _NSSize)miniaturizedSize;
|
||||
- (struct _NSSize)minFrameSize;
|
||||
- (float)_windowBorderThickness;
|
||||
- (float)_windowTitlebarXResizeBorderThickness;
|
||||
- (float)_windowTitlebarYResizeBorderThickness;
|
||||
- (float)_windowResizeBorderThickness;
|
||||
- (float)_minXWindowBorderWidth;
|
||||
- (float)_maxXWindowBorderWidth;
|
||||
- (float)_minYWindowBorderHeight;
|
||||
- (void)_invalidateTitleCellSize;
|
||||
- (void)_invalidateTitleCellWidth;
|
||||
- (float)_titleCellHeight;
|
||||
- (struct _NSSize)_titleCellSize;
|
||||
- (float)_titlebarHeight;
|
||||
- (NSRect)titlebarRect;
|
||||
- (NSRect)_maxTitlebarTitleRect;
|
||||
- (NSRect)_titlebarTitleRect;
|
||||
- (float)_windowTitlebarTitleMinHeight;
|
||||
- (NSRect)dragRectForFrameRect:(NSRect)fp8;
|
||||
- (struct _NSSize)sizeOfTitlebarButtons;
|
||||
- (struct _NSSize)_sizeOfTitlebarFileButton;
|
||||
- (float)_windowTitlebarButtonSpacingWidth;
|
||||
- (float)_minXTitlebarButtonsWidth;
|
||||
- (float)_maxXTitlebarButtonsWidth;
|
||||
- (int)_numberOfTitlebarLines;
|
||||
- (float)windowTitlebarLinesSpacingWidth;
|
||||
- (float)windowTitlebarTitleLinesSpacingWidth;
|
||||
- (float)_minLinesWidthWithSpace;
|
||||
- (NSRect)_minXTitlebarLinesRectWithTitleCellRect:(NSRect)fp8;
|
||||
- (NSRect)_maxXTitlebarLinesRectWithTitleCellRect:(NSRect)fp8;
|
||||
- (float)_minXTitlebarDecorationMinWidth;
|
||||
- (float)_maxXTitlebarDecorationMinWidth;
|
||||
- (struct _NSPoint)_closeButtonOrigin;
|
||||
- (struct _NSPoint)_zoomButtonOrigin;
|
||||
- (struct _NSPoint)_collapseButtonOrigin;
|
||||
- (struct _NSPoint)_fileButtonOrigin;
|
||||
- (float)_maxYTitlebarDragHeight;
|
||||
- (float)_minXTitlebarDragWidth;
|
||||
- (float)_maxXTitlebarDragWidth;
|
||||
- (float)_contentToFrameMinXWidth;
|
||||
- (float)_contentToFrameMaxXWidth;
|
||||
- (float)_contentToFrameMinYHeight;
|
||||
- (float)_contentToFrameMaxYHeight;
|
||||
- (NSRect)contentRect;
|
||||
- (float)_windowResizeCornerThickness;
|
||||
- (NSRect)_minYResizeRect;
|
||||
- (NSRect)_minYminXResizeRect;
|
||||
- (NSRect)_minYmaxXResizeRect;
|
||||
- (NSRect)_minXResizeRect;
|
||||
- (NSRect)_minXminYResizeRect;
|
||||
- (NSRect)_minXmaxYResizeRect;
|
||||
- (NSRect)_maxYResizeRect;
|
||||
- (NSRect)_maxYminXResizeRect;
|
||||
- (NSRect)_maxYmaxXResizeRect;
|
||||
- (NSRect)_maxXResizeRect;
|
||||
- (NSRect)_maxXminYResizeRect;
|
||||
- (NSRect)_maxXmaxYResizeRect;
|
||||
- (NSRect)_minXTitlebarResizeRect;
|
||||
- (NSRect)_maxXTitlebarResizeRect;
|
||||
- (NSRect)_minXBorderRect;
|
||||
- (NSRect)_maxXBorderRect;
|
||||
- (NSRect)_maxYBorderRect;
|
||||
- (NSRect)_minYBorderRect;
|
||||
|
||||
@end
|
@ -1,103 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qpaintdevice.h"
|
||||
#include "qpainter.h"
|
||||
#include "qwidget.h"
|
||||
#include "qbitmap.h"
|
||||
#include "qapplication.h"
|
||||
#include "qprinter.h"
|
||||
#include <qdebug.h>
|
||||
#include <private/qt_mac_p.h>
|
||||
#include <private/qprintengine_mac_p.h>
|
||||
#include <private/qpixmap_mac_p.h>
|
||||
#include <private/qpixmap_raster_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*****************************************************************************
|
||||
Internal variables and functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*! \internal */
|
||||
float qt_mac_defaultDpi_x()
|
||||
{
|
||||
// Mac OS X currently assumes things to be 72 dpi.
|
||||
// (see http://developer.apple.com/releasenotes/GraphicsImaging/RN-ResolutionIndependentUI/)
|
||||
// This may need to be re-worked as we go further in the resolution-independence stuff.
|
||||
return 72;
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
float qt_mac_defaultDpi_y()
|
||||
{
|
||||
// Mac OS X currently assumes things to be 72 dpi.
|
||||
// (see http://developer.apple.com/releasenotes/GraphicsImaging/RN-ResolutionIndependentUI/)
|
||||
// This may need to be re-worked as we go further in the resolution-independence stuff.
|
||||
return 72;
|
||||
}
|
||||
|
||||
|
||||
/*! \internal
|
||||
|
||||
Returns the QuickDraw CGrafPtr of the paint device. 0 is returned
|
||||
if it can't be obtained. Do not hold the pointer around for long
|
||||
as it can be relocated.
|
||||
|
||||
\warning This function is only available on Mac OS X.
|
||||
*/
|
||||
|
||||
Q_WIDGETS_EXPORT GrafPtr qt_mac_qd_context(const QPaintDevice *device)
|
||||
{
|
||||
if (device->devType() == QInternal::Pixmap) {
|
||||
return static_cast<GrafPtr>(static_cast<const QPixmap *>(device)->macQDHandle());
|
||||
} else if(device->devType() == QInternal::Widget) {
|
||||
return static_cast<GrafPtr>(static_cast<const QWidget *>(device)->macQDHandle());
|
||||
} else if(device->devType() == QInternal::Printer) {
|
||||
QPaintEngine *engine = static_cast<const QPrinter *>(device)->paintEngine();
|
||||
return static_cast<GrafPtr>(static_cast<const QMacPrintEngine *>(engine)->handle());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern CGColorSpaceRef qt_mac_colorSpaceForDeviceType(const QPaintDevice *pdev);
|
||||
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
@ -1,256 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPAINTENGINE_MAC_P_H
|
||||
#define QPAINTENGINE_MAC_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "QtGui/qpaintengine.h"
|
||||
#include "private/qt_mac_p.h"
|
||||
#include "private/qpaintengine_p.h"
|
||||
#include "private/qpolygonclipper_p.h"
|
||||
#include "private/qfont_p.h"
|
||||
#include "QtCore/qhash.h"
|
||||
|
||||
typedef struct CGColorSpace *CGColorSpaceRef;
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QCoreGraphicsPaintEnginePrivate;
|
||||
class QCoreGraphicsPaintEngine : public QPaintEngine
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QCoreGraphicsPaintEngine)
|
||||
|
||||
public:
|
||||
QCoreGraphicsPaintEngine();
|
||||
~QCoreGraphicsPaintEngine();
|
||||
|
||||
bool begin(QPaintDevice *pdev);
|
||||
bool end();
|
||||
static CGColorSpaceRef macGenericColorSpace();
|
||||
static CGColorSpaceRef macDisplayColorSpace(const QWidget *widget = 0);
|
||||
|
||||
void updateState(const QPaintEngineState &state);
|
||||
|
||||
void updatePen(const QPen &pen);
|
||||
void updateBrush(const QBrush &brush, const QPointF &pt);
|
||||
void updateFont(const QFont &font);
|
||||
void updateOpacity(qreal opacity);
|
||||
void updateMatrix(const QTransform &matrix);
|
||||
void updateTransform(const QTransform &matrix);
|
||||
void updateClipRegion(const QRegion ®ion, Qt::ClipOperation op);
|
||||
void updateClipPath(const QPainterPath &path, Qt::ClipOperation op);
|
||||
void updateCompositionMode(QPainter::CompositionMode mode);
|
||||
void updateRenderHints(QPainter::RenderHints hints);
|
||||
|
||||
void drawLines(const QLineF *lines, int lineCount);
|
||||
void drawRects(const QRectF *rects, int rectCount);
|
||||
void drawPoints(const QPointF *p, int pointCount);
|
||||
void drawEllipse(const QRectF &r);
|
||||
void drawPath(const QPainterPath &path);
|
||||
|
||||
void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
|
||||
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
|
||||
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
|
||||
|
||||
void drawTextItem(const QPointF &pos, const QTextItem &item);
|
||||
void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
|
||||
Qt::ImageConversionFlags flags = Qt::AutoColor);
|
||||
|
||||
Type type() const { return QPaintEngine::CoreGraphics; }
|
||||
|
||||
CGContextRef handle() const;
|
||||
|
||||
static void initialize();
|
||||
static void cleanup();
|
||||
|
||||
QPainter::RenderHints supportedRenderHints() const;
|
||||
|
||||
//avoid partial shadowed overload warnings...
|
||||
void drawLines(const QLine *lines, int lineCount) { QPaintEngine::drawLines(lines, lineCount); }
|
||||
void drawRects(const QRect *rects, int rectCount) { QPaintEngine::drawRects(rects, rectCount); }
|
||||
void drawPoints(const QPoint *p, int pointCount) { QPaintEngine::drawPoints(p, pointCount); }
|
||||
void drawEllipse(const QRect &r) { QPaintEngine::drawEllipse(r); }
|
||||
void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
|
||||
{ QPaintEngine::drawPolygon(points, pointCount, mode); }
|
||||
|
||||
bool supportsTransformations(qreal, const QTransform &) const { return true; };
|
||||
|
||||
protected:
|
||||
friend class QMacPrintEngine;
|
||||
friend class QMacPrintEnginePrivate;
|
||||
friend void qt_mac_display_change_callbk(CGDirectDisplayID, CGDisplayChangeSummaryFlags, void *);
|
||||
friend void qt_color_profile_changed(CFNotificationCenterRef center, void *,
|
||||
CFStringRef , const void *, CFDictionaryRef);
|
||||
QCoreGraphicsPaintEngine(QPaintEnginePrivate &dptr);
|
||||
|
||||
private:
|
||||
static bool m_postRoutineRegistered;
|
||||
static CGColorSpaceRef m_genericColorSpace;
|
||||
static QHash<CGDirectDisplayID, CGColorSpaceRef> m_displayColorSpaceHash;
|
||||
static void cleanUpMacColorSpaces();
|
||||
Q_DISABLE_COPY(QCoreGraphicsPaintEngine)
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
Private data
|
||||
*****************************************************************************/
|
||||
class QCoreGraphicsPaintEnginePrivate : public QPaintEnginePrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QCoreGraphicsPaintEngine)
|
||||
public:
|
||||
QCoreGraphicsPaintEnginePrivate()
|
||||
: hd(0), shading(0), stackCount(0), complexXForm(false), disabledSmoothFonts(false)
|
||||
{
|
||||
}
|
||||
|
||||
struct {
|
||||
QPen pen;
|
||||
QBrush brush;
|
||||
uint clipEnabled : 1;
|
||||
QRegion clip;
|
||||
QTransform transform;
|
||||
} current;
|
||||
|
||||
//state info (shared with QD)
|
||||
CGAffineTransform orig_xform;
|
||||
|
||||
//cg structures
|
||||
CGContextRef hd;
|
||||
CGShadingRef shading;
|
||||
int stackCount;
|
||||
bool complexXForm;
|
||||
bool disabledSmoothFonts;
|
||||
enum { CosmeticNone, CosmeticTransformPath, CosmeticSetPenWidth } cosmeticPen;
|
||||
|
||||
// pixel and cosmetic pen size in user coordinates.
|
||||
QPointF pixelSize;
|
||||
float cosmeticPenSize;
|
||||
|
||||
//internal functions
|
||||
enum { CGStroke=0x01, CGEOFill=0x02, CGFill=0x04 };
|
||||
void drawPath(uchar ops, CGMutablePathRef path = 0);
|
||||
void setClip(const QRegion *rgn=0);
|
||||
void resetClip();
|
||||
void setFillBrush(const QPointF &origin=QPoint());
|
||||
void setStrokePen(const QPen &pen);
|
||||
inline void saveGraphicsState();
|
||||
inline void restoreGraphicsState();
|
||||
float penOffset();
|
||||
QPointF devicePixelSize(CGContextRef context);
|
||||
float adjustPenWidth(float penWidth);
|
||||
inline void setTransform(const QTransform *matrix=0)
|
||||
{
|
||||
CGContextConcatCTM(hd, CGAffineTransformInvert(CGContextGetCTM(hd)));
|
||||
CGAffineTransform xform = orig_xform;
|
||||
if(matrix) {
|
||||
extern CGAffineTransform qt_mac_convert_transform_to_cg(const QTransform &);
|
||||
xform = CGAffineTransformConcat(qt_mac_convert_transform_to_cg(*matrix), xform);
|
||||
}
|
||||
CGContextConcatCTM(hd, xform);
|
||||
CGContextSetTextMatrix(hd, xform);
|
||||
}
|
||||
};
|
||||
|
||||
inline void QCoreGraphicsPaintEnginePrivate::saveGraphicsState()
|
||||
{
|
||||
++stackCount;
|
||||
CGContextSaveGState(hd);
|
||||
}
|
||||
|
||||
inline void QCoreGraphicsPaintEnginePrivate::restoreGraphicsState()
|
||||
{
|
||||
--stackCount;
|
||||
Q_ASSERT(stackCount >= 0);
|
||||
CGContextRestoreGState(hd);
|
||||
}
|
||||
|
||||
class QMacQuartzPaintDevice : public QPaintDevice
|
||||
{
|
||||
public:
|
||||
QMacQuartzPaintDevice(CGContextRef cg, int width, int height, int bytesPerLine)
|
||||
: mCG(cg), mWidth(width), mHeight(height), mBytesPerLine(bytesPerLine)
|
||||
{ }
|
||||
int devType() const { return QInternal::MacQuartz; }
|
||||
CGContextRef cgContext() const { return mCG; }
|
||||
int metric(PaintDeviceMetric metric) const {
|
||||
switch (metric) {
|
||||
case PdmWidth:
|
||||
return mWidth;
|
||||
case PdmHeight:
|
||||
return mHeight;
|
||||
case PdmWidthMM:
|
||||
return (qt_defaultDpiX() * mWidth) / 2.54;
|
||||
case PdmHeightMM:
|
||||
return (qt_defaultDpiY() * mHeight) / 2.54;
|
||||
case PdmNumColors:
|
||||
return 0;
|
||||
case PdmDepth:
|
||||
return 32;
|
||||
case PdmDpiX:
|
||||
case PdmPhysicalDpiX:
|
||||
return qt_defaultDpiX();
|
||||
case PdmDpiY:
|
||||
case PdmPhysicalDpiY:
|
||||
return qt_defaultDpiY();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
QPaintEngine *paintEngine() const { qWarning("This function should never be called."); return 0; }
|
||||
private:
|
||||
CGContextRef mCG;
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
int mBytesPerLine;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QPAINTENGINE_MAC_P_H
|
File diff suppressed because it is too large
Load Diff
@ -1,134 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPIXMAP_MAC_P_H
|
||||
#define QPIXMAP_MAC_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtGui/qplatformpixmap_qpa.h>
|
||||
#include <QtGui/qplatformpixmapfactory_p.h>
|
||||
#include <QtGui/private/qt_mac_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMacPlatformPixmap : public QPlatformPixmap
|
||||
{
|
||||
public:
|
||||
QMacPlatformPixmap(PixelType type);
|
||||
~QMacPlatformPixmap();
|
||||
|
||||
QPlatformPixmap *createCompatiblePlatformPixmap() const;
|
||||
|
||||
void resize(int width, int height);
|
||||
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
|
||||
void copy(const QPlatformPixmap *data, const QRect &rect);
|
||||
bool scroll(int dx, int dy, const QRect &rect);
|
||||
|
||||
int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
||||
void fill(const QColor &color);
|
||||
QBitmap mask() const;
|
||||
void setMask(const QBitmap &mask);
|
||||
bool hasAlphaChannel() const;
|
||||
// QPixmap transformed(const QTransform &matrix,
|
||||
// Qt::TransformationMode mode) const;
|
||||
void setAlphaChannel(const QPixmap &alphaChannel);
|
||||
QPixmap alphaChannel() const;
|
||||
QImage toImage() const;
|
||||
QPaintEngine* paintEngine() const;
|
||||
|
||||
private:
|
||||
|
||||
uint has_alpha : 1, has_mask : 1, uninit : 1;
|
||||
|
||||
void macSetHasAlpha(bool b);
|
||||
void macGetAlphaChannel(QMacPlatformPixmap *, bool asMask) const;
|
||||
void macSetAlphaChannel(const QMacPlatformPixmap *, bool asMask);
|
||||
void macCreateCGImageRef();
|
||||
void macCreatePixels();
|
||||
void macReleaseCGImageRef();
|
||||
/*
|
||||
pixels stores the pixmap data. pixelsToFree is either 0 or some memory
|
||||
block that was bound to a CGImageRef and released, and for which the
|
||||
release callback has been called. There are two uses to pixelsToFree:
|
||||
|
||||
1. If pixels == pixelsToFree, then we know that the CGImageRef is done\
|
||||
with the data and we can modify pixels without breaking CGImageRef's
|
||||
mutability invariant.
|
||||
|
||||
2. If pixels != pixelsToFree and pixelsToFree != 0, then we can reuse
|
||||
pixelsToFree later on instead of malloc'ing memory.
|
||||
*/
|
||||
quint32 *pixels;
|
||||
uint pixelsSize;
|
||||
quint32 *pixelsToFree;
|
||||
uint bytesPerRow;
|
||||
QRectF cg_mask_rect;
|
||||
CGImageRef cg_data, cg_dataBeingReleased, cg_mask;
|
||||
static QSet<QMacPlatformPixmap*> validDataPointers;
|
||||
|
||||
QPaintEngine *pengine;
|
||||
|
||||
friend class QPixmap;
|
||||
friend class QRasterBuffer;
|
||||
friend class QRasterPaintEngine;
|
||||
friend class QCoreGraphicsPaintEngine;
|
||||
friend CGImageRef qt_mac_create_imagemask(const QPixmap&, const QRectF&);
|
||||
friend quint32 *qt_mac_pixmap_get_base(const QPixmap*);
|
||||
friend int qt_mac_pixmap_get_bytes_per_line(const QPixmap*);
|
||||
friend void qt_mac_cgimage_data_free(void *, const void*, size_t);
|
||||
friend IconRef qt_mac_create_iconref(const QPixmap&);
|
||||
friend CGContextRef qt_mac_cg_context(const QPaintDevice*);
|
||||
friend QColor qcolorForThemeTextColor(ThemeTextColor themeColor);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QPIXMAP_MAC_P_H
|
@ -1,840 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qprintengine_mac_p.h>
|
||||
#include <qdebug.h>
|
||||
#include <qthread.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size);
|
||||
|
||||
QMacPrintEngine::QMacPrintEngine(QPrinter::PrinterMode mode) : QPaintEngine(*(new QMacPrintEnginePrivate))
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
d->mode = mode;
|
||||
d->initialize();
|
||||
}
|
||||
|
||||
bool QMacPrintEngine::begin(QPaintDevice *dev)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
|
||||
Q_ASSERT(dev && dev->devType() == QInternal::Printer);
|
||||
if (!static_cast<QPrinter *>(dev)->isValid())
|
||||
return false;
|
||||
|
||||
if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized()) // Need to reinitialize
|
||||
d->initialize();
|
||||
|
||||
d->paintEngine->state = state;
|
||||
d->paintEngine->begin(dev);
|
||||
Q_ASSERT_X(d->state == QPrinter::Idle, "QMacPrintEngine", "printer already active");
|
||||
|
||||
if (PMSessionValidatePrintSettings(d->session, d->settings, kPMDontWantBoolean) != noErr
|
||||
|| PMSessionValidatePageFormat(d->session, d->format, kPMDontWantBoolean) != noErr) {
|
||||
d->state = QPrinter::Error;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!d->outputFilename.isEmpty()) {
|
||||
QCFType<CFURLRef> outFile = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault,
|
||||
QCFString(d->outputFilename),
|
||||
kCFURLPOSIXPathStyle,
|
||||
false);
|
||||
if (PMSessionSetDestination(d->session, d->settings, kPMDestinationFile,
|
||||
kPMDocumentFormatPDF, outFile) != noErr) {
|
||||
qWarning("QMacPrintEngine::begin: Problem setting file [%s]", d->outputFilename.toUtf8().constData());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
OSStatus status = noErr;
|
||||
status = PMSessionBeginCGDocumentNoDialog(d->session, d->settings, d->format);
|
||||
|
||||
if (status != noErr) {
|
||||
d->state = QPrinter::Error;
|
||||
return false;
|
||||
}
|
||||
|
||||
d->state = QPrinter::Active;
|
||||
setActive(true);
|
||||
d->newPage_helper();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QMacPrintEngine::end()
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
if (d->state == QPrinter::Aborted)
|
||||
return true; // I was just here a function call ago :)
|
||||
if(d->paintEngine->type() == QPaintEngine::CoreGraphics) {
|
||||
// We dont need the paint engine to call restoreGraphicsState()
|
||||
static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->stackCount = 0;
|
||||
static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = 0;
|
||||
}
|
||||
d->paintEngine->end();
|
||||
if (d->state != QPrinter::Idle)
|
||||
d->releaseSession();
|
||||
d->state = QPrinter::Idle;
|
||||
return true;
|
||||
}
|
||||
|
||||
QPaintEngine *
|
||||
QMacPrintEngine::paintEngine() const
|
||||
{
|
||||
return d_func()->paintEngine;
|
||||
}
|
||||
|
||||
Qt::HANDLE QMacPrintEngine::handle() const
|
||||
{
|
||||
QCoreGraphicsPaintEngine *cgEngine = static_cast<QCoreGraphicsPaintEngine*>(paintEngine());
|
||||
return cgEngine->d_func()->hd;
|
||||
}
|
||||
|
||||
QMacPrintEnginePrivate::~QMacPrintEnginePrivate()
|
||||
{
|
||||
[printInfo release];
|
||||
delete paintEngine;
|
||||
}
|
||||
|
||||
void QMacPrintEnginePrivate::setPaperSize(QPrinter::PaperSize ps)
|
||||
{
|
||||
Q_Q(QMacPrintEngine);
|
||||
QSizeF newSize = qt_paperSizeToQSizeF(ps);
|
||||
QCFType<CFArrayRef> formats;
|
||||
PMPrinter printer;
|
||||
|
||||
if (PMSessionGetCurrentPrinter(session, &printer) == noErr
|
||||
&& PMSessionCreatePageFormatList(session, printer, &formats) == noErr) {
|
||||
CFIndex total = CFArrayGetCount(formats);
|
||||
PMPageFormat tmp;
|
||||
PMRect paper;
|
||||
for (CFIndex idx = 0; idx < total; ++idx) {
|
||||
tmp = static_cast<PMPageFormat>(
|
||||
const_cast<void *>(CFArrayGetValueAtIndex(formats, idx)));
|
||||
PMGetUnadjustedPaperRect(tmp, &paper);
|
||||
int wMM = int((paper.right - paper.left) / 72 * 25.4 + 0.5);
|
||||
int hMM = int((paper.bottom - paper.top) / 72 * 25.4 + 0.5);
|
||||
if (newSize.width() == wMM && newSize.height() == hMM) {
|
||||
PMCopyPageFormat(tmp, format);
|
||||
// reset the orientation and resolution as they are lost in the copy.
|
||||
q->setProperty(QPrintEngine::PPK_Orientation, orient);
|
||||
if (PMSessionValidatePageFormat(session, format, kPMDontWantBoolean) != noErr) {
|
||||
// Don't know, warn for the moment.
|
||||
qWarning("QMacPrintEngine, problem setting format and resolution for this page size");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPrinter::PaperSize QMacPrintEnginePrivate::paperSize() const
|
||||
{
|
||||
PMRect paper;
|
||||
PMGetUnadjustedPaperRect(format, &paper);
|
||||
int wMM = int((paper.right - paper.left) / 72 * 25.4 + 0.5);
|
||||
int hMM = int((paper.bottom - paper.top) / 72 * 25.4 + 0.5);
|
||||
for (int i = QPrinter::A4; i < QPrinter::NPaperSize; ++i) {
|
||||
QSizeF s = qt_paperSizeToQSizeF(QPrinter::PaperSize(i));
|
||||
if (s.width() == wMM && s.height() == hMM)
|
||||
return (QPrinter::PaperSize)i;
|
||||
}
|
||||
return QPrinter::Custom;
|
||||
}
|
||||
|
||||
QList<QVariant> QMacPrintEnginePrivate::supportedResolutions() const
|
||||
{
|
||||
Q_ASSERT_X(session, "QMacPrinterEngine::supportedResolutions",
|
||||
"must have a valid printer session");
|
||||
UInt32 resCount;
|
||||
QList<QVariant> resolutions;
|
||||
PMPrinter printer;
|
||||
if (PMSessionGetCurrentPrinter(session, &printer) == noErr) {
|
||||
PMResolution res;
|
||||
OSStatus status = PMPrinterGetPrinterResolutionCount(printer, &resCount);
|
||||
if (status == kPMNotImplemented) {
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
|
||||
// *Sigh* we have to use the non-indexed version.
|
||||
if (PMPrinterGetPrinterResolution(printer, kPMMinSquareResolution, &res) == noErr)
|
||||
resolutions.append(int(res.hRes));
|
||||
if (PMPrinterGetPrinterResolution(printer, kPMMaxSquareResolution, &res) == noErr) {
|
||||
QVariant var(int(res.hRes));
|
||||
if (!resolutions.contains(var))
|
||||
resolutions.append(var);
|
||||
}
|
||||
if (PMPrinterGetPrinterResolution(printer, kPMDefaultResolution, &res) == noErr) {
|
||||
QVariant var(int(res.hRes));
|
||||
if (!resolutions.contains(var))
|
||||
resolutions.append(var);
|
||||
}
|
||||
#endif
|
||||
} else if (status == noErr) {
|
||||
// According to the docs, index start at 1.
|
||||
for (UInt32 i = 1; i <= resCount; ++i) {
|
||||
if (PMPrinterGetIndexedPrinterResolution(printer, i, &res) == noErr)
|
||||
resolutions.append(QVariant(int(res.hRes)));
|
||||
}
|
||||
} else {
|
||||
qWarning("QMacPrintEngine::supportedResolutions: Unexpected error: %ld", long(status));
|
||||
}
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
|
||||
bool QMacPrintEnginePrivate::shouldSuppressStatus() const
|
||||
{
|
||||
if (suppressStatus == true)
|
||||
return true;
|
||||
|
||||
// Supress displaying the automatic progress dialog if we are printing
|
||||
// from a non-gui thread.
|
||||
return (qApp->thread() != QThread::currentThread());
|
||||
}
|
||||
|
||||
QPrinter::PrinterState QMacPrintEngine::printerState() const
|
||||
{
|
||||
return d_func()->state;
|
||||
}
|
||||
|
||||
bool QMacPrintEngine::newPage()
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
OSStatus err =
|
||||
PMSessionEndPageNoDialog(d->session);
|
||||
if (err != noErr) {
|
||||
if (err == kPMCancel) {
|
||||
// User canceled, we need to abort!
|
||||
abort();
|
||||
} else {
|
||||
// Not sure what the problem is...
|
||||
qWarning("QMacPrintEngine::newPage: Cannot end current page. %ld", long(err));
|
||||
d->state = QPrinter::Error;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return d->newPage_helper();
|
||||
}
|
||||
|
||||
bool QMacPrintEngine::abort()
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
if (d->state != QPrinter::Active)
|
||||
return false;
|
||||
bool ret = end();
|
||||
d->state = QPrinter::Aborted;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int qt_get_PDMWidth(PMPageFormat pformat, bool fullPage,
|
||||
const PMResolution &resolution)
|
||||
{
|
||||
int val = 0;
|
||||
PMRect r;
|
||||
qreal hRatio = resolution.hRes / 72;
|
||||
if (fullPage) {
|
||||
if (PMGetAdjustedPaperRect(pformat, &r) == noErr)
|
||||
val = qRound((r.right - r.left) * hRatio);
|
||||
} else {
|
||||
if (PMGetAdjustedPageRect(pformat, &r) == noErr)
|
||||
val = qRound((r.right - r.left) * hRatio);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline int qt_get_PDMHeight(PMPageFormat pformat, bool fullPage,
|
||||
const PMResolution &resolution)
|
||||
{
|
||||
int val = 0;
|
||||
PMRect r;
|
||||
qreal vRatio = resolution.vRes / 72;
|
||||
if (fullPage) {
|
||||
if (PMGetAdjustedPaperRect(pformat, &r) == noErr)
|
||||
val = qRound((r.bottom - r.top) * vRatio);
|
||||
} else {
|
||||
if (PMGetAdjustedPageRect(pformat, &r) == noErr)
|
||||
val = qRound((r.bottom - r.top) * vRatio);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
int QMacPrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const
|
||||
{
|
||||
Q_D(const QMacPrintEngine);
|
||||
int val = 1;
|
||||
switch (m) {
|
||||
case QPaintDevice::PdmWidth:
|
||||
if (d->hasCustomPaperSize) {
|
||||
val = qRound(d->customSize.width());
|
||||
if (d->hasCustomPageMargins) {
|
||||
val -= qRound(d->leftMargin + d->rightMargin);
|
||||
} else {
|
||||
QList<QVariant> margins = property(QPrintEngine::PPK_PageMargins).toList();
|
||||
val -= qRound(margins.at(0).toDouble() + margins.at(2).toDouble());
|
||||
}
|
||||
} else {
|
||||
val = qt_get_PDMWidth(d->format, property(PPK_FullPage).toBool(), d->resolution);
|
||||
}
|
||||
break;
|
||||
case QPaintDevice::PdmHeight:
|
||||
if (d->hasCustomPaperSize) {
|
||||
val = qRound(d->customSize.height());
|
||||
if (d->hasCustomPageMargins) {
|
||||
val -= qRound(d->topMargin + d->bottomMargin);
|
||||
} else {
|
||||
QList<QVariant> margins = property(QPrintEngine::PPK_PageMargins).toList();
|
||||
val -= qRound(margins.at(1).toDouble() + margins.at(3).toDouble());
|
||||
}
|
||||
} else {
|
||||
val = qt_get_PDMHeight(d->format, property(PPK_FullPage).toBool(), d->resolution);
|
||||
}
|
||||
break;
|
||||
case QPaintDevice::PdmWidthMM:
|
||||
val = metric(QPaintDevice::PdmWidth);
|
||||
val = int((val * 254 + 5 * d->resolution.hRes) / (10 * d->resolution.hRes));
|
||||
break;
|
||||
case QPaintDevice::PdmHeightMM:
|
||||
val = metric(QPaintDevice::PdmHeight);
|
||||
val = int((val * 254 + 5 * d->resolution.vRes) / (10 * d->resolution.vRes));
|
||||
break;
|
||||
case QPaintDevice::PdmPhysicalDpiX:
|
||||
case QPaintDevice::PdmPhysicalDpiY: {
|
||||
PMPrinter printer;
|
||||
if(PMSessionGetCurrentPrinter(d->session, &printer) == noErr) {
|
||||
PMResolution resolution;
|
||||
PMPrinterGetOutputResolution(printer, d->settings, &resolution);
|
||||
val = (int)resolution.vRes;
|
||||
break;
|
||||
}
|
||||
//otherwise fall through
|
||||
}
|
||||
case QPaintDevice::PdmDpiY:
|
||||
val = (int)d->resolution.vRes;
|
||||
break;
|
||||
case QPaintDevice::PdmDpiX:
|
||||
val = (int)d->resolution.hRes;
|
||||
break;
|
||||
case QPaintDevice::PdmNumColors:
|
||||
val = (1 << metric(QPaintDevice::PdmDepth));
|
||||
break;
|
||||
case QPaintDevice::PdmDepth:
|
||||
val = 24;
|
||||
break;
|
||||
default:
|
||||
val = 0;
|
||||
qWarning("QPrinter::metric: Invalid metric command");
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
void QMacPrintEnginePrivate::initialize()
|
||||
{
|
||||
Q_Q(QMacPrintEngine);
|
||||
|
||||
Q_ASSERT(!printInfo);
|
||||
|
||||
if (!paintEngine)
|
||||
paintEngine = new QCoreGraphicsPaintEngine();
|
||||
|
||||
q->gccaps = paintEngine->gccaps;
|
||||
|
||||
fullPage = false;
|
||||
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
printInfo = [[NSPrintInfo alloc] initWithDictionary:[NSDictionary dictionary]];
|
||||
session = static_cast<PMPrintSession>([printInfo PMPrintSession]);
|
||||
|
||||
PMPrinter printer;
|
||||
if (session && PMSessionGetCurrentPrinter(session, &printer) == noErr) {
|
||||
QList<QVariant> resolutions = supportedResolutions();
|
||||
if (!resolutions.isEmpty() && mode != QPrinter::ScreenResolution) {
|
||||
if (resolutions.count() > 1 && mode == QPrinter::HighResolution) {
|
||||
int max = 0;
|
||||
for (int i = 0; i < resolutions.count(); ++i) {
|
||||
int value = resolutions.at(i).toInt();
|
||||
if (value > max)
|
||||
max = value;
|
||||
}
|
||||
resolution.hRes = resolution.vRes = max;
|
||||
} else {
|
||||
resolution.hRes = resolution.vRes = resolutions.at(0).toInt();
|
||||
}
|
||||
if(resolution.hRes == 0)
|
||||
resolution.hRes = resolution.vRes = 600;
|
||||
} else {
|
||||
resolution.hRes = resolution.vRes = qt_defaultDpi();
|
||||
}
|
||||
}
|
||||
|
||||
settings = static_cast<PMPrintSettings>([printInfo PMPrintSettings]);
|
||||
format = static_cast<PMPageFormat>([printInfo PMPageFormat]);
|
||||
|
||||
|
||||
QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant>::const_iterator propC;
|
||||
for (propC = valueCache.constBegin(); propC != valueCache.constEnd(); propC++) {
|
||||
q->setProperty(propC.key(), propC.value());
|
||||
}
|
||||
}
|
||||
|
||||
void QMacPrintEnginePrivate::releaseSession()
|
||||
{
|
||||
PMSessionEndPageNoDialog(session);
|
||||
PMSessionEndDocumentNoDialog(session);
|
||||
[printInfo release];
|
||||
printInfo = 0;
|
||||
session = 0;
|
||||
}
|
||||
|
||||
bool QMacPrintEnginePrivate::newPage_helper()
|
||||
{
|
||||
Q_Q(QMacPrintEngine);
|
||||
Q_ASSERT(state == QPrinter::Active);
|
||||
|
||||
if (PMSessionError(session) != noErr) {
|
||||
q->abort();
|
||||
return false;
|
||||
}
|
||||
|
||||
// pop the stack of saved graphic states, in case we get the same
|
||||
// context back - either way, the stack count should be 0 when we
|
||||
// get the new one
|
||||
QCoreGraphicsPaintEngine *cgEngine = static_cast<QCoreGraphicsPaintEngine*>(paintEngine);
|
||||
while (cgEngine->d_func()->stackCount > 0)
|
||||
cgEngine->d_func()->restoreGraphicsState();
|
||||
|
||||
OSStatus status =
|
||||
PMSessionBeginPageNoDialog(session, format, 0);
|
||||
if(status != noErr) {
|
||||
state = QPrinter::Error;
|
||||
return false;
|
||||
}
|
||||
|
||||
QRect page = q->property(QPrintEngine::PPK_PageRect).toRect();
|
||||
QRect paper = q->property(QPrintEngine::PPK_PaperRect).toRect();
|
||||
|
||||
CGContextRef cgContext;
|
||||
OSStatus err = noErr;
|
||||
err = PMSessionGetCGGraphicsContext(session, &cgContext);
|
||||
if(err != noErr) {
|
||||
qWarning("QMacPrintEngine::newPage: Cannot retrieve CoreGraphics context: %ld", long(err));
|
||||
state = QPrinter::Error;
|
||||
return false;
|
||||
}
|
||||
cgEngine->d_func()->hd = cgContext;
|
||||
|
||||
// Set the resolution as a scaling ration of 72 (the default).
|
||||
CGContextScaleCTM(cgContext, 72 / resolution.hRes, 72 / resolution.vRes);
|
||||
|
||||
CGContextScaleCTM(cgContext, 1, -1);
|
||||
CGContextTranslateCTM(cgContext, 0, -paper.height());
|
||||
if (!fullPage)
|
||||
CGContextTranslateCTM(cgContext, page.x() - paper.x(), page.y() - paper.y());
|
||||
cgEngine->d_func()->orig_xform = CGContextGetCTM(cgContext);
|
||||
cgEngine->d_func()->setClip(0);
|
||||
cgEngine->state->dirtyFlags = QPaintEngine::DirtyFlag(QPaintEngine::AllDirty
|
||||
& ~(QPaintEngine::DirtyClipEnabled
|
||||
| QPaintEngine::DirtyClipRegion
|
||||
| QPaintEngine::DirtyClipPath));
|
||||
if (cgEngine->painter()->hasClipping())
|
||||
cgEngine->state->dirtyFlags |= QPaintEngine::DirtyClipEnabled;
|
||||
cgEngine->syncState();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void QMacPrintEngine::updateState(const QPaintEngineState &state)
|
||||
{
|
||||
d_func()->paintEngine->updateState(state);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawRects(const QRectF *r, int num)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawRects(r, num);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawPoints(const QPointF *points, int pointCount)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawPoints(points, pointCount);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawEllipse(const QRectF &r)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawEllipse(r);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawLines(const QLineF *lines, int lineCount)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawLines(lines, lineCount);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawPolygon(points, pointCount, mode);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawPixmap(r, pm, sr);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawImage(r, pm, sr, flags);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawTextItem(const QPointF &p, const QTextItem &ti)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawTextItem(p, ti);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawTiledPixmap(const QRectF &dr, const QPixmap &pixmap, const QPointF &sr)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawTiledPixmap(dr, pixmap, sr);
|
||||
}
|
||||
|
||||
void QMacPrintEngine::drawPath(const QPainterPath &path)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
Q_ASSERT(d->state == QPrinter::Active);
|
||||
d->paintEngine->drawPath(path);
|
||||
}
|
||||
|
||||
|
||||
void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
|
||||
{
|
||||
Q_D(QMacPrintEngine);
|
||||
|
||||
d->valueCache.insert(key, value);
|
||||
if (!d->session)
|
||||
return;
|
||||
|
||||
switch (key) {
|
||||
case PPK_CollateCopies:
|
||||
break;
|
||||
case PPK_ColorMode:
|
||||
break;
|
||||
case PPK_Creator:
|
||||
break;
|
||||
case PPK_DocumentName:
|
||||
break;
|
||||
case PPK_PageOrder:
|
||||
break;
|
||||
case PPK_PaperSource:
|
||||
break;
|
||||
case PPK_SelectionOption:
|
||||
break;
|
||||
case PPK_Resolution: {
|
||||
PMPrinter printer;
|
||||
UInt32 count;
|
||||
if (PMSessionGetCurrentPrinter(d->session, &printer) != noErr)
|
||||
break;
|
||||
if (PMPrinterGetPrinterResolutionCount(printer, &count) != noErr)
|
||||
break;
|
||||
PMResolution resolution = { 0.0, 0.0 };
|
||||
PMResolution bestResolution = { 0.0, 0.0 };
|
||||
int dpi = value.toInt();
|
||||
int bestDistance = INT_MAX;
|
||||
for (UInt32 i = 1; i <= count; ++i) { // Yes, it starts at 1
|
||||
if (PMPrinterGetIndexedPrinterResolution(printer, i, &resolution) == noErr) {
|
||||
if (dpi == int(resolution.hRes)) {
|
||||
bestResolution = resolution;
|
||||
break;
|
||||
} else {
|
||||
int distance = qAbs(dpi - int(resolution.hRes));
|
||||
if (distance < bestDistance) {
|
||||
bestDistance = distance;
|
||||
bestResolution = resolution;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
PMSessionValidatePageFormat(d->session, d->format, kPMDontWantBoolean);
|
||||
break;
|
||||
}
|
||||
|
||||
case PPK_FullPage:
|
||||
d->fullPage = value.toBool();
|
||||
break;
|
||||
case PPK_CopyCount: // fallthrough
|
||||
case PPK_NumberOfCopies:
|
||||
PMSetCopies(d->settings, value.toInt(), false);
|
||||
break;
|
||||
case PPK_Orientation: {
|
||||
if (d->state == QPrinter::Active) {
|
||||
qWarning("QMacPrintEngine::setOrientation: Orientation cannot be changed during a print job, ignoring change");
|
||||
} else {
|
||||
QPrinter::Orientation newOrientation = QPrinter::Orientation(value.toInt());
|
||||
if (d->hasCustomPaperSize && (d->orient != newOrientation))
|
||||
d->customSize = QSizeF(d->customSize.height(), d->customSize.width());
|
||||
d->orient = newOrientation;
|
||||
PMOrientation o = d->orient == QPrinter::Portrait ? kPMPortrait : kPMLandscape;
|
||||
PMSetOrientation(d->format, o, false);
|
||||
PMSessionValidatePageFormat(d->session, d->format, kPMDontWantBoolean);
|
||||
}
|
||||
break; }
|
||||
case PPK_OutputFileName:
|
||||
d->outputFilename = value.toString();
|
||||
break;
|
||||
case PPK_PaperSize:
|
||||
d->setPaperSize(QPrinter::PaperSize(value.toInt()));
|
||||
break;
|
||||
case PPK_PrinterName: {
|
||||
bool printerNameSet = false;
|
||||
OSStatus status = noErr;
|
||||
QCFType<CFArrayRef> printerList;
|
||||
status = PMServerCreatePrinterList(kPMServerLocal, &printerList);
|
||||
if (status == noErr) {
|
||||
CFIndex count = CFArrayGetCount(printerList);
|
||||
for (CFIndex i=0; i<count; ++i) {
|
||||
PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(printerList, i)));
|
||||
QString name = QCFString::toQString(PMPrinterGetName(printer));
|
||||
if (name == value.toString()) {
|
||||
status = PMSessionSetCurrentPMPrinter(d->session, printer);
|
||||
printerNameSet = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status != noErr)
|
||||
qWarning("QMacPrintEngine::setPrinterName: Error setting printer: %ld", long(status));
|
||||
if (!printerNameSet) {
|
||||
qWarning("QMacPrintEngine::setPrinterName: Failed to set printer named '%s'.", qPrintable(value.toString()));
|
||||
d->releaseSession();
|
||||
d->state = QPrinter::Idle;
|
||||
}
|
||||
break; }
|
||||
case PPK_SuppressSystemPrintStatus:
|
||||
d->suppressStatus = value.toBool();
|
||||
break;
|
||||
case PPK_CustomPaperSize:
|
||||
{
|
||||
PMOrientation orientation;
|
||||
PMGetOrientation(d->format, &orientation);
|
||||
d->hasCustomPaperSize = true;
|
||||
d->customSize = value.toSizeF();
|
||||
if (orientation != kPMPortrait)
|
||||
d->customSize = QSizeF(d->customSize.height(), d->customSize.width());
|
||||
break;
|
||||
}
|
||||
case PPK_PageMargins:
|
||||
{
|
||||
QList<QVariant> margins(value.toList());
|
||||
Q_ASSERT(margins.size() == 4);
|
||||
d->leftMargin = margins.at(0).toDouble();
|
||||
d->topMargin = margins.at(1).toDouble();
|
||||
d->rightMargin = margins.at(2).toDouble();
|
||||
d->bottomMargin = margins.at(3).toDouble();
|
||||
d->hasCustomPageMargins = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
|
||||
{
|
||||
Q_D(const QMacPrintEngine);
|
||||
QVariant ret;
|
||||
|
||||
if (!d->session && d->valueCache.contains(key))
|
||||
return *d->valueCache.find(key);
|
||||
|
||||
switch (key) {
|
||||
case PPK_CollateCopies:
|
||||
ret = false;
|
||||
break;
|
||||
case PPK_ColorMode:
|
||||
ret = QPrinter::Color;
|
||||
break;
|
||||
case PPK_Creator:
|
||||
break;
|
||||
case PPK_DocumentName:
|
||||
break;
|
||||
case PPK_FullPage:
|
||||
ret = d->fullPage;
|
||||
break;
|
||||
case PPK_NumberOfCopies:
|
||||
ret = 1;
|
||||
break;
|
||||
case PPK_CopyCount: {
|
||||
UInt32 copies = 1;
|
||||
PMGetCopies(d->settings, &copies);
|
||||
ret = (uint) copies;
|
||||
break;
|
||||
}
|
||||
case PPK_SupportsMultipleCopies:
|
||||
ret = true;
|
||||
break;
|
||||
case PPK_Orientation:
|
||||
PMOrientation orientation;
|
||||
PMGetOrientation(d->format, &orientation);
|
||||
ret = orientation == kPMPortrait ? QPrinter::Portrait : QPrinter::Landscape;
|
||||
break;
|
||||
case PPK_OutputFileName:
|
||||
ret = d->outputFilename;
|
||||
break;
|
||||
case PPK_PageOrder:
|
||||
break;
|
||||
case PPK_PaperSource:
|
||||
break;
|
||||
case PPK_PageRect: {
|
||||
// PageRect is returned in device pixels
|
||||
QRect r;
|
||||
PMRect macrect, macpaper;
|
||||
qreal hRatio = d->resolution.hRes / 72;
|
||||
qreal vRatio = d->resolution.vRes / 72;
|
||||
if (d->hasCustomPaperSize) {
|
||||
r = QRect(0, 0, qRound(d->customSize.width() * hRatio), qRound(d->customSize.height() * vRatio));
|
||||
if (d->hasCustomPageMargins) {
|
||||
r.adjust(qRound(d->leftMargin * hRatio), qRound(d->topMargin * vRatio),
|
||||
-qRound(d->rightMargin * hRatio), -qRound(d->bottomMargin * vRatio));
|
||||
} else {
|
||||
QList<QVariant> margins = property(QPrintEngine::PPK_PageMargins).toList();
|
||||
r.adjust(qRound(margins.at(0).toDouble() * hRatio),
|
||||
qRound(margins.at(1).toDouble() * vRatio),
|
||||
-qRound(margins.at(2).toDouble() * hRatio),
|
||||
-qRound(margins.at(3).toDouble()) * vRatio);
|
||||
}
|
||||
} else if (PMGetAdjustedPageRect(d->format, ¯ect) == noErr
|
||||
&& PMGetAdjustedPaperRect(d->format, &macpaper) == noErr)
|
||||
{
|
||||
if (d->fullPage || d->hasCustomPageMargins) {
|
||||
r.setCoords(int(macpaper.left * hRatio), int(macpaper.top * vRatio),
|
||||
int(macpaper.right * hRatio), int(macpaper.bottom * vRatio));
|
||||
r.translate(-r.x(), -r.y());
|
||||
if (d->hasCustomPageMargins) {
|
||||
r.adjust(qRound(d->leftMargin * hRatio), qRound(d->topMargin * vRatio),
|
||||
-qRound(d->rightMargin * hRatio), -qRound(d->bottomMargin * vRatio));
|
||||
}
|
||||
} else {
|
||||
r.setCoords(int(macrect.left * hRatio), int(macrect.top * vRatio),
|
||||
int(macrect.right * hRatio), int(macrect.bottom * vRatio));
|
||||
r.translate(int(-macpaper.left * hRatio), int(-macpaper.top * vRatio));
|
||||
}
|
||||
}
|
||||
ret = r;
|
||||
break; }
|
||||
case PPK_PaperSize:
|
||||
ret = d->paperSize();
|
||||
break;
|
||||
case PPK_PaperRect: {
|
||||
QRect r;
|
||||
PMRect macrect;
|
||||
if (d->hasCustomPaperSize) {
|
||||
r = QRect(0, 0, qRound(d->customSize.width()), qRound(d->customSize.height()));
|
||||
} else if (PMGetAdjustedPaperRect(d->format, ¯ect) == noErr) {
|
||||
qreal hRatio = d->resolution.hRes / 72;
|
||||
qreal vRatio = d->resolution.vRes / 72;
|
||||
r.setCoords(int(macrect.left * hRatio), int(macrect.top * vRatio),
|
||||
int(macrect.right * hRatio), int(macrect.bottom * vRatio));
|
||||
r.translate(-r.x(), -r.y());
|
||||
}
|
||||
ret = r;
|
||||
break; }
|
||||
case PPK_PrinterName: {
|
||||
PMPrinter printer;
|
||||
OSStatus status = PMSessionGetCurrentPrinter(d->session, &printer);
|
||||
if (status != noErr)
|
||||
qWarning("QMacPrintEngine::printerName: Failed getting current PMPrinter: %ld", long(status));
|
||||
if (printer)
|
||||
ret = QCFString::toQString(PMPrinterGetName(printer));
|
||||
break; }
|
||||
case PPK_Resolution: {
|
||||
ret = d->resolution.hRes;
|
||||
break;
|
||||
}
|
||||
case PPK_SupportedResolutions:
|
||||
ret = d->supportedResolutions();
|
||||
break;
|
||||
case PPK_CustomPaperSize:
|
||||
ret = d->customSize;
|
||||
break;
|
||||
case PPK_PageMargins:
|
||||
{
|
||||
QList<QVariant> margins;
|
||||
if (d->hasCustomPageMargins) {
|
||||
margins << d->leftMargin << d->topMargin
|
||||
<< d->rightMargin << d->bottomMargin;
|
||||
} else {
|
||||
PMPaperMargins paperMargins;
|
||||
PMPaper paper;
|
||||
PMGetPageFormatPaper(d->format, &paper);
|
||||
PMPaperGetMargins(paper, &paperMargins);
|
||||
margins << paperMargins.left << paperMargins.top
|
||||
<< paperMargins.right << paperMargins.bottom;
|
||||
}
|
||||
ret = margins;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_PRINTER
|
@ -1,162 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPRINTENGINE_MAC_P_H
|
||||
#define QPRINTENGINE_MAC_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
#include "QtGui/qprinter.h"
|
||||
#include "QtGui/qprintengine.h"
|
||||
#include "private/qpaintengine_mac_p.h"
|
||||
#include "private/qpainter_p.h"
|
||||
|
||||
#ifdef __OBJC__
|
||||
@class NSPrintInfo;
|
||||
#else
|
||||
typedef void NSPrintInfo;
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QPrinterPrivate;
|
||||
class QMacPrintEnginePrivate;
|
||||
class QMacPrintEngine : public QPaintEngine, public QPrintEngine
|
||||
{
|
||||
Q_DECLARE_PRIVATE(QMacPrintEngine)
|
||||
public:
|
||||
QMacPrintEngine(QPrinter::PrinterMode mode);
|
||||
|
||||
Qt::HANDLE handle() const;
|
||||
|
||||
bool begin(QPaintDevice *dev);
|
||||
bool end();
|
||||
virtual QPaintEngine::Type type() const { return QPaintEngine::MacPrinter; }
|
||||
|
||||
QPaintEngine *paintEngine() const;
|
||||
|
||||
void setProperty(PrintEnginePropertyKey key, const QVariant &value);
|
||||
QVariant property(PrintEnginePropertyKey key) const;
|
||||
|
||||
QPrinter::PrinterState printerState() const;
|
||||
|
||||
bool newPage();
|
||||
bool abort();
|
||||
int metric(QPaintDevice::PaintDeviceMetric) const;
|
||||
|
||||
//forwarded functions
|
||||
|
||||
void updateState(const QPaintEngineState &state);
|
||||
|
||||
virtual void drawLines(const QLineF *lines, int lineCount);
|
||||
virtual void drawRects(const QRectF *r, int num);
|
||||
virtual void drawPoints(const QPointF *p, int pointCount);
|
||||
virtual void drawEllipse(const QRectF &r);
|
||||
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
|
||||
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
|
||||
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags);
|
||||
virtual void drawTextItem(const QPointF &p, const QTextItem &ti);
|
||||
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
|
||||
virtual void drawPath(const QPainterPath &);
|
||||
|
||||
private:
|
||||
friend class QPrintDialog;
|
||||
friend class QPageSetupDialog;
|
||||
};
|
||||
|
||||
class QMacPrintEnginePrivate : public QPaintEnginePrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QMacPrintEngine)
|
||||
public:
|
||||
QPrinter::PrinterMode mode;
|
||||
QPrinter::PrinterState state;
|
||||
QPrinter::Orientation orient;
|
||||
NSPrintInfo *printInfo;
|
||||
PMPageFormat format;
|
||||
PMPrintSettings settings;
|
||||
PMPrintSession session;
|
||||
PMResolution resolution;
|
||||
QString outputFilename;
|
||||
bool fullPage;
|
||||
QPaintEngine *paintEngine;
|
||||
bool suppressStatus;
|
||||
bool hasCustomPaperSize;
|
||||
QSizeF customSize;
|
||||
bool hasCustomPageMargins;
|
||||
qreal leftMargin;
|
||||
qreal topMargin;
|
||||
qreal rightMargin;
|
||||
qreal bottomMargin;
|
||||
QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant> valueCache;
|
||||
QMacPrintEnginePrivate() : mode(QPrinter::ScreenResolution), state(QPrinter::Idle),
|
||||
orient(QPrinter::Portrait), printInfo(0), format(0), settings(0),
|
||||
session(0), paintEngine(0), suppressStatus(false),
|
||||
hasCustomPaperSize(false), hasCustomPageMargins(false) {}
|
||||
~QMacPrintEnginePrivate();
|
||||
void initialize();
|
||||
void releaseSession();
|
||||
bool newPage_helper();
|
||||
void setPaperSize(QPrinter::PaperSize ps);
|
||||
QPrinter::PaperSize paperSize() const;
|
||||
QList<QVariant> supportedResolutions() const;
|
||||
inline bool isPrintSessionInitialized() const
|
||||
{
|
||||
return printInfo != 0;
|
||||
}
|
||||
bool shouldSuppressStatus() const;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_PRINTER
|
||||
|
||||
#endif // QPRINTENGINE_WIN_P_H
|
@ -1,120 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qprinterinfo.h"
|
||||
#include "qprinterinfo_p.h"
|
||||
|
||||
#include "private/qt_mac_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
extern QPrinter::PaperSize qSizeFTopaperSize(const QSizeF &size);
|
||||
|
||||
QList<QPrinterInfo> QPrinterInfo::availablePrinters()
|
||||
{
|
||||
QList<QPrinterInfo> printers;
|
||||
|
||||
QCFType<CFArrayRef> array;
|
||||
if (PMServerCreatePrinterList(kPMServerLocal, &array) == noErr) {
|
||||
CFIndex count = CFArrayGetCount(array);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
PMPrinter printer = static_cast<PMPrinter>(const_cast<void *>(CFArrayGetValueAtIndex(array, i)));
|
||||
QString printerName = QCFString::toQString(PMPrinterGetName(printer));
|
||||
|
||||
QPrinterInfo printerInfo(printerName);
|
||||
if (PMPrinterIsDefault(printer))
|
||||
printerInfo.d_ptr->isDefault = true;
|
||||
printers.append(printerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return printers;
|
||||
}
|
||||
|
||||
QPrinterInfo QPrinterInfo::defaultPrinter()
|
||||
{
|
||||
QList<QPrinterInfo> printers = availablePrinters();
|
||||
foreach (const QPrinterInfo &printerInfo, printers) {
|
||||
if (printerInfo.isDefault())
|
||||
return printerInfo;
|
||||
}
|
||||
|
||||
return printers.value(0);
|
||||
}
|
||||
|
||||
QList<QPrinter::PaperSize> QPrinterInfo::supportedPaperSizes() const
|
||||
{
|
||||
const Q_D(QPrinterInfo);
|
||||
|
||||
QList<QPrinter::PaperSize> paperSizes;
|
||||
if (isNull())
|
||||
return paperSizes;
|
||||
|
||||
PMPrinter cfPrn = PMPrinterCreateFromPrinterID(QCFString::toCFStringRef(d->name));
|
||||
if (!cfPrn)
|
||||
return paperSizes;
|
||||
|
||||
CFArrayRef array;
|
||||
if (PMPrinterGetPaperList(cfPrn, &array) != noErr) {
|
||||
PMRelease(cfPrn);
|
||||
return paperSizes;
|
||||
}
|
||||
|
||||
int count = CFArrayGetCount(array);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
PMPaper paper = static_cast<PMPaper>(const_cast<void *>(CFArrayGetValueAtIndex(array, i)));
|
||||
double width, height;
|
||||
if (PMPaperGetWidth(paper, &width) == noErr && PMPaperGetHeight(paper, &height) == noErr) {
|
||||
QSizeF size(width * 0.3527, height * 0.3527);
|
||||
paperSizes.append(qSizeFTopaperSize(size));
|
||||
}
|
||||
}
|
||||
|
||||
PMRelease(cfPrn);
|
||||
|
||||
return paperSizes;
|
||||
}
|
||||
|
||||
#endif // QT_NO_PRINTER
|
||||
|
||||
QT_END_NAMESPACE
|
@ -1,50 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qt_mac_p.h>
|
||||
#include "qcoreapplication.h"
|
||||
#include <qlibrary.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QRegion::QRegionData QRegion::shared_empty = { Q_BASIC_ATOMIC_INITIALIZER(1), 0 };
|
||||
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
@ -1,308 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2007-2008, Apple, Inc.
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright notice,
|
||||
** this list of conditions and the following disclaimer.
|
||||
**
|
||||
** * Redistributions in binary form must reproduce the above copyright notice,
|
||||
** this list of conditions and the following disclaimer in the documentation
|
||||
** and/or other materials provided with the distribution.
|
||||
**
|
||||
** * Neither the name of Apple, Inc. nor the names of its contributors
|
||||
** may be used to endorse or promote products derived from this software
|
||||
** without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT_COCOA_HELPERS_MAC_P_H
|
||||
#define QT_COCOA_HELPERS_MAC_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
|
||||
// and many other. This header file may change from version to version
|
||||
// without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <private/qt_mac_p.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qdesktopwidget.h>
|
||||
#include <qwidget.h>
|
||||
#include <qevent.h>
|
||||
#include <qhash.h>
|
||||
#include <qlabel.h>
|
||||
#include <qpointer.h>
|
||||
#include <qstyle.h>
|
||||
#include <qstyleoption.h>
|
||||
#include <qstylepainter.h>
|
||||
#include <qtimer.h>
|
||||
#include <qtooltip.h>
|
||||
#include <private/qeffects_p.h>
|
||||
#include <private/qwidget_p.h>
|
||||
#include <qtextdocument.h>
|
||||
#include <qdebug.h>
|
||||
#include <qpoint.h>
|
||||
#include "private/qt_mac_p.h"
|
||||
|
||||
struct HIContentBorderMetrics;
|
||||
|
||||
#ifdef __OBJC__
|
||||
// If the source file including this file also includes e.g. Cocoa/Cocoa.h, typedef-ing NSPoint will
|
||||
// fail since NSPoint will already be a type. So we try to detect this. If the build fails, ensure
|
||||
// that the inclusion of cocoa headers happends before the inclusion of this file.
|
||||
#include <Foundation/NSGeometry.h>
|
||||
#else
|
||||
#ifdef Q_WS_MAC32
|
||||
typedef struct _NSPoint NSPoint; // Just redefine here so I don't have to pull in all of Cocoa.
|
||||
#else
|
||||
typedef struct CGPoint NSPoint;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Qt::MouseButtons qt_mac_get_buttons(int buttons);
|
||||
Qt::MouseButton qt_mac_get_button(EventMouseButton button);
|
||||
void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds = 0.15);
|
||||
void macWindowToolbarShow(const QWidget *widget, bool show );
|
||||
void macWindowToolbarSet( void * /*OSWindowRef*/ window, void* toolbarRef );
|
||||
bool macWindowToolbarIsVisible( void * /*OSWindowRef*/ window );
|
||||
void macWindowSetHasShadow( void * /*OSWindowRef*/ window, bool hasShadow );
|
||||
void macWindowFlush(void * /*OSWindowRef*/ window);
|
||||
void macSendToolbarChangeEvent(QWidget *widget);
|
||||
void qt_mac_updateContentBorderMetricts(void * /*OSWindowRef */window, const ::HIContentBorderMetrics &metrics);
|
||||
void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widget);
|
||||
void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivate *widget);
|
||||
void qt_mac_showBaseLineSeparator(void * /*OSWindowRef */window, bool show);
|
||||
void qt_mac_update_mouseTracking(QWidget *widget);
|
||||
OSStatus qt_mac_drawCGImage(CGContextRef cg, const CGRect *inbounds, CGImageRef);
|
||||
bool qt_mac_checkForNativeSizeGrip(const QWidget *widget);
|
||||
void qt_dispatchTabletProximityEvent(void * /*NSEvent * */ tabletEvent);
|
||||
bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent);
|
||||
// These methods exists only for supporting unified mode.
|
||||
void macDrawRectOnTop(void * /*OSWindowRef */ window);
|
||||
void macSyncDrawingOnFirstInvocation(void * /*OSWindowRef */window);
|
||||
void qt_cocoaStackChildWindowOnTopOfOtherChildren(QWidget *widget);
|
||||
bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEvent);
|
||||
void qt_dispatchModifiersChanged(void * /*NSEvent * */flagsChangedEvent, QWidget *widgetToGetEvent);
|
||||
bool qt_mac_handleTabletEvent(void * /*QCocoaView * */view, void * /*NSEvent * */event);
|
||||
inline QApplication *qAppInstance() { return static_cast<QApplication *>(QCoreApplication::instance()); }
|
||||
struct ::TabletProximityRec;
|
||||
void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec);
|
||||
Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags);
|
||||
Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations);
|
||||
QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height);
|
||||
void qt_mac_constructQIconFromIconRef(const IconRef icon, const IconRef overlayIcon, QIcon *retIcon,
|
||||
QStyle::StandardPixmap standardIcon = QStyle::SP_CustomBase);
|
||||
|
||||
#ifdef __OBJC__
|
||||
struct DnDParams
|
||||
{
|
||||
NSView *view;
|
||||
NSEvent *theEvent;
|
||||
QPoint globalPoint;
|
||||
NSDragOperation performedAction;
|
||||
};
|
||||
|
||||
DnDParams *macCurrentDnDParameters();
|
||||
NSDragOperation qt_mac_mapDropAction(Qt::DropAction action);
|
||||
NSDragOperation qt_mac_mapDropActions(Qt::DropActions actions);
|
||||
Qt::DropAction qt_mac_mapNSDragOperation(NSDragOperation nsActions);
|
||||
Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions);
|
||||
|
||||
QWidget *qt_mac_getTargetForKeyEvent(QWidget *widgetThatReceivedEvent);
|
||||
QWidget *qt_mac_getTargetForMouseEvent(NSEvent *event, QEvent::Type eventType,
|
||||
QPoint &returnLocalPoint, QPoint &returnGlobalPoint, QWidget *nativeWidget, QWidget **returnWidgetUnderMouse);
|
||||
bool qt_mac_handleMouseEvent(NSEvent *event, QEvent::Type eventType, Qt::MouseButton button, QWidget *nativeWidget);
|
||||
void qt_mac_handleNonClientAreaMouseEvent(NSWindow *window, NSEvent *event);
|
||||
#endif
|
||||
|
||||
inline int flipYCoordinate(int y)
|
||||
{
|
||||
return QApplication::desktop()->screenGeometry(0).height() - y;
|
||||
}
|
||||
|
||||
inline qreal flipYCoordinate(qreal y)
|
||||
{
|
||||
return QApplication::desktop()->screenGeometry(0).height() - y;
|
||||
}
|
||||
|
||||
QPointF flipPoint(const NSPoint &p);
|
||||
NSPoint flipPoint(const QPoint &p);
|
||||
NSPoint flipPoint(const QPointF &p);
|
||||
|
||||
QStringList qt_mac_NSArrayToQStringList(void *nsarray);
|
||||
void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list);
|
||||
|
||||
void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow);
|
||||
|
||||
CGFloat qt_mac_get_scalefactor();
|
||||
QString qt_mac_get_pasteboardString(OSPasteboardRef paste);
|
||||
|
||||
#ifdef __OBJC__
|
||||
inline NSMutableArray *qt_mac_QStringListToNSMutableArray(const QStringList &qstrlist)
|
||||
{ return reinterpret_cast<NSMutableArray *>(qt_mac_QStringListToNSMutableArrayVoid(qstrlist)); }
|
||||
|
||||
inline QString qt_mac_NSStringToQString(const NSString *nsstr)
|
||||
{ return QCFString::toQString(reinterpret_cast<const CFStringRef>(nsstr)); }
|
||||
|
||||
inline NSString *qt_mac_QStringToNSString(const QString &qstr)
|
||||
{ return [const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr))) autorelease]; }
|
||||
|
||||
#endif
|
||||
|
||||
class QMacScrollOptimization {
|
||||
// This class is made to optimize for the case when the user
|
||||
// scrolls both horizontally and vertically at the same
|
||||
// time. This will result in two QWheelEvents (one for each
|
||||
// direction), which will typically result in two calls to
|
||||
// QWidget::_scroll_sys. Rather than copying pixels twize on
|
||||
// screen because of this, we add this helper class to try to
|
||||
// get away with only one blit.
|
||||
static QWidgetPrivate *_target;
|
||||
static bool _inWheelEvent;
|
||||
static int _dx;
|
||||
static int _dy;
|
||||
static QRect _scrollRect;
|
||||
|
||||
public:
|
||||
static void initDelayedScroll()
|
||||
{
|
||||
_inWheelEvent = true;
|
||||
}
|
||||
|
||||
static bool delayScroll(QWidgetPrivate *target, int dx, int dy, const QRect &scrollRect)
|
||||
{
|
||||
if (!_inWheelEvent)
|
||||
return false;
|
||||
if (_target && _target != target)
|
||||
return false;
|
||||
if (_scrollRect.width() != -1 && _scrollRect != scrollRect)
|
||||
return false;
|
||||
|
||||
_target = target;
|
||||
_dx += dx;
|
||||
_dy += dy;
|
||||
_scrollRect = scrollRect;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void performDelayedScroll()
|
||||
{
|
||||
if (!_inWheelEvent)
|
||||
return;
|
||||
_inWheelEvent = false;
|
||||
if (!_target)
|
||||
return;
|
||||
|
||||
_target->scroll_sys(_dx, _dy, _scrollRect);
|
||||
|
||||
_target = 0;
|
||||
_dx = 0;
|
||||
_dy = 0;
|
||||
_scrollRect = QRect(0, 0, -1, -1);
|
||||
}
|
||||
};
|
||||
|
||||
void qt_mac_post_retranslateAppMenu();
|
||||
|
||||
void qt_mac_display(QWidget *widget);
|
||||
void qt_mac_setNeedsDisplay(QWidget *widget);
|
||||
void qt_mac_setNeedsDisplayInRect(QWidget *widget, QRegion region);
|
||||
|
||||
|
||||
// Utility functions to ease the use of Core Graphics contexts.
|
||||
|
||||
inline void qt_mac_retain_graphics_context(CGContextRef context)
|
||||
{
|
||||
CGContextRetain(context);
|
||||
CGContextSaveGState(context);
|
||||
}
|
||||
|
||||
inline void qt_mac_release_graphics_context(CGContextRef context)
|
||||
{
|
||||
CGContextRestoreGState(context);
|
||||
CGContextRelease(context);
|
||||
}
|
||||
|
||||
inline void qt_mac_draw_image(CGContextRef context, CGContextRef imageContext, CGRect area, CGRect drawingArea)
|
||||
{
|
||||
CGImageRef image = CGBitmapContextCreateImage(imageContext);
|
||||
CGImageRef subImage = CGImageCreateWithImageInRect(image, area);
|
||||
|
||||
CGContextTranslateCTM (context, 0, drawingArea.origin.y + CGRectGetMaxY(drawingArea));
|
||||
CGContextScaleCTM(context, 1, -1);
|
||||
CGContextDrawImage(context, drawingArea, subImage);
|
||||
|
||||
CGImageRelease(subImage);
|
||||
CGImageRelease(image);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_COCOA_HELPERS_MAC_P_H
|
@ -1,129 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <private/qt_mac_p.h>
|
||||
#include <private/qpixmap_mac_p.h>
|
||||
#include <private/qnativeimage_p.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
static CTFontRef CopyCTThemeFont(ThemeFontID themeID)
|
||||
{
|
||||
CTFontUIFontType ctID = HIThemeGetUIFontType(themeID);
|
||||
return CTFontCreateUIFontForLanguage(ctID, 0, 0);
|
||||
}
|
||||
|
||||
QFont qfontForThemeFont(ThemeFontID themeID)
|
||||
{
|
||||
QCFType<CTFontRef> ctfont = CopyCTThemeFont(themeID);
|
||||
QString familyName = QCFString(CTFontCopyFamilyName(ctfont));
|
||||
QCFType<CFDictionaryRef> dict = CTFontCopyTraits(ctfont);
|
||||
CFNumberRef num = static_cast<CFNumberRef>(CFDictionaryGetValue(dict, kCTFontWeightTrait));
|
||||
float fW;
|
||||
CFNumberGetValue(num, kCFNumberFloat32Type, &fW);
|
||||
QFont::Weight wght = fW > 0. ? QFont::Bold : QFont::Normal;
|
||||
num = static_cast<CFNumberRef>(CFDictionaryGetValue(dict, kCTFontSlantTrait));
|
||||
CFNumberGetValue(num, kCFNumberFloatType, &fW);
|
||||
bool italic = (fW != 0.0);
|
||||
return QFont(familyName, CTFontGetSize(ctfont), wght, italic);
|
||||
}
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
|
||||
static inline QColor leopardBrush(ThemeBrush brush)
|
||||
{
|
||||
QCFType<CGColorRef> cgClr = 0;
|
||||
HIThemeBrushCreateCGColor(brush, &cgClr);
|
||||
return qcolorFromCGColor(cgClr);
|
||||
}
|
||||
#endif
|
||||
|
||||
QColor qcolorForTheme(ThemeBrush brush)
|
||||
{
|
||||
return leopardBrush(brush);
|
||||
}
|
||||
|
||||
QColor qcolorForThemeTextColor(ThemeTextColor themeColor)
|
||||
{
|
||||
#ifdef Q_OS_MAC32
|
||||
RGBColor c;
|
||||
GetThemeTextColor(themeColor, 32, true, &c);
|
||||
QColor color = QColor(c.red / 256, c.green / 256, c.blue / 256);
|
||||
return color;
|
||||
#else
|
||||
// There is no equivalent to GetThemeTextColor in 64-bit and it was rather bad that
|
||||
// I didn't file a request to implement this for Snow Leopard. So, in the meantime
|
||||
// I've encoded the values from the GetThemeTextColor. This is not exactly ideal
|
||||
// as if someone really wants to mess with themeing, these colors will be wrong.
|
||||
// It also means that we need to make sure the values for differences between
|
||||
// OS releases (and it will be likely that we are a step behind.)
|
||||
switch (themeColor) {
|
||||
case kThemeTextColorAlertActive:
|
||||
case kThemeTextColorTabFrontActive:
|
||||
case kThemeTextColorBevelButtonActive:
|
||||
case kThemeTextColorListView:
|
||||
case kThemeTextColorPlacardActive:
|
||||
case kThemeTextColorPopupButtonActive:
|
||||
case kThemeTextColorPopupLabelActive:
|
||||
case kThemeTextColorPushButtonActive:
|
||||
return Qt::black;
|
||||
case kThemeTextColorAlertInactive:
|
||||
case kThemeTextColorDialogInactive:
|
||||
case kThemeTextColorPlacardInactive:
|
||||
return QColor(69, 69, 69, 255);
|
||||
case kThemeTextColorPopupButtonInactive:
|
||||
case kThemeTextColorPopupLabelInactive:
|
||||
case kThemeTextColorPushButtonInactive:
|
||||
case kThemeTextColorTabFrontInactive:
|
||||
case kThemeTextColorBevelButtonInactive:
|
||||
return QColor(127, 127, 127, 255);
|
||||
default: {
|
||||
QNativeImage nativeImage(16,16, QNativeImage::systemFormat());
|
||||
CGRect cgrect = CGRectMake(0, 0, 16, 16);
|
||||
HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
|
||||
CGContextFillRect(nativeImage.cg, cgrect);
|
||||
QColor color = nativeImage.image.pixel(0,0);
|
||||
return QColor(nativeImage.image.pixel(0 , 0));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
QT_END_NAMESPACE
|
File diff suppressed because it is too large
Load Diff
@ -44,6 +44,8 @@
|
||||
.../doc/src/qstyles.qdoc.
|
||||
*/
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
#include "qmacstyle_mac.h"
|
||||
#include "qmacstyle_mac_p.h"
|
||||
#include "qmacstylepixmaps_mac_p.h"
|
||||
|
@ -74,12 +74,6 @@
|
||||
# include <private/qt_x11_p.h>
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC) && !defined(QT_NO_EFFECTS)
|
||||
# include <private/qcore_mac_p.h>
|
||||
# include <private/qt_cocoa_helpers_mac_p.h>
|
||||
#endif
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QMenu *QMenuPrivate::mouseDown = 0;
|
||||
|
@ -55,9 +55,6 @@
|
||||
|
||||
#include "QtWidgets/qmenubar.h"
|
||||
#include "QtWidgets/qstyleoption.h"
|
||||
#ifdef Q_OS_MAC
|
||||
#include "QtWidgets/qmacdefines_mac.h"
|
||||
#endif
|
||||
#include "QtCore/qdatetime.h"
|
||||
#include "QtCore/qmap.h"
|
||||
#include "QtCore/qhash.h"
|
||||
|
@ -43,10 +43,6 @@
|
||||
#define QMENUBAR_H
|
||||
|
||||
#include <QtWidgets/qmenu.h>
|
||||
#ifdef Q_OS_MAC
|
||||
#include "QtWidgets/qmacdefines_mac.h"
|
||||
#endif
|
||||
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
@ -157,12 +153,6 @@ private:
|
||||
friend class QMenu;
|
||||
friend class QMenuPrivate;
|
||||
friend class QWindowsStyle;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
friend class QApplicationPrivate;
|
||||
friend class QWidgetPrivate;
|
||||
friend bool qt_mac_activate_action(MenuRef, uint, QAction::ActionEvent, bool);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // QT_NO_MENUBAR
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
# include <private/qt_mac_p.h>
|
||||
# include <ApplicationServices/ApplicationServices.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user