Foundation classes for a basic GUI implementing simple widgets and events

Dependents:   TouchScreenGUIDemo

Revision:
3:cb004f59b715
Parent:
2:bb9183379488
Child:
4:27546fb8b670
--- a/Widgets/TextWidget.cpp	Fri Mar 25 18:58:50 2016 +0000
+++ b/Widgets/TextWidget.cpp	Sun Mar 27 14:41:31 2016 +0000
@@ -5,7 +5,7 @@
 * If the text does not fit in the bounding-box it will be clipped
 **/
 
-TextWidget::TextWidget(GraphicsDisplay* display) : Widget(display) {}
+TextWidget::TextWidget(GraphicsDisplay* display) : Widget(display), _renderer(display) {}
 
 void TextWidget::setText(char* text)
 {
@@ -17,6 +17,24 @@
     _font = font;
 }
 
+
+void TextWidget::draw()
+{
+    _renderer.clip(_x, _y, _width, _height);
+
+    char c;
+    char *p = _text;
+
+    while(*p != NULL) {
+        c = *p;
+        p++;
+        _renderer.putc(c, _font, _fg, _bg);
+    }
+    
+    _display->copy_to_lcd();
+}
+
+/**
 void TextWidget::draw()
 {
 
@@ -50,7 +68,7 @@
         }
     }
 }
-
+**/
 bool TextWidget::isEventTarget(Event e)
 {
     return e.screenX < (_x+_width) && _x <= e.screenX && e.screenY < (_y+_height) && _y <= e.screenY;