summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h
diff options
context:
space:
mode:
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.h94
1 files changed, 94 insertions, 0 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
index 47afc23..39b21b4 100644
--- 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
@@ -91,6 +91,100 @@ namespace dialogs
91 return ret; 91 return ret;
92 } 92 }
93 //-------------------------------------------------------------------------- 93 //--------------------------------------------------------------------------
94
95 //==========================================================================
96 ///
97 /// \ingroup cpp_kodi_gui_dialogs_ContextMenu
98 /// @brief Show a context menu dialog about given parts.
99 ///
100 /// @param[in] heading Dialog heading name
101 /// @param[in] entries String list about entries
102 /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled
103 ///
104 ///
105 ///-------------------------------------------------------------------------
106 ///
107 /// **Example:**
108 /// ~~~~~~~~~~~~~{.cpp}
109 /// #include <kodi/gui/dialogs/ContextMenu.h>
110 ///
111 /// const std::vector<std::pair<std::string, std::string>> entries
112 /// {
113 /// { "ID 1", "Test 1" },
114 /// { "ID 2", "Test 2" },
115 /// { "ID 3", "Test 3" },
116 /// { "ID 4", "Test 4" },
117 /// { "ID 5", "Test 5" }
118 /// };
119 ///
120 /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries);
121 /// if (selected < 0)
122 /// fprintf(stderr, "Item selection canceled\n");
123 /// else
124 /// fprintf(stderr, "Selected item is: %i\n", selected);
125 /// ~~~~~~~~~~~~~
126 ///
127 inline int Show(const std::string& heading, const std::vector<std::pair<std::string, std::string>>& entries)
128 {
129 using namespace ::kodi::addon;
130 unsigned int size = entries.size();
131 const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**)));
132 for (unsigned int i = 0; i < size; ++i)
133 {
134 cEntries[i] = entries[i].second.c_str();
135 }
136 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
137 free(cEntries);
138 return ret;
139 }
140 //--------------------------------------------------------------------------
141
142 //==========================================================================
143 ///
144 /// \ingroup cpp_kodi_gui_dialogs_ContextMenu
145 /// @brief Show a context menu dialog about given parts.
146 ///
147 /// @param[in] heading Dialog heading name
148 /// @param[in] entries String list about entries
149 /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled
150 ///
151 ///
152 ///-------------------------------------------------------------------------
153 ///
154 /// **Example:**
155 /// ~~~~~~~~~~~~~{.cpp}
156 /// #include <kodi/gui/dialogs/ContextMenu.h>
157 ///
158 /// const std::vector<std::pair<int, std::string>> entries
159 /// {
160 /// { 1, "Test 1" },
161 /// { 2, "Test 2" },
162 /// { 3, "Test 3" },
163 /// { 4, "Test 4" },
164 /// { 5, "Test 5" }
165 /// };
166 ///
167 /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries);
168 /// if (selected < 0)
169 /// fprintf(stderr, "Item selection canceled\n");
170 /// else
171 /// fprintf(stderr, "Selected item is: %i\n", selected);
172 /// ~~~~~~~~~~~~~
173 ///
174 inline int Show(const std::string& heading, const std::vector<std::pair<int, std::string>>& entries)
175 {
176 using namespace ::kodi::addon;
177 unsigned int size = entries.size();
178 const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**)));
179 for (unsigned int i = 0; i < size; ++i)
180 {
181 cEntries[i] = entries[i].second.c_str();
182 }
183 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
184 free(cEntries);
185 return ret;
186 }
187 //--------------------------------------------------------------------------
94 }; 188 };
95 189
96} /* namespace dialogs */ 190} /* namespace dialogs */