| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information ([email protected])
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at [email protected].
|
|---|
| 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 |
|
|---|
| 50 | QT_BEGIN_NAMESPACE
|
|---|
| 51 |
|
|---|
| 52 | QPaintDevice::QPaintDevice()
|
|---|
| 53 | {
|
|---|
| 54 | painters = 0;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp
|
|---|
| 58 |
|
|---|
| 59 | QPaintDevice::~QPaintDevice()
|
|---|
| 60 | {
|
|---|
| 61 | if (paintingActive())
|
|---|
| 62 | qWarning("QPaintDevice: Cannot destroy paint device that is being "
|
|---|
| 63 | "painted");
|
|---|
| 64 | qt_painter_removePaintDevice(this);
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | /*! \internal
|
|---|
| 68 |
|
|---|
| 69 | Returns the X11 Drawable of the paint device. 0 is returned if it
|
|---|
| 70 | can't be obtained.
|
|---|
| 71 | */
|
|---|
| 72 |
|
|---|
| 73 | Drawable Q_GUI_EXPORT qt_x11Handle(const QPaintDevice *pd)
|
|---|
| 74 | {
|
|---|
| 75 | if (!pd) return 0;
|
|---|
| 76 | if (pd->devType() == QInternal::Widget)
|
|---|
| 77 | return static_cast<const QWidget *>(pd)->handle();
|
|---|
| 78 | else if (pd->devType() == QInternal::Pixmap)
|
|---|
| 79 | return static_cast<const QPixmap *>(pd)->handle();
|
|---|
| 80 | return 0;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | /*!
|
|---|
| 84 | \relates QPaintDevice
|
|---|
| 85 |
|
|---|
| 86 | Returns the QX11Info structure for the \a pd paint device. 0 is
|
|---|
| 87 | returned if it can't be obtained.
|
|---|
| 88 | */
|
|---|
| 89 | const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd)
|
|---|
| 90 | {
|
|---|
| 91 | if (!pd) return 0;
|
|---|
| 92 | if (pd->devType() == QInternal::Widget)
|
|---|
| 93 | return &static_cast<const QWidget *>(pd)->x11Info();
|
|---|
| 94 | else if (pd->devType() == QInternal::Pixmap)
|
|---|
| 95 | return &static_cast<const QPixmap *>(pd)->x11Info();
|
|---|
| 96 | return 0;
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | int QPaintDevice::metric(PaintDeviceMetric) const
|
|---|
| 100 | {
|
|---|
| 101 | qWarning("QPaintDevice::metrics: Device has no metric information");
|
|---|
| 102 | return 0;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 | #ifdef QT3_SUPPORT
|
|---|
| 108 |
|
|---|
| 109 | /*!
|
|---|
| 110 | Use QX11Info::display() instead.
|
|---|
| 111 |
|
|---|
| 112 | \oldcode
|
|---|
| 113 | Display *display = widget->x11Display();
|
|---|
| 114 | \newcode
|
|---|
| 115 | Display *display = QX11Info::display();
|
|---|
| 116 | \endcode
|
|---|
| 117 |
|
|---|
| 118 | \sa QWidget::x11Info(), QX11Info::display()
|
|---|
| 119 | */
|
|---|
| 120 | Display *QPaintDevice::x11Display() const
|
|---|
| 121 | {
|
|---|
| 122 | return X11->display;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | /*!
|
|---|
| 126 | Use QX11Info::screen() instead.
|
|---|
| 127 |
|
|---|
| 128 | \oldcode
|
|---|
| 129 | int screen = widget->x11Screen();
|
|---|
| 130 | \newcode
|
|---|
| 131 | int screen = widget->x11Info().screen();
|
|---|
| 132 | \endcode
|
|---|
| 133 |
|
|---|
| 134 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 135 | */
|
|---|
| 136 | int QPaintDevice::x11Screen() const
|
|---|
| 137 | {
|
|---|
| 138 | const QX11Info *info = qt_x11Info(this);
|
|---|
| 139 | if (info)
|
|---|
| 140 | return info->screen();
|
|---|
| 141 | return QX11Info::appScreen();
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | /*!
|
|---|
| 145 | Use QX11Info::visual() instead.
|
|---|
| 146 |
|
|---|
| 147 | \oldcode
|
|---|
| 148 | void *visual = widget->x11Visual();
|
|---|
| 149 | \newcode
|
|---|
| 150 | void *visual = widget->x11Info().visual();
|
|---|
| 151 | \endcode
|
|---|
| 152 |
|
|---|
| 153 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 154 | */
|
|---|
| 155 | void *QPaintDevice::x11Visual() const
|
|---|
| 156 | {
|
|---|
| 157 | const QX11Info *info = qt_x11Info(this);
|
|---|
| 158 | if (info)
|
|---|
| 159 | return info->visual();
|
|---|
| 160 | return QX11Info::appVisual();
|
|---|
| 161 | }
|
|---|
| 162 |
|
|---|
| 163 | /*!
|
|---|
| 164 | Use QX11Info::depth() instead.
|
|---|
| 165 |
|
|---|
| 166 | \oldcode
|
|---|
| 167 | int depth = widget->x11Depth();
|
|---|
| 168 | \newcode
|
|---|
| 169 | int depth = widget->x11Info().depth();
|
|---|
| 170 | \endcode
|
|---|
| 171 |
|
|---|
| 172 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 173 | */
|
|---|
| 174 | int QPaintDevice::x11Depth() const
|
|---|
| 175 | {
|
|---|
| 176 | const QX11Info *info = qt_x11Info(this);
|
|---|
| 177 | if (info)
|
|---|
| 178 | return info->depth();
|
|---|
| 179 | return QX11Info::appDepth();
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | /*!
|
|---|
| 183 | Use QX11Info::cells() instead.
|
|---|
| 184 |
|
|---|
| 185 | \oldcode
|
|---|
| 186 | int cells = widget->x11Cells();
|
|---|
| 187 | \newcode
|
|---|
| 188 | int cells = widget->x11Info().cells();
|
|---|
| 189 | \endcode
|
|---|
| 190 |
|
|---|
| 191 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 192 | */
|
|---|
| 193 | int QPaintDevice::x11Cells() const
|
|---|
| 194 | {
|
|---|
| 195 | const QX11Info *info = qt_x11Info(this);
|
|---|
| 196 | if (info)
|
|---|
| 197 | return info->cells();
|
|---|
| 198 | return QX11Info::appCells();
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | /*!
|
|---|
| 202 | Use QX11Info::colormap() instead.
|
|---|
| 203 |
|
|---|
| 204 | \oldcode
|
|---|
| 205 | unsigned long screen = widget->x11Colormap();
|
|---|
| 206 | \newcode
|
|---|
| 207 | unsigned long screen = widget->x11Info().colormap();
|
|---|
| 208 | \endcode
|
|---|
| 209 |
|
|---|
| 210 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 211 | */
|
|---|
| 212 | Qt::HANDLE QPaintDevice::x11Colormap() const
|
|---|
| 213 | {
|
|---|
| 214 | const QX11Info *info = qt_x11Info(this);
|
|---|
| 215 | if (info)
|
|---|
| 216 | return info->colormap();
|
|---|
| 217 | return QX11Info::appColormap();
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 | /*!
|
|---|
| 221 | Use QX11Info::defaultColormap() instead.
|
|---|
| 222 |
|
|---|
| 223 | \oldcode
|
|---|
| 224 | bool isDefault = widget->x11DefaultColormap();
|
|---|
| 225 | \newcode
|
|---|
| 226 | bool isDefault = widget->x11Info().defaultColormap();
|
|---|
| 227 | \endcode
|
|---|
| 228 |
|
|---|
| 229 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 230 | */
|
|---|
| 231 | bool QPaintDevice::x11DefaultColormap() const
|
|---|
| 232 | {
|
|---|
| 233 | const QX11Info *info = qt_x11Info(this);
|
|---|
| 234 | if (info)
|
|---|
| 235 | return info->defaultColormap();
|
|---|
| 236 | return QX11Info::appDefaultColormap();
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | /*!
|
|---|
| 240 | Use QX11Info::defaultVisual() instead.
|
|---|
| 241 |
|
|---|
| 242 | \oldcode
|
|---|
| 243 | bool isDefault = widget->x11DefaultVisual();
|
|---|
| 244 | \newcode
|
|---|
| 245 | bool isDefault = widget->x11Info().defaultVisual();
|
|---|
| 246 | \endcode
|
|---|
| 247 |
|
|---|
| 248 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 249 | */
|
|---|
| 250 | bool QPaintDevice::x11DefaultVisual() const
|
|---|
| 251 | {
|
|---|
| 252 | const QX11Info *info = qt_x11Info(this);
|
|---|
| 253 | if (info)
|
|---|
| 254 | return info->defaultVisual();
|
|---|
| 255 | return QX11Info::appDefaultVisual();
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | /*!
|
|---|
| 259 | Use QX11Info::visual() instead.
|
|---|
| 260 |
|
|---|
| 261 | \oldcode
|
|---|
| 262 | void *visual = QPaintDevice::x11AppVisual(screen);
|
|---|
| 263 | \newcode
|
|---|
| 264 | void *visual = qApp->x11Info(screen).visual();
|
|---|
| 265 | \endcode
|
|---|
| 266 |
|
|---|
| 267 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 268 | */
|
|---|
| 269 | void *QPaintDevice::x11AppVisual(int screen)
|
|---|
| 270 | { return QX11Info::appVisual(screen); }
|
|---|
| 271 |
|
|---|
| 272 | /*!
|
|---|
| 273 | Use QX11Info::colormap() instead.
|
|---|
| 274 |
|
|---|
| 275 | \oldcode
|
|---|
| 276 | unsigned long colormap = QPaintDevice::x11AppColormap(screen);
|
|---|
| 277 | \newcode
|
|---|
| 278 | unsigned long colormap = qApp->x11Info(screen).colormap();
|
|---|
| 279 | \endcode
|
|---|
| 280 |
|
|---|
| 281 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 282 | */
|
|---|
| 283 | Qt::HANDLE QPaintDevice::x11AppColormap(int screen)
|
|---|
| 284 | { return QX11Info::appColormap(screen); }
|
|---|
| 285 |
|
|---|
| 286 | /*!
|
|---|
| 287 | Use QX11Info::display() instead.
|
|---|
| 288 |
|
|---|
| 289 | \oldcode
|
|---|
| 290 | Display *display = QPaintDevice::x11AppDisplay();
|
|---|
| 291 | \newcode
|
|---|
| 292 | Display *display = qApp->x11Info().display();
|
|---|
| 293 | \endcode
|
|---|
| 294 |
|
|---|
| 295 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 296 | */
|
|---|
| 297 | Display *QPaintDevice::x11AppDisplay()
|
|---|
| 298 | { return QX11Info::display(); }
|
|---|
| 299 |
|
|---|
| 300 | /*!
|
|---|
| 301 | Use QX11Info::screen() instead.
|
|---|
| 302 |
|
|---|
| 303 | \oldcode
|
|---|
| 304 | int screen = QPaintDevice::x11AppScreen();
|
|---|
| 305 | \newcode
|
|---|
| 306 | int screen = qApp->x11Info().screen();
|
|---|
| 307 | \endcode
|
|---|
| 308 |
|
|---|
| 309 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 310 | */
|
|---|
| 311 | int QPaintDevice::x11AppScreen()
|
|---|
| 312 | { return QX11Info::appScreen(); }
|
|---|
| 313 |
|
|---|
| 314 | /*!
|
|---|
| 315 | Use QX11Info::depth() instead.
|
|---|
| 316 |
|
|---|
| 317 | \oldcode
|
|---|
| 318 | int depth = QPaintDevice::x11AppDepth(screen);
|
|---|
| 319 | \newcode
|
|---|
| 320 | int depth = qApp->x11Info(screen).depth();
|
|---|
| 321 | \endcode
|
|---|
| 322 |
|
|---|
| 323 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 324 | */
|
|---|
| 325 | int QPaintDevice::x11AppDepth(int screen)
|
|---|
| 326 | { return QX11Info::appDepth(screen); }
|
|---|
| 327 |
|
|---|
| 328 | /*!
|
|---|
| 329 | Use QX11Info::cells() instead.
|
|---|
| 330 |
|
|---|
| 331 | \oldcode
|
|---|
| 332 | int cells = QPaintDevice::x11AppCells(screen);
|
|---|
| 333 | \newcode
|
|---|
| 334 | int cells = qApp->x11Info(screen).cells();
|
|---|
| 335 | \endcode
|
|---|
| 336 |
|
|---|
| 337 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 338 | */
|
|---|
| 339 | int QPaintDevice::x11AppCells(int screen)
|
|---|
| 340 | { return QX11Info::appCells(screen); }
|
|---|
| 341 |
|
|---|
| 342 | /*!
|
|---|
| 343 | Use QX11Info::appRootWindow() instead.
|
|---|
| 344 |
|
|---|
| 345 | \oldcode
|
|---|
| 346 | unsigned long window = QPaintDevice::x11AppRootWindow(screen);
|
|---|
| 347 | \newcode
|
|---|
| 348 | unsigned long window = qApp->x11Info(screen).appRootWindow();
|
|---|
| 349 | \endcode
|
|---|
| 350 |
|
|---|
| 351 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 352 | */
|
|---|
| 353 | Qt::HANDLE QPaintDevice::x11AppRootWindow(int screen)
|
|---|
| 354 | { return QX11Info::appRootWindow(screen); }
|
|---|
| 355 |
|
|---|
| 356 | /*!
|
|---|
| 357 | Use QX11Info::defaultColormap() instead.
|
|---|
| 358 |
|
|---|
| 359 | \oldcode
|
|---|
| 360 | bool isDefault = QPaintDevice::x11AppDefaultColormap(screen);
|
|---|
| 361 | \newcode
|
|---|
| 362 | bool isDefault = qApp->x11Info(screen).defaultColormap();
|
|---|
| 363 | \endcode
|
|---|
| 364 |
|
|---|
| 365 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 366 | */
|
|---|
| 367 | bool QPaintDevice::x11AppDefaultColormap(int screen)
|
|---|
| 368 | { return QX11Info::appDefaultColormap(screen); }
|
|---|
| 369 |
|
|---|
| 370 | /*!
|
|---|
| 371 | Use QX11Info::defaultVisual() instead.
|
|---|
| 372 |
|
|---|
| 373 | \oldcode
|
|---|
| 374 | bool isDefault = QPaintDevice::x11AppDefaultVisual(screen);
|
|---|
| 375 | \newcode
|
|---|
| 376 | bool isDefault = qApp->x11Info(screen).defaultVisual();
|
|---|
| 377 | \endcode
|
|---|
| 378 |
|
|---|
| 379 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 380 | */
|
|---|
| 381 | bool QPaintDevice::x11AppDefaultVisual(int screen)
|
|---|
| 382 | { return QX11Info::appDefaultVisual(screen); }
|
|---|
| 383 |
|
|---|
| 384 | /*!
|
|---|
| 385 | Use QX11Info::setAppDpiX() instead.
|
|---|
| 386 | */
|
|---|
| 387 | void QPaintDevice::x11SetAppDpiX(int dpi, int screen)
|
|---|
| 388 | {
|
|---|
| 389 | QX11Info::setAppDpiX(dpi, screen);
|
|---|
| 390 | }
|
|---|
| 391 |
|
|---|
| 392 | /*!
|
|---|
| 393 | Use QX11Info::setAppDpiY() instead.
|
|---|
| 394 | */
|
|---|
| 395 | void QPaintDevice::x11SetAppDpiY(int dpi, int screen)
|
|---|
| 396 | {
|
|---|
| 397 | QX11Info::setAppDpiY(dpi, screen);
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 | /*!
|
|---|
| 402 | Use QX11Info::appDpiX() instead.
|
|---|
| 403 |
|
|---|
| 404 | \oldcode
|
|---|
| 405 | bool isDefault = QPaintDevice::x11AppDpiX(screen);
|
|---|
| 406 | \newcode
|
|---|
| 407 | bool isDefault = qApp->x11Info(screen).appDpiX();
|
|---|
| 408 | \endcode
|
|---|
| 409 |
|
|---|
| 410 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 411 | */
|
|---|
| 412 | int QPaintDevice::x11AppDpiX(int screen)
|
|---|
| 413 | {
|
|---|
| 414 | return QX11Info::appDpiX(screen);
|
|---|
| 415 | }
|
|---|
| 416 |
|
|---|
| 417 | /*!
|
|---|
| 418 | Use QX11Info::appDpiY() instead.
|
|---|
| 419 |
|
|---|
| 420 | \oldcode
|
|---|
| 421 | bool isDefault = QPaintDevice::x11AppDpiY(screen);
|
|---|
| 422 | \newcode
|
|---|
| 423 | bool isDefault = qApp->x11Info(screen).appDpiY();
|
|---|
| 424 | \endcode
|
|---|
| 425 |
|
|---|
| 426 | \sa QWidget::x11Info(), QPixmap::x11Info()
|
|---|
| 427 | */
|
|---|
| 428 | int QPaintDevice::x11AppDpiY(int screen)
|
|---|
| 429 | {
|
|---|
| 430 | return QX11Info::appDpiY(screen);
|
|---|
| 431 | }
|
|---|
| 432 | #endif
|
|---|
| 433 |
|
|---|
| 434 |
|
|---|
| 435 | QT_END_NAMESPACE
|
|---|