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