00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef QSVGDEVICE_P_H
00039 #define QSVGDEVICE_P_H
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef QT_H
00054 #include "qpaintdevice.h"
00055 #include "qrect.h"
00056 #include "qdom.h"
00057 #endif // QT_H
00058
00059 #if !defined(QT_MODULE_XML) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_XML )
00060 #define QM_EXPORT_SVG
00061 #else
00062 #define QM_EXPORT_SVG Q_EXPORT
00063 #endif
00064
00065 #ifndef QT_NO_SVG
00066
00067 class QPainter;
00068 class QDomNode;
00069 class QDomNamedNodeMap;
00070 struct QSvgDeviceState;
00071 class QSvgDevicePrivate;
00072
00073 class QM_EXPORT_SVG QSvgDevice : public QPaintDevice
00074 {
00075 public:
00076 QSvgDevice();
00077 ~QSvgDevice();
00078
00079 bool play( QPainter *p );
00080
00081 QString toString() const;
00082
00083 bool load( QIODevice *dev );
00084 bool save( QIODevice *dev );
00085 bool save( const QString &fileName );
00086
00087 QRect boundingRect() const;
00088 void setBoundingRect( const QRect &r );
00089
00090 protected:
00091 virtual bool cmd ( int, QPainter*, QPDevCmdParam* );
00092 virtual int metric( int ) const;
00093
00094 private:
00095
00096 bool play( const QDomNode &node );
00097 void saveAttributes();
00098 void restoreAttributes();
00099 QColor parseColor( const QString &col );
00100 double parseLen( const QString &str, bool *ok=0, bool horiz=TRUE ) const;
00101 int lenToInt( const QDomNamedNodeMap &map, const QString &attr,
00102 int def=0 ) const;
00103 void setStyleProperty( const QString &prop, const QString &val,
00104 QPen *pen, QFont *font, int *talign );
00105 void setStyle( const QString &s );
00106 void setTransform( const QString &tr );
00107 void drawPath( const QString &data );
00108
00109
00110 void applyStyle( QDomElement *e, int c ) const;
00111 void applyTransform( QDomElement *e ) const;
00112
00113
00114 QRect brect;
00115 QDomDocument doc;
00116 QDomNode current;
00117 QPoint curPt;
00118 QSvgDeviceState *curr;
00119 QPainter *pt;
00120
00121
00122 bool dirtyTransform, dirtyStyle;
00123
00124 QSvgDevicePrivate *d;
00125 };
00126
00127 inline QRect QSvgDevice::boundingRect() const
00128 {
00129 return brect;
00130 }
00131
00132 #endif // QT_NO_SVG
00133
00134 #endif // QSVGDEVICE_P_H