mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-24 13:58:00 -05:00
51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
|
|
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include <module-gui/gui/core/RawFont.hpp>
|
|
#include "TextFixedSize.hpp"
|
|
|
|
namespace gui
|
|
{
|
|
TextFixedSize::TextFixedSize(Item *parent, Position x, Position y, Length w, Length h) : Text(parent, x, y, w, h)
|
|
{
|
|
setEditMode(EditMode::Edit);
|
|
lines->setUnderLine(true);
|
|
}
|
|
|
|
void TextFixedSize::setLines(const unsigned int val)
|
|
{
|
|
if (linesCount != val) {
|
|
linesCount = val;
|
|
drawLines();
|
|
}
|
|
}
|
|
|
|
void TextFixedSize::setUnderlinePadding(Position val)
|
|
{
|
|
if (lines->getUnderLinePadding() != val) {
|
|
lines->setUnderLinePadding(val);
|
|
drawLines();
|
|
}
|
|
}
|
|
|
|
void TextFixedSize::drawLines()
|
|
{
|
|
lines->erase();
|
|
|
|
const auto [startDrawBlockNumber, startDrawBlockPosition] = lines->drawStartConditions;
|
|
BlockCursor drawCursor(
|
|
cursor->getDocument(), startDrawBlockPosition, startDrawBlockNumber, getTextFormat().getFont());
|
|
|
|
lines->draw(drawCursor,
|
|
getSizeMinusPadding(Axis::X, Area::Normal) - TextCursor::defaultWidth,
|
|
getSizeMinusPadding(Axis::Y, Area::Normal),
|
|
padding.top,
|
|
padding.left,
|
|
linesCount);
|
|
|
|
lines->linesHAlign(getSizeMinusPadding(Axis::X, Area::Normal));
|
|
lines->linesVAlign(getSizeMinusPadding(Axis::Y, Area::Normal));
|
|
}
|
|
} // namespace gui
|