karbon

vkopainter.h
1/* This file is part of the KDE project
2 Copyright (C) 2001, 2002, 2003 The Karbon Developers
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __VKOPAINTER_H__
21#define __VKOPAINTER_H__
22
23// kopainter/libart wrapper
24
25#include "vpainter.h"
26#include <tqwmatrix.h>
27#include <tqptrlist.h>
28#include <koffice_export.h>
29class TQPainter;
30struct _ArtVpath;
31struct _ArtBpath;
32struct _ArtSVP;
33struct _ArtGradientStop;
34class VGradient;
35class VPattern;
36class KoRect;
37
38class KARBONBASE_EXPORT VKoPainter : public VPainter
39{
40public:
41 VKoPainter( TQPaintDevice *target, unsigned int w = 0, unsigned int h = 0, bool = true );
42 VKoPainter( unsigned char *buffer, unsigned int w = 0, unsigned int h = 0, bool = true );
43 virtual ~VKoPainter();
44
45 virtual void resize( unsigned int w, unsigned int h );
46 virtual void begin();
47 virtual void end();
48 virtual void blit( const KoRect & );
49 void clear();
50 virtual void clear( const TQColor & );
51 virtual void clear( const KoRect &, const TQColor & );
52
53 // matrix manipulation
54 virtual void setWorldMatrix( const TQWMatrix & );
55 virtual const TQWMatrix worldMatrix() { return m_matrix; }
56 virtual void setZoomFactor( double );
57 virtual double zoomFactor() { return m_zoomFactor; }
58
59 // drawing
60 virtual void moveTo( const KoPoint & );
61 virtual void lineTo( const KoPoint & );
62 virtual void curveTo( const KoPoint &, const KoPoint &, const KoPoint & );
63 virtual void newPath();
64 virtual void fillPath();
65 virtual void setFillRule( VFillRule );
66 virtual void strokePath();
67 virtual void setClipPath();
68 virtual void resetClipPath();
69
70 // helper
71 virtual void drawNode( const KoPoint& p, int width );
72 virtual void drawRect( const KoRect & );
73 virtual void drawRect( double, double, double, double );
74
75 // pen + brush
76 virtual void setPen( const VStroke & );
77 virtual void setPen( const TQColor & );
78 virtual void setPen( TQt::PenStyle style );
79 virtual void setBrush( const VFill & );
80 virtual void setBrush( const TQColor & );
81 virtual void setBrush( TQt::BrushStyle style );
82
83 virtual void drawImage( const TQImage &, const TQWMatrix & );
84
85 // stack management
86 virtual void save();
87 virtual void restore();
88
89 //
90 virtual void setRasterOp( TQt::RasterOp );
91
92 virtual TQPaintDevice *device() { return m_target; }
93 unsigned char *buffer() { return m_buffer; }
94
95private:
96 void drawVPath( struct _ArtVpath * );
97 void applyGradient( _ArtSVP *, bool );
98 void applyPattern( _ArtSVP *, bool );
99 _ArtGradientStop *buildStopArray( VGradient &gradient, int & );
100 void clampToViewport( const _ArtSVP &, int &, int &, int &, int & );
101 void clampToViewport( int &, int &, int &, int & );
102 void ensureSpace( unsigned int );
103
104private:
105 struct _ArtBpath *m_path;
106 unsigned int m_index;
107 unsigned int m_alloccount;
108 unsigned char *m_buffer;
109 TQPaintDevice *m_target;
110 unsigned int m_width;
111 unsigned int m_height;
112 TQWMatrix m_matrix;
113 VStroke *m_stroke;
114 VFill *m_fill;
115 VFillRule m_fillRule;
116 double m_zoomFactor;
117 TQPtrList<_ArtSVP> m_clipPaths;
118
119 bool m_bDrawNodes;
120
121 GC gc;
122};
123
124#endif