aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2008-01-24 21:56:23 +0000
committerFelix Domke <tmbinc@elitedvb.net>2008-01-24 21:56:23 +0000
commitd09bd946be9c73d96fb8e1697b15e733d04ddeb6 (patch)
tree0abc2c26f7ee2053934f507abcad2cca79cfa5e5
parenta3a94a50132256f3a6524efd6dba0e52e4774087 (diff)
downloadenigma2-d09bd946be9c73d96fb8e1697b15e733d04ddeb6.tar.gz
enigma2-d09bd946be9c73d96fb8e1697b15e733d04ddeb6.zip
write text support in eCanvas
-rw-r--r--lib/gui/ecanvas.cpp14
-rw-r--r--lib/gui/ecanvas.h1
-rw-r--r--lib/python/Components/Renderer/Canvas.py8
-rw-r--r--lib/python/Components/Sources/CanvasSource.py9
4 files changed, 29 insertions, 3 deletions
diff --git a/lib/gui/ecanvas.cpp b/lib/gui/ecanvas.cpp
index 3b1e6177..c9a1ec82 100644
--- a/lib/gui/ecanvas.cpp
+++ b/lib/gui/ecanvas.cpp
@@ -37,3 +37,17 @@ void eCanvas::fillRect(eRect rect, gRGB color)
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);
+}
diff --git a/lib/gui/ecanvas.h b/lib/gui/ecanvas.h
index 629c603f..b2ad6a06 100644
--- a/lib/gui/ecanvas.h
+++ b/lib/gui/ecanvas.h
@@ -12,6 +12,7 @@ public:
void clear(gRGB color);
void fillRect(eRect rect, gRGB color);
+ void writeText(eRect where, gRGB fg, gRGB bg, gFont *font, const char *string, int flags);
};
#endif
diff --git a/lib/python/Components/Renderer/Canvas.py b/lib/python/Components/Renderer/Canvas.py
index 53757235..bd7ffb5e 100644
--- a/lib/python/Components/Renderer/Canvas.py
+++ b/lib/python/Components/Renderer/Canvas.py
@@ -29,7 +29,13 @@ class Canvas(Renderer):
def draw(self, list):
for l in list:
- self.instance.fillRect(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]))
+ if l[0] == 1:
+ self.instance.fillRect(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]))
+ elif l[0] == 2:
+ self.instance.writeText(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]), gRGB(l[6]), l[7], l[8], l[9])
+ else:
+ print "drawlist entry:", l
+ raise "invalid drawlist entry"
def changed(self, what):
self.pull_updates()
diff --git a/lib/python/Components/Sources/CanvasSource.py b/lib/python/Components/Sources/CanvasSource.py
index 4fd0e02a..2f3aaecc 100644
--- a/lib/python/Components/Sources/CanvasSource.py
+++ b/lib/python/Components/Sources/CanvasSource.py
@@ -16,5 +16,10 @@ class CanvasSource(Source):
drawlist = property(get_drawlist)
def fill(self, x, y, width, height, color):
- self.drawlist[1].append( (1, x, y, width, height, color) )
- self.changed()
+ self.drawlist[1].append((1, x, y, width, height, color))
+
+ def writeText(self, x, y, width, height, fg, bg, font, text, flags = 0):
+ self.drawlist[1].append((2, x, y, width, height, fg, bg, font, text, flags))
+
+ def flush(self):
+ self.changed((self.CHANGED_DEFAULT,))