Qt 4.8
qpaintdevice_x11.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 "qpaintdevice.h"
43 #include "qpainter.h"
44 #include "qwidget.h"
45 #include "qbitmap.h"
46 #include "qapplication.h"
47 #include <private/qt_x11_p.h>
48 #include "qx11info_x11.h"
49 
51 
62 {
63  if (!pd) return 0;
64  if (pd->devType() == QInternal::Widget)
65  return static_cast<const QWidget *>(pd)->handle();
66  else if (pd->devType() == QInternal::Pixmap)
67  return static_cast<const QPixmap *>(pd)->handle();
68  return 0;
69 }
70 
81 {
82  if (!pd) return 0;
83  if (pd->devType() == QInternal::Widget)
84  return &static_cast<const QWidget *>(pd)->x11Info();
85  else if (pd->devType() == QInternal::Pixmap)
86  return &static_cast<const QPixmap *>(pd)->x11Info();
87  return 0;
88 }
89 
90 
91 
92 #ifdef QT3_SUPPORT
93 
94 Display *QPaintDevice::x11Display() const
95 {
96  return X11->display;
97 }
98 
99 int QPaintDevice::x11Screen() const
100 {
101  const QX11Info *info = qt_x11Info(this);
102  if (info)
103  return info->screen();
104  return QX11Info::appScreen();
105 }
106 
107 void *QPaintDevice::x11Visual() const
108 {
109  const QX11Info *info = qt_x11Info(this);
110  if (info)
111  return info->visual();
112  return QX11Info::appVisual();
113 }
114 
115 int QPaintDevice::x11Depth() const
116 {
117  const QX11Info *info = qt_x11Info(this);
118  if (info)
119  return info->depth();
120  return QX11Info::appDepth();
121 }
122 
123 int QPaintDevice::x11Cells() const
124 {
125  const QX11Info *info = qt_x11Info(this);
126  if (info)
127  return info->cells();
128  return QX11Info::appCells();
129 }
130 
131 Qt::HANDLE QPaintDevice::x11Colormap() const
132 {
133  const QX11Info *info = qt_x11Info(this);
134  if (info)
135  return info->colormap();
136  return QX11Info::appColormap();
137 }
138 
139 bool QPaintDevice::x11DefaultColormap() const
140 {
141  const QX11Info *info = qt_x11Info(this);
142  if (info)
143  return info->defaultColormap();
145 }
146 
147 bool QPaintDevice::x11DefaultVisual() const
148 {
149  const QX11Info *info = qt_x11Info(this);
150  if (info)
151  return info->defaultVisual();
153 }
154 
155 void *QPaintDevice::x11AppVisual(int screen)
156 { return QX11Info::appVisual(screen); }
157 
158 Qt::HANDLE QPaintDevice::x11AppColormap(int screen)
159 { return QX11Info::appColormap(screen); }
160 
161 Display *QPaintDevice::x11AppDisplay()
162 { return QX11Info::display(); }
163 
164 int QPaintDevice::x11AppScreen()
165 { return QX11Info::appScreen(); }
166 
167 int QPaintDevice::x11AppDepth(int screen)
168 { return QX11Info::appDepth(screen); }
169 
170 int QPaintDevice::x11AppCells(int screen)
171 { return QX11Info::appCells(screen); }
172 
173 Qt::HANDLE QPaintDevice::x11AppRootWindow(int screen)
174 { return QX11Info::appRootWindow(screen); }
175 
176 bool QPaintDevice::x11AppDefaultColormap(int screen)
177 { return QX11Info::appDefaultColormap(screen); }
178 
179 bool QPaintDevice::x11AppDefaultVisual(int screen)
180 { return QX11Info::appDefaultVisual(screen); }
181 
182 void QPaintDevice::x11SetAppDpiX(int dpi, int screen)
183 {
184  QX11Info::setAppDpiX(dpi, screen);
185 }
186 
187 void QPaintDevice::x11SetAppDpiY(int dpi, int screen)
188 {
189  QX11Info::setAppDpiY(dpi, screen);
190 }
191 
192 int QPaintDevice::x11AppDpiX(int screen)
193 {
194  return QX11Info::appDpiX(screen);
195 }
196 
197 int QPaintDevice::x11AppDpiY(int screen)
198 {
199  return QX11Info::appDpiY(screen);
200 }
201 #endif
202 
203 
int depth() const
Returns the color depth (bits per pixel) of the X display.
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static int appScreen()
Returns the number of the screen where the application is being displayed.
int cells() const
Returns the number of cells.
static int appDepth(int screen=-1)
Returns the color depth (bits per pixel) used by the application on the given screen.
static bool appDefaultVisual(int screen=-1)
Returns true if the application has a default visual on the given screen; otherwise returns false...
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
static Qt::HANDLE appRootWindow(int screen=-1)
Returns a handle for the applications root window on the given screen.
#define X11
Definition: qt_x11_p.h:724
virtual int devType() const
Definition: qpaintdevice.h:167
const Q_GUI_EXPORT QX11Info * qt_x11Info(const QPaintDevice *pd)
Returns the QX11Info structure for the pd paint device.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static int appDpiX(int screen=-1)
Returns the horizontal resolution of the given screen in terms of the number of dots per inch...
static void setAppDpiY(int screen, int dpi)
Sets the vertical resolution of the given screen to the number of dots per inch specified by ydpi...
static bool appDefaultColormap(int screen=-1)
Returns true if the application has a default color map on the given screen; otherwise returns false...
bool defaultVisual() const
Returns true if there is a default visual; otherwise returns false.
Qt::HANDLE colormap() const
Returns a handle for the color map.
void * HANDLE
Definition: qnamespace.h:1671
void * visual() const
Returns the current visual.
static Qt::HANDLE appColormap(int screen=-1)
Returns a handle for the application&#39;s color map on the given screen.
struct _XDisplay Display
Definition: qwindowdefs.h:115
The QX11Info class provides information about the X display configuration.
Definition: qx11info_x11.h:63
static void * appVisual(int screen=-1)
Returns the current visual used by the application on the given screen.
bool defaultColormap() const
Returns true if there is a default color map; otherwise returns false.
static int appCells(int screen=-1)
Returns the number of cells used by the application on the given screen.
static void setAppDpiX(int screen, int dpi)
Sets the horizontal resolution of the given screen to the number of dots per inch specified by xdpi...
static Display * display()
Returns the default display for the application.
int screen() const
Returns the number of the screen currently in use.
Drawable Q_GUI_EXPORT qt_x11Handle(const QPaintDevice *pd)
Returns the X11 Drawable of the paint device.
static int appDpiY(int screen=-1)
Returns the vertical resolution of the given screen in terms of the number of dots per inch...