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
|
/* This file is proposed to be part of the KDE libraries.
* Copyright (C) 2003 Laur Ivan <[email protected]>
*
* Many thanks to:
* - Bernardo Hung <[email protected]> for the enhanced shadow
* algorithm (currently used)
* - Tim Jansen <[email protected]> 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.
*/
#ifndef __FX_SHADOW
#define __FX_SHADOW
#include <tqpixmap.h>
#include <tqimage.h>
#include <tqcolor.h>
#include <kdemacros.h>
class KShadowSettings;
/**
* This class implements the shadow algorithm(s). It uses a FxData
* object for its parameters. Note that the shadow algorithm is using the
* luminosity of the original pixmap for the shadow one.
* @see KShadowSettings
* @author [email protected]
* @since 3.2
*/
class KDE_EXPORT KShadowEngine
{
public:
/// Creates a new shadow engine.
KShadowEngine();
~KShadowEngine();
/**
* Creates a new shadow engine.
* @param fx the shadow settings object with the configuration. The Shadow
* Engine will own this object and also delete it. Must
* be heap-allocated
*/
KShadowEngine(KShadowSettings *fx);
/**
* Set the KShadowSettings object.
* @param fx the shadow settings object with the configuration. The Shadow
* Engine will own this object and also delete it. Must
* be heap-allocated.
*/
void setShadowSettings(KShadowSettings *fx);
/**
* Get the current KShadowSettings.
* @param the current shadow settings
*/
KShadowSettings *shadowSettings();
/**
* Make shadow!
*
* textPixmap is the original pixmap where a (white) text is drawn.
* bgColor is the color used for the shadow.
* @param textPixmap the pixmap of the text
* @param bgColor the background color
* @return the resulting image
*/
TQImage makeShadow(const TQPixmap& textPixmap, const TQColor &bgColor);
private:
// No static objects in libs, and no static deleters in kdefx...
//static KShadowSettings s_defaultShadowSettings;
KShadowSettings *m_shadowSettings;
/*
* a simple algorithm with 3 pixels thickness
*/
double defaultDecay(TQImage& source, int x, int y);
/*
* a slower algorithm where the influence of a pixel
* is tqGray(px)/(abs(dx) + abs(dy) +1).
*/
double doubleLinearDecay(TQImage& source, int x, int y);
/*
* a very slow algorithm where the influence of a pixel
* is tqGray(px)/(sqrt(sqr(dx) + sqr(dy)) +1).
*/
double radialDecay(TQImage& source, int x, int y);
/*
* a nice/fast algorithm proposed by Bernardo Hung
*/
double noDecay(TQImage& source, int x, int y);
void *d;
};
class KDE_EXPORT KTextShadowEngine : public KShadowEngine
{
public:
KTextShadowEngine();
void drawText(TQPainter &p, const TQRect &tr, int tf, const TQString &str, const TQSize &size);
};
#endif
|