diff options
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h')
| -rw-r--r-- | xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h new file mode 100644 index 0000000..873a549 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/controls/Button.h | |||
| @@ -0,0 +1,166 @@ | |||
| 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/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_CButton Control Button | ||
| 25 | /// @ingroup cpp_kodi_gui_windows_controls | ||
| 26 | /// @brief @cpp_class{ kodi::gui::controls::CButton } | ||
| 27 | /// **Standard push button control for window**\n | ||
| 28 | /// The button control is used for creating push buttons in Kodi. | ||
| 29 | /// | ||
| 30 | /// You can choose the position, size, and look of the button, as well as | ||
| 31 | /// choosing what action(s) should be performed when pushed. | ||
| 32 | /// | ||
| 33 | /// It has the header @ref Button.h "#include <kodi/gui/controls/Button.h>" | ||
| 34 | /// be included to enjoy it. | ||
| 35 | /// | ||
| 36 | /// Here you find the needed skin part for a @ref skin_Button_control "button control" | ||
| 37 | /// | ||
| 38 | /// @note The call of the control is only possible from the corresponding | ||
| 39 | /// window as its class and identification number is required. | ||
| 40 | /// | ||
| 41 | class ATTRIBUTE_HIDDEN CButton : public CAddonGUIControlBase | ||
| 42 | { | ||
| 43 | public: | ||
| 44 | //============================================================================ | ||
| 45 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 46 | /// @brief Construct a new control. | ||
| 47 | /// | ||
| 48 | /// @param[in] window Related window control class | ||
| 49 | /// @param[in] controlId Used skin xml control id | ||
| 50 | /// | ||
| 51 | CButton(CWindow* window, int controlId) : CAddonGUIControlBase(window) | ||
| 52 | { | ||
| 53 | m_controlHandle = m_interface->kodi_gui->window->get_control_button( | ||
| 54 | m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 55 | if (!m_controlHandle) | ||
| 56 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CButton can't create control class from Kodi !!!"); | ||
| 57 | } | ||
| 58 | //---------------------------------------------------------------------------- | ||
| 59 | |||
| 60 | //============================================================================ | ||
| 61 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 62 | /// @brief Destructor. | ||
| 63 | /// | ||
| 64 | ~CButton() override = default; | ||
| 65 | //---------------------------------------------------------------------------- | ||
| 66 | |||
| 67 | //============================================================================ | ||
| 68 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 69 | /// @brief Set the control on window to visible. | ||
| 70 | /// | ||
| 71 | /// @param[in] visible If true visible, otherwise hidden | ||
| 72 | /// | ||
| 73 | void SetVisible(bool visible) | ||
| 74 | { | ||
| 75 | m_interface->kodi_gui->control_button->set_visible(m_interface->kodiBase, m_controlHandle, | ||
| 76 | visible); | ||
| 77 | } | ||
| 78 | //---------------------------------------------------------------------------- | ||
| 79 | |||
| 80 | //============================================================================ | ||
| 81 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 82 | /// @brief Set's the control's enabled/disabled state. | ||
| 83 | /// | ||
| 84 | /// @param[in] enabled If true enabled, otherwise disabled | ||
| 85 | /// | ||
| 86 | void SetEnabled(bool enabled) | ||
| 87 | { | ||
| 88 | m_interface->kodi_gui->control_button->set_enabled(m_interface->kodiBase, m_controlHandle, | ||
| 89 | enabled); | ||
| 90 | } | ||
| 91 | //---------------------------------------------------------------------------- | ||
| 92 | |||
| 93 | //============================================================================ | ||
| 94 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 95 | /// @brief To set the text string on button. | ||
| 96 | /// | ||
| 97 | /// @param[in] label Text to show | ||
| 98 | /// | ||
| 99 | void SetLabel(const std::string& label) | ||
| 100 | { | ||
| 101 | m_interface->kodi_gui->control_button->set_label(m_interface->kodiBase, m_controlHandle, | ||
| 102 | label.c_str()); | ||
| 103 | } | ||
| 104 | //---------------------------------------------------------------------------- | ||
| 105 | |||
| 106 | //============================================================================ | ||
| 107 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 108 | /// @brief Get the used text from button. | ||
| 109 | /// | ||
| 110 | /// @return Text shown | ||
| 111 | /// | ||
| 112 | std::string GetLabel() const | ||
| 113 | { | ||
| 114 | std::string label; | ||
| 115 | char* ret = | ||
| 116 | m_interface->kodi_gui->control_button->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 117 | if (ret != nullptr) | ||
| 118 | { | ||
| 119 | if (std::strlen(ret)) | ||
| 120 | label = ret; | ||
| 121 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 122 | } | ||
| 123 | return label; | ||
| 124 | } | ||
| 125 | //---------------------------------------------------------------------------- | ||
| 126 | |||
| 127 | //============================================================================ | ||
| 128 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 129 | /// @brief If two labels are used for button becomes it set with them. | ||
| 130 | /// | ||
| 131 | /// @param[in] label Text for second label | ||
| 132 | /// | ||
| 133 | void SetLabel2(const std::string& label) | ||
| 134 | { | ||
| 135 | m_interface->kodi_gui->control_button->set_label2(m_interface->kodiBase, m_controlHandle, | ||
| 136 | label.c_str()); | ||
| 137 | } | ||
| 138 | //---------------------------------------------------------------------------- | ||
| 139 | |||
| 140 | //============================================================================ | ||
| 141 | /// @ingroup cpp_kodi_gui_windows_controls_CButton | ||
| 142 | /// @brief Get the second label if present. | ||
| 143 | /// | ||
| 144 | /// @return Second label | ||
| 145 | /// | ||
| 146 | std::string GetLabel2() const | ||
| 147 | { | ||
| 148 | std::string label; | ||
| 149 | char* ret = | ||
| 150 | m_interface->kodi_gui->control_button->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 151 | if (ret != nullptr) | ||
| 152 | { | ||
| 153 | if (std::strlen(ret)) | ||
| 154 | label = ret; | ||
| 155 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 156 | } | ||
| 157 | return label; | ||
| 158 | } | ||
| 159 | //---------------------------------------------------------------------------- | ||
| 160 | }; | ||
| 161 | |||
| 162 | } /* namespace controls */ | ||
| 163 | } /* namespace gui */ | ||
| 164 | } /* namespace kodi */ | ||
| 165 | |||
| 166 | #endif /* __cplusplus */ | ||
