~aleteoryx/muditaos

ref: b95894a8abc10cddf0b58dda4b2569b01eec0d7e muditaos/module-gui/gui/widgets/text/Label.cpp -rw-r--r-- 940 bytes
b95894a8 — Lefucjusz [MOS-1064] Fix no input language selected for French/Spanish 1 year, 9 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-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/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 */