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/YesNo.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/YesNo.h')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h new file mode 100644 index 0000000..d9c34ff --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/dialogs/YesNo.h | |||
| @@ -0,0 +1,190 @@ | |||
| 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_YesNo Dialog Yes/No | ||
| 35 | /// \ingroup cpp_kodi_gui | ||
| 36 | /// @{ | ||
| 37 | /// @brief \cpp_namespace{ kodi::gui::dialogs::YesNo } | ||
| 38 | /// **Yes / No dialog** | ||
| 39 | /// | ||
| 40 | /// The Yes / No dialog can be used to inform the user about questions and get | ||
| 41 | /// the answer. | ||
| 42 | /// | ||
| 43 | /// In order to achieve a line break is a <b>\\n</b> directly in the text or | ||
| 44 | /// in the <em>"./resources/language/resource.language.??_??/strings.po"</em> | ||
| 45 | /// to call with <b>std::string kodi::general::GetLocalizedString(...);</b>. | ||
| 46 | /// | ||
| 47 | /// It has the header \ref YesNo.h "#include <kodi/gui/dialogs/YesNo.h>" | ||
| 48 | /// be included to enjoy it. | ||
| 49 | /// | ||
| 50 | /// | ||
| 51 | namespace YesNo | ||
| 52 | { | ||
| 53 | //========================================================================== | ||
| 54 | /// | ||
| 55 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 56 | /// @brief Use dialog to get numeric new password with one text string shown | ||
| 57 | /// everywhere and cancel return field | ||
| 58 | /// | ||
| 59 | /// @param[in] heading Dialog heading | ||
| 60 | /// @param[in] text Multi-line text | ||
| 61 | /// @param[out] canceled Return value about cancel button | ||
| 62 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 63 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 64 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 65 | /// | ||
| 66 | /// @note It is preferred to only use this as it is actually a multi-line text. | ||
| 67 | /// | ||
| 68 | /// | ||
| 69 | ///------------------------------------------------------------------------- | ||
| 70 | /// | ||
| 71 | /// **Example:** | ||
| 72 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 73 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 74 | /// | ||
| 75 | /// bool canceled; | ||
| 76 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 77 | /// "Yes / No test call", /* The Header */ | ||
| 78 | /// "You has opened Yes / No dialog for test\n\nIs this OK for you?", | ||
| 79 | /// canceled, /* return value about cancel button */ | ||
| 80 | /// "Not really", /* No label, is optional and if empty "No" */ | ||
| 81 | /// "Ohhh yes"); /* Yes label, also optional and if empty "Yes" */ | ||
| 82 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 83 | /// ret ? "yes" : "no", | ||
| 84 | /// canceled ? "canceled" : "not canceled"); | ||
| 85 | /// ~~~~~~~~~~~~~ | ||
| 86 | /// | ||
| 87 | inline bool ShowAndGetInput(const std::string& heading, const std::string& text, | ||
| 88 | bool& canceled, const std::string& noLabel = "", | ||
| 89 | const std::string& yesLabel = "") | ||
| 90 | { | ||
| 91 | using namespace ::kodi::addon; | ||
| 92 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 93 | heading.c_str(), text.c_str(), &canceled, | ||
| 94 | noLabel.c_str(), yesLabel.c_str()); | ||
| 95 | } | ||
| 96 | //-------------------------------------------------------------------------- | ||
| 97 | |||
| 98 | //========================================================================== | ||
| 99 | /// | ||
| 100 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 101 | /// @brief Use dialog to get numeric new password with separated line strings | ||
| 102 | /// | ||
| 103 | /// @param[in] heading Dialog heading | ||
| 104 | /// @param[in] line0 Line #0 text | ||
| 105 | /// @param[in] line1 Line #1 text | ||
| 106 | /// @param[in] line2 Line #2 text | ||
| 107 | /// @param[in] noLabel [opt] label to put on the no button. | ||
| 108 | /// @param[in] yesLabel [opt] label to put on the yes button. | ||
| 109 | /// @return Returns True if 'Yes' was pressed, else False. | ||
| 110 | /// | ||
| 111 | /// | ||
| 112 | ///------------------------------------------------------------------------- | ||
| 113 | /// | ||
| 114 | /// **Example:** | ||
| 115 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 116 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 117 | /// | ||
| 118 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 119 | /// "Yes / No test call", // The Header | ||
| 120 | /// "You has opened Yes / No dialog for test", | ||
| 121 | /// "", | ||
| 122 | /// "Is this OK for you?", | ||
| 123 | /// "Not really", // No label, is optional and if empty "No" | ||
| 124 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 125 | /// fprintf(stderr, "You has called Yes/No, returned '%s'\n", | ||
| 126 | /// ret ? "yes" : "no"); | ||
| 127 | /// ~~~~~~~~~~~~~ | ||
| 128 | /// | ||
| 129 | inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, | ||
| 130 | const std::string& line2, const std::string& noLabel = "", | ||
| 131 | const std::string& yesLabel = "") | ||
| 132 | { | ||
| 133 | using namespace ::kodi::addon; | ||
| 134 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 135 | heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), | ||
| 136 | noLabel.c_str(), yesLabel.c_str()); | ||
| 137 | } | ||
| 138 | //-------------------------------------------------------------------------- | ||
| 139 | |||
| 140 | //========================================================================== | ||
| 141 | /// | ||
| 142 | /// \ingroup cpp_kodi_gui_dialogs_YesNo | ||
| 143 | /// @brief Use dialog to get numeric new password with separated line strings and cancel return field | ||
| 144 | /// | ||
| 145 | /// @param[in] heading Dialog heading | ||
| 146 | /// @param[in] line0 Line #0 text | ||
| 147 | /// @param[in] line1 Line #1 text | ||
| 148 | /// @param[in] line2 Line #2 text | ||
| 149 | /// @param[out] canceled Return value about cancel button | ||
| 150 | /// @param[in] noLabel [opt] label to put on the no button | ||
| 151 | /// @param[in] yesLabel [opt] label to put on the yes button | ||
| 152 | /// @return Returns True if 'Yes' was pressed, else False | ||
| 153 | /// | ||
| 154 | /// | ||
| 155 | ///------------------------------------------------------------------------- | ||
| 156 | /// | ||
| 157 | /// **Example:** | ||
| 158 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 159 | /// #include <kodi/gui/dialogs/YesNo.h> | ||
| 160 | /// | ||
| 161 | /// bool canceled; | ||
| 162 | /// bool ret = kodi::gui::dialogs::YesNo::ShowAndGetInput( | ||
| 163 | /// "Yes / No test call", // The Header | ||
| 164 | /// "You has opened Yes / No dialog for test", | ||
| 165 | /// "", | ||
| 166 | /// "Is this OK for you?", | ||
| 167 | /// canceled, // return value about cancel button | ||
| 168 | /// "Not really", // No label, is optional and if empty "No" | ||
| 169 | /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" | ||
| 170 | /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", | ||
| 171 | /// ret ? "yes" : "no", | ||
| 172 | /// canceled ? "canceled" : "not canceled"); | ||
| 173 | /// ~~~~~~~~~~~~~ | ||
| 174 | /// | ||
| 175 | inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, | ||
| 176 | const std::string& line2, bool& canceled, const std::string& noLabel = "", | ||
| 177 | const std::string& yesLabel = "") | ||
| 178 | { | ||
| 179 | using namespace ::kodi::addon; | ||
| 180 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 181 | heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), | ||
| 182 | &canceled, noLabel.c_str(), yesLabel.c_str()); | ||
| 183 | } | ||
| 184 | //-------------------------------------------------------------------------- | ||
| 185 | }; | ||
| 186 | /// @} | ||
| 187 | |||
| 188 | } /* namespace dialogs */ | ||
| 189 | } /* namespace gui */ | ||
| 190 | } /* namespace kodi */ | ||
