~aleteoryx/muditaos

ref: eda92600a7df852e18bdb44388966248a4af3c77 muditaos/module-gui/gui/widgets/text/Label.cpp -rw-r--r-- 952 bytes
eda92600 — Maciej Gibowicz [BH-2095] Add quote interval setting 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#include "Label.hpp"

namespace gui
{
    Label::Label(Item *parent, Position x, Position y, Length w, Length h, const UTF8 &inputText)
        : TextFixedSize(parent, x, y, w, h)
    {
        setEditMode(EditMode::Print);
        setCursorStartPosition(CursorStartPosition::DocumentBegin);
        setTextType(TextType::SingleLine);
        drawUnderline(false);
        setPenFocusWidth(style::window::default_border_rect_no_focus);
        setPenWidth(style::window::default_border_rect_no_focus);

        setText(inputText);
    }

    uint32_t Label::getTextNeedSpace(const UTF8 &inputText) const noexcept
    {
        return inputText.empty() ? format.getFont()->getPixelWidth(getText())
                                 : format.getFont()->getPixelWidth(inputText);
    }
} /* namespace gui */