Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

scpainter.h

Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 
00008 #ifndef __SCPAINTER_H__
00009 #define __SCPAINTER_H__
00010 
00011 #include <QPainterPath>
00012 #include <QPainter>
00013 #include <QList>
00014 #include <QStack>
00015 #include <QColor>
00016 #include <QMatrix>
00017 #include <QFont>
00018 #include <QImage>
00019 #include "scribusapi.h"
00020 #include "scconfig.h"
00021 #include "fpoint.h"
00022 #include "fpointarray.h"
00023 #include "vgradient.h"
00024 #include "scpattern.h"
00025 
00026 #ifdef HAVE_CAIRO
00027 typedef struct _cairo cairo_t;
00028 typedef struct _cairo_surface cairo_surface_t;
00029 typedef struct _cairo_pattern cairo_pattern_t;
00030 #endif
00031 
00032 class SCRIBUS_API ScPainter
00033 {
00034 public:
00035     ScPainter( QImage *target, unsigned int w, unsigned int h, double transparency = 1.0, int blendmode = 0 );
00036 #ifdef HAVE_CAIRO
00037     ScPainter( QString target, unsigned int w, unsigned int h, double transparency = 1.0, int blendmode = 0 );
00038 #endif
00039     virtual ~ScPainter();
00040     enum FillMode { None, Solid, Gradient, Pattern };
00041     virtual void beginLayer(double transparency, int blendmode, FPointArray *clipArray = 0);
00042     virtual void endLayer();
00043     virtual void setAntialiasing(bool enable);
00044     virtual void begin();
00045     virtual void end();
00046     void clear();
00047     virtual void clear( const QColor & );
00048 
00049     // matrix manipulation
00050     virtual void setWorldMatrix( const QMatrix & );
00051     virtual const QMatrix worldMatrix();
00052     virtual void setZoomFactor( double );
00053     virtual double zoomFactor() { return m_zoomFactor; }
00054     virtual void translate( double, double );
00055     virtual void rotate( double );
00056     virtual void scale( double, double );
00057 
00058     // drawing
00059     virtual void moveTo( const double &, const double & );
00060     virtual void lineTo( const double &, const double & );
00061     virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
00062     virtual void newPath();
00063     virtual void closePath();
00064     virtual void fillTextPath();
00065     virtual void strokeTextPath();
00066     virtual void fillPath();
00067     virtual void strokePath();
00068     virtual void setFillRule( bool fillRule );
00069     virtual bool fillRule() { return m_fillRule; }
00070     virtual void setFillMode( int fill );
00071     virtual void setGradient( VGradient::VGradientType mode, FPoint orig, FPoint vec, FPoint foc = FPoint(0,0));
00072     virtual void setPattern(ScPattern *pattern, double scaleX, double scaleY, double offsetX, double offsetY, double rotation);
00073     virtual void setClipPath();
00074 
00075     virtual void drawImage( QImage *image );
00076     virtual void setupPolygon(FPointArray *points, bool closed = true);
00077     virtual void drawPolygon();
00078     virtual void drawPolyLine();
00079     virtual void drawLine(FPoint start, FPoint end);
00080     virtual void drawRect(double, double, double, double);
00081 
00082     // pen + brush
00083     virtual QColor pen();
00084     virtual QColor brush();
00085     virtual void setPen( const QColor & );
00086     virtual void setPen( const QColor &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
00087     virtual void setPenOpacity( double op );
00088     virtual void setLineWidth( double w);
00089     virtual void setDash(const QList<double>& array, double ofs);
00090     virtual void setBrush( const QColor & );
00091     virtual void setBrushOpacity( double op );
00092     virtual void setOpacity( double op );
00093     virtual void setFont( const QFont &f );
00094     virtual QFont font();
00095 
00096     // stack management
00097     virtual void save();
00098     virtual void restore();
00099 
00100 
00101     virtual void setRasterOp( int op );
00102 
00103     VGradient fill_gradient;
00104     VGradient stroke_gradient;
00105     ScPattern *m_pattern;
00106 
00107 private:
00108     void drawVPath( int mode );
00109 #ifdef HAVE_CAIRO
00110     cairo_t *m_cr;
00111     struct layerProp
00112     {
00113         cairo_surface_t *data;
00114         int blendmode;
00115         double tranparency;
00116         FPointArray groupClip;
00117         bool pushed;
00118     };
00119 #else
00120     QPainter painter;
00121     QPainterPath m_path;
00122     struct layerProp
00123     {
00124         QImage *data;
00125         int blendmode;
00126         double tranparency;
00127         FPointArray groupClip;
00128         bool pushed;
00129     };
00130     Qt::PenStyle PLineStyle;
00131 #endif
00132     QStack<layerProp> Layers;
00133     QImage *m_image;
00134     double  m_layerTransparency;
00135     int  m_blendMode;
00136     unsigned int m_width;
00137     unsigned int m_height;
00138     QMatrix m_matrix;
00139     QFont m_font;
00140     bool mf_underline;
00141     bool mf_strikeout;
00142     bool mf_shadow;
00143     bool mf_outlined;
00145     QColor m_fill;
00146     double fill_trans;
00147     bool m_fillRule;
00148     int fillMode;               // 0 = none, 1 = solid, 2 = gradient 3 = pattern
00149     int gradientMode;       // 1 = linear, 2 = radial
00150     double patternScaleX;
00151     double patternScaleY;
00152     double patternOffsetX;
00153     double patternOffsetY;
00154     double patternRotation;
00156     QColor m_stroke;
00157     double stroke_trans;
00158     double LineWidth;
00159 
00161     Qt::PenCapStyle PLineEnd;
00163     Qt::PenJoinStyle PLineJoin;
00165     QList<double> m_array;
00166     double m_offset;
00168     double m_zoomFactor;
00169     bool imageMode;
00170     bool layeredMode;
00171     bool svgMode;
00172 };
00173 
00174 #endif
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.