Qt 4.8
qcocoaintegration.mm
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qcocoaintegration.h"
43 
44 #include "qcocoawindow.h"
45 #include "qcocoawindowsurface.h"
47 
48 #include "qcoretextfontdatabase.h"
49 
50 #include <QtGui/QApplication>
51 
52 #include <private/qpixmap_raster_p.h>
53 
55 
58 {
59  m_screen = [[NSScreen screens] objectAtIndex:screenIndex];
60  NSRect rect = [m_screen frame];
61  m_geometry = QRect(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
62 
64 
65  m_depth = NSBitsPerPixelFromDepth([m_screen depth]);
66 
67  const int dpi = 72;
68  const qreal inch = 25.4;
69  m_physicalSize = QSize(qRound(m_geometry.width() * inch / dpi), qRound(m_geometry.height() *inch / dpi));
70 }
71 
73 {
74 }
75 
77  : mFontDb(new QCoreTextFontDatabase())
78 {
80 
81  //Make sure we have a nsapplication :)
82  [NSApplication sharedApplication];
83 // [[OurApplication alloc] init];
84 
85  NSArray *screens = [NSScreen screens];
86  for (uint i = 0; i < [screens count]; i++) {
87  QCocoaScreen *screen = new QCocoaScreen(i);
88  mScreens.append(screen);
89  }
90 }
91 
93 {
94  delete mPool;
95 }
96 
98 {
99  switch (cap) {
100  case ThreadedPixmaps: return true;
101  default: return QPlatformIntegration::hasCapability(cap);
102  }
103 }
104 
105 
106 
108 {
109  return new QRasterPixmapData(type);
110 }
111 
113 {
114  Q_UNUSED(winId);
115  return new QCocoaWindow(widget);
116 }
117 
119 {
120  return new QCocoaWindowSurface(widget,winId);
121 }
122 
124 {
125  return mFontDb;
126 }
127 
129 {
130  return new QCocoaEventLoopIntegration();
131 }
int depth() const
Reimplement in subclass to return current depth of the screen.
unsigned long WId
Definition: qwindowdefs.h:119
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
The QPlatformScreen class provides an abstraction for visual displays.
QCocoaScreen(int screenIndex)
virtual bool hasCapability(Capability cap) const
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QList< QPlatformScreen * > mScreens
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QPlatformWindow class provides an abstraction for top-level windows.
bool hasCapability(QPlatformIntegration::Capability cap) const
QPlatformFontDatabase * mFontDb
NSScreen * m_screen
QCocoaAutoReleasePool * mPool
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QPixmapData * createPixmapData(QPixmapData::PixelType type) const
Factory function for QPixmapData.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QImage::Format m_format
unsigned int uint
Definition: qglobal.h:996
The QWindowSurface class provides the drawing area for top-level windows.
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QPlatformWindow * createPlatformWindow(QWidget *widget, WId winId=0) const
Factory function for QPlatformWindow.
The QPlatformFontDatabase class makes it possible to customize how fonts are discovered and how they ...
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QList< QPlatformScreen * > screens() const
Accessor function to a list of all the screens on the current system.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
QPlatformEventLoopIntegration * createEventLoopIntegration() const
Factory function for the eventloop integration interface.
QWindowSurface * createWindowSurface(QWidget *widget, WId winId) const
Factory function for QWindowSurface.
QPlatformFontDatabase * fontDatabase() const
Accessor for the platform integrations fontdatabase.