summaryrefslogtreecommitdiffstats
path: root/lib/kopainter/kogradientmanager.h
blob: b898ce89ae141aca05778697dfda2dd88fc8e6d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* This file is part of the KDE project
   Copyright (C) 2005 Tim Beaulen <tbscope@gmail.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef __GRADIENT_LOADER__
#define __GRADIENT_LOADER__

#include <tqptrlist.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqfile.h>
#include <tqdom.h>
#include <tqcolor.h>
#include <koffice_export.h>
struct KoColorStop
{
	double offset;
	double midpoint;
	double opacity;
	double color1;
	double color2;
	double color3;
	double color4;
	int colorType;
	int interpolation;
};

struct KoGradient
{
	double originX;
	double originY;
	double vectorX;
	double vectorY;
	double focalpointX;
	double focalpointY;
	int gradientType;
	int gradientRepeatMethod;

	TQPtrList<KoColorStop> colorStops;
};	

class KOPAINTER_EXPORT KoGradientManager
{
public:

	enum KoGradientType
	{
		gradient_type_linear = 0,
		gradient_type_radial = 1,
		gradient_type_conic = 2
	};
	
	enum KoGradientInterpolation
	{
		interpolation_linear = 0,
		interpolation_curved = 1,
		interpolation_sine = 2,
		interpolation_sphere_increasing = 3,
		interpolation_sphere_decreasing = 4
	};
	
	enum KoGradientColorType
	{
		color_type_rgb = 0,
		color_type_hsv_ccw = 1,
		color_type_hsv_cw = 2,
		color_type_gray = 3,
		color_type_cmyk = 4
	};
	
	enum KoGradientRepeatMethod
	{
		repeat_method_none = 0,
		repeat_method_reflect = 1,
		repeat_method_repeat = 2
	};

	KoGradientManager();
	~KoGradientManager();

	KoGradient* loadGradient(const TQString& filename);
	static TQStringList filters() 
	{
		TQStringList filterList;
		filterList << "*.kgr" << "*.svg" << "*.ggr"; 
		return filterList; 
	}

private:
	KoGradient* loadKarbonGradient(TQFile* file);
	KoGradient* loadChalkGradient(TQFile* file);
	KoGradient* loadSvgGradient(TQFile* file);
	KoGradient* parseKarbonGradient(const TQDomElement& element);
	KoGradient* parseSvgGradient(const TQDomElement& element);
	void parseSvgColor(TQColor &color, const TQString &s);
};

#endif