2022-01-05 16:10:18 +00:00
|
|
|
#include "string_element.h"
|
2021-07-04 16:01:16 +00:00
|
|
|
#include <gui/elements.h>
|
2021-06-28 14:42:30 +00:00
|
|
|
|
|
|
|
StringElement::StringElement() {
|
|
|
|
}
|
|
|
|
|
|
|
|
StringElement::~StringElement() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void StringElement::draw(Canvas* canvas) {
|
|
|
|
if(text) {
|
2022-01-29 09:39:10 +00:00
|
|
|
string_t line;
|
|
|
|
string_init(line);
|
|
|
|
string_set_str(line, text);
|
|
|
|
|
2021-06-28 14:42:30 +00:00
|
|
|
canvas_set_font(canvas, font);
|
2022-01-29 09:39:10 +00:00
|
|
|
if(fit_width != 0) {
|
|
|
|
elements_string_fit_width(canvas, line, fit_width);
|
|
|
|
}
|
|
|
|
elements_multiline_text_aligned(canvas, x, y, horizontal, vertical, string_get_cstr(line));
|
|
|
|
|
|
|
|
string_clear(line);
|
2021-06-28 14:42:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-06 13:37:10 +00:00
|
|
|
bool StringElement::input(InputEvent* /* event */) {
|
2021-06-28 14:42:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StringElement::set_text(
|
|
|
|
const char* _text,
|
|
|
|
uint8_t _x,
|
|
|
|
uint8_t _y,
|
2022-01-29 09:39:10 +00:00
|
|
|
uint8_t _fit_w,
|
2021-06-28 14:42:30 +00:00
|
|
|
Align _horizontal,
|
|
|
|
Align _vertical,
|
|
|
|
Font _font) {
|
|
|
|
lock_model();
|
|
|
|
text = _text;
|
|
|
|
x = _x;
|
|
|
|
y = _y;
|
2022-01-29 09:39:10 +00:00
|
|
|
fit_width = _fit_w;
|
2021-06-28 14:42:30 +00:00
|
|
|
horizontal = _horizontal;
|
|
|
|
vertical = _vertical;
|
|
|
|
font = _font;
|
|
|
|
unlock_model(true);
|
2022-05-06 13:37:10 +00:00
|
|
|
}
|