summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h')
-rw-r--r--xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h171
1 files changed, 171 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h
new file mode 100644
index 0000000..b87920d
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/RadioButton.h
@@ -0,0 +1,171 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2017 Team KODI
4 * http://kodi.tv
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with KODI; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "../../AddonBase.h"
23#include "../Window.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace controls
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_controls_CRadioButton Control Radio Button
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_class{ kodi::gui::controls::CRadioButton }
37 /// **Window control for a radio button (as used for on/off settings)**
38 ///
39 /// The radio button control is used for creating push button on/off settings
40 /// in Kodi. You can choose the position, size, and look of the button. When
41 /// the user clicks on the radio button, the state will change, toggling the
42 /// extra textures (textureradioon and textureradiooff). Used for settings
43 /// controls.
44 ///
45 /// It has the header \ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>"
46 /// be included to enjoy it.
47 ///
48 /// Here you find the needed skin part for a \ref Radio_button_control "radio button control"
49 ///
50 /// @note The call of the control is only possible from the corresponding
51 /// window as its class and identification number is required.
52 ///
53 class CRadioButton : public CAddonGUIControlBase
54 {
55 public:
56 //==========================================================================
57 ///
58 /// \ingroup cpp_kodi_gui_controls_CRadioButton
59 /// @brief Construct a new control
60 ///
61 /// @param[in] window related window control class
62 /// @param[in] controlId Used skin xml control id
63 ///
64 CRadioButton(CWindow* window, int controlId)
65 : CAddonGUIControlBase(window)
66 {
67 m_controlHandle = m_interface->kodi_gui->window->get_control_radio_button(m_interface->kodiBase, m_Window->GetControlHandle(), controlId);
68 if (!m_controlHandle)
69 kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!");
70 }
71 //--------------------------------------------------------------------------
72
73 //==========================================================================
74 ///
75 /// \ingroup cpp_kodi_gui_controls_CRadioButton
76 /// @brief Destructor
77 ///
78 ~CRadioButton() override = default;
79 //--------------------------------------------------------------------------
80
81 //==========================================================================
82 ///
83 /// \ingroup cpp_kodi_gui_controls_CRadioButton
84 /// @brief Set the control on window to visible
85 ///
86 /// @param[in] visible If true visible, otherwise hidden
87 ///
88 void SetVisible(bool visible)
89 {
90 m_interface->kodi_gui->control_radio_button->set_visible(m_interface->kodiBase, m_controlHandle, visible);
91 }
92 //--------------------------------------------------------------------------
93
94 //==========================================================================
95 ///
96 /// \ingroup cpp_kodi_gui_controls_CRadioButton
97 /// @brief Set's the control's enabled/disabled state
98 ///
99 /// @param[in] enabled If true enabled, otherwise disabled
100 ///
101 void SetEnabled(bool enabled)
102 {
103 m_interface->kodi_gui->control_radio_button->set_enabled(m_interface->kodiBase, m_controlHandle, enabled);
104 }
105 //--------------------------------------------------------------------------
106
107 //==========================================================================
108 ///
109 /// \ingroup cpp_kodi_gui_controls_CRadioButton
110 /// @brief To set the text string on radio button
111 ///
112 /// @param[in] label Text to show
113 ///
114 void SetLabel(const std::string& label)
115 {
116 m_interface->kodi_gui->control_radio_button->set_label(m_interface->kodiBase, m_controlHandle, label.c_str());
117 }
118 //--------------------------------------------------------------------------
119
120 //==========================================================================
121 ///
122 /// \ingroup cpp_kodi_gui_controls_CRadioButton
123 /// @brief Get the used text from control
124 ///
125 /// @return Text shown
126 ///
127 std::string GetLabel() const
128 {
129 std::string label;
130 char* ret = m_interface->kodi_gui->control_radio_button->get_label(m_interface->kodiBase, m_controlHandle);
131 if (ret != nullptr)
132 {
133 if (std::strlen(ret))
134 label = ret;
135 m_interface->free_string(m_interface->kodiBase, ret);
136 }
137 return label;
138 }
139 //--------------------------------------------------------------------------
140
141 //==========================================================================
142 ///
143 /// \ingroup cpp_kodi_gui_controls_CRadioButton
144 /// @brief To set radio button condition to on or off
145 ///
146 /// @param[in] selected true set radio button to selection on, otherwise
147 /// off
148 ///
149 void SetSelected(bool selected)
150 {
151 m_interface->kodi_gui->control_radio_button->set_selected(m_interface->kodiBase, m_controlHandle, selected);
152 }
153 //--------------------------------------------------------------------------
154
155 //==========================================================================
156 ///
157 /// \ingroup cpp_kodi_gui_controls_CRadioButton
158 /// @brief Get the current selected condition of radio button
159 ///
160 /// @return Selected condition
161 ///
162 bool IsSelected() const
163 {
164 return m_interface->kodi_gui->control_radio_button->is_selected(m_interface->kodiBase, m_controlHandle);
165 }
166 //--------------------------------------------------------------------------
167 };
168
169} /* namespace controls */
170} /* namespace gui */
171} /* namespace kodi */