qwt_null_paintdevice.cpp
9.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include "qwt_null_paintdevice.h"
#include <qpaintengine.h>
#include <qpixmap.h>
class QwtNullPaintDevice::PrivateData
{
public:
PrivateData():
size( 0, 0 )
{
}
QSize size;
};
class QwtNullPaintDevice::PaintEngine: public QPaintEngine
{
public:
PaintEngine( QPaintEngine::PaintEngineFeatures );
virtual bool begin( QPaintDevice * );
virtual bool end();
virtual Type type () const;
virtual void updateState(const QPaintEngineState &);
virtual void drawRects(const QRect *, int );
virtual void drawRects(const QRectF *, int );
virtual void drawLines(const QLine *, int );
virtual void drawLines(const QLineF *, int );
virtual void drawEllipse(const QRectF &);
virtual void drawEllipse(const QRect &);
virtual void drawPath(const QPainterPath &);
virtual void drawPoints(const QPointF *, int );
virtual void drawPoints(const QPoint *, int );
virtual void drawPolygon(const QPointF *, int , PolygonDrawMode );
virtual void drawPolygon(const QPoint *, int , PolygonDrawMode );
virtual void drawPixmap(const QRectF &,
const QPixmap &, const QRectF &);
virtual void drawTextItem(const QPointF &, const QTextItem &);
virtual void drawTiledPixmap(const QRectF &,
const QPixmap &, const QPointF &s);
virtual void drawImage(const QRectF &,
const QImage &, const QRectF &, Qt::ImageConversionFlags );
private:
QwtNullPaintDevice *d_device;
};
QwtNullPaintDevice::PaintEngine::PaintEngine(
QPaintEngine::PaintEngineFeatures features ):
QPaintEngine( features ),
d_device(NULL)
{
}
bool QwtNullPaintDevice::PaintEngine::begin(
QPaintDevice *device )
{
d_device = static_cast<QwtNullPaintDevice *>( device );
return true;
}
bool QwtNullPaintDevice::PaintEngine::end()
{
d_device = NULL;
return true;
}
QPaintEngine::Type
QwtNullPaintDevice::PaintEngine::type () const
{
return QPaintEngine::User;
}
void QwtNullPaintDevice::PaintEngine::drawRects(
const QRect *rects, int rectCount)
{
if ( d_device )
d_device->drawRects( rects, rectCount );
}
void QwtNullPaintDevice::PaintEngine::drawRects(
const QRectF *rects, int rectCount)
{
if ( d_device )
d_device->drawRects( rects, rectCount );
}
void QwtNullPaintDevice::PaintEngine::drawLines(
const QLine *lines, int lineCount)
{
if ( d_device )
d_device->drawLines( lines, lineCount );
}
void QwtNullPaintDevice::PaintEngine::drawLines(
const QLineF *lines, int lineCount)
{
if ( d_device )
d_device->drawLines( lines, lineCount );
}
void QwtNullPaintDevice::PaintEngine::drawEllipse(
const QRectF &rect)
{
if ( d_device )
d_device->drawEllipse( rect );
}
void QwtNullPaintDevice::PaintEngine::drawEllipse(
const QRect &rect)
{
if ( d_device )
d_device->drawEllipse( rect );
}
void QwtNullPaintDevice::PaintEngine::drawPath(
const QPainterPath &path)
{
if ( d_device )
d_device->drawPath( path );
}
void QwtNullPaintDevice::PaintEngine::drawPoints(
const QPointF *points, int pointCount)
{
if ( d_device )
d_device->drawPoints( points, pointCount );
}
void QwtNullPaintDevice::PaintEngine::drawPoints(
const QPoint *points, int pointCount)
{
if ( d_device )
d_device->drawPoints( points, pointCount );
}
void QwtNullPaintDevice::PaintEngine::drawPolygon(
const QPointF *points, int pointCount, PolygonDrawMode mode)
{
if ( d_device )
d_device->drawPolygon( points, pointCount, mode );
}
void QwtNullPaintDevice::PaintEngine::drawPolygon(
const QPoint *points, int pointCount, PolygonDrawMode mode)
{
if ( d_device )
d_device->drawPolygon( points, pointCount, mode );
}
void QwtNullPaintDevice::PaintEngine::drawPixmap(
const QRectF &rect, const QPixmap &pm, const QRectF &subRect )
{
if ( d_device )
d_device->drawPixmap( rect, pm, subRect );
}
void QwtNullPaintDevice::PaintEngine::drawTextItem(
const QPointF &pos, const QTextItem &textItem)
{
if ( d_device )
d_device->drawTextItem( pos, textItem );
}
void QwtNullPaintDevice::PaintEngine::drawTiledPixmap(
const QRectF &rect, const QPixmap &pixmap,
const QPointF &subRect)
{
if ( d_device )
d_device->drawTiledPixmap( rect, pixmap, subRect );
}
void QwtNullPaintDevice::PaintEngine::drawImage(
const QRectF &rect, const QImage &image,
const QRectF &subRect, Qt::ImageConversionFlags flags)
{
if ( d_device )
d_device->drawImage( rect, image, subRect, flags );
}
void QwtNullPaintDevice::PaintEngine::updateState(
const QPaintEngineState &state)
{
if ( d_device )
d_device->updateState( state );
}
//! Constructor
QwtNullPaintDevice::QwtNullPaintDevice(
QPaintEngine::PaintEngineFeatures features )
{
init( features );
}
//! Constructor
QwtNullPaintDevice::QwtNullPaintDevice( const QSize &size,
QPaintEngine::PaintEngineFeatures features )
{
init( features );
d_data->size = size;
}
void QwtNullPaintDevice::init(
QPaintEngine::PaintEngineFeatures features )
{
d_engine = new PaintEngine( features );
d_data = new PrivateData;
}
//! Destructor
QwtNullPaintDevice::~QwtNullPaintDevice()
{
delete d_engine;
delete d_data;
}
/*!
Set the size of the paint device
\param size Size
\sa size()
*/
void QwtNullPaintDevice::setSize( const QSize & size )
{
d_data->size = size;
}
/*!
\return Size of the paint device
\sa setSize()
*/
QSize QwtNullPaintDevice::size() const
{
return d_data->size;
}
//! See QPaintDevice::paintEngine()
QPaintEngine *QwtNullPaintDevice::paintEngine() const
{
return d_engine;
}
/*!
See QPaintDevice::metric()
\sa setSize()
*/
int QwtNullPaintDevice::metric( PaintDeviceMetric metric ) const
{
static QPixmap pm;
int value;
switch ( metric )
{
case PdmWidth:
value = qMax( d_data->size.width(), 0 );
break;
case PdmHeight:
value = qMax( d_data->size.height(), 0 );
break;
case PdmNumColors:
value = 16777216;
break;
case PdmDepth:
value = 24;
break;
case PdmPhysicalDpiX:
case PdmDpiY:
case PdmPhysicalDpiY:
case PdmWidthMM:
case PdmHeightMM:
case PdmDpiX:
default:
value = 0;
}
return value;
}
//! See QPaintEngine::drawRects()
void QwtNullPaintDevice::drawRects(
const QRect *rects, int rectCount)
{
Q_UNUSED(rects);
Q_UNUSED(rectCount);
}
//! See QPaintEngine::drawRects()
void QwtNullPaintDevice::drawRects(
const QRectF *rects, int rectCount)
{
Q_UNUSED(rects);
Q_UNUSED(rectCount);
}
//! See QPaintEngine::drawLines()
void QwtNullPaintDevice::drawLines(
const QLine *lines, int lineCount)
{
Q_UNUSED(lines);
Q_UNUSED(lineCount);
}
//! See QPaintEngine::drawLines()
void QwtNullPaintDevice::drawLines(
const QLineF *lines, int lineCount)
{
Q_UNUSED(lines);
Q_UNUSED(lineCount);
}
//! See QPaintEngine::drawEllipse()
void QwtNullPaintDevice::drawEllipse( const QRectF &rect )
{
Q_UNUSED(rect);
}
//! See QPaintEngine::drawEllipse()
void QwtNullPaintDevice::drawEllipse( const QRect &rect )
{
Q_UNUSED(rect);
}
//! See QPaintEngine::drawPath()
void QwtNullPaintDevice::drawPath( const QPainterPath &path )
{
Q_UNUSED(path);
}
//! See QPaintEngine::drawPoints()
void QwtNullPaintDevice::drawPoints(
const QPointF *points, int pointCount)
{
Q_UNUSED(points);
Q_UNUSED(pointCount);
}
//! See QPaintEngine::drawPoints()
void QwtNullPaintDevice::drawPoints(
const QPoint *points, int pointCount)
{
Q_UNUSED(points);
Q_UNUSED(pointCount);
}
//! See QPaintEngine::drawPolygon()
void QwtNullPaintDevice::drawPolygon(
const QPointF *points, int pointCount,
QPaintEngine::PolygonDrawMode mode)
{
Q_UNUSED(points);
Q_UNUSED(pointCount);
Q_UNUSED(mode);
}
//! See QPaintEngine::drawPolygon()
void QwtNullPaintDevice::drawPolygon(
const QPoint *points, int pointCount,
QPaintEngine::PolygonDrawMode mode)
{
Q_UNUSED(points);
Q_UNUSED(pointCount);
Q_UNUSED(mode);
}
//! See QPaintEngine::drawPixmap()
void QwtNullPaintDevice::drawPixmap( const QRectF &rect,
const QPixmap &pm, const QRectF &subRect )
{
Q_UNUSED(rect);
Q_UNUSED(pm);
Q_UNUSED(subRect);
}
//! See QPaintEngine::drawTextItem()
void QwtNullPaintDevice::drawTextItem(
const QPointF &pos, const QTextItem &textItem)
{
Q_UNUSED(pos);
Q_UNUSED(textItem);
}
//! See QPaintEngine::drawTiledPixmap()
void QwtNullPaintDevice::drawTiledPixmap(
const QRectF &rect, const QPixmap &pixmap,
const QPointF &subRect)
{
Q_UNUSED(rect);
Q_UNUSED(pixmap);
Q_UNUSED(subRect);
}
//! See QPaintEngine::drawImage()
void QwtNullPaintDevice::drawImage(
const QRectF &rect, const QImage &image,
const QRectF &subRect, Qt::ImageConversionFlags flags)
{
Q_UNUSED(rect);
Q_UNUSED(image);
Q_UNUSED(subRect);
Q_UNUSED(flags);
}
//! See QPaintEngine::updateState()
void QwtNullPaintDevice::updateState(
const QPaintEngineState &state )
{
Q_UNUSED(state);
}