diff options
| author | manuel <manuel@mausz.at> | 2017-06-04 16:57:49 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2017-06-04 16:57:49 +0200 |
| commit | f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (patch) | |
| tree | d8de60fc7e17edeb6f0921726c038ee54b281445 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h | |
| parent | ae08c8b7221bc965ac40d70e53fc8fcddb050c46 (diff) | |
| download | kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.gz kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.tar.bz2 kodi-pvr-build-f44ecaa4f27e7538ddcad66d40e543bffa2d2d86.zip | |
sync with upstream
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h | 336 |
1 files changed, 336 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h new file mode 100644 index 0000000..a473f28 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h | |||
| @@ -0,0 +1,336 @@ | |||
| 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 "definitions.h" | ||
| 24 | |||
| 25 | #include <memory> | ||
| 26 | |||
| 27 | namespace kodi | ||
| 28 | { | ||
| 29 | namespace gui | ||
| 30 | { | ||
| 31 | |||
| 32 | class CWindow; | ||
| 33 | |||
| 34 | class CAddonGUIControlBase | ||
| 35 | { | ||
| 36 | public: | ||
| 37 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } | ||
| 38 | |||
| 39 | protected: | ||
| 40 | CAddonGUIControlBase(CAddonGUIControlBase* window) | ||
| 41 | : m_controlHandle(nullptr), | ||
| 42 | m_interface(::kodi::addon::CAddonBase::m_interface->toKodi), | ||
| 43 | m_Window(window) {} | ||
| 44 | |||
| 45 | virtual ~CAddonGUIControlBase() = default; | ||
| 46 | |||
| 47 | friend class CWindow; | ||
| 48 | |||
| 49 | GUIHANDLE m_controlHandle; | ||
| 50 | AddonToKodiFuncTable_Addon* m_interface; | ||
| 51 | CAddonGUIControlBase* m_Window; | ||
| 52 | |||
| 53 | private: | ||
| 54 | CAddonGUIControlBase() = delete; | ||
| 55 | CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; | ||
| 56 | CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; | ||
| 57 | }; | ||
| 58 | |||
| 59 | class CListItem; | ||
| 60 | typedef std::shared_ptr<CListItem> ListItemPtr; | ||
| 61 | |||
| 62 | //============================================================================ | ||
| 63 | /// | ||
| 64 | /// \defgroup cpp_kodi_gui_CListItem List Item | ||
| 65 | /// \ingroup cpp_kodi_gui | ||
| 66 | /// @brief \cpp_class{ kodi::gui::CListItem } | ||
| 67 | /// **Selectable window list item** | ||
| 68 | /// | ||
| 69 | /// The list item control is used for creating item lists in Kodi | ||
| 70 | /// | ||
| 71 | /// The with \ref ListItem.h "#include <kodi/gui/ListItem.h>" given | ||
| 72 | /// class is used to create a item entry for a list on window and to support it's | ||
| 73 | /// control. | ||
| 74 | /// | ||
| 75 | |||
| 76 | //============================================================================ | ||
| 77 | /// | ||
| 78 | /// \defgroup cpp_kodi_gui_CListItem_Defs Definitions, structures and enumerators | ||
| 79 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 80 | /// @brief **Library definition values** | ||
| 81 | /// | ||
| 82 | |||
| 83 | class CListItem : public CAddonGUIControlBase | ||
| 84 | { | ||
| 85 | public: | ||
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 89 | /// @brief Class constructor with parameters | ||
| 90 | /// | ||
| 91 | /// @param[in] label Item label | ||
| 92 | /// @param[in] label2 Second Item label (if needed) | ||
| 93 | /// @param[in] iconImage Item icon image (if needed) | ||
| 94 | /// @param[in] thumbnailImage Thumbnail Image of item (if needed) | ||
| 95 | /// @param[in] path Path to where item is defined | ||
| 96 | /// | ||
| 97 | CListItem( | ||
| 98 | const std::string& label = "", | ||
| 99 | const std::string& label2 = "", | ||
| 100 | const std::string& iconImage = "", | ||
| 101 | const std::string& thumbnailImage = "", | ||
| 102 | const std::string& path = "") | ||
| 103 | : CAddonGUIControlBase(nullptr) | ||
| 104 | { | ||
| 105 | m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(), | ||
| 106 | label2.c_str(), iconImage.c_str(), | ||
| 107 | thumbnailImage.c_str(), path.c_str()); | ||
| 108 | } | ||
| 109 | |||
| 110 | /* | ||
| 111 | * Constructor used for parts given by list items from addon window | ||
| 112 | * | ||
| 113 | * Related to call of "ListItemPtr kodi::gui::CWindow::GetListItem(int listPos)" | ||
| 114 | * Not needed for addon development itself | ||
| 115 | */ | ||
| 116 | CListItem(GUIHANDLE listItemHandle) | ||
| 117 | : CAddonGUIControlBase(nullptr) | ||
| 118 | { | ||
| 119 | m_controlHandle = listItemHandle; | ||
| 120 | } | ||
| 121 | |||
| 122 | //========================================================================== | ||
| 123 | /// | ||
| 124 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 125 | /// @brief Class destructor | ||
| 126 | /// | ||
| 127 | virtual ~CListItem() | ||
| 128 | { | ||
| 129 | m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 130 | } | ||
| 131 | //-------------------------------------------------------------------------- | ||
| 132 | |||
| 133 | //========================================================================== | ||
| 134 | /// | ||
| 135 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 136 | /// @brief Returns the listitem label. | ||
| 137 | /// | ||
| 138 | /// @return Label of item | ||
| 139 | /// | ||
| 140 | std::string GetLabel() | ||
| 141 | { | ||
| 142 | std::string label; | ||
| 143 | char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 144 | if (ret != nullptr) | ||
| 145 | { | ||
| 146 | if (std::strlen(ret)) | ||
| 147 | label = ret; | ||
| 148 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 149 | } | ||
| 150 | return label; | ||
| 151 | } | ||
| 152 | //-------------------------------------------------------------------------- | ||
| 153 | |||
| 154 | //========================================================================== | ||
| 155 | /// | ||
| 156 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 157 | /// @brief Sets the listitem label. | ||
| 158 | /// | ||
| 159 | /// @param[in] label string or unicode - text string. | ||
| 160 | /// | ||
| 161 | void SetLabel(const std::string& label) | ||
| 162 | { | ||
| 163 | m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 164 | } | ||
| 165 | //-------------------------------------------------------------------------- | ||
| 166 | |||
| 167 | //========================================================================== | ||
| 168 | /// | ||
| 169 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 170 | /// @brief Returns the second listitem label. | ||
| 171 | /// | ||
| 172 | /// @return Second label of item | ||
| 173 | /// | ||
| 174 | std::string GetLabel2() | ||
| 175 | { | ||
| 176 | std::string label; | ||
| 177 | char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 178 | if (ret != nullptr) | ||
| 179 | { | ||
| 180 | if (std::strlen(ret)) | ||
| 181 | label = ret; | ||
| 182 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 183 | } | ||
| 184 | return label; | ||
| 185 | } | ||
| 186 | //-------------------------------------------------------------------------- | ||
| 187 | |||
| 188 | //========================================================================== | ||
| 189 | /// | ||
| 190 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 191 | /// @brief Sets the listitem's label2. | ||
| 192 | /// | ||
| 193 | /// @param[in] label string or unicode - text string. | ||
| 194 | /// | ||
| 195 | void SetLabel2(const std::string& label) | ||
| 196 | { | ||
| 197 | m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 198 | } | ||
| 199 | //-------------------------------------------------------------------------- | ||
| 200 | |||
| 201 | //========================================================================== | ||
| 202 | /// | ||
| 203 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 204 | /// @brief To get current icon image of entry | ||
| 205 | /// | ||
| 206 | /// @return The current icon image path (if present) | ||
| 207 | /// | ||
| 208 | std::string GetIconImage() | ||
| 209 | { | ||
| 210 | std::string image; | ||
| 211 | char* ret = m_interface->kodi_gui->listItem->get_icon_image(m_interface->kodiBase, m_controlHandle); | ||
| 212 | if (ret != nullptr) | ||
| 213 | { | ||
| 214 | if (std::strlen(ret)) | ||
| 215 | image = ret; | ||
| 216 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 217 | } | ||
| 218 | return image; | ||
| 219 | } | ||
| 220 | //-------------------------------------------------------------------------- | ||
| 221 | |||
| 222 | //========================================================================== | ||
| 223 | /// | ||
| 224 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 225 | /// @brief To set icon image of entry | ||
| 226 | /// | ||
| 227 | /// @param image The image to use for. | ||
| 228 | /// | ||
| 229 | /// @note Alternative can be \ref SetArt used | ||
| 230 | /// | ||
| 231 | /// | ||
| 232 | void SetIconImage(const std::string& image) | ||
| 233 | { | ||
| 234 | m_interface->kodi_gui->listItem->set_icon_image(m_interface->kodiBase, m_controlHandle, image.c_str()); | ||
| 235 | } | ||
| 236 | //-------------------------------------------------------------------------- | ||
| 237 | |||
| 238 | //========================================================================== | ||
| 239 | /// | ||
| 240 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 241 | /// @brief Sets the listitem's art | ||
| 242 | /// | ||
| 243 | /// @param[in] type Type of Art to set | ||
| 244 | /// - Some default art values (any string possible): | ||
| 245 | /// | value (type) | Type | | ||
| 246 | /// |:-------------:|:--------------------------------------------------| | ||
| 247 | /// | thumb | string - image filename | ||
| 248 | /// | poster | string - image filename | ||
| 249 | /// | banner | string - image filename | ||
| 250 | /// | fanart | string - image filename | ||
| 251 | /// | clearart | string - image filename | ||
| 252 | /// | clearlogo | string - image filename | ||
| 253 | /// | landscape | string - image filename | ||
| 254 | /// | icon | string - image filename | ||
| 255 | /// @return The url to use for Art | ||
| 256 | /// | ||
| 257 | std::string GetArt(const std::string& type) | ||
| 258 | { | ||
| 259 | std::string strReturn; | ||
| 260 | char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle, type.c_str()); | ||
| 261 | if (ret != nullptr) | ||
| 262 | { | ||
| 263 | if (std::strlen(ret)) | ||
| 264 | strReturn = ret; | ||
| 265 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 266 | } | ||
| 267 | return strReturn; | ||
| 268 | } | ||
| 269 | //-------------------------------------------------------------------------- | ||
| 270 | |||
| 271 | //========================================================================== | ||
| 272 | /// | ||
| 273 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 274 | /// @brief Sets the listitem's art | ||
| 275 | /// | ||
| 276 | /// @param[in] type Type of Art to set | ||
| 277 | /// @param[in] url The url to use for Art | ||
| 278 | /// - Some default art values (any string possible): | ||
| 279 | /// | value (type) | Type | | ||
| 280 | /// |:-------------:|:--------------------------------------------------| | ||
| 281 | /// | thumb | string - image filename | ||
| 282 | /// | poster | string - image filename | ||
| 283 | /// | banner | string - image filename | ||
| 284 | /// | fanart | string - image filename | ||
| 285 | /// | clearart | string - image filename | ||
| 286 | /// | clearlogo | string - image filename | ||
| 287 | /// | landscape | string - image filename | ||
| 288 | /// | icon | string - image filename | ||
| 289 | /// | ||
| 290 | void SetArt(const std::string& type, const std::string& url) | ||
| 291 | { | ||
| 292 | m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(), url.c_str()); | ||
| 293 | } | ||
| 294 | //-------------------------------------------------------------------------- | ||
| 295 | |||
| 296 | //========================================================================== | ||
| 297 | /// | ||
| 298 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 299 | /// @brief Returns the path / filename of this listitem. | ||
| 300 | /// | ||
| 301 | /// @return Path string | ||
| 302 | /// | ||
| 303 | std::string GetPath() | ||
| 304 | { | ||
| 305 | std::string strReturn; | ||
| 306 | char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle); | ||
| 307 | if (ret != nullptr) | ||
| 308 | { | ||
| 309 | if (std::strlen(ret)) | ||
| 310 | strReturn = ret; | ||
| 311 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 312 | } | ||
| 313 | return strReturn; | ||
| 314 | } | ||
| 315 | //-------------------------------------------------------------------------- | ||
| 316 | |||
| 317 | //========================================================================== | ||
| 318 | /// | ||
| 319 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 320 | /// @brief Sets the listitem's path. | ||
| 321 | /// | ||
| 322 | /// @param[in] path string or unicode - path, activated when | ||
| 323 | /// item is clicked. | ||
| 324 | /// | ||
| 325 | /// @note You can use the above as keywords for arguments. | ||
| 326 | /// | ||
| 327 | void SetPath(const std::string& path) | ||
| 328 | { | ||
| 329 | m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str()); | ||
| 330 | } | ||
| 331 | //-------------------------------------------------------------------------- | ||
| 332 | |||
| 333 | }; | ||
| 334 | |||
| 335 | } /* namespace gui */ | ||
| 336 | } /* namespace kodi */ | ||
