Subversion Repositories Scribus

Rev

Rev 2969 | Rev 3173 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 Franz 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., 59 Temple Place - Suite 330,
17
   Boston, MA 02111-1307, USA.
18
*/
19
/* Adapted for Scribus 22.08.2003 by Franz Schmid */
20
 
21
#ifndef __SCPAINTER_H__
22
#define __SCPAINTER_H__
23
 
24
// libart wrapper
25
 
1669 craig 26
#include <qglobal.h>
68 Franz 27
#include <qwmatrix.h>
28
#include <qvaluelist.h>
29
#include <qvaluestack.h>
30
#include <qcolor.h>
31
#include <qfont.h>
3113 fschmid 32
#include <qpixmap.h>
2969 craig 33
#include "scribusapi.h"
3113 fschmid 34
#include "scconfig.h"
68 Franz 35
#include "fpoint.h"
36
#include "fpointarray.h"
37
#include "vgradient.h"
38
 
1669 craig 39
// If defined, use gdk-pixbuf for ScPainter::end() on X11 (ignored on other
40
// platforms). Otherwise use portable ScPainter::end() and omit X11-specific
41
// code and pixbuf support.
42
#ifndef SC_USE_PIXBUF
43
#define SC_USE_PIXBUF
44
#endif
45
 
2686 craig 46
// If defined, use Win32 GDI functions for ScPainter::end() on Win32 (ignored 
47
// on other platforms). Otherwise use portable ScPainter::end()
48
#ifndef SC_USE_GDI
49
#define SC_USE_GDI
50
#endif
51
 
3113 fschmid 52
 
68 Franz 53
class QPainter;
3113 fschmid 54
#ifdef HAVE_CAIRO
55
typedef struct _cairo cairo_t;
56
#else
68 Franz 57
struct _ArtVpath;
58
struct _ArtBpath;
59
struct _ArtSVP;
60
struct _ArtGradientStop;
3113 fschmid 61
#endif
68 Franz 62
 
