Foundation classes for a basic GUI implementing simple widgets and events

Dependents:   TouchScreenGUIDemo

Revision:
7:303850a4b30c
Parent:
4:27546fb8b670
Child:
8:a460cabc85ac
diff -r b1ddfe0eb88e -r 303850a4b30c Widgets/TextWidget.cpp
--- a/Widgets/TextWidget.cpp	Mon Mar 28 12:59:37 2016 +0000
+++ b/Widgets/TextWidget.cpp	Sun Apr 10 16:48:44 2016 +0000
@@ -4,8 +4,11 @@
 * A basic widget implementation which just draws some text.
 * If the text does not fit in the bounding-box it will be clipped
 **/
-
-TextWidget::TextWidget(GraphicsDisplay* display) : Widget(display), _renderer(display) {}
+TextWidget::TextWidget(GraphicsDisplay& display, FontRenderer* renderer) :
+    Widget(display),
+    _renderer(renderer)
+{
+}
 
 void TextWidget::setText(char* text)
 {
@@ -20,7 +23,10 @@
 
 void TextWidget::draw()
 {
-    _renderer.clip(_x, _y, _width, _height);
+    _renderer->window(_x, _y, _width, _height, false);
+    _renderer->setForeground(_fg);
+    _renderer->setBackground(_bg);
+    _renderer->setFont(_font);
 
     char c;
     char *p = _text;
@@ -28,8 +34,8 @@
     while(*p != NULL) {
         c = *p;
         p++;
-        _renderer.putc(c, _font, _fg, _bg);
+        _renderer->putc(c, _display);
     }
-    
-    _display->copy_to_lcd();
+
+    _display.copy_to_lcd();
 }