Qt 4.8
qplatformscreen_qpa.cpp
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 QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qplatformscreen_qpa.h"
43 #include <QtGui/qapplication.h>
44 #include <QtGui/private/qapplication_p.h>
45 #include <QtGui/qdesktopwidget.h>
46 #include <QtGui/qplatformintegration_qpa.h>
47 #include <QtGui/qwidget.h>
48 #include <QtGui/private/qwidget_p.h>
49 
57 {
59  for (int i = list.size()-1; i >= 0; --i) {
60  QWidget *w = list[i];
61  //### mask is ignored
62  if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos))
63  return w;
64  }
65 
66  return 0;
67 }
68 
80 {
81  static const int dpi = 100;
82  int width = geometry().width() / dpi * qreal(25.4) ;
83  int height = geometry().height() / dpi * qreal(25.4) ;
84  return QSize(width,height);
85 }
86 
89 {
90  QWidget *window = widget->window();
91  QWidgetPrivate *windowPrivate = qt_widget_private(window);
92  QTLWExtra * topData = windowPrivate->topData();
93  QPlatformIntegration *integration =
94  QApplicationPrivate::platformIntegration();
95  return integration->screens()[topData->screenIndex];
96 }
97 
double qreal
Definition: qglobal.h:1193
QPointer< QWidget > widget
The QPlatformScreen class provides an abstraction for visual displays.
bool isVisible() const
Definition: qwidget.h:1005
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
virtual QWidget * topLevelAt(const QPoint &point) const
Return the given top level widget for a given position.
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
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
NSWindow * window
virtual QList< QPlatformScreen * > screens() const =0
Accessor function to a list of all the screens on the current system.
static QPlatformScreen * platformScreenForWidget(const QWidget *widget)
QTLWExtra * topData() const
Definition: qwidget_p.h:1004
virtual QRect geometry() const =0
Reimplement in subclass to return the pixel geometry of the screen.
static QWidgetList topLevelWidgets()
Returns a list of the top-level widgets (windows) in the application.
virtual QSize physicalSize() const
Reimplement this function in subclass to return the physical size of the screen.
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
Definition: qrect.cpp:1101
The QPlatformIntegration class is the entry for WindowSystem specific functionality.
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:158
The QList class is a template class that provides lists.
Definition: qdatastream.h:62