Subversion Repositories Scribus

Rev

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

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
68 Franz 7
/* This file is part of the KDE project
8
   Copyright (C) 2001, 2002, 2003 The Karbon Developers
9
 
10
   This library is free software; you can redistribute it and/or
11
   modify it under the terms of the GNU Library General Public
12
   License as published by the Free Software Foundation; either
13
   version 2 of the License, or (at your option) any later version.
14
 
15
   This library is distributed in the hope that it will be useful,
16
   but WITHOUT ANY WARRANTY; without even the implied warranty of
17
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
   Library General Public License for more details.
19
 
20
   You should have received a copy of the GNU Library General Public License
21
   along with this library; see the file COPYING.LIB.  If not, write to
22
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23
   Boston, MA 02111-1307, USA.
24
*/
25
/* Adapted for Scribus 22.08.2003 by Franz Schmid */
26
 
27
#ifndef __SCPAINTER_H__
28
#define __SCPAINTER_H__
29
 
30
// libart wrapper
31
 
1669 craig 32
#include <qglobal.h>
68 Franz 33
#include <qwmatrix.h>
34
#include <qvaluelist.h>
35
#include <qvaluestack.h>
36
#include <qcolor.h>
37
#include <qfont.h>
3113 fschmid 38
#include <qpixmap.h>
5373 fschmid 39
#include <qimage.h>
2969 craig 40
#include "scribusapi.h"
3113 fschmid 41
#include "scconfig.h"
68 Franz 42
#include "fpoint.h"
43
#include "fpointarray.h"
44
#include "vgradient.h"
45
 
1669 craig 46
// If defined, use gdk-pixbuf for ScPainter::end() on X11 (ignored on other
47
// platforms). Otherwise use portable ScPainter::end() and omit X11-specific
48
// code and pixbuf support.
49
#ifndef SC_USE_PIXBUF
50
#define SC_USE_PIXBUF
51
#endif
52
 
4646 subik 53
// If defined, use Win32 GDI functions for ScPainter::end() on Win32 (ignored
2686 craig 54
// on other platforms). Otherwise use portable ScPainter::end()
55
#ifndef SC_USE_GDI
56
#define SC_USE_GDI
57
#endif
58
 
3113 fschmid 59
 
68 Franz 60
class QPainter;
3113 fschmid 61
#ifdef HAVE_CAIRO
62
typedef struct _cairo cairo_t;
5604 fschmid 63
typedef struct _cairo_surface cairo_surface_t;
3113 fschmid 64
#else
68 Franz 65
struct _ArtVpath;
66
struct _ArtBpath;
67
struct _ArtSVP;
68
struct _ArtGradientStop;
3113 fschmid 69
#endif
68 Franz 70
 
