1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qplatformintegration_qpa.h"
44 #include <QtGui/QPlatformFontDatabase>
45 #include <QtGui/QPlatformClipboard>
46 #include <QtGui/QPlatformPrinterSupport>
47 #include <QtGui/private/qguiapplication_p.h>
48 #include <QtGui/private/qpixmap_raster_p.h>
49 #include <private/qdnd_p.h>
54 Accessor for the platform integration's fontdatabase.
56 Default implementation returns a default QPlatformFontDatabase.
58 \sa QPlatformFontDatabase
60 QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const
62 static QPlatformFontDatabase *db = 0;
64 db = new QPlatformFontDatabase;
70 Accessor for the platform integration's clipboard.
72 Default implementation returns a default QPlatformClipboard.
74 \sa QPlatformClipboard
78 #ifndef QT_NO_CLIPBOARD
80 QPlatformClipboard *QPlatformIntegration::clipboard() const
82 static QPlatformClipboard *clipboard = 0;
84 clipboard = new QPlatformClipboard;
91 #ifndef QT_NO_DRAGANDDROP
93 Accessor for the platform integration's drag object.
95 Default implementation returns 0, implying no drag and drop support.
98 QPlatformDrag *QPlatformIntegration::drag() const
104 QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
110 \class QPlatformIntegration
115 \brief The QPlatformIntegration class is the entry for WindowSystem specific functionality.
117 QPlatformIntegration is the single entry point for windowsystem specific functionality when
118 using the QPA platform. It has factory functions for creating platform specific pixmaps and
119 windows. The class also controls the font subsystem.
121 QPlatformIntegration is a singleton class which gets instantiated in the QGuiApplication
122 constructor. The QPlatformIntegration instance do not have ownership of objects it creates in
123 functions where the name starts with create. However, functions which don't have a name
124 starting with create acts as accessors to member variables.
126 It is not trivial to create or build a platform plugin outside of the Qt source tree. Therefore
127 the recommended approach for making new platform plugin is to copy an existing plugin inside
128 the QTSRCTREE/src/plugins/platform and develop the plugin inside the source tree.
130 The minimal platform integration is the smallest platform integration it is possible to make,
131 which makes it an ideal starting point for new plugins. For a slightly more advanced plugin,
132 consider reviewing the directfb plugin, or the testlite plugin.
136 \fn QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
138 Factory function for QPlatformPixmap. PixelType can be either PixmapType or BitmapType.
143 \fn QPlatformWindow *QPlatformIntegration::createPlatformWindow(QWindow *window) const
145 Factory function for QPlatformWindow. The \a window parameter is a pointer to the top level
146 window which the QPlatformWindow is supposed to be created for.
148 All top level windows have to have a QPlatformWindow, and it will be created when the
149 QPlatformWindow is set to be visible for the first time. If the top level window's flags are
150 changed, or if the top level window's QPlatformWindowFormat is changed, then the top level
151 window's QPlatformWindow is deleted and a new one is created.
153 In the constructor, of the QPlatformWindow, the window flags, state, title and geometry
154 of the \a window should be applied to the underlying window. If the resulting flags or state
155 differs, the resulting values should be set on the \a window using QWindow::setWindowFlags()
156 or QWindow::setWindowState(), respectively.
158 \sa QPlatformWindow, QPlatformWindowFormat
159 \sa createPlatformBackingStore(QWindow *window) const
163 \fn QPlatformBackingStore *QPlatformIntegration::createPlatformBackingStore(QWindow *window) const
165 Factory function for QPlatformBackingStore. The QWindow parameter is a pointer to the
166 top level widget(tlw) the window surface is created for. A QPlatformWindow is always created
167 before the QPlatformBackingStore for tlw where the widget also requires a backing store.
170 \sa createPlatformWindow(QWindow *window, WId winId = 0) const
174 \fn QAbstractEventDispatcher *createEventDispatcher() const
176 Factory function for the event dispatcher. The platform plugin
177 must create and and return a QAbstractEventDispatcher subclass when
178 this function is called.
181 bool QPlatformIntegration::hasCapability(Capability cap) const
187 QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
189 return new QRasterPlatformPixmap(type);
192 QPlatformGLContext *QPlatformIntegration::createPlatformGLContext(QGuiGLContext *context) const
194 qWarning("This plugin does not support createPlatformGLContext!");
200 Returns the platform's printing support.
205 QPlatformPrinterSupport *QPlatformIntegration::printerSupport() const
207 static QPlatformPrinterSupport *ps = 0;
208 #ifndef QT_NO_PRINTER
210 ps = new QPlatformPrinterSupport;
216 Returns the platforms input context.
218 The default implementation returns 0, implying no input method support.
220 QPlatformInputContext *QPlatformIntegration::inputContext() const
226 Should be called by the implementation whenever a new screen is added.
228 The first screen added will be the primary screen, used for default-created
229 windows, GL contexts, and other resources unless otherwise specified.
231 This adds the screen to QGuiApplication::screens(), and emits the
232 QGuiApplication::screenAdded() signal.
234 The screen is automatically removed when the QPlatformScreen is destroyed.
236 void QPlatformIntegration::screenAdded(QPlatformScreen *ps)
238 QScreen *screen = ps ? ps->screen() : 0;
239 if (screen && !QGuiApplicationPrivate::screen_list.contains(screen)) {
240 QGuiApplicationPrivate::screen_list << screen;
241 emit qGuiApp->screenAdded(screen);