mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 07:24:58 +00:00
28 lines
583 B
C++
28 lines
583 B
C++
#include "GLabel.h"
|
|
#include <SharedGraphics/Painter.h>
|
|
|
|
GLabel::GLabel(GWidget* parent)
|
|
: GWidget(parent)
|
|
{
|
|
}
|
|
|
|
GLabel::~GLabel()
|
|
{
|
|
}
|
|
|
|
void GLabel::setText(String&& text)
|
|
{
|
|
if (text == m_text)
|
|
return;
|
|
m_text = move(text);
|
|
update();
|
|
}
|
|
|
|
void GLabel::paintEvent(GPaintEvent&)
|
|
{
|
|
Painter painter(*this);
|
|
if (fillWithBackgroundColor())
|
|
painter.fill_rect({ 0, 0, width(), height() }, backgroundColor());
|
|
if (!text().is_empty())
|
|
painter.draw_text({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, foregroundColor());
|
|
}
|