Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TouchScreenGUIDemo
Diff: Widgets/TextWidget.cpp
- Revision:
- 8:a460cabc85ac
- Parent:
- 7:303850a4b30c
- Child:
- 9:616a9686d5db
--- a/Widgets/TextWidget.cpp Sun Apr 10 16:48:44 2016 +0000 +++ b/Widgets/TextWidget.cpp Mon Apr 11 16:54:02 2016 +0000 @@ -4,9 +4,24 @@ * 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, FontRenderer* renderer) : - Widget(display), - _renderer(renderer) +TextWidget::TextWidget(GUI* gui) : + Widget(gui), + _renderer(gui->fontRenderer()), + _font(gui->defaultFont()) +{ +} + +TextWidget::TextWidget(GUI* gui, FontRenderer* renderer) : + Widget(gui), + _renderer(renderer), + _font(gui->defaultFont()) +{ +} + +TextWidget::TextWidget(GUI* gui, FontRenderer* renderer, Font* font) : + Widget(gui), + _renderer(renderer), + _font(font) { } @@ -21,21 +36,24 @@ } -void TextWidget::draw() +void TextWidget::_draw() { _renderer->window(_x, _y, _width, _height, false); _renderer->setForeground(_fg); _renderer->setBackground(_bg); - _renderer->setFont(_font); - + char c; char *p = _text; while(*p != NULL) { c = *p; p++; - _renderer->putc(c, _display); + _renderer->putc(c, _gui->display(), _font); } - _display.copy_to_lcd(); + _gui->display()->copy_to_lcd(); } + +void TextWidget::_clear() { + _gui->display()->fillrect(_x, _y, _x+_width, _y+_height, _bg); +} \ No newline at end of file