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