00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- ***************************** 00002 * Qwt Widget Library 00003 * Copyright (C) 1997 Josef Wilgen 00004 * Copyright (C) 2002 Uwe Rathmann 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the Qwt License, Version 1.0 00008 *****************************************************************************/ 00009 00010 #ifndef QWT_PAINTER_COMMAND_H 00011 #define QWT_PAINTER_COMMAND_H 00012 00013 #include "qwt_global.h" 00014 #include <qpaintengine.h> 00015 #include <qpixmap.h> 00016 #include <qimage.h> 00017 #include <qpolygon.h> 00018 00019 class QPainterPath; 00020 00030 class QWT_EXPORT QwtPainterCommand 00031 { 00032 public: 00034 enum Type 00035 { 00037 Invalid = -1, 00038 00040 Path, 00041 00043 Pixmap, 00044 00046 Image, 00047 00049 State 00050 }; 00051 00053 struct PixmapData 00054 { 00055 QRectF rect; 00056 QPixmap pixmap; 00057 QRectF subRect; 00058 }; 00059 00061 struct ImageData 00062 { 00063 QRectF rect; 00064 QImage image; 00065 QRectF subRect; 00066 Qt::ImageConversionFlags flags; 00067 }; 00068 00070 struct StateData 00071 { 00072 QPaintEngine::DirtyFlags flags; 00073 00074 QPen pen; 00075 QBrush brush; 00076 QPointF brushOrigin; 00077 QBrush backgroundBrush; 00078 Qt::BGMode backgroundMode; 00079 QFont font; 00080 QMatrix matrix; 00081 QTransform transform; 00082 00083 Qt::ClipOperation clipOperation; 00084 QRegion clipRegion; 00085 QPainterPath clipPath; 00086 bool isClipEnabled; 00087 00088 QPainter::RenderHints renderHints; 00089 QPainter::CompositionMode compositionMode; 00090 qreal opacity; 00091 }; 00092 00093 QwtPainterCommand(); 00094 QwtPainterCommand(const QwtPainterCommand &); 00095 00096 explicit QwtPainterCommand( const QPainterPath & ); 00097 00098 QwtPainterCommand( const QRectF &rect, 00099 const QPixmap &, const QRectF& subRect ); 00100 00101 QwtPainterCommand( const QRectF &rect, 00102 const QImage &, const QRectF& subRect, 00103 Qt::ImageConversionFlags ); 00104 00105 explicit QwtPainterCommand( const QPaintEngineState & ); 00106 00107 ~QwtPainterCommand(); 00108 00109 QwtPainterCommand &operator=(const QwtPainterCommand & ); 00110 00111 Type type() const; 00112 00113 QPainterPath *path(); 00114 const QPainterPath *path() const; 00115 00116 PixmapData* pixmapData(); 00117 const PixmapData* pixmapData() const; 00118 00119 ImageData* imageData(); 00120 const ImageData* imageData() const; 00121 00122 StateData* stateData(); 00123 const StateData* stateData() const; 00124 00125 private: 00126 void copy( const QwtPainterCommand & ); 00127 void reset(); 00128 00129 Type d_type; 00130 00131 union 00132 { 00133 QPainterPath *d_path; 00134 PixmapData *d_pixmapData; 00135 ImageData *d_imageData; 00136 StateData *d_stateData; 00137 }; 00138 }; 00139 00141 inline QwtPainterCommand::Type QwtPainterCommand::type() const 00142 { 00143 return d_type; 00144 } 00145 00147 inline const QPainterPath *QwtPainterCommand::path() const 00148 { 00149 return d_path; 00150 } 00151 00153 inline const QwtPainterCommand::PixmapData* 00154 QwtPainterCommand::pixmapData() const 00155 { 00156 return d_pixmapData; 00157 } 00158 00160 inline const QwtPainterCommand::ImageData * 00161 QwtPainterCommand::imageData() const 00162 { 00163 return d_imageData; 00164 } 00165 00167 inline const QwtPainterCommand::StateData * 00168 QwtPainterCommand::stateData() const 00169 { 00170 return d_stateData; 00171 } 00172 00173 #endif