diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h new file mode 100644 index 0000000..f74ac03 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/controls/Label.h | |||
| @@ -0,0 +1,128 @@ | |||
| 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_CLabel Control Label | ||
| 35 | /// \ingroup cpp_kodi_gui | ||
| 36 | /// @brief \cpp_class{ kodi::gui::controls::CLabel } | ||
| 37 | /// **Window control used to show some lines of text.** | ||
| 38 | /// | ||
| 39 | /// The label control is used for displaying text in Kodi. You can choose | ||
| 40 | /// the font, size, colour, location and contents of the text to be displayed. | ||
| 41 | /// | ||
| 42 | /// It has the header \ref Label.h "#include <kodi/gui/controls/Label.h>" | ||
| 43 | /// be included to enjoy it. | ||
| 44 | /// | ||
| 45 | /// Here you find the needed skin part for a \ref Label_Control "label control" | ||
| 46 | /// | ||
| 47 | /// @note The call of the control is only possible from the corresponding | ||
| 48 | /// window as its class and identification number is required. | ||
| 49 | /// | ||
| 50 | class CLabel : public CAddonGUIControlBase | ||
| 51 | { | ||
| 52 | public: | ||
| 53 | //========================================================================== | ||
| 54 | /// | ||
| 55 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 56 | /// @brief Construct a new control | ||
| 57 | /// | ||
| 58 | /// @param[in] window related window control class | ||
| 59 | /// @param[in] controlId Used skin xml control id | ||
| 60 | /// | ||
| 61 | CLabel(CWindow* window, int controlId) | ||
| 62 | : CAddonGUIControlBase(window) | ||
| 63 | { | ||
| 64 | m_controlHandle = m_interface->kodi_gui->window->get_control_label(m_interface->kodiBase, m_Window->GetControlHandle(), controlId); | ||
| 65 | if (!m_controlHandle) | ||
| 66 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::controls::CLabel can't create control class from Kodi !!!"); | ||
| 67 | } | ||
| 68 | //-------------------------------------------------------------------------- | ||
| 69 | |||
| 70 | //========================================================================== | ||
| 71 | /// | ||
| 72 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 73 | /// @brief Destructor | ||
| 74 | /// | ||
| 75 | ~CLabel() override = default; | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 81 | /// @brief Set the control on window to visible | ||
| 82 | /// | ||
| 83 | /// @param[in] visible If true visible, otherwise hidden | ||
| 84 | /// | ||
| 85 | void SetVisible(bool visible) | ||
| 86 | { | ||
| 87 | m_interface->kodi_gui->control_label->set_visible(m_interface->kodiBase, m_controlHandle, visible); | ||
| 88 | } | ||
| 89 | //-------------------------------------------------------------------------- | ||
| 90 | |||
| 91 | //========================================================================== | ||
| 92 | /// | ||
| 93 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 94 | /// @brief To set the text string on label | ||
| 95 | /// | ||
| 96 | /// @param[in] text Text to show | ||
| 97 | /// | ||
| 98 | void SetLabel(const std::string& text) | ||
| 99 | { | ||
| 100 | m_interface->kodi_gui->control_label->set_label(m_interface->kodiBase, m_controlHandle, text.c_str()); | ||
| 101 | } | ||
| 102 | //-------------------------------------------------------------------------- | ||
| 103 | |||
| 104 | //========================================================================== | ||
| 105 | /// | ||
| 106 | /// \ingroup cpp_kodi_gui_controls_CLabel | ||
| 107 | /// @brief Get the used text from control | ||
| 108 | /// | ||
| 109 | /// @return Used text on label control | ||
| 110 | /// | ||
| 111 | std::string GetLabel() const | ||
| 112 | { | ||
| 113 | std::string label; | ||
| 114 | char* ret = m_interface->kodi_gui->control_label->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 115 | if (ret != nullptr) | ||
| 116 | { | ||
| 117 | if (std::strlen(ret)) | ||
| 118 | label = ret; | ||
| 119 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 120 | } | ||
| 121 | return label; | ||
| 122 | } | ||
| 123 | //-------------------------------------------------------------------------- | ||
| 124 | }; | ||
| 125 | |||
| 126 | } /* namespace controls */ | ||
| 127 | } /* namespace gui */ | ||
| 128 | } /* namespace kodi */ | ||
