ladybird/Widgets/Label.cpp

36 lines
696 B
C++
Raw Normal View History

2018-10-10 16:49:36 +02:00
#include "Label.h"
#include "Painter.h"
#include <cstdio>
Label::Label(Widget* parent)
: Widget(parent)
{
}
Label::~Label()
{
}
void Label::setText(String&& text)
{
if (text == m_text)
return;
m_text = std::move(text);
update();
}
2018-10-10 16:49:36 +02:00
void Label::onPaint(PaintEvent&)
{
Painter painter(*this);
2018-10-11 00:10:36 +02:00
painter.fillRect({ 0, 0, width(), height() }, Color(0x0, 0x0, 0x0));
if (!text().isEmpty())
2018-10-11 01:48:09 +02:00
painter.drawText({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, Color(0xff, 0xff, 0xff));
2018-10-10 16:49:36 +02:00
}
void Label::onMouseMove(MouseEvent& event)
{
printf("Label::onMouseMove: x=%d, y=%d\n", event.x(), event.y());
Widget::onMouseMove(event);
}