~aleteoryx/muditaos

muditaos/module-apps/application-messages/widgets/SMSTemplateItem.cpp -rw-r--r-- 1.0 KiB
a405cad6Aleteoryx trim readme 6 days 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
// 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 "SMSTemplateItem.hpp"

#include <time/time_conversion.hpp>
#include <Style.hpp>

namespace gui
{
    SMSTemplateItem::SMSTemplateItem()
    {
        setMargins(Margins(0, style::margins::big, 0, 0));
        setMinimumSize(style::smsTemplItem::w, style::smsTemplItem::h);
        setMaximumSize(style::smsTemplItem::w, style::smsTemplItem::h);

        text = new gui::Label(this, 0, 0, 0, 0);
        style::window::decorateOption(text);
        text->setTextEllipsisType(gui::TextEllipsis::Right);

        dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
            text->setArea({0, 0, newDim.w, newDim.h});
            return true;
        };
    }

    void SMSTemplateItem::setTemplate(std::shared_ptr<SMSTemplateRecord> templ)
    {
        this->templ = templ;
        text->setText(templ->text);
    }

} /* namespace gui */