home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / scpainterex_gdiplus.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-03-25  |  5.8 KB  |  188 lines

  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., 59 Temple Place - Suite 330,
  23.    Boston, MA 02111-1307, 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 __SCPAINTEREX_GDIPLUS_H__
  29. #define __SCPAINTEREX_GDIPLUS_H__
  30.  
  31. // libart wrapper
  32.  
  33. #include <QColor>
  34. #include <QFont>
  35. #include <QGlobalStatic>
  36. #include <QList>
  37. #include <QMatrix>
  38. #include <QPixmap>
  39. #include <QStack>
  40.  
  41. #include "scribusapi.h"
  42. #include "scconfig.h"
  43. #include "fpoint.h"
  44. #include "fpointarray.h"
  45. #include "vgradient.h"
  46.  
  47. #include "scpainterexbase.h"
  48.  
  49. #include <valarray>
  50. #include <windows.h>
  51.  
  52. class QPainter;
  53. class ScribusDoc;
  54.  
  55. namespace Gdiplus
  56. {
  57.     class Graphics;
  58.     class GraphicsPath;
  59. }; 
  60.  
  61. class SCRIBUS_API ScPainterEx_GDIPlus : public ScPainterExBase
  62. {
  63. public:
  64.  
  65.     ScPainterEx_GDIPlus(HDC hDC, QRect& rect, ScribusDoc* doc, bool gray );
  66.     virtual ~ScPainterEx_GDIPlus();
  67.  
  68.     virtual Capabilities capabilities() { return transparencies; }
  69.  
  70.     virtual int supportedColorModes() { return (int) rgbMode; }
  71.     virtual ColorMode preferredColorMode() { return rgbMode; }
  72.     virtual ImageMode imageMode() { return rgbImages; }
  73.  
  74.     virtual void begin();
  75.     virtual void end();
  76.     virtual void clear();
  77.     virtual void clear( ScColorShade & );
  78.  
  79.     // matrix manipulation
  80.     virtual void setWorldMatrix( const QMatrix & );
  81.     virtual const QMatrix worldMatrix();
  82.     virtual void translate( double, double );
  83.     virtual void rotate( double );
  84.     virtual void scale( double, double );
  85.  
  86.     // drawing
  87.     virtual void moveTo( const double &, const double & );
  88.     virtual void lineTo( const double &, const double & );
  89.     virtual void curveTo( FPoint p1, FPoint p2, FPoint p3 );
  90.     virtual void newPath();
  91.     virtual void fillTextPath();
  92.     virtual void strokeTextPath();
  93.     virtual void fillPath();
  94.     virtual void strokePath();
  95.     virtual void setFillRule( bool fillRule );
  96.     virtual bool fillRule() { return m_fillRule; }
  97.     virtual void setFillMode( int fill );
  98.     virtual int  fillMode() { return m_fillMode; }
  99.     virtual void setGradient( VGradientEx::Type mode, FPoint orig, FPoint vec, FPoint foc = FPoint(0,0));
  100.     virtual void setPattern ( ScPattern* pattern, QMatrix& patternTransform );
  101.     virtual void setClipPath();
  102.  
  103.     virtual void drawImage( ScImage *image, ScPainterExBase::ImageMode mode );
  104.     virtual void setupPolygon(FPointArray *points, bool closed = true);
  105.     virtual void drawPolygon();
  106.     virtual void drawPolyLine();
  107.     virtual void drawLine(FPoint start, FPoint end);
  108.     virtual void drawRect(double, double, double, double);
  109.  
  110.     // pen + brush
  111.     virtual ScColorShade pen();
  112.     virtual ScColorShade brush();
  113.     virtual void setPen( const ScColorShade & );
  114.     virtual void setPen( const ScColorShade &c, double w, Qt::PenStyle st, Qt::PenCapStyle ca, Qt::PenJoinStyle jo );
  115.     virtual void setPenOpacity( double op );
  116.     virtual void setLineWidth( double w);
  117.     virtual void setDash(const QList<double>& array, double ofs);
  118.     virtual void setBrush( const ScColorShade & );
  119.     virtual void setBrushOpacity( double op );
  120.     virtual void setOpacity( double op );
  121.     virtual void setFont( const QFont &f );
  122.     virtual QFont font();
  123.  
  124.     // stack management
  125.     virtual void save();
  126.     virtual void restore();
  127.  
  128.     virtual void setRasterOp( int op );
  129.  
  130. private:
  131.  
  132.     void drawVPath( int mode );
  133.     void drawGradient( VGradientEx& gradient );
  134.     void drawLinearGradient( VGradientEx& gradient, const QRect& rect );
  135.     void drawCircularGradient( VGradientEx& gradient, const QRect& rect );
  136.     void getClipPathDimensions( QRect& r );
  137.     void transformPoint( const FPoint& in, FPoint& out );
  138.     void transformPoints( const FPoint* in, FPoint* out, uint length );
  139.  
  140.     ScribusDoc* m_doc;
  141.  
  142.     unsigned int m_width;
  143.     unsigned int m_height;
  144.     QMatrix  m_matrix;
  145.     QFont m_font;
  146. /* Filling */
  147.     ScColorShade m_fillColor;
  148.     double m_fillTrans;
  149.     bool   m_fillRule;
  150.     int    m_fillMode;            // 0 = none, 1 = solid, 2 = gradient
  151.     int    m_gradientMode;        // 1 = linear, 2 = radial
  152. /* Stroking */
  153.     ScColorShade m_strokeColor;
  154.     double m_strokeTrans;
  155.     double m_lineWidth;
  156. /* Grayscale conversion option */
  157.     bool   m_convertToGray;
  158.  
  159. /* Line End Style */
  160.     Qt::PenCapStyle m_lineEnd;
  161. /* Line Join Style */
  162.     Qt::PenJoinStyle m_lineJoin;
  163. /* The Dash Array */
  164.     QList<double> m_array;
  165.     double m_offset;
  166. /* Transformation Stack */
  167.     QStack<QMatrix> m_stack;
  168.  
  169. /* Some data to describe state of drawing */    
  170.     bool m_pathIsClosed;
  171.     bool m_drawingClosedPath;
  172.  
  173. /* Device context */
  174.     HDC m_dc;
  175.  
  176. /* Color conversion function */
  177.     QColor transformColor( ScColorShade& colorShade, double trans );
  178.     void   transformImage( QImage* image, uchar* data, int scan);
  179.  
  180.     QStack<int> m_gStates;
  181.     Gdiplus::Graphics* m_graphics;
  182.     Gdiplus::GraphicsPath* m_graphicsPath;
  183.     double m_positionX;
  184.     double m_positionY;
  185. };
  186.  
  187. #endif
  188.