Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
RadioButton.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/radio_button.h"
12#include "../Window.h"
13
14#ifdef __cplusplus
15
16namespace kodi
17{
18namespace gui
19{
20namespace controls
21{
22
23//==============================================================================
96class ATTR_DLL_LOCAL CRadioButton : public CAddonGUIControlBase
97{
98public:
99 //============================================================================
106 CRadioButton(CWindow* window, int controlId) : CAddonGUIControlBase(window)
107 {
108 m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button(
109 m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
110 if (!m_controlHandle)
112 "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!");
113 }
114 //----------------------------------------------------------------------------
115
116 //============================================================================
120 ~CRadioButton() override = default;
121 //----------------------------------------------------------------------------
122
123 //============================================================================
129 void SetVisible(bool visible)
130 {
131 m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle,
132 visible);
133 }
134 //----------------------------------------------------------------------------
135
136 //============================================================================
142 void SetEnabled(bool enabled)
143 {
144 m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle,
145 enabled);
146 }
147 //----------------------------------------------------------------------------
148
149 //============================================================================
155 void SetLabel(const std::string& label)
156 {
157 m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle,
158 label.c_str());
159 }
160 //----------------------------------------------------------------------------
161
162 //============================================================================
168 std::string GetLabel() const
169 {
170 std::string label;
171 char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase,
172 m_controlHandle);
173 if (ret != nullptr)
174 {
175 if (std::strlen(ret))
176 label = ret;
177 m_interface->free_string(m_interface->kodiBase, ret);
178 }
179 return label;
180 }
181 //----------------------------------------------------------------------------
182
183 //============================================================================
189 void SetSelected(bool selected)
190 {
191 m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase,
192 m_controlHandle, selected);
193 }
194 //----------------------------------------------------------------------------
195
196 //============================================================================
202 bool IsSelected() const
203 {
204 return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase,
205 m_controlHandle);
206 }
207 //----------------------------------------------------------------------------
208};
209
210} /* namespace controls */
211} /* namespace gui */
212} /* namespace kodi */
213
214#endif /* __cplusplus */
Definition ListItem.h:26
Definition Window.h:110
Definition RadioButton.h:97
@ ADDON_LOG_FATAL
4 : To notify fatal unrecoverable errors, which can may also indicate upcoming crashes.
Definition addon_base.h:197
~CRadioButton() override=default
Destructor.
bool IsSelected() const
Get the current selected condition of radio button.
Definition RadioButton.h:202
std::string GetLabel() const
Get the used text from control.
Definition RadioButton.h:168
void SetVisible(bool visible)
Set the control on window to visible.
Definition RadioButton.h:129
void SetEnabled(bool enabled)
Set's the control's enabled/disabled state.
Definition RadioButton.h:142
void SetLabel(const std::string &label)
To set the text string on radio button.
Definition RadioButton.h:155
CRadioButton(CWindow *window, int controlId)
Construct a new control.
Definition RadioButton.h:106
void SetSelected(bool selected)
To set radio button condition to on or off.
Definition RadioButton.h:189
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition AddonBase.h:1938