aboutsummaryrefslogtreecommitdiff
path: root/lib/gui/ecanvas.cpp
blob: c9a1ec828101c243cb6f86466e0f478bca6814e6 (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
#include <lib/gui/ecanvas.h>

eCanvas::eCanvas(eWidget *parent): ePixmap(parent)
{
}

void eCanvas::setSize(eSize size)
{
	setPixmap(new gPixmap(size, 32)); /* TODO: do we need 8bit surfaces? */
}

void eCanvas::clear(gRGB color)
{
	if (!m_pixmap)
		return;

	ePtr<gDC> d = new gDC(m_pixmap);
	gPainter p(d, eRect());
	p.resetClip(eRect(ePoint(0,0), m_pixmap->size()));
	p.setBackgroundColor(color);
	p.clear();

	invalidate();
}

void eCanvas::fillRect(eRect rect, gRGB color)
{
	if (!m_pixmap)
		return;

	ePtr<gDC> dc = new gDC(m_pixmap);

	gPainter p(dc);
	p.resetClip(eRect(ePoint(0,0), m_pixmap->size()));
	p.setForegroundColor(color);
	p.fill(rect);

	invalidate(rect);
}

void eCanvas::writeText(eRect rect, gRGB fg, gRGB bg, gFont *font, const char *string, int flags)
{
	ePtr<gDC> dc = new gDC(m_pixmap);

	gPainter p(dc);
	p.setFont(font);
	p.resetClip(eRect(ePoint(0,0), m_pixmap->size()));
	p.setForegroundColor(fg);
	p.setBackgroundColor(bg);
	p.renderText(rect, string, flags);

	invalidate(rect);
}