Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
Label.h
1/*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#include "../../c-api/gui/controls/label.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
39class ATTR_DLL_LOCAL CLabel : public CAddonGUIControlBase
40{
41public:
42 //============================================================================
49 CLabel(CWindow* window, int controlId) : CAddonGUIControlBase(window)
50 {
51 m_controlHandle = m_interface->kodi_gui->window->get_control_label(
52 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
53 if (!m_controlHandle)
55 "kodi::gui::controls::CLabel can't create control class from Kodi !!!");
56 }
57 //----------------------------------------------------------------------------
58
59 //============================================================================
63 ~CLabel() override = default;
64 //----------------------------------------------------------------------------
65
66 //============================================================================
72 void SetVisible(bool visible)
73 {
74 m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle,
75 visible);
76 }
77 //----------------------------------------------------------------------------
78
79 //============================================================================
85 void SetLabel(const std::string& text)
86 {
87 m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle,
88 text.c_str());
89 }
90 //----------------------------------------------------------------------------
91
92 //============================================================================
98 std::string GetLabel() const
99 {
100 std::string label;
101 char* ret =
102 m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle);
103 if (ret != nullptr)
104 {
105 if (std::strlen(ret))
106 label = ret;
107 m_interface->free_string(m_interface->kodiBase, ret);
108 }
109 return label;
110 }
111 //----------------------------------------------------------------------------
112};
113
114} /* namespace controls */
115} /* namespace gui */
116} /* namespace kodi */
117
118#endif /* __cplusplus */
Definition ListItem.h:26
Definition Window.h:110
Definition Label.h:40
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
void SetLabel(const std::string &text)
To set the text string on label.
Definition Label.h:85
CLabel(CWindow *window, int controlId)
Construct a new control.
Definition Label.h:49
std::string GetLabel() const
Get the used text from control.
Definition Label.h:98
void SetVisible(bool visible)
Set the control on window to visible.
Definition Label.h:72
~CLabel() override=default
Destructor.
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938