summaryrefslogtreecommitdiffstats
path: root/kicker/libkicker/kshadowengine.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kicker/libkicker/kshadowengine.h
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kicker/libkicker/kshadowengine.h')
-rw-r--r--kicker/libkicker/kshadowengine.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/kicker/libkicker/kshadowengine.h b/kicker/libkicker/kshadowengine.h
new file mode 100644
index 000000000..0fc4877fa
--- /dev/null
+++ b/kicker/libkicker/kshadowengine.h
@@ -0,0 +1,123 @@
+/* This file is proposed to be part of the KDE libraries.
+ * Copyright (C) 2003 Laur Ivan <laurivan@eircom.net>
+ *
+ * Many thanks to:
+ * - Bernardo Hung <deciare@gta.igs.net> for the enhanced shadow
+ * algorithm (currently used)
+ * - 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.
+ */
+
+#ifndef __FX_SHADOW
+#define __FX_SHADOW
+
+#include <qpixmap.h>
+#include <qimage.h>
+#include <qcolor.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 laur.ivan@corvil.com
+ * @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
+ */
+ QImage makeShadow(const QPixmap& textPixmap, const QColor &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(QImage& source, int x, int y);
+
+ /*
+ * a slower algorithm where the influence of a pixel
+ * is qGray(px)/(abs(dx) + abs(dy) +1).
+ */
+ double doubleLinearDecay(QImage& source, int x, int y);
+
+ /*
+ * a very slow algorithm where the influence of a pixel
+ * is qGray(px)/(sqrt(sqr(dx) + sqr(dy)) +1).
+ */
+ double radialDecay(QImage& source, int x, int y);
+
+ /*
+ * a nice/fast algorithm proposed by Bernardo Hung
+ */
+ double noDecay(QImage& source, int x, int y);
+
+ void *d;
+};
+
+class KDE_EXPORT KTextShadowEngine : public KShadowEngine
+{
+public:
+ KTextShadowEngine();
+
+ void drawText(QPainter &p, const QRect &tr, int tf, const QString &str, const QSize &size);
+};
+
+#endif