summaryrefslogtreecommitdiffstats
path: root/kicker/libkicker/kshadowsettings.cpp
blob: 9c935d30f47efe72f733a28c0a0170d2d996bc69 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* This file is proposed to be part of the KDE libraries.
 * Copyright (C) 2003 Laur Ivan <laurivan@eircom.net>
 *
 * Many thanks to:
 *  - Tim Jansen <tim@tjansen.de> for the API updates and fixes.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License version 2 as published by the Free Software Foundation.
 *
 * 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.
 */

#include <qstring.h>
#include <qstringlist.h>
#include "kshadowsettings.h"

KShadowSettings::KShadowSettings()
{
	// init the components with some default values
	setDefaults();
}

// load/save methods
void KShadowSettings::fromString(const QString &val)
{
  setOffsetX(val.section(',', OFFSET_X, OFFSET_X).toInt());
  setOffsetY(val.section(',', OFFSET_Y, OFFSET_Y).toInt());
  setMultiplicationFactor(val.section(',', MULTIPLICATION_FACTOR, MULTIPLICATION_FACTOR).toDouble());
  setMaxOpacity(val.section(',', MAX_OPACITY, MAX_OPACITY).toDouble());
  setThickness(val.section(',', THICKNESS, THICKNESS).toInt());
  setAlgorithm((Algorithm) val.section(',', ALGORITHM, ALGORITHM).toInt());
  setSelectionType((SelectionType)val.section(',', SELECTION_TYPE, SELECTION_TYPE).toInt());
}

QString KShadowSettings::toString() const
{
  QString result;
  result.sprintf("%d,%d,%f,%f,%d,%d,%d",
		 offsetX(),
		 offsetY(),
		 multiplicationFactor(),
		 maxOpacity(),
		 thickness(),
		 (int)algorithm(),
		 (int)selectionType());
  return result;
}

//***********************************
//               get methods
//***********************************

/**
 * Returns the decay algorithm to be used (see the alg. enumeration in the .h)
 */
KShadowSettings::Algorithm KShadowSettings::algorithm() const
{
	return _algorithm;
}

/**
 * Returns a multiplication facor used to average the resulted data
 */
double KShadowSettings::multiplicationFactor() const
{
	return _multiplicationFactor;
}

/**
 * Returns the max opacity allowed (0 = transparent, 255 = opaque)
 */
double KShadowSettings::maxOpacity() const
{
	return _maxOpacity;
}

/**
 * Returns the Y offset (0 is centered on text)
 */
int KShadowSettings::offsetX() const
{
	return _offsetX;
}

/**
 * Returns the Y offset (0 is centered on text)
 */
int KShadowSettings::offsetY() const
{
	return _offsetY;
}

/**
 * Returns the thickness. Used by the KShadow algorithm
 */
int KShadowSettings::thickness() const
{
	return _thickness;
}

/**
 * Returns the selection type
 */
KShadowSettings::SelectionType KShadowSettings::selectionType() const
{
	return _selectionType;
}

// set methods
/**
 * set the default parameters
 */
void KShadowSettings::setDefaults()
{
	fromString(DEFAULT_SHADOW_CONFIGURATION);
}


/**
 * Set the algorithm
 */
void KShadowSettings::setAlgorithm(Algorithm val)
{
	_algorithm = val;
}

/**
 * Set the multiplication factor
 */
void KShadowSettings::setMultiplicationFactor(double val)
{
	_multiplicationFactor = val;
}

/**
 * Set the max. opacity
 */
void KShadowSettings::setMaxOpacity(double val)
{
	_maxOpacity = val;
}

/**
 * Set the X offset of the shadow
 */
void KShadowSettings::setOffsetX(int val)
{
	_offsetX = val;
}

/**
 * Set the Y offset of the shadow
 */
void KShadowSettings::setOffsetY(int val)
{
	_offsetY = val;
}

/**
 * Set the shadow thickness
 */
void KShadowSettings::setThickness(int val)
{
	_thickness = val;
}

/**
 * Set the selection type
 */
void KShadowSettings::setSelectionType(SelectionType val)
{
	_selectionType = val;
}