summaryrefslogtreecommitdiffstats
path: root/noatun/modules/kjofol-skin/kjwidget.cpp
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
commite2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch)
tree9047cf9e6b5c43878d5bf82660adae77ceee097a /noatun/modules/kjofol-skin/kjwidget.cpp
downloadtdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz
tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.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/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'noatun/modules/kjofol-skin/kjwidget.cpp')
-rw-r--r--noatun/modules/kjofol-skin/kjwidget.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/noatun/modules/kjofol-skin/kjwidget.cpp b/noatun/modules/kjofol-skin/kjwidget.cpp
new file mode 100644
index 00000000..e7b6a4d1
--- /dev/null
+++ b/noatun/modules/kjofol-skin/kjwidget.cpp
@@ -0,0 +1,70 @@
+/***************************************************************************
+ kjwidget.cpp - Base Class for all widgets
+ --------------------------------------
+ Maintainer: Stefan Gehn <sgehn@gmx.net>
+
+ ***************************************************************************/
+
+// local includes
+#include "kjwidget.h"
+//#include <kdebug.h>
+
+// ugly static functions and stuff
+#include "helpers.cpp"
+
+#include <qpainter.h>
+
+KJWidget::KJWidget(KJLoader *p) : mParent(p)
+{
+}
+
+QBitmap KJWidget::getMask(const QImage &_rect, register QRgb transparent)
+{
+ QImage result(_rect.width(), _rect.height(), 1,2, QImage::LittleEndian);
+#if QT_VERSION < 0x030300
+ result.setColor(0, qRgb(0,0,0)); //TODO: maybe use Qt::color0 and Qt::color1
+ result.setColor(1, qRgb(255,255,255));
+#else
+ result.setColor(1, qRgb(0,0,0));
+ result.setColor(0, qRgb(255,255,255));
+#endif
+
+ for(int height=0;height<_rect.height(); height++)
+ {
+ for(int width=0; width<_rect.width(); width++)
+ setPixel1BPP(result, width, height, _rect.pixel(width, height)!=transparent);
+ }
+ QBitmap bm;
+ bm.convertFromImage(result);
+ return bm;
+}
+
+void KJWidget::repaint(bool me, const QRect &r, bool clear)
+{
+ QPainter p(parent());
+ if (me)
+ paint(&p, r.isValid() ? r : rect());
+ else
+ parent()->repaint(r.isValid() ? r : rect(), clear);
+}
+
+const QString &KJWidget::backgroundPressed(const QString &bmp) const
+{
+ if(bmp.isEmpty()) // play safe
+ {
+// kdDebug(66666) << k_funcinfo << "empty argument 'bmp', returning QString::null!" << endl;
+ return QString::null;
+ }
+
+// kdDebug(66666) << k_funcinfo << "Returning pressed pixmap for '" << bmp.latin1() << "'" << endl;
+
+ // make absolutely sure the wanted backgroundimagepressedX line is there
+ QStringList item = parser()["backgroundimagepressed"+QString::number(bmp.mid(3).toInt())];
+ if(item.count() < 2)
+ {
+// kdDebug(66666) << k_funcinfo << "backgroundimagepressed doesn't have enough keys in its line!" << endl;
+ return QString::null;
+ }
+ else
+ return item[1];
+}