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
*/
4360 cbradney 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
18122 mrdocs 22
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23
   Boston, MA 02110-1301, USA.
4360 cbradney 24
*/
25
 
26
#ifndef __VGRADIENTEX_H__
27
#define __VGRADIENTEX_H__
28
 
9982 fschmid 29
#include <QList>
13951 fschmid 30
#include <QTransform>
10223 cbradney 31
 
32
#include "fpoint.h"
33
#include "sccolor.h"
4360 cbradney 34
#include "scribusapi.h"
10601 mrdocs 35
class ScribusDoc;
36
class VGradient;
4360 cbradney 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
 
6510 jghali 77
// comparison function for use with stable_sort
78
bool compareStopsEx( const VColorStopEx* item1, const VColorStopEx* item2 );
79
 
4360 cbradney 80
class SCRIBUS_API VGradientEx
81
{
82
        // friend class VGradientWidget;
83
 
84
public:
85
        enum Type
86
        {
87
            linear = 0,
88
            radial = 1,
14981 fschmid 89
            fourcolor  = 2,
15024 fschmid 90
            diamond = 3,
16729 fschmid 91
                mesh = 4,
92
                freemesh = 5
4360 cbradney 93
        };
94
 
95
        enum RepeatMethod
96
        {
97
            none    = 0,
98
            reflect = 1,
99
            repeat  = 2
100
        };
101
 
102
        VGradientEx( VGradientEx::Type type = linear );
103
        VGradientEx( const VGradientEx& gradient );
104
        VGradientEx( const VGradient& gradient, ScribusDoc& doc );
9992 jghali 105
        ~VGradientEx();
4360 cbradney 106
 
107
        VGradientEx& operator=(const VGradientEx& gradient);
108
 
109
        VGradientEx::Type type() const { return m_type; }
110
        void setType( VGradientEx::Type type ) { m_type = type; }
111
 
112
        VGradientEx::RepeatMethod repeatMethod() const { return m_repeatMethod; }
113
        void setRepeatMethod( VGradientEx::RepeatMethod repeatMethod ) { m_repeatMethod = repeatMethod; }
114
 
10009 jghali 115
        const QList<VColorStopEx*> colorStops() const;
4360 cbradney 116
        void addStop( const VColorStopEx& colorStop );
117
        void addStop( const ScColor &color, double rampPoint, double midPoint, double opa, QString name = "", int shade = 100 );
9982 fschmid 118
        void removeStop( VColorStopEx& colorStop );
4360 cbradney 119
        void removeStop( uint n );
120
        void clearStops();
121
        uint Stops() { return m_colorStops.count(); }
122
 
123
        FPoint origin() const { return m_origin; }
124
        void setOrigin( const FPoint &origin ) { m_origin = origin; }
125
 
126
        FPoint focalPoint() const { return m_focalPoint; }
127
        void setFocalPoint( const FPoint &focalPoint ) { m_focalPoint = focalPoint; }
128
 
129
        FPoint vector() const { return m_vector; }
130
        void setVector( const FPoint &vector ) { m_vector = vector; }
131
 
13951 fschmid 132
        void transform( const QTransform& m );
4360 cbradney 133
 
134
protected:
10009 jghali 135
        QList<VColorStopEx*>        m_colorStops;
4360 cbradney 136
 
10009 jghali 137
        int  compareItems( const VColorStopEx* item1, const VColorStopEx* item2 ) const;
138
        void inSort( VColorStopEx* d );
139
 
4360 cbradney 140
private:
15024 fschmid 141
        VGradientEx::Type         m_type;
4360 cbradney 142
        VGradientEx::RepeatMethod m_repeatMethod        : 2;
143
 
144
        // coordinates:
145
        FPoint m_origin;
146
        FPoint m_focalPoint;
147
        FPoint m_vector;
148
}
149
; // VGradientEx
150
 
151
#endif /* __VGRADIENT_H__ */