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.
Fork of SimpleGUI by
Widgets/TextWidget.cpp
- Committer:
- duncanFrance
- Date:
- 2016-04-10
- Revision:
- 7:303850a4b30c
- Parent:
- 4:27546fb8b670
- Child:
- 8:a460cabc85ac
File content as of revision 7:303850a4b30c:
#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(GraphicsDisplay& display, FontRenderer* renderer) :
Widget(display),
_renderer(renderer)
{
}
void TextWidget::setText(char* text)
{
_text = text;
}
void TextWidget::setFont(Font* font)
{
_font = font;
}
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);
}
_display.copy_to_lcd();
}
