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