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