2969 craig 71
class SCRIBUS_API ScPainter
68 Franz 72
{
73
public:
1624 fschmid 74
        ScPainter( QPaintDevice *target, unsigned int w = 0, unsigned int h = 0, unsigned int x = 0, unsigned int y = 0 );
1815 fschmid 75
        ScPainter( QImage *target, unsigned int w = 0, unsigned int h = 0, unsigned int x = 0, unsigned int y = 0 );
5373 fschmid 76
#ifdef HAVE_CAIRO
77
        ScPainter( QImage *target, unsigned int w, unsigned int h, double transparency, int blendmode );
5471 fschmid 78
        ScPainter( QString target, unsigned int w, unsigned int h, double transparency, int blendmode );
5373 fschmid 79
#endif
68 Franz 80
        virtual ~ScPainter();
456 fschmid 81
        enum FillMode { None, Solid, Gradient };
5373 fschmid 82
#ifdef HAVE_CAIRO
83
        virtual void beginLayer(double transparency, int blendmode);
84
        virtual void endLayer();
85
#endif
68 Franz 86
        virtual void begin();
87
        virtual void end();
88
        void clear();
89
        virtual void clear( const QColor & );
90
 
91
        // matrix manipulation
92
        virtual void setWorldMatrix( const QWMatrix & );
3113 fschmid 93
        virtual const QWMatrix worldMatrix();
68 Franz 94
        virtual void setZoomFactor( double );
95
        virtual double zoomFactor() { return m_zoomFactor; }
96
        virtual void translate( double, double );
97
        virtual void rotate( double );
98
        virtual void scale( double, double );
99
 
100
        // drawing
101
        virtual void moveTo( const double &, const double & );
102
        virtual void lineTo( const double &, const double & );
103
        virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
104
        virtual void newPath();
5233 fschmid 105
        virtual void closePath();
1998 fschmid 106
        virtual void fillTextPath();
107
        virtual void strokeTextPath();
68 Franz 108
        virtual void fillPath();
1998 fschmid 109
        virtual void strokePath();
68 Franz 110
        virtual void setFillRule( bool fillRule );
1888 fschmid 111
        virtual bool fillRule() { return m_fillRule; }
68 Franz 112
        virtual void setFillMode( int fill );
113
        virtual void setGradient( VGradient::VGradientType mode, FPoint orig, FPoint vec, FPoint foc = FPoint(0,0));
267 Franz 114
        virtual void setClipPath();
4748 fschmid 115
#ifndef HAVE_CAIRO
116
        virtual void setClipPath2(FPointArray *points, bool closed);
117
#endif
68 Franz 118
 
270 Franz 119
        virtual void drawImage( QImage *image );
264 Franz 120
        virtual void setupPolygon(FPointArray *points, bool closed = true);
638 fschmid 121
        virtual void setupTextPolygon(FPointArray *points);
68 Franz 122
        virtual void drawPolygon();
123
        virtual void drawPolyLine();
124
        virtual void drawLine(FPoint start, FPoint end);
125
        virtual void drawRect(double, double, double, double);
126
 
127
        // pen + brush
128
        virtual QColor pen();
129
        virtual QColor brush();
130
        virtual void setPen( const QColor & );
80 Franz 131
        virtual void setPen( const QColor &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
132
        virtual void setPenOpacity( double op );
133
        virtual void setLineWidth( double w);
134
        virtual void setDash(const QValueList<double>& array, double ofs);
68 Franz 135
        virtual void setBrush( const QColor & );
80 Franz 136
        virtual void setBrushOpacity( double op );
137
        virtual void setOpacity( double op );
68 Franz 138
        virtual void setFont( const QFont &f );
80 Franz 139
        virtual QFont font();
68 Franz 140
 
141
 
142
        // stack management
143
        virtual void save();
144
        virtual void restore();
145
 
146
        //
3173 fschmid 147
        virtual void setRasterOp( int op );
68 Franz 148
 
80 Franz 149
        virtual QPaintDevice *device() { return m_target; }
68 Franz 150
        unsigned char *buffer() { return m_buffer; }
151
        VGradient fill_gradient;
152
        VGradient stroke_gradient;
153
 
154
private:
3113 fschmid 155
#ifdef HAVE_CAIRO
156
        void drawVPath( int mode );
157
#else
4646 subik 158
        void drawVPath( struct _ArtVpath *vec, int mode, bool preCal = false );
159
        void applyGradient( _ArtSVP *svp, bool fill );
3113 fschmid 160
        virtual void resize( unsigned int w, unsigned int h );
68 Franz 161
        _ArtGradientStop *buildStopArray( VGradient &gradient, int & );
4646 subik 162
        void clampToViewport( const _ArtSVP &svp, int &x0, int &y0, int &x1, int &y1 );
4645 subik 163
        void clampToViewport( int &x0, int &y0, int &x1, int &y1 );
68 Franz 164
        void ensureSpace( unsigned int );
165
        struct _ArtBpath *m_path;
166
        struct _ArtBpath *m_path2;
3113 fschmid 167
        struct _ArtSVP *m_clipPath;
168
#endif
68 Franz 169
        unsigned int m_index;
170
        unsigned int m_alloccount;
171
        unsigned char *m_buffer;
172
        QPaintDevice *m_target;
1815 fschmid 173
        QImage *m_image;
5373 fschmid 174
        QImage  tmp_image;
175
        double  m_layerTransparency;
176
        int  m_blendMode;
3113 fschmid 177
        QPixmap pixm;
68 Franz 178
        unsigned int m_width;
179
        unsigned int m_height;
1624 fschmid 180
        unsigned int m_x;
181
        unsigned int m_y;
68 Franz 182
        QWMatrix m_matrix;
183
        QFont m_font;
184
        bool mf_underline;
185
        bool mf_strikeout;
186
        bool mf_shadow;
187
        bool mf_outlined;
4646 subik 188
        /*! \brief Filling */
68 Franz 189
        QColor m_fill;
80 Franz 190
        double fill_trans;
68 Franz 191
        bool m_fillRule;
192
        int fillMode;                           // 0 = none, 1 = solid, 2 = gradient
193
        int gradientMode;               // 1 = linear, 2 = radial
4646 subik 194
        /*! \brief Stroking */
68 Franz 195
        QColor m_stroke;
80 Franz 196
        double stroke_trans;
197
        double LineWidth;
198
 
4646 subik 199
        /*! \brief Line End Style */
68 Franz 200
  Qt::PenCapStyle PLineEnd;
4646 subik 201
  /*! \brief Line Join Style */
68 Franz 202
  Qt::PenJoinStyle PLineJoin;
4646 subik 203
  /*! \brief The Dash Array */
80 Franz 204
        QValueList<double> m_array;
205
        double m_offset;
4646 subik 206
        /*! \brief Transformation Stack */
68 Franz 207
        QValueStack<QWMatrix> MStack;
4646 subik 208
        /*! \brief Zoom Factor of the Painter */
68 Franz 209
        double m_zoomFactor;
1815 fschmid 210
        bool imageMode;
5373 fschmid 211
        bool layeredMode;
5471 fschmid 212
        bool svgMode;
1669 craig 213
#if defined(Q_WS_X11) && defined(SC_USE_PIXBUF)
3113 fschmid 214
#ifdef HAVE_CAIRO
215
        cairo_t *m_cr;
5604 fschmid 216
        struct layerProp
217
        {
218
                cairo_surface_t *data;
219
                int blendmode;
220
                double tranparency;
221
        };
222
        QValueStack<layerProp> Layers;
3113 fschmid 223
#else
68 Franz 224
        GC gc;
3113 fschmid 225
#endif
2686 craig 226
#elif defined(_WIN32) && defined(SC_USE_GDI)
227
        HDC dc;
1669 craig 228
#endif
68 Franz 229
};
230
 
231
#endif