diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h | 185 |
1 files changed, 0 insertions, 185 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h deleted file mode 100644 index d545030..0000000 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h +++ /dev/null | |||
| @@ -1,185 +0,0 @@ | |||
| 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 "../definitions.h" | ||
| 12 | #include "../../AddonBase.h" | ||
| 13 | |||
| 14 | namespace kodi | ||
| 15 | { | ||
| 16 | namespace gui | ||
| 17 | { | ||
| 18 | namespace dialogs | ||
| 19 | { | ||
| 20 | |||
| 21 | //============================================================================ | ||
| 22 | /// | ||
| 23 | /// \defgroup cpp_kodi_gui_dialogs_ContextMenu Dialog Context Menu | ||
| 24 | /// \ingroup cpp_kodi_gui | ||
| 25 | /// @brief \cpp_namespace{ kodi::gui::dialogs::ContextMenu } | ||
| 26 | /// **Context menu dialog** | ||
| 27 | /// | ||
| 28 | /// The function listed below permits the call of a dialogue as context menu to | ||
| 29 | /// select of an entry as a key | ||
| 30 | /// | ||
| 31 | /// It has the header \ref ContextMenu.h "#include <kodi/gui/dialogs/ContextMenu.h>" | ||
| 32 | /// be included to enjoy it. | ||
| 33 | /// | ||
| 34 | /// | ||
| 35 | namespace ContextMenu | ||
| 36 | { | ||
| 37 | //========================================================================== | ||
| 38 | /// | ||
| 39 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 40 | /// @brief Show a context menu dialog about given parts. | ||
| 41 | /// | ||
| 42 | /// @param[in] heading Dialog heading name | ||
| 43 | /// @param[in] entries String list about entries | ||
| 44 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 45 | /// | ||
| 46 | /// | ||
| 47 | ///------------------------------------------------------------------------- | ||
| 48 | /// | ||
| 49 | /// **Example:** | ||
| 50 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 51 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 52 | /// | ||
| 53 | /// const std::vector<std::string> entries | ||
| 54 | /// { | ||
| 55 | /// "Test 1", | ||
| 56 | /// "Test 2", | ||
| 57 | /// "Test 3", | ||
| 58 | /// "Test 4", | ||
| 59 | /// "Test 5" | ||
| 60 | /// }; | ||
| 61 | /// | ||
| 62 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 63 | /// if (selected < 0) | ||
| 64 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 65 | /// else | ||
| 66 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 67 | /// ~~~~~~~~~~~~~ | ||
| 68 | /// | ||
| 69 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 70 | const std::vector<std::string>& entries) | ||
| 71 | { | ||
| 72 | using namespace ::kodi::addon; | ||
| 73 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 74 | const char** cEntries = static_cast<const char**>(malloc(size * sizeof(const char**))); | ||
| 75 | for (unsigned int i = 0; i < size; ++i) | ||
| 76 | { | ||
| 77 | cEntries[i] = entries[i].c_str(); | ||
| 78 | } | ||
| 79 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open( | ||
| 80 | CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 81 | free(cEntries); | ||
| 82 | return ret; | ||
| 83 | } | ||
| 84 | //-------------------------------------------------------------------------- | ||
| 85 | |||
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 89 | /// @brief Show a context menu dialog about given parts. | ||
| 90 | /// | ||
| 91 | /// @param[in] heading Dialog heading name | ||
| 92 | /// @param[in] entries String list about entries | ||
| 93 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 94 | /// | ||
| 95 | /// | ||
| 96 | ///------------------------------------------------------------------------- | ||
| 97 | /// | ||
| 98 | /// **Example:** | ||
| 99 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 100 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 101 | /// | ||
| 102 | /// const std::vector<std::pair<std::string, std::string>> entries | ||
| 103 | /// { | ||
| 104 | /// { "ID 1", "Test 1" }, | ||
| 105 | /// { "ID 2", "Test 2" }, | ||
| 106 | /// { "ID 3", "Test 3" }, | ||
| 107 | /// { "ID 4", "Test 4" }, | ||
| 108 | /// { "ID 5", "Test 5" } | ||
| 109 | /// }; | ||
| 110 | /// | ||
| 111 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 112 | /// if (selected < 0) | ||
| 113 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 114 | /// else | ||
| 115 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 116 | /// ~~~~~~~~~~~~~ | ||
| 117 | /// | ||
| 118 | inline int ATTRIBUTE_HIDDEN Show( | ||
| 119 | const std::string& heading, const std::vector<std::pair<std::string, std::string>>& entries) | ||
| 120 | { | ||
| 121 | using namespace ::kodi::addon; | ||
| 122 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 123 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | ||
| 124 | for (unsigned int i = 0; i < size; ++i) | ||
| 125 | { | ||
| 126 | cEntries[i] = entries[i].second.c_str(); | ||
| 127 | } | ||
| 128 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 129 | free(cEntries); | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_dialogs_ContextMenu | ||
| 137 | /// @brief Show a context menu dialog about given parts. | ||
| 138 | /// | ||
| 139 | /// @param[in] heading Dialog heading name | ||
| 140 | /// @param[in] entries String list about entries | ||
| 141 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 142 | /// | ||
| 143 | /// | ||
| 144 | ///------------------------------------------------------------------------- | ||
| 145 | /// | ||
| 146 | /// **Example:** | ||
| 147 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 148 | /// #include <kodi/gui/dialogs/ContextMenu.h> | ||
| 149 | /// | ||
| 150 | /// const std::vector<std::pair<int, std::string>> entries | ||
| 151 | /// { | ||
| 152 | /// { 1, "Test 1" }, | ||
| 153 | /// { 2, "Test 2" }, | ||
| 154 | /// { 3, "Test 3" }, | ||
| 155 | /// { 4, "Test 4" }, | ||
| 156 | /// { 5, "Test 5" } | ||
| 157 | /// }; | ||
| 158 | /// | ||
| 159 | /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries); | ||
| 160 | /// if (selected < 0) | ||
| 161 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 162 | /// else | ||
| 163 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 164 | /// ~~~~~~~~~~~~~ | ||
| 165 | /// | ||
| 166 | inline int ATTRIBUTE_HIDDEN Show(const std::string& heading, | ||
| 167 | const std::vector<std::pair<int, std::string>>& entries) | ||
| 168 | { | ||
| 169 | using namespace ::kodi::addon; | ||
| 170 | unsigned int size = static_cast<unsigned int>(entries.size()); | ||
| 171 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | ||
| 172 | for (unsigned int i = 0; i < size; ++i) | ||
| 173 | { | ||
| 174 | cEntries[i] = entries[i].second.c_str(); | ||
| 175 | } | ||
| 176 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 177 | free(cEntries); | ||
| 178 | return ret; | ||
| 179 | } | ||
| 180 | //-------------------------------------------------------------------------- | ||
| 181 | }; | ||
| 182 | |||
| 183 | } /* namespace dialogs */ | ||
| 184 | } /* namespace gui */ | ||
| 185 | } /* namespace kodi */ | ||
