Code

Cleaned up virtual destructor problem and compile warnings.
[inkscape.git] / src / extension / internal / libwpg / WPGGradient.cpp
1 /* libwpg
2  * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the 
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
17  * Boston, MA  02111-1301 USA
18  *
19  * For further information visit http://libwpg.sourceforge.net
20  */
22 /* "This product is not manufactured, approved, or supported by
23  * Corel Corporation or Corel Corporation Limited."
24  */
26 #include "WPGGradient.h"
27 #include "WPGColor.h"
29 #include <vector>
31 namespace libwpg
32 {
34 class WPGGradientStop
35 {
36 public:
37         double offset;
38         WPGColor color;
39         
40         WPGGradientStop(): offset(0) {}
41         
42         WPGGradientStop(double ofs, const WPGColor& c): offset(ofs), color(c) {}
43 };
45 class WPGGradientPrivate
46 {
47 public:
48     double angle;
49         std::vector<WPGGradientStop> gradientStops;
50 };
52 } // namespace libwpg
54 using namespace libwpg;
56 WPGGradient::WPGGradient()
57 {
58         d = new WPGGradientPrivate;
59         d->angle = 0.0;
60 }
62 WPGGradient::~WPGGradient()
63 {
64         delete d;
65 }
67 WPGGradient::WPGGradient(const WPGGradient& g)
68 {
69         d = new WPGGradientPrivate;
70         d->angle = g.d->angle;
71         d->gradientStops = g.d->gradientStops;
72 }
73         
74 WPGGradient& WPGGradient::operator=(const WPGGradient& g)
75 {
76         d->angle = g.d->angle;
77         d->gradientStops = g.d->gradientStops;
78         return *this;
79 }
81 double WPGGradient::angle() const
82 {
83         return d->angle;
84 }
86 void WPGGradient::setAngle(double a)
87 {
88         d->angle = a;
89 }
90         
91 unsigned WPGGradient::count() const
92 {
93         return d->gradientStops.size();
94 }
96 double WPGGradient::stopOffset(unsigned index) const
97 {
98         return d->gradientStops[index].offset;
99 }
101 WPGColor WPGGradient::stopColor(unsigned index) const
103         return d->gradientStops[index].color;
106 void WPGGradient::clear()
108         d->gradientStops.clear();
111 void WPGGradient::addStop(double offset, const WPGColor& color)
113         WPGGradientStop stop(offset, color);
114         d->gradientStops.push_back(stop);