qwt_null_paintdevice.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #ifndef QWT_NULL_PAINT_DEVICE_H
  10. #define QWT_NULL_PAINT_DEVICE_H 1
  11. #include "qwt_global.h"
  12. #include <qpaintdevice.h>
  13. #include <qpaintengine.h>
  14. /*!
  15. \brief A null paint device doing nothing
  16. Sometimes important layout/rendering geometries are not
  17. available or changeable from the public Qt class interface.
  18. ( f.e hidden in the style implementation ).
  19. QwtNullPaintDevice can be used to manipulate or filter out
  20. this information by analyzing the stream of paint primitives.
  21. F.e. QwtNullPaintDevice is used by QwtPlotCanvas to identify
  22. styled backgrounds with rounded corners.
  23. */
  24. class QWT_EXPORT QwtNullPaintDevice: public QPaintDevice
  25. {
  26. public:
  27. /*!
  28. \brief Render mode
  29. \sa setMode(), mode()
  30. */
  31. enum Mode
  32. {
  33. /*!
  34. All vector graphic primitives are painted by
  35. the corresponding draw methods
  36. */
  37. NormalMode,
  38. /*!
  39. Vector graphic primitives ( beside polygons ) are mapped to a QPainterPath
  40. and are painted by drawPath. In PathMode mode
  41. only a few draw methods are called:
  42. - drawPath()
  43. - drawPixmap()
  44. - drawImage()
  45. - drawPolygon()
  46. */
  47. PolygonPathMode,
  48. /*!
  49. Vector graphic primitives are mapped to a QPainterPath
  50. and are painted by drawPath. In PathMode mode
  51. only a few draw methods are called:
  52. - drawPath()
  53. - drawPixmap()
  54. - drawImage()
  55. */
  56. PathMode
  57. };
  58. QwtNullPaintDevice();
  59. virtual ~QwtNullPaintDevice();
  60. void setMode( Mode );
  61. Mode mode() const;
  62. virtual QPaintEngine *paintEngine() const;
  63. virtual int metric( PaintDeviceMetric ) const;
  64. virtual void drawRects(const QRect *, int );
  65. virtual void drawRects(const QRectF *, int );
  66. virtual void drawLines(const QLine *, int );
  67. virtual void drawLines(const QLineF *, int );
  68. virtual void drawEllipse(const QRectF &);
  69. virtual void drawEllipse(const QRect &);
  70. virtual void drawPath(const QPainterPath &);
  71. virtual void drawPoints(const QPointF *, int );
  72. virtual void drawPoints(const QPoint *, int );
  73. virtual void drawPolygon(
  74. const QPointF *, int , QPaintEngine::PolygonDrawMode );
  75. virtual void drawPolygon(
  76. const QPoint *, int , QPaintEngine::PolygonDrawMode );
  77. virtual void drawPixmap(const QRectF &,
  78. const QPixmap &, const QRectF &);
  79. virtual void drawTextItem(const QPointF &, const QTextItem &);
  80. virtual void drawTiledPixmap(const QRectF &,
  81. const QPixmap &, const QPointF & );
  82. virtual void drawImage(const QRectF &,
  83. const QImage &, const QRectF &, Qt::ImageConversionFlags );
  84. virtual void updateState( const QPaintEngineState & );
  85. protected:
  86. //! \return Size needed to implement metric()
  87. virtual QSize sizeMetrics() const = 0;
  88. private:
  89. class PaintEngine;
  90. PaintEngine *d_engine;
  91. class PrivateData;
  92. PrivateData *d_data;
  93. };
  94. #endif