mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 14:53:52 +00:00
43 lines
968 B
C++
43 lines
968 B
C++
#include "PLLabelWidget.h"
|
|
#include "PLQDraw.h"
|
|
#include "FontFamily.h"
|
|
#include "PLStandardColors.h"
|
|
|
|
#include <algorithm>
|
|
|
|
namespace PortabilityLayer
|
|
{
|
|
LabelWidget::LabelWidget(const WidgetBasicState &state)
|
|
: WidgetSpec<LabelWidget>(state)
|
|
, m_text(state.m_text)
|
|
{
|
|
}
|
|
|
|
bool LabelWidget::Init(const WidgetBasicState &state)
|
|
{
|
|
(void)state;
|
|
return true;
|
|
}
|
|
|
|
void LabelWidget::SetString(const PLPasStr &str)
|
|
{
|
|
m_text.Set(str.Length(), str.Chars());
|
|
}
|
|
|
|
PLPasStr LabelWidget::GetString() const
|
|
{
|
|
return m_text.ToShortStr();
|
|
}
|
|
|
|
void LabelWidget::DrawControl(DrawSurface *surface)
|
|
{
|
|
surface->SetSystemFont(12, PortabilityLayer::FontFamilyFlag_Bold);
|
|
surface->SetForeColor(StdColors::Black());
|
|
|
|
const Point topLeftCorner = Point::Create(m_rect.left, m_rect.top);
|
|
const Point textStartPoint = topLeftCorner + Point::Create(0, surface->MeasureFontAscender());
|
|
|
|
surface->DrawStringWrap(textStartPoint, m_rect, m_text.ToShortStr(), true);
|
|
}
|
|
}
|