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-11
- Revision:
- 10:e9d13e3a9d4f
- Parent:
- 9:616a9686d5db
- Child:
- 11:b485561aa112
File content as of revision 10:e9d13e3a9d4f:
#include "TextWidget.h"
#include "string.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(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)
{
}
void TextWidget::setText(char* text)
{
_text = text; //strncpy(_text, text, strlen(text));
}
void TextWidget::setFont(Font* font)
{
_font = font;
}
void TextWidget::_draw()
{
_renderer->window(_x, _y, _width, _height, false);
_renderer->setForeground(_fg);
_renderer->setBackground(_bg);
_gui->display()->fillrect(_x, _y, _x+_width, _y+_height, _bg);
_renderer->puts(_text, _gui->display(), _font);
_gui->display()->copy_to_lcd();
}
void TextWidget::_clear() {
_gui->display()->fillrect(_x, _y, _x+_width, _y+_height, _bg);
}
