source: ntrip/trunk/GnssCenter/qwt/qwt_null_paintdevice.cpp@ 10460

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