summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2017-07-23 16:59:43 +0200
committermanuel <manuel@mausz.at>2017-07-23 16:59:43 +0200
commit4c3251ec645c8b71820dab7e51e612e5919d4e75 (patch)
tree9533268a93e58fc2e16de1b8ee3fafe3784e5225 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h
parentf44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (diff)
downloadkodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.gz
kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.tar.bz2
kodi-pvr-build-4c3251ec645c8b71820dab7e51e612e5919d4e75.zip
sync with upstream
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.h98
1 files changed, 98 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
new file mode 100644
index 0000000..47afc23
--- /dev/null
+++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/ContextMenu.h
@@ -0,0 +1,98 @@
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 "../definitions.h"
23#include "../../AddonBase.h"
24
25namespace kodi
26{
27namespace gui
28{
29namespace dialogs
30{
31
32 //============================================================================
33 ///
34 /// \defgroup cpp_kodi_gui_dialogs_ContextMenu Dialog Context Menu
35 /// \ingroup cpp_kodi_gui
36 /// @brief \cpp_namespace{ kodi::gui::dialogs::ContextMenu }
37 /// **Context menu dialog**
38 ///
39 /// The function listed below permits the call of a dialogue as context menu to
40 /// select of an entry as a key
41 ///
42 /// It has the header \ref ContextMenu.h "#include <kodi/gui/dialogs/ContextMenu.h>"
43 /// be included to enjoy it.
44 ///
45 ///
46 namespace ContextMenu
47 {
48 //==========================================================================
49 ///
50 /// \ingroup cpp_kodi_gui_dialogs_ContextMenu
51 /// @brief Show a context menu dialog about given parts.
52 ///
53 /// @param[in] heading Dialog heading name
54 /// @param[in] entries String list about entries
55 /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled
56 ///
57 ///
58 ///-------------------------------------------------------------------------
59 ///
60 /// **Example:**
61 /// ~~~~~~~~~~~~~{.cpp}
62 /// #include <kodi/gui/dialogs/ContextMenu.h>
63 ///
64 /// const std::vector<std::string> entries
65 /// {
66 /// "Test 1",
67 /// "Test 2",
68 /// "Test 3",
69 /// "Test 4",
70 /// "Test 5"
71 /// };
72 ///
73 /// int selected = kodi::gui::dialogs::ContextMenu::Show("Test selection", entries);
74 /// if (selected < 0)
75 /// fprintf(stderr, "Item selection canceled\n");
76 /// else
77 /// fprintf(stderr, "Selected item is: %i\n", selected);
78 /// ~~~~~~~~~~~~~
79 ///
80 inline int Show(const std::string& heading, const std::vector<std::string>& entries)
81 {
82 using namespace ::kodi::addon;
83 unsigned int size = entries.size();
84 const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**)));
85 for (unsigned int i = 0; i < size; ++i)
86 {
87 cEntries[i] = entries[i].c_str();
88 }
89 int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size);
90 free(cEntries);
91 return ret;
92 }
93 //--------------------------------------------------------------------------
94 };
95
96} /* namespace dialogs */
97} /* namespace gui */
98} /* namespace kodi */