Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
CLabel.hpp
Go to the documentation of this file.
1#ifndef LIBS_GUI_CLABEL_HPP_
2#define LIBS_GUI_CLABEL_HPP_
3
5#include "core/concepts.hpp"
6#include "third_party/magic_enum/magic_enum.hpp"
8#include "ui/gui/enums.hpp"
10#include "utils/stringUtils.hpp"
11
12#include <string>
13
14class CResourceImage;
15
17{
18public:
19 static CLabel *createLabel(std::string_view text, CEnumCommon::eType type = CEnumCommon::eType::Value,
21 static CLabel *createLabel(std::string_view nameResource, const uint64_t &width, const uint64_t &height);
22 static CLabel *createLabelBool(const bool &isOk);
23 static CLabel *createLabel(std::string_view text, std::string_view nameResource, const uint64_t &width,
24 const uint64_t &height, double spacing = 5,
26
27 template<iv::concepts::EnumType T>
28 static CLabel *createLabelEnum(T enumValue)
29 {
30 return createLabel(magic_enum::enum_name(enumValue));
31 }
32
33 template<iv::concepts::IntegerType T>
34 static CLabel *createLabelValue(const T value)
35 {
37 }
38
39 ~CLabel() override;
40
41 void setText(std::string_view text);
42 std::string getText();
43
44 void setResource(std::string_view nameResource, const uint64_t &width, const uint64_t &height);
45
46 void setColor(iv::types::color color);
47
48 void setHeight(double fontHeight);
49
50 void setSpacing(double spacing);
51
52 void setLabelStyle(iv::gui::eLabelStyle labelStyle);
53
54private:
55 CLabel(std::string_view text, const std::optional<iv::ui::resources::ImageResource> &resourceOpt,
56 CEnumCommon::eType type, double spacing = 5);
57
58 IWidget *createWidget(CDialog *dialogFatherRef) override;
59
60 std::string m_text;
61
62 double m_spacing;
65 uint32_t m_colorText;
67 double m_fontHeight {0};
68
69 std::optional<iv::ui::resources::ImageResource> m_imageResourceOpt;
71
73};
74
75#endif /* LIBS_GUI_CLABEL_HPP_ */
Definition AbstractComponentGUI.hpp:30
Definition CDialog.hpp:21
eType
Definition CEnumCommon.hpp:27
Definition CLabel.hpp:17
IWidget * createWidget(CDialog *dialogFatherRef) override
Definition CLabel.cpp:137
void setText(std::string_view text)
Definition CLabel.cpp:59
void setSpacing(double spacing)
Setea el espaciado entre la imagen y el texto.
Definition CLabel.cpp:95
std::optional< iv::ui::resources::ImageResource > m_imageResourceOpt
Definition CLabel.hpp:69
uint32_t m_colorText
Definition CLabel.hpp:65
static CLabel * createLabelEnum(T enumValue)
Definition CLabel.hpp:28
void setColor(iv::types::color color)
Definition CLabel.cpp:69
iv::gui::eLabelStyle m_labelStyle
Definition CLabel.hpp:70
CLabel(std::string_view text, const std::optional< iv::ui::resources::ImageResource > &resourceOpt, CEnumCommon::eType type, double spacing=5)
Definition CLabel.cpp:8
static CLabel * createLabel(std::string_view text, CEnumCommon::eType type=CEnumCommon::eType::Value, iv::gui::eLabelStyle labelStyle=iv::gui::eLabelStyle::Normal)
Definition CLabel.cpp:26
~CLabel() override
void setLabelStyle(iv::gui::eLabelStyle labelStyle)
Definition CLabel.cpp:105
double m_spacing
Definition CLabel.hpp:62
IWidget * m_labelRef
Definition CLabel.hpp:72
CEnumCommon::eType m_type
Definition CLabel.hpp:63
void setHeight(double fontHeight)
Definition CLabel.cpp:80
bool m_isFontHeightDefined
Definition CLabel.hpp:66
double m_fontHeight
Definition CLabel.hpp:67
static CLabel * createLabelValue(const T value)
Definition CLabel.hpp:34
bool m_isColorDefined
Definition CLabel.hpp:64
std::string m_text
Definition CLabel.hpp:60
static CLabel * createLabelBool(const bool &isOk)
Definition CLabel.cpp:41
std::string getText()
Definition CLabel.cpp:115
void setResource(std::string_view nameResource, const uint64_t &width, const uint64_t &height)
Definition CLabel.cpp:120
Definition CResourceImage.hpp:9
Definition IWidget.hpp:5
eLabelStyle
Definition enums.hpp:14
uint32_t color
Definition types.hpp:12
std::string formatNumber(T number, std::optional< uint8_t > precision=std::nullopt)
Check if a string is a number, only applies precision to floating point numbers.
Definition stringUtils.hpp:343