1 | /****************************************************************************
|
---|
2 | ** $Id: qsvgdevice_p.h 2 2005-11-16 15:49:26Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of the QSvgDevice class
|
---|
5 | **
|
---|
6 | ** Created : 001024
|
---|
7 | **
|
---|
8 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the xml module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this
|
---|
22 | ** file in accordance with the Qt Commercial License Agreement provided
|
---|
23 | ** with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | *****************************************************************************/
|
---|
37 |
|
---|
38 | #ifndef QSVGDEVICE_P_H
|
---|
39 | #define QSVGDEVICE_P_H
|
---|
40 |
|
---|
41 | //
|
---|
42 | // W A R N I N G
|
---|
43 | // -------------
|
---|
44 | //
|
---|
45 | // This file is not part of the Qt API. It exists for the convenience
|
---|
46 | // of the QPicture class. This header file may change from
|
---|
47 | // version to version without notice, or even be removed.
|
---|
48 | //
|
---|
49 | // We mean it.
|
---|
50 | //
|
---|
51 | //
|
---|
52 |
|
---|
53 | #ifndef QT_H
|
---|
54 | #include "qpaintdevice.h"
|
---|
55 | #include "qrect.h"
|
---|
56 | #include "qdom.h"
|
---|
57 | #endif // QT_H
|
---|
58 |
|
---|
59 | #if !defined(QT_MODULE_XML) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_XML )
|
---|
60 | #define QM_EXPORT_SVG
|
---|
61 | #else
|
---|
62 | #define QM_EXPORT_SVG Q_EXPORT
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | #ifndef QT_NO_SVG
|
---|
66 |
|
---|
67 | class QPainter;
|
---|
68 | class QDomNode;
|
---|
69 | class QDomNamedNodeMap;
|
---|
70 | struct QSvgDeviceState;
|
---|
71 | class QSvgDevicePrivate;
|
---|
72 |
|
---|
73 | class QM_EXPORT_SVG QSvgDevice : public QPaintDevice
|
---|
74 | {
|
---|
75 | public:
|
---|
76 | QSvgDevice();
|
---|
77 | ~QSvgDevice();
|
---|
78 |
|
---|
79 | bool play( QPainter *p );
|
---|
80 |
|
---|
81 | QString toString() const;
|
---|
82 |
|
---|
83 | bool load( QIODevice *dev );
|
---|
84 | bool save( QIODevice *dev );
|
---|
85 | bool save( const QString &fileName );
|
---|
86 |
|
---|
87 | QRect boundingRect() const;
|
---|
88 | void setBoundingRect( const QRect &r );
|
---|
89 |
|
---|
90 | protected:
|
---|
91 | virtual bool cmd ( int, QPainter*, QPDevCmdParam* );
|
---|
92 | virtual int metric( int ) const;
|
---|
93 |
|
---|
94 | private:
|
---|
95 | // reading
|
---|
96 | bool play( const QDomNode &node );
|
---|
97 | void saveAttributes();
|
---|
98 | void restoreAttributes();
|
---|
99 | QColor parseColor( const QString &col );
|
---|
100 | double parseLen( const QString &str, bool *ok=0, bool horiz=TRUE ) const;
|
---|
101 | int lenToInt( const QDomNamedNodeMap &map, const QString &attr,
|
---|
102 | int def=0 ) const;
|
---|
103 | double lenToDouble( const QDomNamedNodeMap &map, const QString &attr,
|
---|
104 | int def=0 ) const;
|
---|
105 | void setStyleProperty( const QString &prop, const QString &val,
|
---|
106 | QPen *pen, QFont *font, int *talign );
|
---|
107 | void setStyle( const QString &s );
|
---|
108 | void setTransform( const QString &tr );
|
---|
109 | void drawPath( const QString &data );
|
---|
110 |
|
---|
111 | // writing
|
---|
112 | void appendChild( QDomElement &e, int c );
|
---|
113 | void applyStyle( QDomElement *e, int c ) const;
|
---|
114 | void applyTransform( QDomElement *e ) const;
|
---|
115 |
|
---|
116 | // reading
|
---|
117 | QRect brect; // bounding rectangle
|
---|
118 | QDomDocument doc; // document tree
|
---|
119 | QDomNode current;
|
---|
120 | QPoint curPt;
|
---|
121 | QSvgDeviceState *curr;
|
---|
122 | QPainter *pt; // used by play() et al
|
---|
123 |
|
---|
124 | // writing
|
---|
125 | bool dirtyTransform, dirtyStyle;
|
---|
126 |
|
---|
127 | QSvgDevicePrivate *d;
|
---|
128 | };
|
---|
129 |
|
---|
130 | inline QRect QSvgDevice::boundingRect() const
|
---|
131 | {
|
---|
132 | return brect;
|
---|
133 | }
|
---|
134 |
|
---|
135 | #endif // QT_NO_SVG
|
---|
136 |
|
---|
137 | #endif // QSVGDEVICE_P_H
|
---|