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 / vgradientex.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-09-09  |  4.1 KB  |  149 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) 2002, 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.  
  26. #ifndef __VGRADIENTEX_H__
  27. #define __VGRADIENTEX_H__
  28.  
  29. #include <QList>
  30. #include <QMatrix>
  31.  
  32. #include "fpoint.h"
  33. #include "sccolor.h"
  34. #include "scribusapi.h"
  35. class ScribusDoc;
  36. class VGradient;
  37.  
  38. class SCRIBUS_API VColorStopEx
  39. {
  40. public:
  41.     VColorStopEx( double r, double m, ScColor c, double o, QString n, int s )
  42.     {
  43.         rampPoint = r;
  44.         midPoint = m; 
  45.         color = c;
  46.         opacity = o; 
  47.         name = n;
  48.         shade = s;
  49.     };
  50.     
  51.     VColorStopEx( const VColorStopEx& colorStop )
  52.     {
  53.         rampPoint = colorStop.rampPoint;
  54.         midPoint = colorStop.midPoint;
  55.         color = colorStop.color;
  56.         opacity = colorStop.opacity;
  57.         name = colorStop.name;
  58.         shade = colorStop.shade;
  59.     };
  60.  
  61.     ScColor color;
  62.  
  63.     // relative position of color point (0.0-1.0):
  64.     double rampPoint;
  65.  
  66.     // relative position of midpoint (0.0-1.0)
  67.     // between two ramp points. ignored for last VColorStop.
  68.     double midPoint;
  69.     double opacity;
  70.     int shade;
  71.     QString name;
  72.     friend inline bool operator== ( VColorStopEx& s1, VColorStopEx& s2 )
  73.     { return s1.rampPoint == s2.rampPoint; };
  74. }
  75. ; // VColorStopEx
  76.  
  77. // comparison function for use with stable_sort
  78. bool compareStopsEx( const VColorStopEx* item1, const VColorStopEx* item2 );
  79.  
  80. class SCRIBUS_API VGradientEx
  81. {
  82.     // friend class VGradientWidget;
  83.  
  84. public:
  85.     enum Type
  86.     {
  87.         linear = 0,
  88.         radial = 1,
  89.         conic  = 2
  90.     };
  91.  
  92.     enum RepeatMethod
  93.     {
  94.         none    = 0,
  95.         reflect = 1,
  96.         repeat  = 2
  97.     };
  98.  
  99.     VGradientEx( VGradientEx::Type type = linear );
  100.     VGradientEx( const VGradientEx& gradient );
  101.     VGradientEx( const VGradient& gradient, ScribusDoc& doc );
  102.     ~VGradientEx();
  103.  
  104.     VGradientEx& operator=(const VGradientEx& gradient);
  105.  
  106.     VGradientEx::Type type() const { return m_type; }
  107.     void setType( VGradientEx::Type type ) { m_type = type; }
  108.  
  109.     VGradientEx::RepeatMethod repeatMethod() const { return m_repeatMethod; }
  110.     void setRepeatMethod( VGradientEx::RepeatMethod repeatMethod ) { m_repeatMethod = repeatMethod; }
  111.  
  112.     const QList<VColorStopEx*> colorStops() const;
  113.     void addStop( const VColorStopEx& colorStop );
  114.     void addStop( const ScColor &color, double rampPoint, double midPoint, double opa, QString name = "", int shade = 100 );
  115.     void removeStop( VColorStopEx& colorStop );
  116.     void removeStop( uint n );
  117.     void clearStops();
  118.     uint Stops() { return m_colorStops.count(); }
  119.  
  120.     FPoint origin() const { return m_origin; }
  121.     void setOrigin( const FPoint &origin ) { m_origin = origin; }
  122.  
  123.     FPoint focalPoint() const { return m_focalPoint; }
  124.     void setFocalPoint( const FPoint &focalPoint ) { m_focalPoint = focalPoint; }
  125.  
  126.     FPoint vector() const { return m_vector; }
  127.     void setVector( const FPoint &vector ) { m_vector = vector; }
  128.  
  129.     void transform( const QMatrix& m );
  130.  
  131. protected:
  132.     QList<VColorStopEx*>        m_colorStops;
  133.  
  134.     int  compareItems( const VColorStopEx* item1, const VColorStopEx* item2 ) const;
  135.     void inSort( VColorStopEx* d );
  136.  
  137. private:
  138.     VGradientEx::Type         m_type            : 2;
  139.     VGradientEx::RepeatMethod m_repeatMethod    : 2;
  140.  
  141.     // coordinates:
  142.     FPoint m_origin;
  143.     FPoint m_focalPoint;
  144.     FPoint m_vector;
  145. }
  146. ; // VGradientEx
  147.  
  148. #endif /* __VGRADIENT_H__ */
  149.