diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h')
| -rw-r--r-- | xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h new file mode 100644 index 0000000..3b6a23c --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/RadioButton.h | |||
| @@ -0,0 +1,214 @@ | |||
| 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 | |||
| 16 | namespace kodi | ||
| 17 | { | ||
| 18 | namespace gui | ||
| 19 | { | ||
| 20 | namespace controls | ||
| 21 | { | ||
| 22 | |||
| 23 | //============================================================================== | ||
| 24 | /// @defgroup cpp_kodi_gui_windows_controls_CRadioButton Control Radio Button | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CRadioButton } | ||
| 27 | /// **Window control for a radio button (as used for on/off settings)**\n | ||
| 28 | /// The radio button control is used for creating push button on/off settings | ||
| 29 | /// in Kodi. | ||
| 30 | /// | ||
| 31 | /// You can choose the position, size, and look of the button. When the user | ||
| 32 | /// clicks on the radio button, the state will change, toggling the extra | ||
| 33 | /// textures (textureradioon and textureradiooff). Used for settings | ||
| 34 | /// controls. | ||
| 35 | /// | ||
| 36 | /// It has the header @ref RadioButton.h "#include <kodi/gui/controls/RadioButton.h>" | ||
| 37 | /// be included to enjoy it. | ||
| 38 | /// | ||
| 39 | /// Here you find the needed skin part for a @ref Radio_button_control "radio button control". | ||
| 40 | /// | ||
| 41 | /// @note The call of the control is only possible from the corresponding | ||
| 42 | /// window as its class and identification number is required. | ||
| 43 | /// | ||
| 44 | /// | ||
| 45 | /// -------------------------------------------------------------------------- | ||
| 46 | /// **Example:** | ||
| 47 | /// ~~~~~~~~~~~~cpp | ||
| 48 | /// #include <kodi/gui/Window.h> | ||
| 49 | /// | ||
| 50 | /// #define MY_RADIO_BUTTON_CONTROL 1 | ||
| 51 | /// | ||
| 52 | /// class CMyWindow : public kodi::gui::CWindow | ||
| 53 | /// { | ||
| 54 | /// public: | ||
| 55 | /// CMyWindow() | ||
| 56 | /// | ||
| 57 | /// void ShowWindow(); | ||
| 58 | /// | ||
| 59 | /// bool OnInit() override; | ||
| 60 | /// bool OnClick(int controlId) override; | ||
| 61 | /// | ||
| 62 | /// private: | ||
| 63 | /// kodi::gui::controls::CSpin m_myRadioButtonControl; | ||
| 64 | /// }; | ||
| 65 | /// | ||
| 66 | /// CMyWindow::CMyWindow() | ||
| 67 | /// : kodi::gui::CWindow("my_skin.xml", "skin.estuary", true, false), | ||
| 68 | /// m_myRadioButtonControl(this, MY_RADIO_BUTTON_CONTROL) | ||
| 69 | /// { | ||
| 70 | /// } | ||
| 71 | /// | ||
| 72 | /// void CMyWindow::ShowWindow() | ||
| 73 | /// { | ||
| 74 | /// kodi::gui::CWindow::DoModal(); | ||
| 75 | /// } | ||
| 76 | /// | ||
| 77 | /// bool CMyWindow::OnInit() | ||
| 78 | /// { | ||
| 79 | /// m_myRadioButtonControl.SetSelected(false); // can also on skin set to default | ||
| 80 | /// return true; | ||
| 81 | /// } | ||
| 82 | /// | ||
| 83 | /// bool CMyWindow::OnClick(int controlId) | ||
| 84 | /// { | ||
| 85 | /// if (controlId == MY_RADIO_BUTTON_CONTROL) | ||
| 86 | /// { | ||
| 87 | /// bool selected = m_myRadioButtonControl.IsSelected(); | ||
| 88 | /// ... | ||
| 89 | /// } | ||
| 90 | /// return true; | ||
| 91 | /// } | ||
| 92 | /// return false; | ||
| 93 | /// } | ||
| 94 | /// ~~~~~~~~~~~~ | ||
| 95 | /// | ||
| 96 | class ATTRIBUTE_HIDDEN CRadioButton : public CAddonGUIControlBase | ||
| 97 | { | ||
| 98 | public: | ||
| 99 | //============================================================================ | ||
| 100 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 101 | /// @brief Construct a new control. | ||
| 102 | /// | ||
| 103 | /// @param[in] window Related window control class | ||
| 104 | /// @param[in] controlId Used skin xml control id | ||
| 105 | /// | ||
| 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) | ||
| 111 | kodi::Log(ADDON_LOG_FATAL, | ||
| 112 | "kodi::gui::controls::CRadioButton can't create control class from Kodi !!!"); | ||
| 113 | } | ||
| 114 | //---------------------------------------------------------------------------- | ||
| 115 | |||
| 116 | //============================================================================ | ||
| 117 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 118 | /// @brief Destructor. | ||
| 119 | /// | ||
| 120 | ~CRadioButton() override = default; | ||
| 121 | //---------------------------------------------------------------------------- | ||
| 122 | |||
| 123 | //============================================================================ | ||
| 124 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton. | ||
| 125 | /// @brief Set the control on window to visible. | ||
| 126 | /// | ||
| 127 | /// @param[in] visible If true visible, otherwise hidden | ||
| 128 | /// | ||
| 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 | //============================================================================ | ||
| 137 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 138 | /// @brief Set's the control's enabled/disabled state. | ||
| 139 | /// | ||
| 140 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 141 | /// | ||
| 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 | //============================================================================ | ||
| 150 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 151 | /// @brief To set the text string on radio button. | ||
| 152 | /// | ||
| 153 | /// @param[in] label Text to show | ||
| 154 | /// | ||
| 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 | //============================================================================ | ||
| 163 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 164 | /// @brief Get the used text from control. | ||
| 165 | /// | ||
| 166 | /// @return Text shown | ||
| 167 | /// | ||
| 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 | //============================================================================ | ||
| 184 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 185 | /// @brief To set radio button condition to on or off. | ||
| 186 | /// | ||
| 187 | /// @param[in] selected true set radio button to selection on, otherwise off | ||
| 188 | /// | ||
| 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 | //============================================================================ | ||
| 197 | /// @ingroup cpp_kodi_gui_windows_controls_CRadioButton | ||
| 198 | /// @brief Get the current selected condition of radio button. | ||
| 199 | /// | ||
| 200 | /// @return Selected condition | ||
| 201 | /// | ||
| 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 */ | ||
