~aleteoryx/muditaos

ref: 0ef0d615f34e275f088890a1244dd480dd467920 muditaos/module-gui/gui/widgets/Icon.cpp -rw-r--r-- 1.6 KiB
0ef0d615 — Krzysztof Mozdzynski [EGD-4150] Change filename i18 to i18n (#1108) 5 years 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Icon.hpp"
#include "TextParse.hpp"
#include <module-utils/i18n/i18n.hpp>
#include <Style.hpp>
#include <Font.hpp>

using namespace gui;

namespace style
{
    namespace img
    {
        constexpr uint32_t x = 176;
        constexpr uint32_t y = 90;
    } // namespace img
    namespace text
    {
        constexpr uint32_t x  = 40;
        constexpr uint32_t y  = 247;
        constexpr uint32_t w  = 400;
        constexpr uint32_t h  = 66;
        constexpr Color color = {7, 0};
    } // namespace text
} // namespace style

Icon::Icon(Item *parent,
           const uint32_t &x,
           const uint32_t &y,
           const uint32_t &w,
           const uint32_t &h,
           const UTF8 imageName,
           const UTF8 &str)
    : Rect(parent, x, y, w, h)
{
    setEdges(RectangleEdge::None);
    setPenFocusWidth(style::window::default_border_no_focus_w);
    setPenWidth(style::window::default_border_no_focus_w);

    new Image(this, style::img::x, style::img::y, imageName);
    text = new Text(this, style::text::x, style::text::y, style::text::w, style::text::h);
    text->setTextType(TextType::MULTI_LINE);
    text->setEditMode(EditMode::BROWSE);
    text->setEdges(RectangleEdge::None);
    text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));

    auto format = TextFormat(Font(27).raw(), Color(7, 0));
    for (auto &el : textToTextBlocks(str, format)) {
        text->addText(el);
    }
}