diff options
| author | manuel <manuel@mausz.at> | 2017-07-23 16:59:43 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2017-07-23 16:59:43 +0200 |
| commit | 4c3251ec645c8b71820dab7e51e612e5919d4e75 (patch) | |
| tree | 9533268a93e58fc2e16de1b8ee3fafe3784e5225 /xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h | |
| parent | f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 (diff) | |
| download | kodi-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/Select.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h new file mode 100644 index 0000000..963c84c --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/Select.h | |||
| @@ -0,0 +1,105 @@ | |||
| 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 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | namespace dialogs | ||
| 30 | { | ||
| 31 | |||
| 32 | //============================================================================ | ||
| 33 | /// | ||
| 34 | /// \defgroup cpp_kodi_gui_dialogs_Select Dialog Select | ||
| 35 | /// \ingroup cpp_kodi_gui | ||
| 36 | /// @{ | ||
| 37 | /// @brief \cpp_namespace{ kodi::gui::dialogs::Select } | ||
| 38 | /// **Selection dialog** | ||
| 39 | /// | ||
| 40 | /// The function listed below permits the call of a dialogue to select of an | ||
| 41 | /// entry as a key | ||
| 42 | /// | ||
| 43 | /// It has the header \ref Select.h "#include <kodi/gui/dialogs/Select.h>" | ||
| 44 | /// be included to enjoy it. | ||
| 45 | /// | ||
| 46 | /// | ||
| 47 | namespace Select | ||
| 48 | { | ||
| 49 | //========================================================================== | ||
| 50 | /// | ||
| 51 | /// \ingroup cpp_kodi_gui_dialogs_Select | ||
| 52 | /// @brief Show a selection dialog about given parts. | ||
| 53 | /// | ||
| 54 | /// @param[in] heading Dialog heading name | ||
| 55 | /// @param[in] entries String list about entries | ||
| 56 | /// @param[in] selected [opt] Predefined selection (default is | ||
| 57 | /// <tt>-1</tt> for the first) | ||
| 58 | /// @param[in] autoclose [opt] To close dialog automatic after the given | ||
| 59 | /// time in ms. As '0' it stays open. | ||
| 60 | /// @return The selected entry, if return <tt>-1</tt> was | ||
| 61 | /// nothing selected or canceled | ||
| 62 | /// | ||
| 63 | /// | ||
| 64 | ///------------------------------------------------------------------------- | ||
| 65 | /// | ||
| 66 | /// **Example:** | ||
| 67 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 68 | /// #include <kodi/gui/dialogs/Select.h> | ||
| 69 | /// | ||
| 70 | /// const std::vector<std::string> entries | ||
| 71 | /// { | ||
| 72 | /// "Test 1", | ||
| 73 | /// "Test 2", | ||
| 74 | /// "Test 3", | ||
| 75 | /// "Test 4", | ||
| 76 | /// "Test 5" | ||
| 77 | /// }; | ||
| 78 | /// | ||
| 79 | /// int selected = kodi::gui::dialogs::Select::Show("Test selection", entries, -1); | ||
| 80 | /// if (selected < 0) | ||
| 81 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 82 | /// else | ||
| 83 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 84 | /// ~~~~~~~~~~~~~ | ||
| 85 | /// | ||
| 86 | inline int Show(const std::string& heading, const std::vector<std::string>& entries, int selected = -1, unsigned int autoclose = 0) | ||
| 87 | { | ||
| 88 | using namespace ::kodi::addon; | ||
| 89 | unsigned int size = entries.size(); | ||
| 90 | const char** cEntries = (const char**)malloc(size*sizeof(const char**)); | ||
| 91 | for (unsigned int i = 0; i < size; ++i) | ||
| 92 | { | ||
| 93 | cEntries[i] = entries[i].c_str(); | ||
| 94 | } | ||
| 95 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, autoclose); | ||
| 96 | free(cEntries); | ||
| 97 | return ret; | ||
| 98 | } | ||
| 99 | //-------------------------------------------------------------------------- | ||
| 100 | }; | ||
| 101 | /// @} | ||
| 102 | |||
| 103 | } /* namespace dialogs */ | ||
| 104 | } /* namespace gui */ | ||
| 105 | } /* namespace kodi */ | ||
