Subversion Repositories Scribus

Rev

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