Subversion Repositories Scribus

Rev

Rev 16729 | Rev 19103 | 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) 2002, The Karbon Developers
295 Franz 9
 
68 Franz 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.
295 Franz 14
 
68 Franz 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.
295 Franz 19
 
68 Franz 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
18122 mrdocs 22
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23
   Boston, MA 02110-1301, USA.
68 Franz 24
*/
25
 
26
#ifndef __VGRADIENT_H__
27
#define __VGRADIENT_H__
28
 
10223 cbradney 29
#include <QColor>
9982 fschmid 30
#include <QList>
13951 fschmid 31
#include <QTransform>
10223 cbradney 32
 
33
#include "fpoint.h"
2969 craig 34
#include "scribusapi.h"
68 Franz 35
 
2969 craig 36
class SCRIBUS_API VColorStop
68 Franz 37
{
295 Franz 38
public:
39
        VColorStop( double r, double m, QColor c, double o, QString n, int s )
40
        {
41
                rampPoint = r;
42
                midPoint = m;
43
                color = c;
44
                opacity = o;
45
                name = n;
46
                shade = s;
47
        };
48
 
49
        VColorStop( const VColorStop& colorStop )
50
        {
51
                rampPoint = colorStop.rampPoint;
52
                midPoint = colorStop.midPoint;
53
                color = colorStop.color;
54
                opacity = colorStop.opacity;
55
                name = colorStop.name;
56
                shade = colorStop.shade;
57
        };
68 Franz 58
 
295 Franz 59
        QColor color;
68 Franz 60
 
295 Franz 61
        // relative position of color point (0.0-1.0):
62
        double rampPoint;
68 Franz 63
 
295 Franz 64
        // relative position of midpoint (0.0-1.0)
65
        // between two ramp points. ignored for last VColorStop.
66
        double midPoint;
67
        double opacity;
68
        int shade;
69
        QString name;
70
        friend inline bool operator== ( VColorStop& s1, VColorStop& s2 )
71
        { return s1.rampPoint == s2.rampPoint; };
72
}
73
; // VColorStop
68 Franz 74
 
6510 jghali 75
// comparison function for use with stable_sort
76
bool compareStops( const VColorStop* item1, const VColorStop* item2 );
77
 
2969 craig 78
class SCRIBUS_API VGradient
68 Franz 79
{
295 Franz 80
        // friend class VGradientWidget;
68 Franz 81
 
82
public:
83
        enum VGradientType
84
        {
295 Franz 85
            linear = 0,
86
            radial = 1,
14981 fschmid 87
            fourcolor  = 2,
15024 fschmid 88
            diamond = 3,
16729 fschmid 89
                mesh = 4,
90
                freemesh = 5
68 Franz 91
        };
92
 
93
        enum VGradientRepeatMethod
94
        {
295 Franz 95
            none    = 0,
96
            reflect = 1,
97
            repeat  = 2
68 Franz 98
        };
99
 
100
        VGradient( VGradientType type = linear );
101
        VGradient( const VGradient& gradient );
9992 jghali 102
        ~VGradient();
68 Franz 103
 
104
        VGradient& operator=(const VGradient& gradient);
14154 fschmid 105
        bool operator==(const VGradient& gradient) const;
68 Franz 106
 
107
        VGradientType type() const { return m_type; }
108
        void setType( VGradientType type ) { m_type = type; }
109
 
110
        VGradientRepeatMethod repeatMethod() const { return m_repeatMethod; }
111
        void setRepeatMethod( VGradientRepeatMethod repeatMethod ) { m_repeatMethod = repeatMethod; }
112
 
10009 jghali 113
        const QList<VColorStop*>& colorStops() const;
68 Franz 114
        void addStop( const VColorStop& colorStop );
295 Franz 115
        void addStop( const QColor &color, double rampPoint, double midPoint, double opa, QString name = "", int shade = 100 );
13182 jghali 116
        void setStop( const QColor &color, double rampPoint, double midPoint, double opa, QString name = "", int shade = 100 );
9982 fschmid 117
        void removeStop( VColorStop& colorStop );
295 Franz 118
        void removeStop( uint n );
68 Franz 119
        void clearStops();
8195 avox 120
        uint Stops()  const { return m_colorStops.count(); }
68 Franz 121
 
6495 jghali 122
        // This function let only one stop with offset value equal to 0 and 1.0
123
        // by removing the firsts with 0.0 value and the lasts with 1.0 value;
124
        void filterStops(void);
125
 
68 Franz 126
        FPoint origin() const { return m_origin; }
127
        void setOrigin( const FPoint &origin ) { m_origin = origin; }
128
 
129
        FPoint focalPoint() const { return m_focalPoint; }
130
        void setFocalPoint( const FPoint &focalPoint ) { m_focalPoint = focalPoint; }
131
 
132
        FPoint vector() const { return m_vector; }
133
        void setVector( const FPoint &vector ) { m_vector = vector; }
134
 
13951 fschmid 135
        void transform( const QTransform& m );
68 Franz 136
 
137
protected:
10009 jghali 138
        QList<VColorStop*>        m_colorStops;
295 Franz 139
 
10009 jghali 140
        int  compareItems(const VColorStop* item1, const VColorStop* item2 ) const;
141
        void inSort( VColorStop* d );
142
 
68 Franz 143
private:
15024 fschmid 144
        VGradientType         m_type;
10009 jghali 145
        VGradientRepeatMethod m_repeatMethod    : 2;
68 Franz 146
 
147
        // coordinates:
148
        FPoint m_origin;
149
        FPoint m_focalPoint;
150
        FPoint m_vector;
295 Franz 151
}
152
; // VGradient
68 Franz 153
 
154
#endif /* __VGRADIENT_H__ */