2969 craig 63
class SCRIBUS_API ScPainter
68 Franz 64
{
65
public:
1624 fschmid 66
        ScPainter( QPaintDevice *target, unsigned int w = 0, unsigned int h = 0, unsigned int x = 0, unsigned int y = 0 );
1815 fschmid 67
        ScPainter( QImage *target, unsigned int w = 0, unsigned int h = 0, unsigned int x = 0, unsigned int y = 0 );
68 Franz 68
        virtual ~ScPainter();
456 fschmid 69
        enum FillMode { None, Solid, Gradient };
68 Franz 70
        virtual void begin();
71
        virtual void end();
72
        void clear();
73
        virtual void clear( const QColor & );
74
 
75
        // matrix manipulation
76
        virtual void setWorldMatrix( const QWMatrix & );
3113 fschmid 77
        virtual const QWMatrix worldMatrix();
68 Franz 78
        virtual void setZoomFactor( double );
79
        virtual double zoomFactor() { return m_zoomFactor; }
80
        virtual void translate( double, double );
81
        virtual void rotate( double );
82
        virtual void scale( double, double );
83
 
84
        // drawing
85
        virtual void moveTo( const double &, const double & );
86
        virtual void lineTo( const double &, const double & );
87
        virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
88
        virtual void newPath();
1998 fschmid 89
        virtual void fillTextPath();
90
        virtual void strokeTextPath();
68 Franz 91
        virtual void fillPath();
1998 fschmid 92
        virtual void strokePath();
68 Franz 93
        virtual void setFillRule( bool fillRule );
1888 fschmid 94
        virtual bool fillRule() { return m_fillRule; }
68 Franz 95
        virtual void setFillMode( int fill );
96
        virtual void setGradient( VGradient::VGradientType mode, FPoint orig, FPoint vec, FPoint foc = FPoint(0,0));
267 Franz 97
        virtual void setClipPath();
68 Franz 98
 
270 Franz 99
        virtual void drawImage( QImage *image );
264 Franz 100
        virtual void setupPolygon(FPointArray *points, bool closed = true);
638 fschmid 101
        virtual void setupTextPolygon(FPointArray *points);
68 Franz 102
        virtual void drawPolygon();
103
        virtual void drawPolyLine();
104
        virtual void drawLine(FPoint start, FPoint end);
105
        virtual void drawRect(double, double, double, double);
106
 
107
        // pen + brush
108
        virtual QColor pen();
109
        virtual QColor brush();
110
        virtual void setPen( const QColor & );
80 Franz 111
        virtual void setPen( const QColor &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
112
        virtual void setPenOpacity( double op );
113
        virtual void setLineWidth( double w);
114
        virtual void setDash(const QValueList<double>& array, double ofs);
68 Franz 115
        virtual void setBrush( const QColor & );
80 Franz 116
        virtual void setBrushOpacity( double op );
117
        virtual void setOpacity( double op );
68 Franz 118
        virtual void setFont( const QFont &f );
80 Franz 119
        virtual QFont font();
68 Franz 120
 
121
 
122
        // stack management
123
        virtual void save();
124
        virtual void restore();
125
 
126
        //
127
        virtual void setRasterOp( Qt::RasterOp );
128
 
80 Franz 129
        virtual QPaintDevice *device() { return m_target; }
68 Franz 130
        unsigned char *buffer() { return m_buffer; }
131
        VGradient fill_gradient;
132
        VGradient stroke_gradient;
133
 
134
private:
3113 fschmid 135
#ifdef HAVE_CAIRO
136
        void drawVPath( int mode );
137
#else
1998 fschmid 138
        void drawVPath( struct _ArtVpath *vec, int mode, bool preCal = false );
68 Franz 139
        void applyGradient( _ArtSVP *, bool );
3113 fschmid 140
        virtual void resize( unsigned int w, unsigned int h );
68 Franz 141
        _ArtGradientStop *buildStopArray( VGradient &gradient, int & );
142
        void clampToViewport( const _ArtSVP &, int &, int &, int &, int & );
143
        void clampToViewport( int &, int &, int &, int & );
144
        void ensureSpace( unsigned int );
145
        struct _ArtBpath *m_path;
146
        struct _ArtBpath *m_path2;
3113 fschmid 147
        struct _ArtSVP *m_clipPath;
148
#endif
68 Franz 149
        unsigned int m_index;
150
        unsigned int m_alloccount;
151
        unsigned char *m_buffer;
152
        QPaintDevice *m_target;
1815 fschmid 153
        QImage *m_image;
3113 fschmid 154
        QPixmap pixm;
68 Franz 155
        unsigned int m_width;
156
        unsigned int m_height;
1624 fschmid 157
        unsigned int m_x;
158
        unsigned int m_y;
68 Franz 159
        QWMatrix m_matrix;
160
        QFont m_font;
161
        bool mf_underline;
162
        bool mf_strikeout;
163
        bool mf_shadow;
164
        bool mf_outlined;
165
/* Filling */
166
        QColor m_fill;
80 Franz 167
        double fill_trans;
68 Franz 168
        bool m_fillRule;
169
        int fillMode;                           // 0 = none, 1 = solid, 2 = gradient
170
        int gradientMode;               // 1 = linear, 2 = radial
171
/* Stroking */
172
        QColor m_stroke;
80 Franz 173
        double stroke_trans;
174
        double LineWidth;
175
 
68 Franz 176
/* Line End Style */
177
  Qt::PenCapStyle PLineEnd;
178
/* Line Join Style */
179
  Qt::PenJoinStyle PLineJoin;
180
/* The Dash Array */
80 Franz 181
        QValueList<double> m_array;
182
        double m_offset;
68 Franz 183
/* Transformation Stack */
184
        QValueStack<QWMatrix> MStack;
185
/* Zoom Factor of the Painter */
186
        double m_zoomFactor;
1815 fschmid 187
        bool imageMode;
1669 craig 188
#if defined(Q_WS_X11) && defined(SC_USE_PIXBUF)
3113 fschmid 189
#ifdef HAVE_CAIRO
190
        cairo_t *m_cr;
191
#else
68 Franz 192
        GC gc;
3113 fschmid 193
#endif
2686 craig 194
#elif defined(_WIN32) && defined(SC_USE_GDI)
195
        HDC dc;
1669 craig 196
#endif
68 Franz 197
};
198
 
199
#endif