[2] | 1 | /****************************************************************************
|
---|
| 2 | ** $Id: qpaintdevice.h 8 2005-11-16 19:36:46Z dmik $
|
---|
| 3 | **
|
---|
| 4 | ** Definition of QPaintDevice class
|
---|
| 5 | **
|
---|
| 6 | ** Created : 940721
|
---|
| 7 | **
|
---|
| 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
---|
| 9 | **
|
---|
| 10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
| 11 | **
|
---|
| 12 | ** This file may be distributed under the terms of the Q Public License
|
---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
| 14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
| 15 | **
|
---|
| 16 | ** This file may be distributed and/or modified under the terms of the
|
---|
| 17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 19 | ** packaging of this file.
|
---|
| 20 | **
|
---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
| 23 | ** Agreement provided with the Software.
|
---|
| 24 | **
|
---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 27 | **
|
---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
| 29 | ** information about Qt Commercial License Agreements.
|
---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
| 32 | **
|
---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
| 34 | ** not clear to you.
|
---|
| 35 | **
|
---|
| 36 | **********************************************************************/
|
---|
| 37 |
|
---|
| 38 | #ifndef QPAINTDEVICE_H
|
---|
| 39 | #define QPAINTDEVICE_H
|
---|
| 40 |
|
---|
| 41 | #ifndef QT_H
|
---|
| 42 | #include "qwindowdefs.h"
|
---|
| 43 | #include "qrect.h"
|
---|
| 44 | #endif // QT_H
|
---|
| 45 |
|
---|
| 46 | #if defined(Q_WS_QWS)
|
---|
| 47 | class QWSDisplay;
|
---|
| 48 | class QGfx;
|
---|
| 49 | #endif
|
---|
| 50 |
|
---|
| 51 | class QIODevice;
|
---|
| 52 | class QString;
|
---|
| 53 | class QTextItem;
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | #if defined(Q_WS_X11)
|
---|
| 57 | struct QPaintDeviceX11Data;
|
---|
| 58 | #endif
|
---|
| 59 |
|
---|
| 60 | union QPDevCmdParam {
|
---|
| 61 | int ival;
|
---|
| 62 | int *ivec;
|
---|
| 63 | QString *str;
|
---|
| 64 | const QPoint *point;
|
---|
| 65 | const QRect *rect;
|
---|
| 66 | const QPointArray *ptarr;
|
---|
| 67 | const QPixmap *pixmap;
|
---|
| 68 | const QImage *image;
|
---|
| 69 | const QColor *color;
|
---|
| 70 | const QFont *font;
|
---|
| 71 | const QPen *pen;
|
---|
| 72 | const QBrush *brush;
|
---|
| 73 | const QRegion *rgn;
|
---|
| 74 | const QWMatrix *matrix;
|
---|
| 75 | const QTextItem *textItem;
|
---|
| 76 | QIODevice *device;
|
---|
| 77 | };
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | class Q_EXPORT QPaintDevice // device for QPainter
|
---|
| 82 | {
|
---|
| 83 | public:
|
---|
| 84 | virtual ~QPaintDevice();
|
---|
| 85 |
|
---|
| 86 | int devType() const;
|
---|
| 87 | bool isExtDev() const;
|
---|
| 88 | bool paintingActive() const;
|
---|
| 89 |
|
---|
| 90 | virtual void setResolution( int );
|
---|
| 91 | virtual int resolution() const;
|
---|
| 92 |
|
---|
| 93 | // Windows: get device context
|
---|
| 94 | // X-Windows: get drawable
|
---|
| 95 | #if defined(Q_WS_WIN)
|
---|
| 96 | virtual HDC handle() const;
|
---|
[8] | 97 | #elif defined(Q_WS_PM)
|
---|
| 98 | virtual HPS handle() const;
|
---|
[2] | 99 | #elif defined(Q_WS_X11)
|
---|
| 100 | virtual Qt::HANDLE handle() const;
|
---|
| 101 | virtual Qt::HANDLE x11RenderHandle() const;
|
---|
| 102 | #elif defined(Q_WS_MAC)
|
---|
| 103 | virtual Qt::HANDLE handle() const;
|
---|
| 104 | #elif defined(Q_WS_QWS)
|
---|
| 105 | virtual Qt::HANDLE handle() const;
|
---|
| 106 | #endif
|
---|
| 107 |
|
---|
| 108 | #if defined(Q_WS_X11)
|
---|
| 109 | Display *x11Display() const;
|
---|
| 110 | int x11Screen() const;
|
---|
| 111 | int x11Depth() const;
|
---|
| 112 | int x11Cells() const;
|
---|
| 113 | Qt::HANDLE x11Colormap() const;
|
---|
| 114 | bool x11DefaultColormap() const;
|
---|
| 115 | void *x11Visual() const;
|
---|
| 116 | bool x11DefaultVisual() const;
|
---|
| 117 |
|
---|
| 118 | static Display *x11AppDisplay();
|
---|
| 119 | static int x11AppScreen();
|
---|
| 120 |
|
---|
| 121 | static int x11AppDpiX();
|
---|
| 122 | static int x11AppDpiY();
|
---|
| 123 | static void x11SetAppDpiX(int);
|
---|
| 124 | static void x11SetAppDpiY(int);
|
---|
| 125 | static int x11AppDepth();
|
---|
| 126 | static int x11AppCells();
|
---|
| 127 | static Qt::HANDLE x11AppRootWindow();
|
---|
| 128 | static Qt::HANDLE x11AppColormap();
|
---|
| 129 | static bool x11AppDefaultColormap();
|
---|
| 130 | static void *x11AppVisual();
|
---|
| 131 | static bool x11AppDefaultVisual();
|
---|
| 132 |
|
---|
| 133 | // ### in 4.0, the above need to go away, the below needs to take a -1 default
|
---|
| 134 | // argument, signifying the default screen...
|
---|
| 135 | static int x11AppDepth( int screen );
|
---|
| 136 | static int x11AppCells( int screen );
|
---|
| 137 | static Qt::HANDLE x11AppRootWindow( int screen );
|
---|
| 138 | static Qt::HANDLE x11AppColormap( int screen );
|
---|
| 139 | static void *x11AppVisual( int screen );
|
---|
| 140 | static bool x11AppDefaultColormap( int screen );
|
---|
| 141 | static bool x11AppDefaultVisual( int screen );
|
---|
| 142 | static int x11AppDpiX( int );
|
---|
| 143 | static int x11AppDpiY( int );
|
---|
| 144 | static void x11SetAppDpiX( int, int );
|
---|
| 145 | static void x11SetAppDpiY( int, int );
|
---|
| 146 | #endif
|
---|
| 147 |
|
---|
| 148 | #if defined(Q_WS_QWS)
|
---|
| 149 | static QWSDisplay *qwsDisplay();
|
---|
| 150 | virtual unsigned char * scanLine(int) const;
|
---|
| 151 | virtual int bytesPerLine() const;
|
---|
| 152 | virtual QGfx * graphicsContext(bool clip_children=TRUE) const;
|
---|
| 153 | #endif
|
---|
| 154 |
|
---|
| 155 | enum PDevCmd {
|
---|
| 156 | PdcNOP = 0, // <void>
|
---|
| 157 | PdcDrawPoint = 1, // point
|
---|
| 158 | PdcDrawFirst = PdcDrawPoint,
|
---|
| 159 | PdcMoveTo = 2, // point
|
---|
| 160 | PdcLineTo = 3, // point
|
---|
| 161 | PdcDrawLine = 4, // point,point
|
---|
| 162 | PdcDrawRect = 5, // rect
|
---|
| 163 | PdcDrawRoundRect = 6, // rect,ival,ival
|
---|
| 164 | PdcDrawEllipse = 7, // rect
|
---|
| 165 | PdcDrawArc = 8, // rect,ival,ival
|
---|
| 166 | PdcDrawPie = 9, // rect,ival,ival
|
---|
| 167 | PdcDrawChord = 10, // rect,ival,ival
|
---|
| 168 | PdcDrawLineSegments = 11, // ptarr
|
---|
| 169 | PdcDrawPolyline = 12, // ptarr
|
---|
| 170 | PdcDrawPolygon = 13, // ptarr,ival
|
---|
| 171 | PdcDrawCubicBezier = 14, // ptarr
|
---|
| 172 | PdcDrawText = 15, // point,str
|
---|
| 173 | PdcDrawTextFormatted = 16, // rect,ival,str
|
---|
| 174 | PdcDrawPixmap = 17, // rect,pixmap
|
---|
| 175 | PdcDrawImage = 18, // rect,image
|
---|
| 176 | PdcDrawText2 = 19, // point,str
|
---|
| 177 | PdcDrawText2Formatted = 20, // rect,ival,str
|
---|
| 178 | PdcDrawTextItem = 21,
|
---|
| 179 | PdcDrawLast = PdcDrawTextItem,
|
---|
| 180 |
|
---|
| 181 | // no painting commands below PdcDrawLast.
|
---|
| 182 |
|
---|
| 183 | PdcBegin = 30, // <void>
|
---|
| 184 | PdcEnd = 31, // <void>
|
---|
| 185 | PdcSave = 32, // <void>
|
---|
| 186 | PdcRestore = 33, // <void>
|
---|
| 187 | PdcSetdev = 34, // device - PRIVATE
|
---|
| 188 | PdcSetBkColor = 40, // color
|
---|
| 189 | PdcSetBkMode = 41, // ival
|
---|
| 190 | PdcSetROP = 42, // ival
|
---|
| 191 | PdcSetBrushOrigin = 43, // point
|
---|
| 192 | PdcSetFont = 45, // font
|
---|
| 193 | PdcSetPen = 46, // pen
|
---|
| 194 | PdcSetBrush = 47, // brush
|
---|
| 195 | PdcSetTabStops = 48, // ival
|
---|
| 196 | PdcSetTabArray = 49, // ival,ivec
|
---|
| 197 | PdcSetUnit = 50, // ival
|
---|
| 198 | PdcSetVXform = 51, // ival
|
---|
| 199 | PdcSetWindow = 52, // rect
|
---|
| 200 | PdcSetViewport = 53, // rect
|
---|
| 201 | PdcSetWXform = 54, // ival
|
---|
| 202 | PdcSetWMatrix = 55, // matrix,ival
|
---|
| 203 | PdcSaveWMatrix = 56,
|
---|
| 204 | PdcRestoreWMatrix = 57,
|
---|
| 205 | PdcSetClip = 60, // ival
|
---|
| 206 | PdcSetClipRegion = 61, // rgn
|
---|
| 207 |
|
---|
| 208 | PdcReservedStart = 0, // codes 0-199 are reserved
|
---|
| 209 | PdcReservedStop = 199 // for Qt
|
---|
| 210 | };
|
---|
| 211 |
|
---|
| 212 | protected:
|
---|
| 213 | QPaintDevice( uint devflags );
|
---|
| 214 |
|
---|
| 215 | #if defined(Q_WS_WIN)
|
---|
| 216 | HDC hdc; // device context
|
---|
[8] | 217 | #elif defined(Q_WS_PM)
|
---|
| 218 | HPS hps; // presentation space handle
|
---|
[2] | 219 | #elif defined(Q_WS_X11)
|
---|
| 220 | Qt::HANDLE hd; // handle to drawable
|
---|
| 221 | Qt::HANDLE rendhd; // handle to RENDER pict
|
---|
| 222 |
|
---|
| 223 | void copyX11Data( const QPaintDevice * );
|
---|
| 224 | void cloneX11Data( const QPaintDevice * );
|
---|
| 225 | virtual void setX11Data( const QPaintDeviceX11Data* );
|
---|
| 226 | QPaintDeviceX11Data* getX11Data( bool def=FALSE ) const;
|
---|
| 227 | #elif defined(Q_WS_MAC)
|
---|
| 228 | #if !defined( QMAC_NO_QUARTZ )
|
---|
| 229 | CGContextRef ctx;
|
---|
| 230 | #endif
|
---|
| 231 | void * hd;
|
---|
| 232 | #elif defined(Q_WS_QWS)
|
---|
| 233 | Qt::HANDLE hd;
|
---|
| 234 | #endif
|
---|
| 235 |
|
---|
| 236 | virtual bool cmd( int, QPainter *, QPDevCmdParam * );
|
---|
| 237 | virtual int metric( int ) const;
|
---|
| 238 | virtual int fontMet( QFont *, int, const char * = 0, int = 0 ) const;
|
---|
| 239 | virtual int fontInf( QFont *, int ) const;
|
---|
| 240 |
|
---|
| 241 | ushort devFlags; // device flags
|
---|
| 242 | ushort painters; // refcount
|
---|
| 243 |
|
---|
| 244 | friend class QPainter;
|
---|
| 245 | friend class QPaintDeviceMetrics;
|
---|
| 246 | #if defined(Q_WS_MAC)
|
---|
| 247 | #ifndef QMAC_NO_QUARTZ
|
---|
| 248 | virtual CGContextRef macCGContext(bool clipped=TRUE) const;
|
---|
| 249 | #endif
|
---|
| 250 | friend Q_EXPORT void unclippedScaledBitBlt( QPaintDevice *, int, int, int, int,
|
---|
| 251 | const QPaintDevice *, int, int, int, int, Qt::RasterOp, bool, bool );
|
---|
| 252 | #else
|
---|
| 253 | friend Q_EXPORT void bitBlt( QPaintDevice *, int, int,
|
---|
| 254 | const QPaintDevice *,
|
---|
| 255 | int, int, int, int, Qt::RasterOp, bool );
|
---|
| 256 | #endif
|
---|
| 257 | #if defined(Q_WS_X11)
|
---|
| 258 | friend void qt_init_internal( int *, char **, Display *, Qt::HANDLE, Qt::HANDLE );
|
---|
| 259 | friend void qt_cleanup();
|
---|
| 260 | #endif
|
---|
| 261 |
|
---|
| 262 | private:
|
---|
| 263 | #if defined(Q_WS_X11)
|
---|
| 264 | static Display *x_appdisplay;
|
---|
| 265 | static int x_appscreen;
|
---|
| 266 |
|
---|
| 267 | static int x_appdepth;
|
---|
| 268 | static int x_appcells;
|
---|
| 269 | static Qt::HANDLE x_approotwindow;
|
---|
| 270 | static Qt::HANDLE x_appcolormap;
|
---|
| 271 | static bool x_appdefcolormap;
|
---|
| 272 | static void *x_appvisual;
|
---|
| 273 | static bool x_appdefvisual;
|
---|
| 274 |
|
---|
| 275 | // ### in 4.0, remove the above, and replace with the below
|
---|
| 276 | static int *x_appdepth_arr;
|
---|
| 277 | static int *x_appcells_arr;
|
---|
| 278 | static Qt::HANDLE *x_approotwindow_arr;
|
---|
| 279 | static Qt::HANDLE *x_appcolormap_arr;
|
---|
| 280 | static bool *x_appdefcolormap_arr;
|
---|
| 281 | static void **x_appvisual_arr;
|
---|
| 282 | static bool *x_appdefvisual_arr;
|
---|
| 283 |
|
---|
| 284 | QPaintDeviceX11Data* x11Data;
|
---|
| 285 | #endif
|
---|
| 286 |
|
---|
| 287 | private: // Disabled copy constructor and operator=
|
---|
| 288 | #if defined(Q_DISABLE_COPY)
|
---|
| 289 | QPaintDevice( const QPaintDevice & );
|
---|
| 290 | QPaintDevice &operator=( const QPaintDevice & );
|
---|
| 291 | #endif
|
---|
| 292 | };
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 | Q_EXPORT
|
---|
| 296 | void bitBlt( QPaintDevice *dst, int dx, int dy,
|
---|
| 297 | const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
|
---|
| 298 | Qt::RasterOp = Qt::CopyROP, bool ignoreMask=FALSE );
|
---|
| 299 |
|
---|
| 300 | Q_EXPORT
|
---|
| 301 | void bitBlt( QPaintDevice *dst, int dx, int dy,
|
---|
| 302 | const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
|
---|
| 303 | int conversion_flags=0 );
|
---|
| 304 |
|
---|
| 305 |
|
---|
| 306 | #if defined(Q_WS_X11)
|
---|
| 307 |
|
---|
| 308 | struct Q_EXPORT QPaintDeviceX11Data : public QShared {
|
---|
| 309 | Display* x_display;
|
---|
| 310 | int x_screen;
|
---|
| 311 | int x_depth;
|
---|
| 312 | int x_cells;
|
---|
| 313 | Qt::HANDLE x_colormap;
|
---|
| 314 | bool x_defcolormap;
|
---|
| 315 | void* x_visual;
|
---|
| 316 | bool x_defvisual;
|
---|
| 317 | };
|
---|
| 318 |
|
---|
| 319 | #endif
|
---|
| 320 |
|
---|
| 321 | /*****************************************************************************
|
---|
| 322 | Inline functions
|
---|
| 323 | *****************************************************************************/
|
---|
| 324 |
|
---|
| 325 | inline int QPaintDevice::devType() const
|
---|
| 326 | { return devFlags & QInternal::DeviceTypeMask; }
|
---|
| 327 |
|
---|
| 328 | inline bool QPaintDevice::isExtDev() const
|
---|
| 329 | { return (devFlags & QInternal::ExternalDevice) != 0; }
|
---|
| 330 |
|
---|
| 331 | inline bool QPaintDevice::paintingActive() const
|
---|
| 332 | { return painters != 0; }
|
---|
| 333 |
|
---|
| 334 | #if defined(Q_WS_X11)
|
---|
| 335 | inline Display *QPaintDevice::x11Display() const
|
---|
| 336 | { return x11Data ? x11Data->x_display : x_appdisplay; }
|
---|
| 337 |
|
---|
| 338 | inline int QPaintDevice::x11Screen() const
|
---|
| 339 | { return x11Data ? x11Data->x_screen : x_appscreen; }
|
---|
| 340 |
|
---|
| 341 | inline int QPaintDevice::x11Depth() const
|
---|
| 342 | { return x11Data ? x11Data->x_depth : x_appdepth; }
|
---|
| 343 |
|
---|
| 344 | inline int QPaintDevice::x11Cells() const
|
---|
| 345 | { return x11Data ? x11Data->x_cells : x_appcells; }
|
---|
| 346 |
|
---|
| 347 | inline Qt::HANDLE QPaintDevice::x11Colormap() const
|
---|
| 348 | { return x11Data ? x11Data->x_colormap : x_appcolormap; }
|
---|
| 349 |
|
---|
| 350 | inline bool QPaintDevice::x11DefaultColormap() const
|
---|
| 351 | { return x11Data ? x11Data->x_defcolormap : x_appdefcolormap; }
|
---|
| 352 |
|
---|
| 353 | inline void *QPaintDevice::x11Visual() const
|
---|
| 354 | { return x11Data ? x11Data->x_visual : x_appvisual; }
|
---|
| 355 |
|
---|
| 356 | inline bool QPaintDevice::x11DefaultVisual() const
|
---|
| 357 | { return x11Data ? x11Data->x_defvisual : x_appdefvisual; }
|
---|
| 358 |
|
---|
| 359 | inline Display *QPaintDevice::x11AppDisplay()
|
---|
| 360 | { return x_appdisplay; }
|
---|
| 361 |
|
---|
| 362 | inline int QPaintDevice::x11AppScreen()
|
---|
| 363 | { return x_appscreen; }
|
---|
| 364 |
|
---|
| 365 | inline int QPaintDevice::x11AppDepth( int screen )
|
---|
| 366 | { return x_appdepth_arr[ screen == -1 ? x_appscreen : screen ]; }
|
---|
| 367 |
|
---|
| 368 | inline int QPaintDevice::x11AppCells( int screen )
|
---|
| 369 | { return x_appcells_arr[ screen == -1 ? x_appscreen : screen ]; }
|
---|
| 370 |
|
---|
| 371 | inline Qt::HANDLE QPaintDevice::x11AppRootWindow( int screen )
|
---|
| 372 | { return x_approotwindow_arr[ screen == -1 ? x_appscreen : screen ]; }
|
---|
| 373 |
|
---|
| 374 | inline Qt::HANDLE QPaintDevice::x11AppColormap( int screen )
|
---|
| 375 | { return x_appcolormap_arr[ screen == -1 ? x_appscreen : screen ]; }
|
---|
| 376 |
|
---|
| 377 | inline bool QPaintDevice::x11AppDefaultColormap( int screen )
|
---|
| 378 | { return x_appdefcolormap_arr[ screen == -1 ? x_appscreen : screen ]; }
|
---|
| 379 |
|
---|
| 380 | inline void *QPaintDevice::x11AppVisual( int screen )
|
---|
| 381 | { return x_appvisual_arr[ screen == -1 ? x_appscreen : screen ]; }
|
---|
| 382 |
|
---|
| 383 | inline bool QPaintDevice::x11AppDefaultVisual( int screen )
|
---|
| 384 | { return x_appdefvisual_arr[ screen == -1 ? x_appscreen : screen ]; }
|
---|
| 385 |
|
---|
| 386 | inline int QPaintDevice::x11AppDepth()
|
---|
| 387 | { return x_appdepth; }
|
---|
| 388 |
|
---|
| 389 | inline int QPaintDevice::x11AppCells()
|
---|
| 390 | { return x_appcells; }
|
---|
| 391 |
|
---|
| 392 | inline Qt::HANDLE QPaintDevice::x11AppRootWindow()
|
---|
| 393 | { return x_approotwindow; }
|
---|
| 394 |
|
---|
| 395 | inline Qt::HANDLE QPaintDevice::x11AppColormap()
|
---|
| 396 | { return x_appcolormap; }
|
---|
| 397 |
|
---|
| 398 | inline bool QPaintDevice::x11AppDefaultColormap()
|
---|
| 399 | { return x_appdefcolormap; }
|
---|
| 400 |
|
---|
| 401 | inline void *QPaintDevice::x11AppVisual()
|
---|
| 402 | { return x_appvisual; }
|
---|
| 403 |
|
---|
| 404 | inline bool QPaintDevice::x11AppDefaultVisual()
|
---|
| 405 | { return x_appdefvisual; }
|
---|
| 406 |
|
---|
| 407 | #endif // Q_WS_X11
|
---|
| 408 |
|
---|
| 409 |
|
---|
| 410 | Q_EXPORT
|
---|
| 411 | inline void bitBlt( QPaintDevice *dst, const QPoint &dp,
|
---|
| 412 | const QPaintDevice *src, const QRect &sr =QRect(0,0,-1,-1),
|
---|
| 413 | Qt::RasterOp rop=Qt::CopyROP, bool ignoreMask=FALSE )
|
---|
| 414 | {
|
---|
| 415 | bitBlt( dst, dp.x(), dp.y(), src, sr.x(), sr.y(), sr.width(), sr.height(),
|
---|
| 416 | rop, ignoreMask );
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 |
|
---|
| 420 |
|
---|
| 421 |
|
---|
| 422 | #endif // QPAINTDEVICE_H
|
---|