karbon

vkopainter.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, 2002, 2003 The Karbon Developers
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __VKOPAINTER_H__
00021 #define __VKOPAINTER_H__
00022 
00023 // kopainter/libart wrapper
00024 
00025 #include "vpainter.h"
00026 #include <qwmatrix.h>
00027 #include <qptrlist.h>
00028 #include <koffice_export.h>
00029 class QPainter;
00030 struct _ArtVpath;
00031 struct _ArtBpath;
00032 struct _ArtSVP;
00033 struct _ArtGradientStop;
00034 class VGradient;
00035 class VPattern;
00036 class KoRect;
00037 
00038 class KARBONBASE_EXPORT VKoPainter : public VPainter
00039 {
00040 public:
00041     VKoPainter( QPaintDevice *target, unsigned int w = 0, unsigned int h = 0, bool = true );
00042     VKoPainter( unsigned char *buffer, unsigned int w = 0, unsigned int h = 0, bool = true );
00043     virtual ~VKoPainter();
00044 
00045     virtual void resize( unsigned int w, unsigned int h );
00046     virtual void begin();
00047     virtual void end();
00048     virtual void blit( const KoRect & );
00049     void clear();
00050     virtual void clear( const QColor & );
00051     virtual void clear( const KoRect &, const QColor & );
00052 
00053     // matrix manipulation
00054     virtual void setWorldMatrix( const QWMatrix & );
00055     virtual const QWMatrix worldMatrix() { return m_matrix; }
00056     virtual void setZoomFactor( double );
00057     virtual double zoomFactor() { return m_zoomFactor; }
00058 
00059     // drawing
00060     virtual void moveTo( const KoPoint & );
00061     virtual void lineTo( const KoPoint & );
00062     virtual void curveTo( const KoPoint &, const KoPoint &, const KoPoint & );
00063     virtual void newPath();
00064     virtual void fillPath();
00065     virtual void setFillRule( VFillRule );
00066     virtual void strokePath();
00067     virtual void setClipPath();
00068     virtual void resetClipPath();
00069 
00070     // helper
00071     virtual void drawNode( const KoPoint& p, int width );
00072     virtual void drawRect( const KoRect & );
00073     virtual void drawRect( double, double, double, double );
00074 
00075     // pen + brush
00076     virtual void setPen( const VStroke & );
00077     virtual void setPen( const QColor & );
00078     virtual void setPen( Qt::PenStyle style );
00079     virtual void setBrush( const VFill & );
00080     virtual void setBrush( const QColor & );
00081     virtual void setBrush( Qt::BrushStyle style );
00082 
00083     virtual void drawImage( const QImage &, const QWMatrix & );
00084 
00085     // stack management
00086     virtual void save();
00087     virtual void restore();
00088 
00089     //
00090     virtual void setRasterOp( Qt::RasterOp );
00091 
00092     virtual QPaintDevice *device() { return m_target; } 
00093     unsigned char *buffer() { return m_buffer; }
00094 
00095 private:
00096     void drawVPath( struct _ArtVpath * );
00097     void applyGradient( _ArtSVP *, bool );
00098     void applyPattern( _ArtSVP *, bool );
00099     _ArtGradientStop *buildStopArray( VGradient &gradient, int & );
00100     void clampToViewport( const _ArtSVP &, int &, int &, int &, int & );
00101     void clampToViewport( int &, int &, int &, int & );
00102     void ensureSpace( unsigned int );
00103 
00104 private:
00105     struct _ArtBpath *m_path;
00106     unsigned int m_index;
00107     unsigned int m_alloccount;
00108     unsigned char *m_buffer;
00109     QPaintDevice *m_target;
00110     unsigned int m_width;
00111     unsigned int m_height;
00112     QWMatrix m_matrix;
00113     VStroke *m_stroke;
00114     VFill *m_fill;
00115     VFillRule m_fillRule;
00116     double m_zoomFactor;
00117     QPtrList<_ArtSVP> m_clipPaths;
00118 
00119     bool m_bDrawNodes;
00120 
00121     GC gc;
00122 };
00123 
00124 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys