ladybird/Widgets/Label.cpp

36 lines
699 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();
}
void Label::paintEvent(PaintEvent&)
2018-10-10 16:49:36 +02:00
{
Painter painter(*this);
painter.fillRect({ 0, 0, width(), height() }, backgroundColor());
2018-10-11 00:10:36 +02:00
if (!text().isEmpty())
painter.drawText({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, foregroundColor());
2018-10-10 16:49:36 +02:00
}
void Label::mouseMoveEvent(MouseEvent& event)
2018-10-10 16:49:36 +02:00
{
printf("Label::mouseMoveEvent: x=%d, y=%d\n", event.x(), event.y());
Widget::mouseMoveEvent(event);
2018-10-10 16:49:36 +02:00
}