Scribus
Open source desktop publishing at your fingertips
scpainterexbase.h
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 */
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., 51 Franklin Street, Fifth Floor,
23  Boston, MA 02110-1301, USA.
24 */
25 /* Adapted for Scribus 22.08.2003 by Franz Schmid */
26 /* Adapted for Scribus 15.01.2006 by Jean Ghali */
27 
28 #ifndef __SCPAINTEREXBASE_H__
29 #define __SCPAINTEREXBASE_H__
30 
31 #include <QColor>
32 #include <QFont>
33 #include <QGlobalStatic>
34 #include <QList>
35 #include <QTransform>
36 #include <QPixmap>
37 #include <QStack>
38 
39 #include "scribusapi.h"
40 #include "scconfig.h"
41 #include "fpoint.h"
42 #include "fpointarray.h"
43 #include "mesh.h"
44 #include "vgradientex.h"
45 #include "sccolorshade.h"
46 
47 class ScImage;
48 class ScPattern;
49 
50 class SCRIBUS_API ScPainterExBase
51 {
52 protected:
53  int m_capabilities;
54  ScPainterExBase(void);
55 public:
56 
57  virtual ~ScPainterExBase() {};
58  enum FillMode { None, Solid, Gradient, Pattern };
59  enum ColorMode { rgbMode = 1, cmykMode = 2 };
60  enum ImageMode { cmykImages, rgbImages, rawImages };
61  enum Capabilities{ basic = 0, transparencies = 1, patterns = 2 };
62 
63  virtual Capabilities capabilities() { return basic; }
64  virtual bool hasCapability(Capabilities cap) { return ((m_capabilities & (int) cap) != 0); }
65 
66  virtual int supportedColorModes() = 0;
67  virtual ColorMode preferredColorMode() = 0;
68  virtual ImageMode imageMode() = 0;
69 
70  virtual void begin() = 0;
71  virtual void end() = 0;
72  virtual void clear() = 0;
73  virtual void clear( ScColorShade& ) = 0;
74 
75  // matrix manipulation
76  virtual void setWorldMatrix( const QTransform & ) = 0;
77  virtual const QTransform worldMatrix() = 0;
78  virtual void translate( double, double ) = 0;
79  virtual void rotate( double ) = 0;
80  virtual void scale( double, double ) = 0;
81 
82  // drawing
83  virtual void moveTo( const double &, const double & ) = 0;
84  virtual void lineTo( const double &, const double & ) = 0;
85  virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 ) = 0;
86  virtual void newPath() = 0;
87  virtual void fillPath() = 0;
88  virtual void strokePath() = 0;
89  virtual void setFillRule( bool fillRule ) = 0;
90  virtual bool fillRule() = 0;
91  virtual void setFillMode( int fill ) = 0;
92  virtual int fillMode() = 0;
93  virtual void setStrokeMode( int stroke ) = 0;
94  virtual int strokeMode() = 0;
95  virtual void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew ) = 0;
96  virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY) = 0;
97 
98  virtual void setMaskMode( int mask ) = 0;
99  virtual void setGradientMask(VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc, double scale, double skew) = 0;
100  virtual void setPatternMask(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation, double skewX, double skewY, bool mirrorX, bool mirrorY) = 0;
101 
102  virtual void set4ColorGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4) = 0;
103  virtual void set4ColorColors(const ScColorShade& col1, const ScColorShade& col2, const ScColorShade& col3, const ScColorShade& col4) = 0;
104  virtual void setDiamondGeometry(FPoint p1, FPoint p2, FPoint p3, FPoint p4, FPoint c1, FPoint c2, FPoint c3, FPoint c4, FPoint c5) = 0;
105  virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<QList<meshPoint> > meshArray) = 0;
106  virtual void setMeshGradient(FPoint p1, FPoint p2, FPoint p3, FPoint p4, QList<meshGradientPatch> meshPatches) = 0;
107 
108  virtual void setClipPath() = 0;
109 
110  virtual void drawImage( ScImage *image, ScPainterExBase::ImageMode mode ) = 0;
111  virtual void setupPolygon(FPointArray *points, bool closed = true) = 0;
112  virtual void drawPolygon() = 0;
113  virtual void drawPolyLine() = 0;
114  virtual void drawLine(FPoint start, FPoint end) = 0;
115  virtual void drawRect(double, double, double, double) = 0;
116 
117  // pen + brush
118  virtual ScColorShade pen() = 0;
119  virtual ScColorShade brush() = 0;
120  virtual void setPen( const ScColorShade &c ) = 0;
121  virtual void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo ) = 0;
122  virtual void setPenOpacity( double op ) = 0;
123  virtual void setLineWidth( double w) = 0;
124  virtual void setDash(const QVector<double>& array, double ofs) = 0;
125  virtual void setBrush( const ScColorShade & ) = 0;
126  virtual void setBrushOpacity( double op ) = 0;
127  virtual void setOpacity( double op ) = 0;
128  virtual void setFont( const QFont &f ) = 0;
129  virtual QFont font() = 0;
130 
131  // stack management
132  virtual void save() = 0;
133  virtual void restore() = 0;
134 
135  virtual void setRasterOp( int op ) = 0;
136  virtual void setBlendModeFill( int blendMode ) = 0;
137  virtual void setBlendModeStroke( int blendMode ) = 0;
138 
139  VGradientEx m_fillGradient;
140  VGradientEx m_strokeGradient;
141  VGradientEx m_maskGradient;
142  ScPattern* m_pattern;
143  ScPattern* m_maskPattern;
144  QTransform m_patternTransform;
145 };
146 
147 #endif
Definition: sccolorshade.h:29
Definition: scpattern.h:36
Definition: scimage.h:36
A point with floating point precision.
Definition: fpoint.h:43
Definition: vgradientex.h:80
Definition: scpainterexbase.h:50
Definition: fpointarray.h:42