Foundation classes for a basic GUI implementing simple widgets and events
Dependents: TouchScreenGUIDemo
Widgets/TextWidget.cpp
- Committer:
- duncanFrance
- Date:
- 2016-05-08
- Revision:
- 12:63db16fea709
- Parent:
- 11:b485561aa112
- Child:
- 13:6714534e7974
File content as of revision 12:63db16fea709:
#include "TextWidget.h" /** * 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(GraphicsContext *context) : Widget(context), _renderer(context->fontRenderer()), _font(context->defaultFont()) { } TextWidget::TextWidget(GraphicsContext *context, FontRenderer* renderer) : Widget(context), _renderer(renderer), _font(context->defaultFont()) { } TextWidget::TextWidget(GraphicsContext *context, FontRenderer* renderer, Font* font) : Widget(context), _renderer(renderer), _font(font) { } void TextWidget::setText(char* text) { _text = text; dirty(); } void TextWidget::setFont(Font* font) { _font = font; dirty(); } void TextWidget::_draw() { Widget::_draw(); _renderer->window(_inner.x, _inner.y, _inner.width, _inner.height, false); _renderer->setForeground(_fg); _renderer->setBackground(_bg); display()->fillrect(_inner.x, _inner.y, _inner.x+_inner.width, _inner.y+_inner.height, _bg); _renderer->puts(_text, display(), _font); display()->copy_to_lcd(); }