summaryrefslogtreecommitdiffstats
path: root/noatun/modules/kjofol-skin/kjwidget.cpp
blob: 25aa2d48a20f216add617c892176c7e2901b9fa1 (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
/***************************************************************************
	kjwidget.cpp  -  Base Class for all widgets
	--------------------------------------
	Maintainer: Stefan Gehn <[email protected]>

 ***************************************************************************/

// local includes
#include "kjwidget.h"
//#include <kdebug.h>

// ugly static functions and stuff
#include "helpers.cpp"

#include <tqpainter.h>

KJWidget::KJWidget(KJLoader *p) : mParent(p)
{
}

TQBitmap KJWidget::getMask(const TQImage &_rect, TQRgb transparent)
{
	TQImage result(_rect.width(), _rect.height(), 1,2, TQImage::LittleEndian);
	result.setColor(1, tqRgb(0,0,0));
	result.setColor(0, tqRgb(255,255,255));

	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);
	}
	TQBitmap bm;
	bm.convertFromImage(result);
	return bm;
}

void KJWidget::repaint(bool me, const TQRect &r, bool clear)
{
	TQPainter p(parent());
	if (me)
		paint(&p, r.isValid() ? r : rect());
	else
		parent()->repaint(r.isValid() ? r : rect(), clear);
}

const TQString &KJWidget::backgroundPressed(const TQString &bmp) const
{
	if(bmp.isEmpty()) // play safe
	{
//		kdDebug(66666) << k_funcinfo << "empty argument 'bmp', returning TQString()!" << endl;
		return TQString();
	}

//	kdDebug(66666) << k_funcinfo << "Returning pressed pixmap for '" << bmp.latin1() << "'" << endl;

	// make absolutely sure the wanted backgroundimagepressedX line is there
	TQStringList item = parser()["backgroundimagepressed"+TQString::number(bmp.mid(3).toInt())];
	if(item.count() < 2)
	{
//		kdDebug(66666) << k_funcinfo << "backgroundimagepressed doesn't have enough keys in its line!" << endl;
		return TQString();
	}
	else
		return item[1];
}