diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui')
14 files changed, 3374 insertions, 0 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h new file mode 100644 index 0000000..66a1c90 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h | |||
| @@ -0,0 +1,95 @@ | |||
| 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_DialogContextMenu Dialog Context Menu | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_namespace{ kodi::gui::DialogContextMenu } | ||
| 35 | /// **Context menu dialog** | ||
| 36 | /// | ||
| 37 | /// The function listed below permits the call of a dialogue as context menu to | ||
| 38 | /// select of an entry as a key | ||
| 39 | /// | ||
| 40 | /// It has the header \ref DialogContextMenu.h "#include <kodi/gui/DialogContextMenu.h>" | ||
| 41 | /// be included to enjoy it. | ||
| 42 | /// | ||
| 43 | /// | ||
| 44 | namespace DialogContextMenu | ||
| 45 | { | ||
| 46 | //========================================================================== | ||
| 47 | /// | ||
| 48 | /// \ingroup cpp_kodi_gui_DialogContextMenu | ||
| 49 | /// @brief Show a context menu dialog about given parts. | ||
| 50 | /// | ||
| 51 | /// @param[in] heading Dialog heading name | ||
| 52 | /// @param[in] entries String list about entries | ||
| 53 | /// @return The selected entry, if return <tt>-1</tt> was nothing selected or canceled | ||
| 54 | /// | ||
| 55 | /// | ||
| 56 | ///------------------------------------------------------------------------- | ||
| 57 | /// | ||
| 58 | /// **Example:** | ||
| 59 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 60 | /// #include <kodi/gui/DialogContextMenu.h> | ||
| 61 | /// | ||
| 62 | /// const std::vector<std::string> entries | ||
| 63 | /// { | ||
| 64 | /// "Test 1", | ||
| 65 | /// "Test 2", | ||
| 66 | /// "Test 3", | ||
| 67 | /// "Test 4", | ||
| 68 | /// "Test 5" | ||
| 69 | /// }; | ||
| 70 | /// | ||
| 71 | /// int selected = kodi::gui::DialogContextMenu::Show("Test selection", entries); | ||
| 72 | /// if (selected < 0) | ||
| 73 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 74 | /// else | ||
| 75 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 76 | /// ~~~~~~~~~~~~~ | ||
| 77 | /// | ||
| 78 | inline int Show(const std::string& heading, const std::vector<std::string>& entries) | ||
| 79 | { | ||
| 80 | using namespace ::kodi::addon; | ||
| 81 | unsigned int size = entries.size(); | ||
| 82 | const char** cEntries = static_cast<const char**>(malloc(size*sizeof(const char**))); | ||
| 83 | for (unsigned int i = 0; i < size; ++i) | ||
| 84 | { | ||
| 85 | cEntries[i] = entries[i].c_str(); | ||
| 86 | } | ||
| 87 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); | ||
| 88 | free(cEntries); | ||
| 89 | return ret; | ||
| 90 | } | ||
| 91 | //-------------------------------------------------------------------------- | ||
| 92 | }; | ||
| 93 | |||
| 94 | } /* namespace gui */ | ||
| 95 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h new file mode 100644 index 0000000..b6f2deb --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h | |||
| @@ -0,0 +1,244 @@ | |||
| 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_CDialogExtendedProgress Dialog Extended Progress | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_class{ kodi::gui::CDialogExtendedProgress } | ||
| 35 | /// **Progress dialog shown for background work** | ||
| 36 | /// | ||
| 37 | /// The with \ref DialogExtendedProgress.h "#include <kodi/gui/DialogExtendedProgress.h>" | ||
| 38 | /// given class are basically used to create Kodi's extended progress. | ||
| 39 | /// | ||
| 40 | /// | ||
| 41 | /// -------------------------------------------------------------------------- | ||
| 42 | /// | ||
| 43 | /// **Example:** | ||
| 44 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 45 | /// #include <kodi/gui/DialogExtendedProgress.h> | ||
| 46 | /// | ||
| 47 | /// kodi::gui::CDialogExtendedProgress *ext_progress = new kodi::gui::CDialogExtendedProgress("Test Extended progress"); | ||
| 48 | /// ext_progress->SetText("Test progress"); | ||
| 49 | /// for (unsigned int i = 0; i < 50; i += 10) | ||
| 50 | /// { | ||
| 51 | /// ext_progress->SetProgress(i, 100); | ||
| 52 | /// sleep(1); | ||
| 53 | /// } | ||
| 54 | /// | ||
| 55 | /// ext_progress->SetTitle("Test Extended progress - Second round"); | ||
| 56 | /// ext_progress->SetText("Test progress - Step 2"); | ||
| 57 | /// | ||
| 58 | /// for (unsigned int i = 50; i < 100; i += 10) | ||
| 59 | /// { | ||
| 60 | /// ext_progress->SetProgress(i, 100); | ||
| 61 | /// sleep(1); | ||
| 62 | /// } | ||
| 63 | /// delete ext_progress; | ||
| 64 | /// ~~~~~~~~~~~~~ | ||
| 65 | /// | ||
| 66 | class CDialogExtendedProgress | ||
| 67 | { | ||
| 68 | public: | ||
| 69 | //========================================================================== | ||
| 70 | /// | ||
| 71 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 72 | /// Construct a new dialog | ||
| 73 | /// | ||
| 74 | /// @param[in] title Title string | ||
| 75 | /// | ||
| 76 | CDialogExtendedProgress(const std::string& title = "") | ||
| 77 | { | ||
| 78 | using namespace ::kodi::addon; | ||
| 79 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); | ||
| 80 | if (!m_DialogHandle) | ||
| 81 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); | ||
| 82 | } | ||
| 83 | //-------------------------------------------------------------------------- | ||
| 84 | |||
| 85 | //========================================================================== | ||
| 86 | /// | ||
| 87 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 88 | /// Destructor | ||
| 89 | /// | ||
| 90 | ~CDialogExtendedProgress() | ||
| 91 | { | ||
| 92 | using namespace ::kodi::addon; | ||
| 93 | if (m_DialogHandle) | ||
| 94 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 95 | } | ||
| 96 | //-------------------------------------------------------------------------- | ||
| 97 | |||
| 98 | //========================================================================== | ||
| 99 | /// | ||
| 100 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 101 | /// @brief Get the used title | ||
| 102 | /// | ||
| 103 | /// @return Title string | ||
| 104 | /// | ||
| 105 | std::string Title() const | ||
| 106 | { | ||
| 107 | using namespace ::kodi::addon; | ||
| 108 | std::string text; | ||
| 109 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 110 | if (strMsg != nullptr) | ||
| 111 | { | ||
| 112 | if (std::strlen(strMsg)) | ||
| 113 | text = strMsg; | ||
| 114 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 115 | } | ||
| 116 | return text; | ||
| 117 | } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 123 | /// @brief To set the title of dialog | ||
| 124 | /// | ||
| 125 | /// @param[in] title Title string | ||
| 126 | /// | ||
| 127 | void SetTitle(const std::string& title) | ||
| 128 | { | ||
| 129 | using namespace ::kodi::addon; | ||
| 130 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 137 | /// @brief Get the used text information string | ||
| 138 | /// | ||
| 139 | /// @return Text string | ||
| 140 | /// | ||
| 141 | std::string Text() const | ||
| 142 | { | ||
| 143 | using namespace ::kodi::addon; | ||
| 144 | std::string text; | ||
| 145 | char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 146 | if (strMsg != nullptr) | ||
| 147 | { | ||
| 148 | if (std::strlen(strMsg)) | ||
| 149 | text = strMsg; | ||
| 150 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); | ||
| 151 | } | ||
| 152 | return text; | ||
| 153 | } | ||
| 154 | //-------------------------------------------------------------------------- | ||
| 155 | |||
| 156 | //========================================================================== | ||
| 157 | /// | ||
| 158 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 159 | /// @brief To set the used text information string | ||
| 160 | /// | ||
| 161 | /// @param[in] text information text to set | ||
| 162 | /// | ||
| 163 | void SetText(const std::string& text) | ||
| 164 | { | ||
| 165 | using namespace ::kodi::addon; | ||
| 166 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); | ||
| 167 | } | ||
| 168 | //-------------------------------------------------------------------------- | ||
| 169 | |||
| 170 | //========================================================================== | ||
| 171 | /// | ||
| 172 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 173 | /// @brief To ask dialog is finished | ||
| 174 | /// | ||
| 175 | /// @return True if on end | ||
| 176 | /// | ||
| 177 | bool IsFinished() const | ||
| 178 | { | ||
| 179 | using namespace ::kodi::addon; | ||
| 180 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 181 | } | ||
| 182 | //-------------------------------------------------------------------------- | ||
| 183 | |||
| 184 | //========================================================================== | ||
| 185 | /// | ||
| 186 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 187 | /// @brief Mark progress finished | ||
| 188 | /// | ||
| 189 | void MarkFinished() | ||
| 190 | { | ||
| 191 | using namespace ::kodi::addon; | ||
| 192 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 193 | } | ||
| 194 | //-------------------------------------------------------------------------- | ||
| 195 | |||
| 196 | //========================================================================== | ||
| 197 | /// | ||
| 198 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 199 | /// @brief Get the current progress position as percent | ||
| 200 | /// | ||
| 201 | /// @return Position | ||
| 202 | /// | ||
| 203 | float Percentage() const | ||
| 204 | { | ||
| 205 | using namespace ::kodi::addon; | ||
| 206 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 207 | } | ||
| 208 | //-------------------------------------------------------------------------- | ||
| 209 | |||
| 210 | //========================================================================== | ||
| 211 | /// | ||
| 212 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 213 | /// @brief To set the current progress position as percent | ||
| 214 | /// | ||
| 215 | /// @param[in] percentage Position to use from 0.0 to 100.0 | ||
| 216 | /// | ||
| 217 | void SetPercentage(float percentage) | ||
| 218 | { | ||
| 219 | using namespace ::kodi::addon; | ||
| 220 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 221 | } | ||
| 222 | //-------------------------------------------------------------------------- | ||
| 223 | |||
| 224 | //========================================================================== | ||
| 225 | /// | ||
| 226 | /// \ingroup cpp_kodi_gui_CDialogExtendedProgress | ||
| 227 | /// @brief To set progress position with predefined places | ||
| 228 | /// | ||
| 229 | /// @param[in] currentItem Place position to use | ||
| 230 | /// @param[in] itemCount Amount of used places | ||
| 231 | /// | ||
| 232 | void SetProgress(int currentItem, int itemCount) | ||
| 233 | { | ||
| 234 | using namespace ::kodi::addon; | ||
| 235 | CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); | ||
| 236 | } | ||
| 237 | //-------------------------------------------------------------------------- | ||
| 238 | |||
| 239 | private: | ||
| 240 | void* m_DialogHandle; | ||
| 241 | }; | ||
| 242 | |||
| 243 | } /* namespace gui */ | ||
| 244 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h new file mode 100644 index 0000000..e348125 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h | |||
| @@ -0,0 +1,293 @@ | |||
| 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_DialogFileBrowser Dialog File Browser | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_namespace{ kodi::gui::DialogFileBrowser } | ||
| 35 | /// **File browser dialog** | ||
| 36 | /// | ||
| 37 | /// The functions listed below of the class "DialogFileBrowser" offer | ||
| 38 | /// the possibility to select to a file by the user of the add-on. | ||
| 39 | /// | ||
| 40 | /// It allows all the options that are possible in Kodi itself and offers all | ||
| 41 | /// support file types. | ||
| 42 | /// | ||
| 43 | /// It has the header \ref DialogFileBrowser.h "#include <kodi/gui/DialogFileBrowser.h>" | ||
| 44 | /// be included to enjoy it. | ||
| 45 | /// | ||
| 46 | namespace DialogFileBrowser | ||
| 47 | { | ||
| 48 | //========================================================================== | ||
| 49 | /// | ||
| 50 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 51 | /// @brief Directory selection dialog | ||
| 52 | /// | ||
| 53 | /// @param[in] shares With Shares becomes the available start folders | ||
| 54 | /// be set. | ||
| 55 | /// @param[in] heading Dialog header name | ||
| 56 | /// @param[in,out] path As in the path to start and return value about | ||
| 57 | /// selected directory | ||
| 58 | /// @param[in] writeOnly If set only writeable folders are shown. | ||
| 59 | /// @return False if selection becomes canceled. | ||
| 60 | /// | ||
| 61 | /// **Example:** | ||
| 62 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 63 | /// #include <kodi/gui/DialogFileBrowser.h> | ||
| 64 | /// | ||
| 65 | /// /* | ||
| 66 | /// * Example show directory selection dialog with on 'share' (first value) | ||
| 67 | /// * defined directory types. | ||
| 68 | /// * | ||
| 69 | /// * If this becomes leaved empty and 'directory' is empty goes it to the | ||
| 70 | /// * base path of the hard disk. | ||
| 71 | /// * | ||
| 72 | /// * Also can be with path written to 'directory' before the dialog forced | ||
| 73 | /// * to a start place. | ||
| 74 | /// */ | ||
| 75 | /// std::string directory; | ||
| 76 | /// bool ret = kodi::gui::DialogFileBrowser::ShowAndGetDirectory("local|network|removable", | ||
| 77 | /// "Test directory selection", | ||
| 78 | /// directory, | ||
| 79 | /// false); | ||
| 80 | /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); | ||
| 81 | /// ~~~~~~~~~~~~~ | ||
| 82 | /// | ||
| 83 | inline bool ShowAndGetDirectory(const std::string& shares, const std::string& heading, std::string& path, bool writeOnly = false) | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | char* retString = nullptr; | ||
| 87 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 88 | shares.c_str(), heading.c_str(), path.c_str(), &retString, writeOnly); | ||
| 89 | if (retString != nullptr) | ||
| 90 | { | ||
| 91 | if (std::strlen(retString)) | ||
| 92 | path = retString; | ||
| 93 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 94 | } | ||
| 95 | return ret; | ||
| 96 | } | ||
| 97 | //-------------------------------------------------------------------------- | ||
| 98 | |||
| 99 | //========================================================================== | ||
| 100 | /// | ||
| 101 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 102 | /// @brief File selection dialog | ||
| 103 | /// | ||
| 104 | /// @param[in] shares With Shares becomes the available start | ||
| 105 | /// folders be set. | ||
| 106 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 107 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 108 | /// @param[in] heading Dialog header name | ||
| 109 | /// @param[in,out] path As in the path to start and Return value | ||
| 110 | /// about selected file | ||
| 111 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 112 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 113 | /// handled as directories. | ||
| 114 | /// @return False if selection becomes canceled. | ||
| 115 | /// | ||
| 116 | inline bool ShowAndGetFile(const std::string& shares, const std::string& mask, const std::string& heading, | ||
| 117 | std::string& path, bool useThumbs = false, bool useFileDirectories = false) | ||
| 118 | { | ||
| 119 | using namespace ::kodi::addon; | ||
| 120 | char* retString = nullptr; | ||
| 121 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 122 | shares.c_str(), mask.c_str(), heading.c_str(), path.c_str(), &retString, | ||
| 123 | useThumbs, useFileDirectories); | ||
| 124 | if (retString != nullptr) | ||
| 125 | { | ||
| 126 | if (std::strlen(retString)) | ||
| 127 | path = retString; | ||
| 128 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 129 | } | ||
| 130 | return ret; | ||
| 131 | } | ||
| 132 | //-------------------------------------------------------------------------- | ||
| 133 | |||
| 134 | //========================================================================== | ||
| 135 | /// | ||
| 136 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 137 | /// @brief File selection from a directory | ||
| 138 | /// | ||
| 139 | /// @param[in] directory The directory name where the dialog | ||
| 140 | /// start, possible are normal names and | ||
| 141 | /// kodi's special names. | ||
| 142 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 143 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 144 | /// @param[in] heading Dialog header name | ||
| 145 | /// @param[in,out] path As in the path to start and Return value | ||
| 146 | /// about selected file | ||
| 147 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 148 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 149 | /// handled as directories. | ||
| 150 | /// @param[in] singleList | ||
| 151 | /// @return False if selection becomes canceled. | ||
| 152 | /// | ||
| 153 | inline bool ShowAndGetFileFromDir(const std::string& directory, const std::string& mask, const std::string& heading, std::string& path, | ||
| 154 | bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) | ||
| 155 | { | ||
| 156 | using namespace ::kodi::addon; | ||
| 157 | char* retString = nullptr; | ||
| 158 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 159 | directory.c_str(), mask.c_str(), heading.c_str(), | ||
| 160 | path.c_str(), &retString, useThumbs, | ||
| 161 | useFileDirectories, singleList); | ||
| 162 | if (retString != nullptr) | ||
| 163 | { | ||
| 164 | if (std::strlen(retString)) | ||
| 165 | path = retString; | ||
| 166 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 167 | } | ||
| 168 | return ret; | ||
| 169 | } | ||
| 170 | //-------------------------------------------------------------------------- | ||
| 171 | |||
| 172 | //========================================================================== | ||
| 173 | /// | ||
| 174 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 175 | /// @brief File selection dialog to get several in to a list | ||
| 176 | /// | ||
| 177 | /// @param[in] shares With Shares becomes the available start | ||
| 178 | /// folders be set. | ||
| 179 | /// @param[in] mask The mask to filter visible files, e.g. | ||
| 180 | /// ".m3u|.pls|.b4s|.wpl". | ||
| 181 | /// @param[in] heading Dialog header name | ||
| 182 | /// @param[out] fileList Return value about selected files | ||
| 183 | /// @param[in] useThumbs If set show thumbs if possible on dialog. | ||
| 184 | /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are | ||
| 185 | /// handled as directories. | ||
| 186 | /// @return False if selection becomes canceled. | ||
| 187 | /// | ||
| 188 | inline bool ShowAndGetFileList(const std::string& shares, const std::string& mask, const std::string& heading, | ||
| 189 | std::vector<std::string>& fileList, bool useThumbs = false, bool useFileDirectories = false) | ||
| 190 | { | ||
| 191 | using namespace ::kodi::addon; | ||
| 192 | char** list = nullptr; | ||
| 193 | unsigned int listSize = 0; | ||
| 194 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 195 | shares.c_str(), mask.c_str(), heading.c_str(), &list, &listSize, | ||
| 196 | useThumbs, useFileDirectories); | ||
| 197 | if (ret) | ||
| 198 | { | ||
| 199 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 200 | fileList.push_back(list[i]); | ||
| 201 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 202 | } | ||
| 203 | return ret; | ||
| 204 | } | ||
| 205 | //-------------------------------------------------------------------------- | ||
| 206 | |||
| 207 | //========================================================================== | ||
| 208 | /// | ||
| 209 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 210 | /// @brief Source selection dialog | ||
| 211 | /// | ||
| 212 | /// @param[in,out] path As in the path to start and Return value | ||
| 213 | /// about selected source | ||
| 214 | /// @param[in] allowNetworkShares Allow also access to network | ||
| 215 | /// @param[in] additionalShare With additionalShare becomes the available | ||
| 216 | /// start folders be set (optional). | ||
| 217 | /// @param[in] type | ||
| 218 | /// @return False if selection becomes canceled. | ||
| 219 | /// | ||
| 220 | inline bool ShowAndGetSource(std::string& path, bool allowNetworkShares, const std::string& additionalShare = "", const std::string& type = "") | ||
| 221 | { | ||
| 222 | using namespace ::kodi::addon; | ||
| 223 | char* retString = nullptr; | ||
| 224 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, | ||
| 225 | allowNetworkShares, additionalShare.c_str(), type.c_str()); | ||
| 226 | if (retString != nullptr) | ||
| 227 | { | ||
| 228 | if (std::strlen(retString)) | ||
| 229 | path = retString; | ||
| 230 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 231 | } | ||
| 232 | return ret; | ||
| 233 | } | ||
| 234 | //-------------------------------------------------------------------------- | ||
| 235 | |||
| 236 | //========================================================================== | ||
| 237 | /// | ||
| 238 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 239 | /// @brief Image selection dialog | ||
| 240 | /// | ||
| 241 | /// @param[in] shares With Shares becomes the available start folders be | ||
| 242 | /// set. | ||
| 243 | /// @param[in] heading Dialog header name | ||
| 244 | /// @param[out] path Return value about selected image | ||
| 245 | /// @return False if selection becomes canceled. | ||
| 246 | /// | ||
| 247 | inline bool ShowAndGetImage(const std::string& shares, const std::string& heading, std::string& path) | ||
| 248 | { | ||
| 249 | using namespace ::kodi::addon; | ||
| 250 | char* retString = nullptr; | ||
| 251 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 252 | shares.c_str(), heading.c_str(), path.c_str(), &retString); | ||
| 253 | if (retString != nullptr) | ||
| 254 | { | ||
| 255 | if (std::strlen(retString)) | ||
| 256 | path = retString; | ||
| 257 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 258 | } | ||
| 259 | return ret; | ||
| 260 | } | ||
| 261 | //-------------------------------------------------------------------------- | ||
| 262 | |||
| 263 | //========================================================================== | ||
| 264 | /// | ||
| 265 | /// \ingroup cpp_kodi_gui_DialogFileBrowser | ||
| 266 | /// @brief Image selection dialog to get several in to a list | ||
| 267 | /// | ||
| 268 | /// @param[in] shares With Shares becomes the available start folders | ||
| 269 | /// be set. | ||
| 270 | /// @param[in] heading Dialog header name | ||
| 271 | /// @param[out] file_list Return value about selected images | ||
| 272 | /// @return False if selection becomes canceled. | ||
| 273 | /// | ||
| 274 | inline bool ShowAndGetImageList(const std::string& shares, const std::string& heading, std::vector<std::string>& file_list) | ||
| 275 | { | ||
| 276 | using namespace ::kodi::addon; | ||
| 277 | char** list = nullptr; | ||
| 278 | unsigned int listSize = 0; | ||
| 279 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 280 | shares.c_str(), heading.c_str(), &list, &listSize); | ||
| 281 | if (ret) | ||
| 282 | { | ||
| 283 | for (unsigned int i = 0; i < listSize; ++i) | ||
| 284 | file_list.push_back(list[i]); | ||
| 285 | CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); | ||
| 286 | } | ||
| 287 | return ret; | ||
| 288 | } | ||
| 289 | //-------------------------------------------------------------------------- | ||
| 290 | }; | ||
| 291 | |||
| 292 | } /* namespace gui */ | ||
| 293 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h new file mode 100644 index 0000000..9261972 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h | |||
| @@ -0,0 +1,416 @@ | |||
| 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_DialogKeyboard Dialog Keyboard | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_namespace{ kodi::gui::DialogKeyboard } | ||
| 35 | /// **Keyboard dialogs** | ||
| 36 | /// | ||
| 37 | /// The functions listed below have to be permitted by the user for the | ||
| 38 | /// representation of a keyboard around an input. | ||
| 39 | /// | ||
| 40 | /// The class supports several kinds, from an easy text choice up to the | ||
| 41 | /// passport Word production and their confirmation for add-on. | ||
| 42 | /// | ||
| 43 | /// It has the header \ref DialogKeyboard.h "#include <kodi/gui/DialogKeyboard.h>" | ||
| 44 | /// be included to enjoy it. | ||
| 45 | /// | ||
| 46 | namespace DialogKeyboard | ||
| 47 | { | ||
| 48 | //========================================================================== | ||
| 49 | /// | ||
| 50 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 51 | /// @brief Show keyboard with initial value `text` and replace with result | ||
| 52 | /// string. | ||
| 53 | /// | ||
| 54 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 55 | /// @param[in] heading String shown on dialog title. | ||
| 56 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 57 | /// @param[in] hiddenInput The inserted input is not shown as text. | ||
| 58 | /// @param[in] autoCloseMs To close the dialog after a specified | ||
| 59 | /// time, in milliseconds, default is 0 which | ||
| 60 | /// keeps the dialog open indefinitely. | ||
| 61 | /// @return true if successful display and user input. | ||
| 62 | /// false if unsuccessful display, no user | ||
| 63 | /// input, or canceled editing. | ||
| 64 | /// | ||
| 65 | /// | ||
| 66 | ///------------------------------------------------------------------------- | ||
| 67 | /// | ||
| 68 | /// **Example:** | ||
| 69 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 70 | /// #include <kodi/gui/DialogKeyboard.h> | ||
| 71 | /// | ||
| 72 | /// /* | ||
| 73 | /// * The example shows the display of keyboard call dialog at Kodi from the add-on. | ||
| 74 | /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0) | ||
| 75 | /// * to be released if not needed. | ||
| 76 | /// */ | ||
| 77 | /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a | ||
| 78 | /// entry text added */ | ||
| 79 | /// bool bRet = ::kodi::gui::DialogKeyboard::ShowAndGetInput(text, | ||
| 80 | /// "Demonstration text entry", | ||
| 81 | /// true, | ||
| 82 | /// false, | ||
| 83 | /// 0); | ||
| 84 | /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n", | ||
| 85 | /// text.c_str(), bRet ? "OK" : "Canceled"); | ||
| 86 | /// ~~~~~~~~~~~~~ | ||
| 87 | /// | ||
| 88 | inline bool ShowAndGetInput(std::string& text, const std::string& heading, bool allowEmptyResult, bool hiddenInput = false, unsigned int autoCloseMs = 0) | ||
| 89 | { | ||
| 90 | using namespace ::kodi::addon; | ||
| 91 | char* retString = nullptr; | ||
| 92 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 93 | text.c_str(), &retString, heading.c_str(), allowEmptyResult, | ||
| 94 | hiddenInput, autoCloseMs); | ||
| 95 | if (retString != nullptr) | ||
| 96 | { | ||
| 97 | if (std::strlen(retString)) | ||
| 98 | text = retString; | ||
| 99 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 100 | } | ||
| 101 | return ret; | ||
| 102 | } | ||
| 103 | //-------------------------------------------------------------------------- | ||
| 104 | |||
| 105 | //========================================================================== | ||
| 106 | /// | ||
| 107 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 108 | /// @brief The example shows the display of keyboard call dialog at Kodi | ||
| 109 | /// from the add-on. | ||
| 110 | /// | ||
| 111 | /// @param[out] text Overwritten with user input if return=true. | ||
| 112 | /// @param[in] allowEmptyResult If set to true keyboard can also exited | ||
| 113 | /// without entered text. | ||
| 114 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 115 | /// in milliseconds, default is 0 which keeps | ||
| 116 | /// the dialog open indefinitely. | ||
| 117 | /// @return true if successful display and user input. | ||
| 118 | /// false if unsuccessful display, no user | ||
| 119 | /// input, or canceled editing. | ||
| 120 | /// | ||
| 121 | inline bool ShowAndGetInput(std::string& text, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 122 | { | ||
| 123 | using namespace ::kodi::addon; | ||
| 124 | char* retString = nullptr; | ||
| 125 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 126 | text.c_str(), &retString, | ||
| 127 | allowEmptyResult, autoCloseMs); | ||
| 128 | if (retString != nullptr) | ||
| 129 | { | ||
| 130 | if (std::strlen(retString)) | ||
| 131 | text = retString; | ||
| 132 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 133 | } | ||
| 134 | return ret; | ||
| 135 | } | ||
| 136 | //-------------------------------------------------------------------------- | ||
| 137 | |||
| 138 | //========================================================================== | ||
| 139 | /// | ||
| 140 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 141 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 142 | /// `ShowAndVerifyNewPassword()` in that no second verification | ||
| 143 | /// | ||
| 144 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 145 | /// @param[in] heading String shown on dialog title. | ||
| 146 | /// @param[in] allowEmptyResult Whether a blank password is valid or not. | ||
| 147 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 148 | /// in milliseconds, default is 0 which keeps | ||
| 149 | /// the dialog open indefinitely. | ||
| 150 | /// @return true if successful display and user input. | ||
| 151 | /// false if unsuccessful display, no user | ||
| 152 | /// input, or canceled editing. | ||
| 153 | /// | ||
| 154 | inline bool ShowAndGetNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 155 | { | ||
| 156 | using namespace ::kodi::addon; | ||
| 157 | char* retString = nullptr; | ||
| 158 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 159 | newPassword.c_str(), &retString, heading.c_str(), | ||
| 160 | allowEmptyResult, autoCloseMs); | ||
| 161 | if (retString != nullptr) | ||
| 162 | { | ||
| 163 | if (std::strlen(retString)) | ||
| 164 | newPassword = retString; | ||
| 165 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 166 | } | ||
| 167 | return ret; | ||
| 168 | } | ||
| 169 | //-------------------------------------------------------------------------- | ||
| 170 | |||
| 171 | //========================================================================== | ||
| 172 | /// | ||
| 173 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 174 | /// @brief Shows keyboard and prompts for a password. Differs from | ||
| 175 | /// `ShowAndVerifyNewPassword()` in that no second verification | ||
| 176 | /// | ||
| 177 | /// @param[in,out] newPassword Overwritten with user input if return=true. | ||
| 178 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 179 | /// in milliseconds, default is 0 which keeps | ||
| 180 | /// the dialog open indefinitely. | ||
| 181 | /// @return true if successful display and user input. | ||
| 182 | /// false if unsuccessful display, no user | ||
| 183 | /// input, or canceled editing. | ||
| 184 | /// | ||
| 185 | inline bool ShowAndGetNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) | ||
| 186 | { | ||
| 187 | using namespace ::kodi::addon; | ||
| 188 | char* retString = nullptr; | ||
| 189 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 190 | newPassword.c_str(), &retString, autoCloseMs); | ||
| 191 | if (retString != nullptr) | ||
| 192 | { | ||
| 193 | if (std::strlen(retString)) | ||
| 194 | newPassword = retString; | ||
| 195 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 196 | } | ||
| 197 | return ret; | ||
| 198 | } | ||
| 199 | //-------------------------------------------------------------------------- | ||
| 200 | |||
| 201 | //========================================================================== | ||
| 202 | /// | ||
| 203 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 204 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 205 | /// string. | ||
| 206 | /// | ||
| 207 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 208 | /// @param[in] heading String shown on dialog title. | ||
| 209 | /// @param[in] allowEmptyResult | ||
| 210 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 211 | /// in milliseconds, default is 0 which keeps | ||
| 212 | /// the dialog open indefinitely. | ||
| 213 | /// @return true if successful display and user input. | ||
| 214 | /// false if unsuccessful display, no user | ||
| 215 | /// input, or canceled editing. | ||
| 216 | /// | ||
| 217 | /// | ||
| 218 | ///------------------------------------------------------------------------- | ||
| 219 | /// | ||
| 220 | /// **Example:** | ||
| 221 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 222 | /// #include <kodi/General.h> | ||
| 223 | /// #include <kodi/gui/DialogKeyboard.h> | ||
| 224 | /// | ||
| 225 | /// /* | ||
| 226 | /// * The example below shows the complete use of keyboard dialog for password | ||
| 227 | /// * check. If only one check from add-on needed can be function with retries | ||
| 228 | /// * set to '0' called alone. | ||
| 229 | /// * | ||
| 230 | /// * The use of MD5 translated password is always required for the check on Kodi! | ||
| 231 | /// */ | ||
| 232 | /// | ||
| 233 | /// int maxretries = 3; | ||
| 234 | /// /* | ||
| 235 | /// * Password names need to be send as md5 sum to kodi. | ||
| 236 | /// */ | ||
| 237 | /// std::string password; | ||
| 238 | /// kodi::GetMD5("kodi", password); | ||
| 239 | /// | ||
| 240 | /// /* | ||
| 241 | /// * To the loop about password checks. | ||
| 242 | /// */ | ||
| 243 | /// int ret; | ||
| 244 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 245 | /// { | ||
| 246 | /// /* | ||
| 247 | /// * Ask the user about the password. | ||
| 248 | /// */ | ||
| 249 | /// ret = ::kodi::gui::DialogKeyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0); | ||
| 250 | /// if (ret == 0) | ||
| 251 | /// { | ||
| 252 | /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1); | ||
| 253 | /// break; | ||
| 254 | /// } | ||
| 255 | /// else if (ret < 0) | ||
| 256 | /// { | ||
| 257 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 258 | /// break; | ||
| 259 | /// } | ||
| 260 | /// else /* if (ret > 0) */ | ||
| 261 | /// { | ||
| 262 | /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1); | ||
| 263 | /// } | ||
| 264 | /// } | ||
| 265 | /// ~~~~~~~~~~~~~ | ||
| 266 | /// | ||
| 267 | inline bool ShowAndVerifyNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) | ||
| 268 | { | ||
| 269 | using namespace ::kodi::addon; | ||
| 270 | char* retString = nullptr; | ||
| 271 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 272 | &retString, heading.c_str(), allowEmptyResult, | ||
| 273 | autoCloseMs); | ||
| 274 | if (retString != nullptr) | ||
| 275 | { | ||
| 276 | if (std::strlen(retString)) | ||
| 277 | newPassword = retString; | ||
| 278 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 279 | } | ||
| 280 | return ret; | ||
| 281 | } | ||
| 282 | //-------------------------------------------------------------------------- | ||
| 283 | |||
| 284 | //========================================================================== | ||
| 285 | /// | ||
| 286 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 287 | /// @brief Show keyboard twice to get and confirm a user-entered password | ||
| 288 | /// string. | ||
| 289 | /// | ||
| 290 | /// @param[out] newPassword Overwritten with user input if return=true. | ||
| 291 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 292 | /// in milliseconds, default is 0 which keeps | ||
| 293 | /// the dialog open indefinitely. | ||
| 294 | /// @return true if successful display and user input. | ||
| 295 | /// false if unsuccessful display, no user | ||
| 296 | /// input, or canceled editing. | ||
| 297 | /// | ||
| 298 | inline bool ShowAndVerifyNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) | ||
| 299 | { | ||
| 300 | using namespace ::kodi::addon; | ||
| 301 | char* retString = nullptr; | ||
| 302 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 303 | &retString, autoCloseMs); | ||
| 304 | if (retString != nullptr) | ||
| 305 | { | ||
| 306 | if (std::strlen(retString)) | ||
| 307 | newPassword = retString; | ||
| 308 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 309 | } | ||
| 310 | return ret; | ||
| 311 | } | ||
| 312 | //-------------------------------------------------------------------------- | ||
| 313 | |||
| 314 | //========================================================================== | ||
| 315 | /// | ||
| 316 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 317 | /// @brief Show keyboard and verify user input against `password`. | ||
| 318 | /// | ||
| 319 | /// @param[in,out] password Value to compare against user input. | ||
| 320 | /// @param[in] heading String shown on dialog title. | ||
| 321 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 322 | /// password, %d retries left" on dialog line 2, | ||
| 323 | /// else line 2 is blank. | ||
| 324 | /// @param[in] autoCloseMs To close the dialog after a specified time, | ||
| 325 | /// in milliseconds, default is 0 which keeps | ||
| 326 | /// the dialog open indefinitely. | ||
| 327 | /// @return 0 if successful display and user input. 1 if | ||
| 328 | /// unsuccessful input. -1 if no user input or | ||
| 329 | /// canceled editing. | ||
| 330 | /// | ||
| 331 | inline int ShowAndVerifyPassword(std::string& password, const std::string& heading, int retries, unsigned int autoCloseMs = 0) | ||
| 332 | { | ||
| 333 | using namespace ::kodi::addon; | ||
| 334 | char* retString = nullptr; | ||
| 335 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 336 | password.c_str(), &retString, heading.c_str(), | ||
| 337 | retries, autoCloseMs); | ||
| 338 | if (retString != nullptr) | ||
| 339 | { | ||
| 340 | if (std::strlen(retString)) | ||
| 341 | password = retString; | ||
| 342 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 343 | } | ||
| 344 | return ret; | ||
| 345 | } | ||
| 346 | //-------------------------------------------------------------------------- | ||
| 347 | |||
| 348 | //========================================================================== | ||
| 349 | /// | ||
| 350 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 351 | /// @brief Shows a filter related keyboard | ||
| 352 | /// | ||
| 353 | /// @param[in,out] text Overwritten with user input if return=true. | ||
| 354 | /// @param[in] searching Use dialog for search and send our search | ||
| 355 | /// message in safe way (only the active window | ||
| 356 | /// needs it) | ||
| 357 | /// - header name if true is "Enter search string" | ||
| 358 | /// - header name if false is "Enter value" | ||
| 359 | /// @param autoCloseMs To close the dialog after a specified time, | ||
| 360 | /// in milliseconds, default is 0 which keeps | ||
| 361 | /// the dialog open indefinitely. | ||
| 362 | /// @return true if successful display and user input. | ||
| 363 | /// false if unsuccessful display, no user | ||
| 364 | /// input, or canceled editing. | ||
| 365 | /// | ||
| 366 | inline bool ShowAndGetFilter(std::string& text, bool searching, unsigned int autoCloseMs = 0) | ||
| 367 | { | ||
| 368 | using namespace ::kodi::addon; | ||
| 369 | char* retString = nullptr; | ||
| 370 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 371 | text.c_str(), &retString, searching, autoCloseMs); | ||
| 372 | if (retString != nullptr) | ||
| 373 | { | ||
| 374 | if (std::strlen(retString)) | ||
| 375 | text = retString; | ||
| 376 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 377 | } | ||
| 378 | return ret; | ||
| 379 | } | ||
| 380 | //-------------------------------------------------------------------------- | ||
| 381 | |||
| 382 | //========================================================================== | ||
| 383 | /// | ||
| 384 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 385 | /// @brief Send a text to a visible keyboard | ||
| 386 | /// | ||
| 387 | /// @param[in] text Overwritten with user input if return=true. | ||
| 388 | /// @param[in] closeKeyboard The open dialog is if also closed on 'true'. | ||
| 389 | /// @return true if successful done, false if | ||
| 390 | /// unsuccessful or keyboard not present. | ||
| 391 | /// | ||
| 392 | inline bool SendTextToActiveKeyboard(const std::string& text, bool closeKeyboard = false) | ||
| 393 | { | ||
| 394 | using namespace ::kodi::addon; | ||
| 395 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 396 | text.c_str(), closeKeyboard); | ||
| 397 | } | ||
| 398 | //-------------------------------------------------------------------------- | ||
| 399 | |||
| 400 | //========================================================================== | ||
| 401 | /// | ||
| 402 | /// \ingroup cpp_kodi_gui_DialogKeyboard | ||
| 403 | /// @brief Check for visible keyboard on GUI | ||
| 404 | /// | ||
| 405 | /// @return true if keyboard present, false if not present | ||
| 406 | /// | ||
| 407 | inline bool IsKeyboardActivated() | ||
| 408 | { | ||
| 409 | using namespace ::kodi::addon; | ||
| 410 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 411 | } | ||
| 412 | //-------------------------------------------------------------------------- | ||
| 413 | }; | ||
| 414 | |||
| 415 | } /* namespace gui */ | ||
| 416 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h new file mode 100644 index 0000000..8b5c592 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h | |||
| @@ -0,0 +1,366 @@ | |||
| 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_DialogNumeric Dialog Numeric | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogNumeric } | ||
| 36 | /// **Numeric dialogs** | ||
| 37 | /// | ||
| 38 | /// The functions listed below have to be permitted by the user for the | ||
| 39 | /// representation of a numeric keyboard around an input. | ||
| 40 | /// | ||
| 41 | /// The class supports several kinds, from an easy number choice up to the | ||
| 42 | /// passport Word production and their confirmation for add-on. | ||
| 43 | /// | ||
| 44 | /// It has the header \ref DialogNumeric.h "#include <kodi/gui/DialogNumeric.h>" | ||
| 45 | /// be included to enjoy it. | ||
| 46 | /// | ||
| 47 | namespace DialogNumeric | ||
| 48 | { | ||
| 49 | //========================================================================== | ||
| 50 | /// | ||
| 51 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 52 | /// @brief Use dialog to get numeric new password | ||
| 53 | /// | ||
| 54 | /// @param[out] newPassword String to preload into the keyboard | ||
| 55 | /// accumulator. Overwritten with user input | ||
| 56 | /// if return=true. Returned in MD5 format. | ||
| 57 | /// @return true if successful display and user | ||
| 58 | /// input entry/re-entry. | ||
| 59 | /// false if unsuccessful display, no user | ||
| 60 | /// input, or canceled editing. | ||
| 61 | /// | ||
| 62 | inline bool ShowAndVerifyNewPassword(std::string& newPassword) | ||
| 63 | { | ||
| 64 | using namespace ::kodi::addon; | ||
| 65 | char* pw = nullptr; | ||
| 66 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, &pw); | ||
| 67 | if (pw != nullptr) | ||
| 68 | { | ||
| 69 | if (std::strlen(pw)) | ||
| 70 | newPassword = pw; | ||
| 71 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw); | ||
| 72 | } | ||
| 73 | return ret; | ||
| 74 | } | ||
| 75 | //-------------------------------------------------------------------------- | ||
| 76 | |||
| 77 | //========================================================================== | ||
| 78 | /// | ||
| 79 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 80 | /// @brief Use dialog to verify numeric password. | ||
| 81 | /// | ||
| 82 | /// @param[in] password Password to compare with user input, need | ||
| 83 | /// in MD5 format. | ||
| 84 | /// @param[in] heading Heading to display | ||
| 85 | /// @param[in] retries If greater than 0, shows "Incorrect | ||
| 86 | /// password, %d retries left" on dialog | ||
| 87 | /// line 2, else line 2 is blank. | ||
| 88 | /// @return Possible values: | ||
| 89 | /// - 0 if successful display and user input. | ||
| 90 | /// - 1 if unsuccessful input. | ||
| 91 | /// - -1 if no user input or canceled editing. | ||
| 92 | /// | ||
| 93 | /// | ||
| 94 | ///------------------------------------------------------------------------- | ||
| 95 | /// | ||
| 96 | /// **Example:** | ||
| 97 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 98 | /// #include <stdio.h> /* fprintf */ | ||
| 99 | /// #include <kodi/General.h> | ||
| 100 | /// #include <kodi/gui/DialogNumeric.h> | ||
| 101 | /// | ||
| 102 | /// /* | ||
| 103 | /// * The example below shows the complete use of keyboard dialog for password | ||
| 104 | /// * check. If only one check from add-on needed can be function with retries | ||
| 105 | /// * set to '0' called alone. | ||
| 106 | /// * | ||
| 107 | /// * The use of MD5 translated password is always required for the check on Kodi! | ||
| 108 | /// */ | ||
| 109 | /// | ||
| 110 | /// int maxretries = 3; | ||
| 111 | /// | ||
| 112 | /// /* | ||
| 113 | /// * Password names need to be send as md5 sum to kodi. | ||
| 114 | /// */ | ||
| 115 | /// std::string password = kodi::GetMD5("1234"); | ||
| 116 | /// | ||
| 117 | /// /* | ||
| 118 | /// * To the loop about password checks. | ||
| 119 | /// */ | ||
| 120 | /// int ret; | ||
| 121 | /// for (unsigned int i = 0; i < maxretries; i++) | ||
| 122 | /// { | ||
| 123 | /// /* | ||
| 124 | /// * Ask the user about the password. | ||
| 125 | /// */ | ||
| 126 | /// ret = kodi::gui::DialogNumeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i); | ||
| 127 | /// if (ret == 0) | ||
| 128 | /// { | ||
| 129 | /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1); | ||
| 130 | /// break; | ||
| 131 | /// } | ||
| 132 | /// else if (ret < 0) | ||
| 133 | /// { | ||
| 134 | /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); | ||
| 135 | /// break; | ||
| 136 | /// } | ||
| 137 | /// else /* if (ret > 0) */ | ||
| 138 | /// { | ||
| 139 | /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1); | ||
| 140 | /// } | ||
| 141 | /// } | ||
| 142 | /// ~~~~~~~~~~~~~ | ||
| 143 | /// | ||
| 144 | inline int ShowAndVerifyPassword(const std::string& password, const std::string& heading, int retries) | ||
| 145 | { | ||
| 146 | using namespace ::kodi::addon; | ||
| 147 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 148 | password.c_str(), heading.c_str(), retries); | ||
| 149 | } | ||
| 150 | //-------------------------------------------------------------------------- | ||
| 151 | |||
| 152 | //========================================================================== | ||
| 153 | /// | ||
| 154 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 155 | /// @brief Use dialog to verify numeric password | ||
| 156 | /// | ||
| 157 | /// @param[in,out] toVerify Value to compare against user input. | ||
| 158 | /// @param[in] heading Heading to display | ||
| 159 | /// @param[in] verifyInput If set as true we verify the users input | ||
| 160 | /// versus toVerify. | ||
| 161 | /// @return true if successful display and user | ||
| 162 | /// input. false if unsuccessful display, no | ||
| 163 | /// user input, or canceled editing. | ||
| 164 | /// | ||
| 165 | inline bool ShowAndVerifyInput(std::string& toVerify, const std::string& heading, bool verifyInput) | ||
| 166 | { | ||
| 167 | using namespace ::kodi::addon; | ||
| 168 | char* retString = nullptr; | ||
| 169 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 170 | toVerify.c_str(), &retString, heading.c_str(), verifyInput); | ||
| 171 | if (retString != nullptr) | ||
| 172 | { | ||
| 173 | if (std::strlen(retString)) | ||
| 174 | toVerify = retString; | ||
| 175 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 176 | } | ||
| 177 | return ret; | ||
| 178 | } | ||
| 179 | //-------------------------------------------------------------------------- | ||
| 180 | |||
| 181 | //========================================================================== | ||
| 182 | /// | ||
| 183 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 184 | /// @brief Use dialog to get time value. | ||
| 185 | /// | ||
| 186 | /// @param[out] time Overwritten with user input if | ||
| 187 | /// return=true and time inserted. | ||
| 188 | /// @param[in] heading Heading to display. | ||
| 189 | /// @return true if successful display and user | ||
| 190 | /// input. false if unsuccessful display, no | ||
| 191 | /// user input, or canceled editing. | ||
| 192 | /// | ||
| 193 | /// | ||
| 194 | ///------------------------------------------------------------------------- | ||
| 195 | /// | ||
| 196 | /// **Example:** | ||
| 197 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 198 | /// #include <stdio.h> /* printf */ | ||
| 199 | /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */ | ||
| 200 | /// #include <kodi/gui/DialogNumeric.h> | ||
| 201 | /// | ||
| 202 | /// time_t rawtime; | ||
| 203 | /// struct tm * timeinfo; | ||
| 204 | /// char buffer [10]; | ||
| 205 | /// | ||
| 206 | /// time (&rawtime); | ||
| 207 | /// timeinfo = localtime(&rawtime); | ||
| 208 | /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetTime(*timeinfo, "Selected time test call"); | ||
| 209 | /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo); | ||
| 210 | /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 211 | /// ~~~~~~~~~~~~~ | ||
| 212 | /// | ||
| 213 | inline bool ShowAndGetTime(tm& time, const std::string& heading) | ||
| 214 | { | ||
| 215 | using namespace ::kodi::addon; | ||
| 216 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); | ||
| 217 | } | ||
| 218 | //-------------------------------------------------------------------------- | ||
| 219 | |||
| 220 | //========================================================================== | ||
| 221 | /// | ||
| 222 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 223 | /// @brief Use dialog to get date value. | ||
| 224 | /// | ||
| 225 | /// @param[in,out] date Overwritten with user input if | ||
| 226 | /// return=true and date inserted. | ||
| 227 | /// @param[in] heading Heading to display | ||
| 228 | /// @return true if successful display and user | ||
| 229 | /// input. false if unsuccessful display, no | ||
| 230 | /// user input, or canceled editing. | ||
| 231 | /// | ||
| 232 | /// | ||
| 233 | ///------------------------------------------------------------------------- | ||
| 234 | /// | ||
| 235 | /// **Example:** | ||
| 236 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 237 | /// #include <stdio.h> /* printf */ | ||
| 238 | /// #include <time.h> /* time_t, struct tm, time, localtime, strftime */ | ||
| 239 | /// #include <kodi/gui/DialogNumeric.h> | ||
| 240 | /// | ||
| 241 | /// time_t rawtime; | ||
| 242 | /// struct tm * timeinfo; | ||
| 243 | /// char buffer [20]; | ||
| 244 | /// | ||
| 245 | /// time (&rawtime); | ||
| 246 | /// timeinfo = localtime(&rawtime); | ||
| 247 | /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetDate(*timeinfo, "Selected date test call"); | ||
| 248 | /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo); | ||
| 249 | /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); | ||
| 250 | /// ~~~~~~~~~~~~~ | ||
| 251 | /// | ||
| 252 | inline bool ShowAndGetDate(tm& date, const std::string& heading) | ||
| 253 | { | ||
| 254 | using namespace ::kodi::addon; | ||
| 255 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); | ||
| 256 | } | ||
| 257 | //-------------------------------------------------------------------------- | ||
| 258 | |||
| 259 | //========================================================================== | ||
| 260 | /// | ||
| 261 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 262 | /// @brief Use dialog to get a IP | ||
| 263 | /// | ||
| 264 | /// @param[in,out] ipAddress Overwritten with user input if | ||
| 265 | /// return=true and IP address inserted. | ||
| 266 | /// @param[in] heading Heading to display. | ||
| 267 | /// @return true if successful display and | ||
| 268 | /// user input. false if unsuccessful | ||
| 269 | /// display, no user input, or canceled | ||
| 270 | /// editing. | ||
| 271 | /// | ||
| 272 | inline bool ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading) | ||
| 273 | { | ||
| 274 | using namespace ::kodi::addon; | ||
| 275 | char* retString = nullptr; | ||
| 276 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 277 | ipAddress.c_str(), &retString, heading.c_str()); | ||
| 278 | if (retString != nullptr) | ||
| 279 | { | ||
| 280 | if (std::strlen(retString)) | ||
| 281 | ipAddress = retString; | ||
| 282 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 283 | } | ||
| 284 | return ret; | ||
| 285 | } | ||
| 286 | //-------------------------------------------------------------------------- | ||
| 287 | |||
| 288 | //========================================================================== | ||
| 289 | /// | ||
| 290 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 291 | /// @brief Use dialog to get normal number. | ||
| 292 | /// | ||
| 293 | /// @param[in,out] input Overwritten with user input if | ||
| 294 | /// return=true and time in seconds inserted | ||
| 295 | /// @param[in] heading Heading to display | ||
| 296 | /// @param[in] autoCloseTimeoutMs To close the dialog after a specified | ||
| 297 | /// time, in milliseconds, default is 0 | ||
| 298 | /// which keeps the dialog open | ||
| 299 | /// indefinitely. | ||
| 300 | /// @return true if successful display and user | ||
| 301 | /// input. false if unsuccessful display, no | ||
| 302 | /// user input, or canceled editing. | ||
| 303 | /// | ||
| 304 | /// | ||
| 305 | ///------------------------------------------------------------------------- | ||
| 306 | /// | ||
| 307 | /// **Example:** | ||
| 308 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 309 | /// #include <stdio.h> /* printf */ | ||
| 310 | /// #include <stdlib.h> /* strtoull (C++11) */ | ||
| 311 | /// #include <kodi/gui/DialogNumeric.h> | ||
| 312 | /// | ||
| 313 | /// std::string number; | ||
| 314 | /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetNumber(number, "Number test call"); | ||
| 315 | /// printf("Written number input is : %llu and was %s\n", | ||
| 316 | /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); | ||
| 317 | /// ~~~~~~~~~~~~~ | ||
| 318 | /// | ||
| 319 | inline bool ShowAndGetNumber(std::string& input, const std::string& heading, unsigned int autoCloseTimeoutMs = 0) | ||
| 320 | { | ||
| 321 | using namespace ::kodi::addon; | ||
| 322 | char* retString = nullptr; | ||
| 323 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 324 | input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs); | ||
| 325 | if (retString != nullptr) | ||
| 326 | { | ||
| 327 | if (std::strlen(retString)) | ||
| 328 | input = retString; | ||
| 329 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 330 | } | ||
| 331 | return ret; | ||
| 332 | } | ||
| 333 | //-------------------------------------------------------------------------- | ||
| 334 | |||
| 335 | //========================================================================== | ||
| 336 | /// | ||
| 337 | /// \ingroup cpp_kodi_gui_DialogNumeric | ||
| 338 | /// @brief Show numeric keypad to get seconds. | ||
| 339 | /// | ||
| 340 | /// @param[in,out] time Overwritten with user input if return=true and | ||
| 341 | /// time in seconds inserted. | ||
| 342 | /// @param[in] heading Heading to display | ||
| 343 | /// @return true if successful display and user input. false | ||
| 344 | /// if unsuccessful display, no user input, or | ||
| 345 | /// canceled editing. | ||
| 346 | /// | ||
| 347 | inline bool ShowAndGetSeconds(std::string& time, const std::string& heading) | ||
| 348 | { | ||
| 349 | using namespace ::kodi::addon; | ||
| 350 | char* retString = nullptr; | ||
| 351 | bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 352 | time.c_str(), &retString, heading.c_str()); | ||
| 353 | if (retString != nullptr) | ||
| 354 | { | ||
| 355 | if (std::strlen(retString)) | ||
| 356 | time = retString; | ||
| 357 | CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); | ||
| 358 | } | ||
| 359 | return ret; | ||
| 360 | } | ||
| 361 | //-------------------------------------------------------------------------- | ||
| 362 | }; | ||
| 363 | /// @} | ||
| 364 | |||
| 365 | } /* namespace gui */ | ||
| 366 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h new file mode 100644 index 0000000..fa98241 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h | |||
| @@ -0,0 +1,104 @@ | |||
| 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 "../AddonBase.h" | ||
| 23 | #include "definitions.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | /// \defgroup cpp_kodi_gui_DialogOK Dialog OK | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogOK } | ||
| 36 | /// **OK dialog** | ||
| 37 | /// | ||
| 38 | /// The functions listed below permit the call of a dialogue of information, a | ||
| 39 | /// confirmation of the user by press from OK required. | ||
| 40 | /// | ||
| 41 | /// It has the header \ref DialogOK.h "#include <kodi/gui/DialogOK.h>" | ||
| 42 | /// be included to enjoy it. | ||
| 43 | /// | ||
| 44 | namespace DialogOK | ||
| 45 | { | ||
| 46 | //========================================================================== | ||
| 47 | /// | ||
| 48 | /// \ingroup cpp_kodi_gui_DialogOK | ||
| 49 | /// @brief Use dialog to inform user with text and confirmation with OK with continued string. | ||
| 50 | /// | ||
| 51 | /// @param[in] heading Dialog heading. | ||
| 52 | /// @param[in] text Multi-line text. | ||
| 53 | /// | ||
| 54 | /// | ||
| 55 | ///------------------------------------------------------------------------- | ||
| 56 | /// | ||
| 57 | /// **Example:** | ||
| 58 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 59 | /// #include <kodi/gui/DialogOK.h> | ||
| 60 | /// ... | ||
| 61 | /// kodi::gui::DialogOK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); | ||
| 62 | /// ~~~~~~~~~~~~~ | ||
| 63 | /// | ||
| 64 | inline void ShowAndGetInput(const std::string& heading, const std::string& text) | ||
| 65 | { | ||
| 66 | using namespace ::kodi::addon; | ||
| 67 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 68 | heading.c_str(), text.c_str()); | ||
| 69 | } | ||
| 70 | //-------------------------------------------------------------------------- | ||
| 71 | |||
| 72 | //========================================================================== | ||
| 73 | /// | ||
| 74 | /// \ingroup cpp_kodi_gui_DialogOK | ||
| 75 | /// @brief Use dialog to inform user with text and confirmation with OK with strings separated to the lines. | ||
| 76 | /// | ||
| 77 | /// @param[in] heading Dialog heading. | ||
| 78 | /// @param[in] line0 Line #1 text. | ||
| 79 | /// @param[in] line1 Line #2 text. | ||
| 80 | /// @param[in] line2 Line #3 text. | ||
| 81 | /// | ||
| 82 | /// | ||
| 83 | ///------------------------------------------------------------------------- | ||
| 84 | /// | ||
| 85 | /// **Example:** | ||
| 86 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 87 | /// #include <kodi/gui/DialogOK.h> | ||
| 88 | /// ... | ||
| 89 | /// kodi::gui::DialogOK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); | ||
| 90 | /// ~~~~~~~~~~~~~ | ||
| 91 | /// | ||
| 92 | inline void ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2) | ||
| 93 | { | ||
| 94 | using namespace ::kodi::addon; | ||
| 95 | CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, | ||
| 96 | heading.c_str(), line0.c_str(), line1.c_str(), | ||
| 97 | line2.c_str()); | ||
| 98 | } | ||
| 99 | //-------------------------------------------------------------------------- | ||
| 100 | } | ||
| 101 | /// @} | ||
| 102 | |||
| 103 | } /* namespace gui */ | ||
| 104 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h new file mode 100644 index 0000000..e652644 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h | |||
| @@ -0,0 +1,249 @@ | |||
| 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_CDialogProgress Dialog Progress | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @brief \cpp_class{ kodi::gui::CDialogProgress } | ||
| 35 | /// **Progress dialog shown in center** | ||
| 36 | /// | ||
| 37 | /// The with \ref DialogProgress.h "#include <kodi/gui/DialogProgress.h>" | ||
| 38 | /// given class are basically used to create Kodi's progress dialog with named | ||
| 39 | /// text fields. | ||
| 40 | /// | ||
| 41 | /// **Example:** | ||
| 42 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 43 | /// #include <kodi/gui/DialogProgress.h> | ||
| 44 | /// | ||
| 45 | /// kodi::gui::CDialogProgress *progress = new kodi::gui::CDialogProgress; | ||
| 46 | /// progress->SetHeading("Test progress"); | ||
| 47 | /// progress->SetLine(1, "line 1"); | ||
| 48 | /// progress->SetLine(2, "line 2"); | ||
| 49 | /// progress->SetLine(3, "line 3"); | ||
| 50 | /// progress->SetCanCancel(true); | ||
| 51 | /// progress->ShowProgressBar(true); | ||
| 52 | /// progress->Open(); | ||
| 53 | /// for (unsigned int i = 0; i < 100; i += 10) | ||
| 54 | /// { | ||
| 55 | /// progress->SetPercentage(i); | ||
| 56 | /// sleep(1); | ||
| 57 | /// } | ||
| 58 | /// delete progress; | ||
| 59 | /// ~~~~~~~~~~~~~ | ||
| 60 | /// | ||
| 61 | class CDialogProgress | ||
| 62 | { | ||
| 63 | public: | ||
| 64 | //========================================================================== | ||
| 65 | /// | ||
| 66 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 67 | /// @brief Construct a new dialog | ||
| 68 | /// | ||
| 69 | CDialogProgress() | ||
| 70 | { | ||
| 71 | using namespace ::kodi::addon; | ||
| 72 | m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 73 | if (!m_DialogHandle) | ||
| 74 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogProgress can't create window class from Kodi !!!"); | ||
| 75 | } | ||
| 76 | //-------------------------------------------------------------------------- | ||
| 77 | |||
| 78 | //========================================================================== | ||
| 79 | /// | ||
| 80 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 81 | /// @brief Destructor | ||
| 82 | /// | ||
| 83 | ~CDialogProgress() | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | if (m_DialogHandle) | ||
| 87 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 88 | } | ||
| 89 | //-------------------------------------------------------------------------- | ||
| 90 | |||
| 91 | //========================================================================== | ||
| 92 | /// | ||
| 93 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 94 | /// @brief To open the dialog | ||
| 95 | /// | ||
| 96 | void Open() | ||
| 97 | { | ||
| 98 | using namespace ::kodi::addon; | ||
| 99 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 100 | } | ||
| 101 | //-------------------------------------------------------------------------- | ||
| 102 | |||
| 103 | //========================================================================== | ||
| 104 | /// | ||
| 105 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 106 | /// @brief Set the heading title of dialog | ||
| 107 | /// | ||
| 108 | /// @param[in] heading Title string to use | ||
| 109 | /// | ||
| 110 | void SetHeading(const std::string& heading) | ||
| 111 | { | ||
| 112 | using namespace ::kodi::addon; | ||
| 113 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); | ||
| 114 | } | ||
| 115 | //-------------------------------------------------------------------------- | ||
| 116 | |||
| 117 | //========================================================================== | ||
| 118 | /// | ||
| 119 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 120 | /// @brief To set the line text field on dialog from 0 - 2 | ||
| 121 | /// | ||
| 122 | /// @param[in] iLine Line number | ||
| 123 | /// @param[in] line Text string | ||
| 124 | /// | ||
| 125 | void SetLine(unsigned int iLine, const std::string& line) | ||
| 126 | { | ||
| 127 | using namespace ::kodi::addon; | ||
| 128 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); | ||
| 129 | } | ||
| 130 | //-------------------------------------------------------------------------- | ||
| 131 | |||
| 132 | //========================================================================== | ||
| 133 | /// | ||
| 134 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 135 | /// @brief To enable and show cancel button on dialog | ||
| 136 | /// | ||
| 137 | /// @param[in] canCancel if true becomes it shown | ||
| 138 | /// | ||
| 139 | void SetCanCancel(bool canCancel) | ||
| 140 | { | ||
| 141 | using namespace ::kodi::addon; | ||
| 142 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); | ||
| 143 | } | ||
| 144 | //-------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | //========================================================================== | ||
| 147 | /// | ||
| 148 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 149 | /// @brief To check dialog for clicked cancel button | ||
| 150 | /// | ||
| 151 | /// @return True if canceled | ||
| 152 | /// | ||
| 153 | bool IsCanceled() const | ||
| 154 | { | ||
| 155 | using namespace ::kodi::addon; | ||
| 156 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 157 | } | ||
| 158 | //-------------------------------------------------------------------------- | ||
| 159 | |||
| 160 | //========================================================================== | ||
| 161 | /// | ||
| 162 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 163 | /// @brief Get the current progress position as percent | ||
| 164 | /// | ||
| 165 | /// @param[in] percentage Position to use from 0 to 100 | ||
| 166 | /// | ||
| 167 | void SetPercentage(int percentage) | ||
| 168 | { | ||
| 169 | using namespace ::kodi::addon; | ||
| 170 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); | ||
| 171 | } | ||
| 172 | //-------------------------------------------------------------------------- | ||
| 173 | |||
| 174 | //========================================================================== | ||
| 175 | /// | ||
| 176 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 177 | /// @brief To set the current progress position as percent | ||
| 178 | /// | ||
| 179 | /// @return Current Position used from 0 to 100 | ||
| 180 | /// | ||
| 181 | int GetPercentage() const | ||
| 182 | { | ||
| 183 | using namespace ::kodi::addon; | ||
| 184 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 185 | } | ||
| 186 | //-------------------------------------------------------------------------- | ||
| 187 | |||
| 188 | //========================================================================== | ||
| 189 | /// | ||
| 190 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 191 | /// @brief To show or hide progress bar dialog | ||
| 192 | /// | ||
| 193 | /// @param[in] onOff If true becomes it shown | ||
| 194 | /// | ||
| 195 | void ShowProgressBar(bool onOff) | ||
| 196 | { | ||
| 197 | using namespace ::kodi::addon; | ||
| 198 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); | ||
| 199 | } | ||
| 200 | //-------------------------------------------------------------------------- | ||
| 201 | |||
| 202 | //========================================================================== | ||
| 203 | /// | ||
| 204 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 205 | /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used | ||
| 206 | /// | ||
| 207 | /// @param[in] max Biggest usable position to use | ||
| 208 | /// | ||
| 209 | void SetProgressMax(int max) | ||
| 210 | { | ||
| 211 | using namespace ::kodi::addon; | ||
| 212 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); | ||
| 213 | } | ||
| 214 | //-------------------------------------------------------------------------- | ||
| 215 | |||
| 216 | //========================================================================== | ||
| 217 | /// | ||
| 218 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 219 | /// @brief To increase progress bar by defined step size until reach of maximum position | ||
| 220 | /// | ||
| 221 | /// @param[in] steps Step size to increase, default is 1 | ||
| 222 | /// | ||
| 223 | void SetProgressAdvance(int steps=1) | ||
| 224 | { | ||
| 225 | using namespace ::kodi::addon; | ||
| 226 | CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); | ||
| 227 | } | ||
| 228 | //-------------------------------------------------------------------------- | ||
| 229 | |||
| 230 | //========================================================================== | ||
| 231 | /// | ||
| 232 | /// \ingroup cpp_kodi_gui_CDialogProgress | ||
| 233 | /// @brief To check progress was canceled on work | ||
| 234 | /// | ||
| 235 | /// @return True if aborted | ||
| 236 | /// | ||
| 237 | bool Abort() | ||
| 238 | { | ||
| 239 | using namespace ::kodi::addon; | ||
| 240 | return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); | ||
| 241 | } | ||
| 242 | //-------------------------------------------------------------------------- | ||
| 243 | |||
| 244 | private: | ||
| 245 | void* m_DialogHandle; | ||
| 246 | }; | ||
| 247 | |||
| 248 | } /* namespace gui */ | ||
| 249 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h new file mode 100644 index 0000000..36433db --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h | |||
| @@ -0,0 +1,101 @@ | |||
| 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_DialogSelect Dialog Select | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogSelect } | ||
| 36 | /// **Selection dialog** | ||
| 37 | /// | ||
| 38 | /// The function listed below permits the call of a dialogue to select of an | ||
| 39 | /// entry as a key | ||
| 40 | /// | ||
| 41 | /// It has the header \ref DialogSelect.h "#include <kodi/gui/DialogSelect.h>" | ||
| 42 | /// be included to enjoy it. | ||
| 43 | /// | ||
| 44 | /// | ||
| 45 | namespace DialogSelect | ||
| 46 | { | ||
| 47 | //========================================================================== | ||
| 48 | /// | ||
| 49 | /// \ingroup cpp_kodi_gui_DialogSelect | ||
| 50 | /// @brief Show a selection dialog about given parts. | ||
| 51 | /// | ||
| 52 | /// @param[in] heading Dialog heading name | ||
| 53 | /// @param[in] entries String list about entries | ||
| 54 | /// @param[in] selected [opt] Predefined selection (default is | ||
| 55 | /// <tt>-1</tt> for the first) | ||
| 56 | /// @param[in] autoclose [opt] To close dialog automatic after a time | ||
| 57 | /// @return The selected entry, if return <tt>-1</tt> was | ||
| 58 | /// nothing selected or canceled | ||
| 59 | /// | ||
| 60 | /// | ||
| 61 | ///------------------------------------------------------------------------- | ||
| 62 | /// | ||
| 63 | /// **Example:** | ||
| 64 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 65 | /// #include <kodi/gui/DialogSelect.h> | ||
| 66 | /// | ||
| 67 | /// const std::vector<std::string> entries | ||
| 68 | /// { | ||
| 69 | /// "Test 1", | ||
| 70 | /// "Test 2", | ||
| 71 | /// "Test 3", | ||
| 72 | /// "Test 4", | ||
| 73 | /// "Test 5" | ||
| 74 | /// }; | ||
| 75 | /// | ||
| 76 | /// int selected = kodi::gui::DialogSelect::Show("Test selection", entries, -1); | ||
| 77 | /// if (selected < 0) | ||
| 78 | /// fprintf(stderr, "Item selection canceled\n"); | ||
| 79 | /// else | ||
| 80 | /// fprintf(stderr, "Selected item is: %i\n", selected); | ||
| 81 | /// ~~~~~~~~~~~~~ | ||
| 82 | /// | ||
| 83 | inline int Show(const std::string& heading, const std::vector<std::string>& entries, int selected = -1, bool autoclose = false) | ||
| 84 | { | ||
| 85 | using namespace ::kodi::addon; | ||
| 86 | unsigned int size = entries.size(); | ||
| 87 | const char** cEntries = (const char**)malloc(size*sizeof(const char**)); | ||
| 88 | for (unsigned int i = 0; i < size; ++i) | ||
| 89 | { | ||
| 90 | cEntries[i] = entries[i].c_str(); | ||
| 91 | } | ||
| 92 | int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, autoclose); | ||
| 93 | free(cEntries); | ||
| 94 | return ret; | ||
| 95 | } | ||
| 96 | //-------------------------------------------------------------------------- | ||
| 97 | }; | ||
| 98 | /// @} | ||
| 99 | |||
| 100 | } /* namespace gui */ | ||
| 101 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h new file mode 100644 index 0000000..09c81bd --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2015-2016 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_DialogTextViewer Dialog Text Viewer | ||
| 33 | /// \ingroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief \cpp_namespace{ kodi::gui::DialogTextViewer } | ||
| 36 | /// **Text viewer dialog** | ||
| 37 | /// | ||
| 38 | /// The text viewer dialog can be used to display descriptions, help texts or | ||
| 39 | /// other larger texts. | ||
| 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 DialogTextViewer.h "#include <kodi/gui/DialogTextViewer.h>" | ||
| 46 | /// be included to enjoy it. | ||
| 47 | /// | ||
| 48 | namespace DialogTextViewer | ||
| 49 | { | ||
| 50 | //========================================================================== | ||
| 51 | /// | ||
| 52 | /// \ingroup cpp_kodi_gui_DialogTextViewer | ||
| 53 | /// @brief Show info text dialog | ||
| 54 | /// | ||
| 55 | /// @param[in] heading Small heading text | ||
| 56 | /// @param[in] text Showed text on dialog | ||
| 57 | /// | ||
| 58 | /// | ||
| 59 | ///------------------------------------------------------------------------- | ||
| 60 | /// | ||
| 61 | /// **Example:** | ||
| 62 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 63 | /// #include <kodi/gui/DialogTextViewer.h> | ||
| 64 | /// | ||
| 65 | /// kodi::gui::DialogTextViewer::Show("The Wizard of Oz (1939 film)", | ||
| 66 | /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film " | ||
| 67 | /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially " | ||
| 68 | /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz " | ||
| 69 | /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film" | ||
| 70 | /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, " | ||
| 71 | /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and " | ||
| 72 | /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n" | ||
| 73 | /// "\n" | ||
| 74 | /// "Notable for its use of Technicolor, fantasy storytelling, musical score and " | ||
| 75 | /// "unusual characters, over the years it has become an icon of American popular " | ||
| 76 | /// "culture. It was nominated for six Academy Awards, including Best Picture but " | ||
| 77 | /// "lost to Gone with the Wind. It did win in two other categories including Best " | ||
| 78 | /// "Original Song for \"Over the Rainbow\". However, the film was a box office " | ||
| 79 | /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 " | ||
| 80 | /// "budget, despite receiving largely positive reviews. It was MGM's most " | ||
| 81 | /// "expensive production at that time, and did not completely recoup the studio's " | ||
| 82 | /// "investment and turn a profit until theatrical re-releases starting in 1949.\n" | ||
| 83 | /// "\n" | ||
| 84 | /// "The 1956 broadcast television premiere of the film on CBS re-introduced the " | ||
| 85 | /// "film to the wider public and eventually made the presentation an annual " | ||
| 86 | /// "tradition, making it one of the most known films in cinema history. The " | ||
| 87 | /// "film was named the most-viewed motion picture on television syndication by " | ||
| 88 | /// "the Library of Congress who also included the film in its National Film " | ||
| 89 | /// "Registry in its inaugural year in 1989. Designation on the registry calls " | ||
| 90 | /// "for efforts to preserve it for being \"culturally, historically, and " | ||
| 91 | /// "aesthetically significant\". It is also one of the few films on UNESCO's " | ||
| 92 | /// "Memory of the World Register.\n" | ||
| 93 | /// "\n" | ||
| 94 | /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public " | ||
| 95 | /// "polls. It is the source of many quotes referenced in modern popular culture. " | ||
| 96 | /// "It was directed primarily by Victor Fleming (who left production to take " | ||
| 97 | /// "over direction on the troubled Gone with the Wind production). Noel Langley, " | ||
| 98 | /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, " | ||
| 99 | /// "but there were uncredited contributions by others. The songs were written " | ||
| 100 | /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental " | ||
| 101 | /// "music, based largely on the songs, was composed by Herbert Stothart, with " | ||
| 102 | /// "interspersed renderings from classical composers.\n"); | ||
| 103 | /// ~~~~~~~~~~~~~ | ||
| 104 | /// | ||
| 105 | inline void Show(const std::string& heading, const std::string& text) | ||
| 106 | { | ||
| 107 | using namespace ::kodi::addon; | ||
| 108 | CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); | ||
| 109 | } | ||
| 110 | //-------------------------------------------------------------------------- | ||
| 111 | }; | ||
| 112 | /// @} | ||
| 113 | |||
| 114 | } /* namespace gui */ | ||
| 115 | } /* namespace kodi */ | ||
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 */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h new file mode 100644 index 0000000..f1df60d --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h | |||
| @@ -0,0 +1,156 @@ | |||
| 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 "../AddonBase.h" | ||
| 23 | #include "definitions.h" | ||
| 24 | |||
| 25 | namespace kodi | ||
| 26 | { | ||
| 27 | namespace gui | ||
| 28 | { | ||
| 29 | |||
| 30 | //============================================================================ | ||
| 31 | /// | ||
| 32 | // \defgroup cpp_kodi_gui ::general | ||
| 33 | /// \addtogroup cpp_kodi_gui | ||
| 34 | /// @{ | ||
| 35 | /// @brief **Allow use of binary classes and function to use on add-on's** | ||
| 36 | /// | ||
| 37 | /// Permits the use of the required functions of the add-on to Kodi. This class | ||
| 38 | /// also contains some functions to the control. | ||
| 39 | /// | ||
| 40 | /// These are pure functions them no other initialization need. | ||
| 41 | /// | ||
| 42 | /// It has the header \ref kodi/gui/General.h "#include <kodi/gui/General.h>" be included | ||
| 43 | /// to enjoy it. | ||
| 44 | /// | ||
| 45 | |||
| 46 | //========================================================================== | ||
| 47 | /// | ||
| 48 | /// \ingroup cpp_kodi_gui | ||
| 49 | /// @brief Performs a graphical lock of rendering engine | ||
| 50 | /// | ||
| 51 | inline void Lock() | ||
| 52 | { | ||
| 53 | using namespace ::kodi::addon; | ||
| 54 | CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); | ||
| 55 | } | ||
| 56 | |||
| 57 | //-------------------------------------------------------------------------- | ||
| 58 | |||
| 59 | //========================================================================== | ||
| 60 | /// | ||
| 61 | /// \ingroup cpp_kodi_gui | ||
| 62 | /// @brief Performs a graphical unlock of previous locked rendering engine | ||
| 63 | /// | ||
| 64 | inline void Unlock() | ||
| 65 | { | ||
| 66 | using namespace ::kodi::addon; | ||
| 67 | CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); | ||
| 68 | } | ||
| 69 | //-------------------------------------------------------------------------- | ||
| 70 | |||
| 71 | //========================================================================== | ||
| 72 | /// | ||
| 73 | /// \ingroup cpp_kodi_gui | ||
| 74 | /// @brief Return the the current screen height with pixel | ||
| 75 | /// | ||
| 76 | inline int GetScreenHeight() | ||
| 77 | { | ||
| 78 | using namespace ::kodi::addon; | ||
| 79 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 80 | } | ||
| 81 | //-------------------------------------------------------------------------- | ||
| 82 | |||
| 83 | //========================================================================== | ||
| 84 | /// | ||
| 85 | /// \ingroup cpp_kodi_gui | ||
| 86 | /// @brief Return the the current screen width with pixel | ||
| 87 | /// | ||
| 88 | inline int GetScreenWidth() | ||
| 89 | { | ||
| 90 | using namespace ::kodi::addon; | ||
| 91 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 92 | } | ||
| 93 | //-------------------------------------------------------------------------- | ||
| 94 | |||
| 95 | //========================================================================== | ||
| 96 | /// | ||
| 97 | /// \ingroup cpp_kodi_gui | ||
| 98 | /// @brief Return the the current screen rendering resolution | ||
| 99 | /// | ||
| 100 | inline int GetVideoResolution() | ||
| 101 | { | ||
| 102 | using namespace ::kodi::addon; | ||
| 103 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 104 | } | ||
| 105 | //-------------------------------------------------------------------------- | ||
| 106 | |||
| 107 | //========================================================================== | ||
| 108 | /// | ||
| 109 | /// \ingroup cpp_kodi_gui | ||
| 110 | /// @brief Returns the id for the current 'active' dialog as an integer. | ||
| 111 | /// | ||
| 112 | /// @return The currently active dialog Id | ||
| 113 | /// | ||
| 114 | /// | ||
| 115 | ///------------------------------------------------------------------------- | ||
| 116 | /// | ||
| 117 | /// **Example:** | ||
| 118 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 119 | /// .. | ||
| 120 | /// int wid = kodi::gui::GetCurrentWindowDialogId() | ||
| 121 | /// .. | ||
| 122 | /// ~~~~~~~~~~~~~ | ||
| 123 | /// | ||
| 124 | inline int GetCurrentWindowDialogId() | ||
| 125 | { | ||
| 126 | using namespace ::kodi::addon; | ||
| 127 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 128 | } | ||
| 129 | //-------------------------------------------------------------------------- | ||
| 130 | |||
| 131 | //========================================================================== | ||
| 132 | /// | ||
| 133 | /// \ingroup cpp_kodi_gui | ||
| 134 | /// @brief Returns the id for the current 'active' window as an integer. | ||
| 135 | /// | ||
| 136 | /// @return The currently active window Id | ||
| 137 | /// | ||
| 138 | /// | ||
| 139 | ///------------------------------------------------------------------------- | ||
| 140 | /// | ||
| 141 | /// **Example:** | ||
| 142 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 143 | /// .. | ||
| 144 | /// int wid = kodi::gui::GetCurrentWindowId() | ||
| 145 | /// .. | ||
| 146 | /// ~~~~~~~~~~~~~ | ||
| 147 | /// | ||
| 148 | inline int GetCurrentWindowId() | ||
| 149 | { | ||
| 150 | using namespace ::kodi::addon; | ||
| 151 | return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(CAddonBase::m_interface->toKodi->kodiBase); | ||
| 152 | } | ||
| 153 | //-------------------------------------------------------------------------- | ||
| 154 | |||
| 155 | } /* namespace gui */ | ||
| 156 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h new file mode 100644 index 0000000..a473f28 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h | |||
| @@ -0,0 +1,336 @@ | |||
| 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 "../AddonBase.h" | ||
| 23 | #include "definitions.h" | ||
| 24 | |||
| 25 | #include <memory> | ||
| 26 | |||
| 27 | namespace kodi | ||
| 28 | { | ||
| 29 | namespace gui | ||
| 30 | { | ||
| 31 | |||
| 32 | class CWindow; | ||
| 33 | |||
| 34 | class CAddonGUIControlBase | ||
| 35 | { | ||
| 36 | public: | ||
| 37 | GUIHANDLE GetControlHandle() const { return m_controlHandle; } | ||
| 38 | |||
| 39 | protected: | ||
| 40 | CAddonGUIControlBase(CAddonGUIControlBase* window) | ||
| 41 | : m_controlHandle(nullptr), | ||
| 42 | m_interface(::kodi::addon::CAddonBase::m_interface->toKodi), | ||
| 43 | m_Window(window) {} | ||
| 44 | |||
| 45 | virtual ~CAddonGUIControlBase() = default; | ||
| 46 | |||
| 47 | friend class CWindow; | ||
| 48 | |||
| 49 | GUIHANDLE m_controlHandle; | ||
| 50 | AddonToKodiFuncTable_Addon* m_interface; | ||
| 51 | CAddonGUIControlBase* m_Window; | ||
| 52 | |||
| 53 | private: | ||
| 54 | CAddonGUIControlBase() = delete; | ||
| 55 | CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; | ||
| 56 | CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; | ||
| 57 | }; | ||
| 58 | |||
| 59 | class CListItem; | ||
| 60 | typedef std::shared_ptr<CListItem> ListItemPtr; | ||
| 61 | |||
| 62 | //============================================================================ | ||
| 63 | /// | ||
| 64 | /// \defgroup cpp_kodi_gui_CListItem List Item | ||
| 65 | /// \ingroup cpp_kodi_gui | ||
| 66 | /// @brief \cpp_class{ kodi::gui::CListItem } | ||
| 67 | /// **Selectable window list item** | ||
| 68 | /// | ||
| 69 | /// The list item control is used for creating item lists in Kodi | ||
| 70 | /// | ||
| 71 | /// The with \ref ListItem.h "#include <kodi/gui/ListItem.h>" given | ||
| 72 | /// class is used to create a item entry for a list on window and to support it's | ||
| 73 | /// control. | ||
| 74 | /// | ||
| 75 | |||
| 76 | //============================================================================ | ||
| 77 | /// | ||
| 78 | /// \defgroup cpp_kodi_gui_CListItem_Defs Definitions, structures and enumerators | ||
| 79 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 80 | /// @brief **Library definition values** | ||
| 81 | /// | ||
| 82 | |||
| 83 | class CListItem : public CAddonGUIControlBase | ||
| 84 | { | ||
| 85 | public: | ||
| 86 | //========================================================================== | ||
| 87 | /// | ||
| 88 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 89 | /// @brief Class constructor with parameters | ||
| 90 | /// | ||
| 91 | /// @param[in] label Item label | ||
| 92 | /// @param[in] label2 Second Item label (if needed) | ||
| 93 | /// @param[in] iconImage Item icon image (if needed) | ||
| 94 | /// @param[in] thumbnailImage Thumbnail Image of item (if needed) | ||
| 95 | /// @param[in] path Path to where item is defined | ||
| 96 | /// | ||
| 97 | CListItem( | ||
| 98 | const std::string& label = "", | ||
| 99 | const std::string& label2 = "", | ||
| 100 | const std::string& iconImage = "", | ||
| 101 | const std::string& thumbnailImage = "", | ||
| 102 | const std::string& path = "") | ||
| 103 | : CAddonGUIControlBase(nullptr) | ||
| 104 | { | ||
| 105 | m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(), | ||
| 106 | label2.c_str(), iconImage.c_str(), | ||
| 107 | thumbnailImage.c_str(), path.c_str()); | ||
| 108 | } | ||
| 109 | |||
| 110 | /* | ||
| 111 | * Constructor used for parts given by list items from addon window | ||
| 112 | * | ||
| 113 | * Related to call of "ListItemPtr kodi::gui::CWindow::GetListItem(int listPos)" | ||
| 114 | * Not needed for addon development itself | ||
| 115 | */ | ||
| 116 | CListItem(GUIHANDLE listItemHandle) | ||
| 117 | : CAddonGUIControlBase(nullptr) | ||
| 118 | { | ||
| 119 | m_controlHandle = listItemHandle; | ||
| 120 | } | ||
| 121 | |||
| 122 | //========================================================================== | ||
| 123 | /// | ||
| 124 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 125 | /// @brief Class destructor | ||
| 126 | /// | ||
| 127 | virtual ~CListItem() | ||
| 128 | { | ||
| 129 | m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 130 | } | ||
| 131 | //-------------------------------------------------------------------------- | ||
| 132 | |||
| 133 | //========================================================================== | ||
| 134 | /// | ||
| 135 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 136 | /// @brief Returns the listitem label. | ||
| 137 | /// | ||
| 138 | /// @return Label of item | ||
| 139 | /// | ||
| 140 | std::string GetLabel() | ||
| 141 | { | ||
| 142 | std::string label; | ||
| 143 | char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle); | ||
| 144 | if (ret != nullptr) | ||
| 145 | { | ||
| 146 | if (std::strlen(ret)) | ||
| 147 | label = ret; | ||
| 148 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 149 | } | ||
| 150 | return label; | ||
| 151 | } | ||
| 152 | //-------------------------------------------------------------------------- | ||
| 153 | |||
| 154 | //========================================================================== | ||
| 155 | /// | ||
| 156 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 157 | /// @brief Sets the listitem label. | ||
| 158 | /// | ||
| 159 | /// @param[in] label string or unicode - text string. | ||
| 160 | /// | ||
| 161 | void SetLabel(const std::string& label) | ||
| 162 | { | ||
| 163 | m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 164 | } | ||
| 165 | //-------------------------------------------------------------------------- | ||
| 166 | |||
| 167 | //========================================================================== | ||
| 168 | /// | ||
| 169 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 170 | /// @brief Returns the second listitem label. | ||
| 171 | /// | ||
| 172 | /// @return Second label of item | ||
| 173 | /// | ||
| 174 | std::string GetLabel2() | ||
| 175 | { | ||
| 176 | std::string label; | ||
| 177 | char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle); | ||
| 178 | if (ret != nullptr) | ||
| 179 | { | ||
| 180 | if (std::strlen(ret)) | ||
| 181 | label = ret; | ||
| 182 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 183 | } | ||
| 184 | return label; | ||
| 185 | } | ||
| 186 | //-------------------------------------------------------------------------- | ||
| 187 | |||
| 188 | //========================================================================== | ||
| 189 | /// | ||
| 190 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 191 | /// @brief Sets the listitem's label2. | ||
| 192 | /// | ||
| 193 | /// @param[in] label string or unicode - text string. | ||
| 194 | /// | ||
| 195 | void SetLabel2(const std::string& label) | ||
| 196 | { | ||
| 197 | m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle, label.c_str()); | ||
| 198 | } | ||
| 199 | //-------------------------------------------------------------------------- | ||
| 200 | |||
| 201 | //========================================================================== | ||
| 202 | /// | ||
| 203 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 204 | /// @brief To get current icon image of entry | ||
| 205 | /// | ||
| 206 | /// @return The current icon image path (if present) | ||
| 207 | /// | ||
| 208 | std::string GetIconImage() | ||
| 209 | { | ||
| 210 | std::string image; | ||
| 211 | char* ret = m_interface->kodi_gui->listItem->get_icon_image(m_interface->kodiBase, m_controlHandle); | ||
| 212 | if (ret != nullptr) | ||
| 213 | { | ||
| 214 | if (std::strlen(ret)) | ||
| 215 | image = ret; | ||
| 216 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 217 | } | ||
| 218 | return image; | ||
| 219 | } | ||
| 220 | //-------------------------------------------------------------------------- | ||
| 221 | |||
| 222 | //========================================================================== | ||
| 223 | /// | ||
| 224 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 225 | /// @brief To set icon image of entry | ||
| 226 | /// | ||
| 227 | /// @param image The image to use for. | ||
| 228 | /// | ||
| 229 | /// @note Alternative can be \ref SetArt used | ||
| 230 | /// | ||
| 231 | /// | ||
| 232 | void SetIconImage(const std::string& image) | ||
| 233 | { | ||
| 234 | m_interface->kodi_gui->listItem->set_icon_image(m_interface->kodiBase, m_controlHandle, image.c_str()); | ||
| 235 | } | ||
| 236 | //-------------------------------------------------------------------------- | ||
| 237 | |||
| 238 | //========================================================================== | ||
| 239 | /// | ||
| 240 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 241 | /// @brief Sets the listitem's art | ||
| 242 | /// | ||
| 243 | /// @param[in] type Type of Art to set | ||
| 244 | /// - Some default art values (any string possible): | ||
| 245 | /// | value (type) | Type | | ||
| 246 | /// |:-------------:|:--------------------------------------------------| | ||
| 247 | /// | thumb | string - image filename | ||
| 248 | /// | poster | string - image filename | ||
| 249 | /// | banner | string - image filename | ||
| 250 | /// | fanart | string - image filename | ||
| 251 | /// | clearart | string - image filename | ||
| 252 | /// | clearlogo | string - image filename | ||
| 253 | /// | landscape | string - image filename | ||
| 254 | /// | icon | string - image filename | ||
| 255 | /// @return The url to use for Art | ||
| 256 | /// | ||
| 257 | std::string GetArt(const std::string& type) | ||
| 258 | { | ||
| 259 | std::string strReturn; | ||
| 260 | char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle, type.c_str()); | ||
| 261 | if (ret != nullptr) | ||
| 262 | { | ||
| 263 | if (std::strlen(ret)) | ||
| 264 | strReturn = ret; | ||
| 265 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 266 | } | ||
| 267 | return strReturn; | ||
| 268 | } | ||
| 269 | //-------------------------------------------------------------------------- | ||
| 270 | |||
| 271 | //========================================================================== | ||
| 272 | /// | ||
| 273 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 274 | /// @brief Sets the listitem's art | ||
| 275 | /// | ||
| 276 | /// @param[in] type Type of Art to set | ||
| 277 | /// @param[in] url The url to use for Art | ||
| 278 | /// - Some default art values (any string possible): | ||
| 279 | /// | value (type) | Type | | ||
| 280 | /// |:-------------:|:--------------------------------------------------| | ||
| 281 | /// | thumb | string - image filename | ||
| 282 | /// | poster | string - image filename | ||
| 283 | /// | banner | string - image filename | ||
| 284 | /// | fanart | string - image filename | ||
| 285 | /// | clearart | string - image filename | ||
| 286 | /// | clearlogo | string - image filename | ||
| 287 | /// | landscape | string - image filename | ||
| 288 | /// | icon | string - image filename | ||
| 289 | /// | ||
| 290 | void SetArt(const std::string& type, const std::string& url) | ||
| 291 | { | ||
| 292 | m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(), url.c_str()); | ||
| 293 | } | ||
| 294 | //-------------------------------------------------------------------------- | ||
| 295 | |||
| 296 | //========================================================================== | ||
| 297 | /// | ||
| 298 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 299 | /// @brief Returns the path / filename of this listitem. | ||
| 300 | /// | ||
| 301 | /// @return Path string | ||
| 302 | /// | ||
| 303 | std::string GetPath() | ||
| 304 | { | ||
| 305 | std::string strReturn; | ||
| 306 | char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle); | ||
| 307 | if (ret != nullptr) | ||
| 308 | { | ||
| 309 | if (std::strlen(ret)) | ||
| 310 | strReturn = ret; | ||
| 311 | m_interface->free_string(m_interface->kodiBase, ret); | ||
| 312 | } | ||
| 313 | return strReturn; | ||
| 314 | } | ||
| 315 | //-------------------------------------------------------------------------- | ||
| 316 | |||
| 317 | //========================================================================== | ||
| 318 | /// | ||
| 319 | /// \ingroup cpp_kodi_gui_CListItem | ||
| 320 | /// @brief Sets the listitem's path. | ||
| 321 | /// | ||
| 322 | /// @param[in] path string or unicode - path, activated when | ||
| 323 | /// item is clicked. | ||
| 324 | /// | ||
| 325 | /// @note You can use the above as keywords for arguments. | ||
| 326 | /// | ||
| 327 | void SetPath(const std::string& path) | ||
| 328 | { | ||
| 329 | m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str()); | ||
| 330 | } | ||
| 331 | //-------------------------------------------------------------------------- | ||
| 332 | |||
| 333 | }; | ||
| 334 | |||
| 335 | } /* namespace gui */ | ||
| 336 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h new file mode 100644 index 0000000..7069e63 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h | |||
| @@ -0,0 +1,503 @@ | |||
| 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 "../AddonBase.h" | ||
| 23 | #include "ListItem.h" | ||
| 24 | |||
| 25 | #ifdef BUILD_KODI_ADDON | ||
| 26 | #include "../ActionIDs.h" | ||
| 27 | #else | ||
| 28 | #include "input/ActionIDs.h" | ||
| 29 | #endif | ||
| 30 | |||
| 31 | namespace kodi | ||
| 32 | { | ||
| 33 | namespace gui | ||
| 34 | { | ||
| 35 | |||
| 36 | class CListItem; | ||
| 37 | |||
| 38 | //============================================================================ | ||
| 39 | /// | ||
| 40 | /// \defgroup cpp_kodi_gui_CWindow Window | ||
| 41 | /// \ingroup cpp_kodi_gui | ||
| 42 | /// @brief \cpp_class{ kodi::gui::CWindow } | ||
| 43 | /// **Main window control class** | ||
| 44 | /// | ||
| 45 | /// The with \ref Window.h "#include <kodi/gui/Window.h>" | ||
| 46 | /// included file brings support to create a window or dialog on Kodi. | ||
| 47 | /// | ||
| 48 | /// -------------------------------------------------------------------------- | ||
| 49 | /// | ||
| 50 | /// On functions defined input variable <b><tt>controlId</tt> (GUI control identifier)</b> | ||
| 51 | /// is the on window.xml defined value behind type added with <tt><b>id="..."</b></tt> and | ||
| 52 | /// used to identify for changes there and on callbacks. | ||
| 53 | /// | ||
| 54 | /// ~~~~~~~~~~~~~{.xml} | ||
| 55 | /// <control type="label" id="31"> | ||
| 56 | /// <description>Title Label</description> | ||
| 57 | /// ... | ||
| 58 | /// </control> | ||
| 59 | /// <control type="progress" id="32"> | ||
| 60 | /// <description>progress control</description> | ||
| 61 | /// ... | ||
| 62 | /// </control> | ||
| 63 | /// ~~~~~~~~~~~~~ | ||
| 64 | /// | ||
| 65 | /// | ||
| 66 | |||
| 67 | //============================================================================ | ||
| 68 | /// | ||
| 69 | /// \defgroup cpp_kodi_gui_CWindow_Defs Definitions, structures and enumerators | ||
| 70 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 71 | /// @brief <b>Library definition values</b> | ||
| 72 | /// | ||
| 73 | |||
| 74 | class CWindow : public CAddonGUIControlBase | ||
| 75 | { | ||
| 76 | public: | ||
| 77 | //========================================================================== | ||
| 78 | /// | ||
| 79 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 80 | /// @brief Class constructor with needed values for window / dialog. | ||
| 81 | /// | ||
| 82 | /// Creates a new Window class. | ||
| 83 | /// | ||
| 84 | /// @param[in] xmlFilename XML file for the skin | ||
| 85 | /// @param[in] defaultSkin default skin to use if needed not available | ||
| 86 | /// @param[in] asDialog Use window as dialog if set | ||
| 87 | /// @param[in] isMedia [opt] bool - if False, create a regular window. | ||
| 88 | /// if True, create a mediawindow. | ||
| 89 | /// (default=false) | ||
| 90 | /// @note only usable for windows not for dialogs. | ||
| 91 | /// | ||
| 92 | /// | ||
| 93 | CWindow(const std::string& xmlFilename, const std::string& defaultSkin, bool asDialog, bool isMedia = false) | ||
| 94 | : CAddonGUIControlBase(nullptr) | ||
| 95 | { | ||
| 96 | m_controlHandle = m_interface->kodi_gui->window->create(m_interface->kodiBase, xmlFilename.c_str(), | ||
| 97 | defaultSkin.c_str(), asDialog, isMedia); | ||
| 98 | if (!m_controlHandle) | ||
| 99 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow can't create window class from Kodi !!!"); | ||
| 100 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, this, | ||
| 101 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 102 | CBGetContextButtons, CBOnContextButton); | ||
| 103 | } | ||
| 104 | //-------------------------------------------------------------------------- | ||
| 105 | |||
| 106 | //========================================================================== | ||
| 107 | /// | ||
| 108 | /// \ingroup CWindow | ||
| 109 | /// @brief Class destructor | ||
| 110 | /// | ||
| 111 | /// | ||
| 112 | /// | ||
| 113 | virtual ~CWindow() | ||
| 114 | { | ||
| 115 | if (m_controlHandle) | ||
| 116 | m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle); | ||
| 117 | } | ||
| 118 | //-------------------------------------------------------------------------- | ||
| 119 | |||
| 120 | //========================================================================== | ||
| 121 | /// | ||
| 122 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 123 | /// @brief Show this window. | ||
| 124 | /// | ||
| 125 | /// Shows this window by activating it, calling close() after it wil activate the | ||
| 126 | /// current window again. | ||
| 127 | /// | ||
| 128 | /// @note If your Add-On ends this window will be closed to. To show it forever, | ||
| 129 | /// make a loop at the end of your Add-On or use doModal() instead. | ||
| 130 | /// | ||
| 131 | /// @return Return true if call and show is successed, | ||
| 132 | /// if false was something failed to get needed | ||
| 133 | /// skin parts. | ||
| 134 | /// | ||
| 135 | bool Show() | ||
| 136 | { | ||
| 137 | return m_interface->kodi_gui->window->show(m_interface->kodiBase, m_controlHandle); | ||
| 138 | } | ||
| 139 | //-------------------------------------------------------------------------- | ||
| 140 | |||
| 141 | //========================================================================== | ||
| 142 | /// | ||
| 143 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 144 | /// @brief Closes this window. | ||
| 145 | /// | ||
| 146 | /// Closes this window by activating the old window. | ||
| 147 | /// @note The window is not deleted with this method. | ||
| 148 | /// | ||
| 149 | void Close() | ||
| 150 | { | ||
| 151 | m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); | ||
| 152 | } | ||
| 153 | //-------------------------------------------------------------------------- | ||
| 154 | |||
| 155 | //========================================================================== | ||
| 156 | /// | ||
| 157 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 158 | /// @brief Display this window until close() is called. | ||
| 159 | /// | ||
| 160 | void DoModal() | ||
| 161 | { | ||
| 162 | m_interface->kodi_gui->window->do_modal(m_interface->kodiBase, m_controlHandle); | ||
| 163 | } | ||
| 164 | //-------------------------------------------------------------------------- | ||
| 165 | |||
| 166 | //========================================================================== | ||
| 167 | /// | ||
| 168 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 169 | /// @brief Function delete all entries in integrated list. | ||
| 170 | /// | ||
| 171 | /// | ||
| 172 | /// | ||
| 173 | void ClearList() | ||
| 174 | { | ||
| 175 | m_interface->kodi_gui->window->clear_item_list(m_interface->kodiBase, m_controlHandle); | ||
| 176 | } | ||
| 177 | //-------------------------------------------------------------------------- | ||
| 178 | |||
| 179 | //========================================================================== | ||
| 180 | /// | ||
| 181 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 182 | /// @brief To add a list item in the on window integrated list. | ||
| 183 | /// | ||
| 184 | /// @param[in] item List item to add | ||
| 185 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 186 | /// | ||
| 187 | /// | ||
| 188 | void AddListItem(ListItemPtr item, int itemPosition = -1) | ||
| 189 | { | ||
| 190 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle, itemPosition); | ||
| 191 | } | ||
| 192 | //-------------------------------------------------------------------------- | ||
| 193 | |||
| 194 | //========================================================================== | ||
| 195 | /// | ||
| 196 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 197 | /// @brief To add a list item based upon string in the on window integrated list. | ||
| 198 | /// | ||
| 199 | /// @param[in] item List item to add | ||
| 200 | /// @param[in] itemPosition [opt] The position for item, default is on end | ||
| 201 | /// | ||
| 202 | /// | ||
| 203 | void AddListItem(const std::string item, int itemPosition = -1) | ||
| 204 | { | ||
| 205 | m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, std::make_shared<kodi::gui::CListItem>(item)->m_controlHandle, itemPosition); | ||
| 206 | } | ||
| 207 | //-------------------------------------------------------------------------- | ||
| 208 | |||
| 209 | //========================================================================== | ||
| 210 | /// | ||
| 211 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 212 | /// @brief To get list item control class on wanted position. | ||
| 213 | /// | ||
| 214 | /// @param[in] listPos Position from where control is needed | ||
| 215 | /// @return The list item control class or null if not found | ||
| 216 | /// | ||
| 217 | /// @warning Function returns a new generated **CListItem** class! | ||
| 218 | /// | ||
| 219 | ListItemPtr GetListItem(int listPos) | ||
| 220 | { | ||
| 221 | GUIHANDLE handle = m_interface->kodi_gui->window->get_list_item(m_interface->kodiBase, m_controlHandle, listPos); | ||
| 222 | if (!handle) | ||
| 223 | return ListItemPtr(); | ||
| 224 | |||
| 225 | return std::make_shared<kodi::gui::CListItem>(handle); | ||
| 226 | } | ||
| 227 | //-------------------------------------------------------------------------- | ||
| 228 | |||
| 229 | //========================================================================== | ||
| 230 | // | ||
| 231 | /// @defgroup cpp_kodi_gui_CWindow_callbacks Callback functions from Kodi to add-on | ||
| 232 | /// \ingroup cpp_kodi_gui_CWindow | ||
| 233 | //@{ | ||
| 234 | /// @brief <b>GUI window callback functions.</b> | ||
| 235 | /// | ||
| 236 | /// Functions to handle control callbacks from Kodi | ||
| 237 | /// | ||
| 238 | /// ------------------------------------------------------------------------ | ||
| 239 | /// | ||
| 240 | /// @link cpp_kodi_gui_CWindow Go back to normal functions from CWindow@endlink | ||
| 241 | // | ||
| 242 | |||
| 243 | //========================================================================== | ||
| 244 | /// | ||
| 245 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 246 | /// @brief OnInit method. | ||
| 247 | /// | ||
| 248 | /// @return Return true if initialize was done successful | ||
| 249 | /// | ||
| 250 | /// | ||
| 251 | virtual bool OnInit() { return false; } | ||
| 252 | //-------------------------------------------------------------------------- | ||
| 253 | |||
| 254 | //========================================================================== | ||
| 255 | /// | ||
| 256 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 257 | /// @brief OnFocus method. | ||
| 258 | /// | ||
| 259 | /// @param[in] controlId GUI control identifier | ||
| 260 | /// @return Return true if focus condition was handled there or false to handle them by Kodi itself | ||
| 261 | /// | ||
| 262 | /// | ||
| 263 | virtual bool OnFocus(int controlId) { return false; } | ||
| 264 | //-------------------------------------------------------------------------- | ||
| 265 | |||
| 266 | //========================================================================== | ||
| 267 | /// | ||
| 268 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 269 | /// @brief OnClick method. | ||
| 270 | /// | ||
| 271 | /// @param[in] controlId GUI control identifier | ||
| 272 | /// @return Return true if click was handled there | ||
| 273 | /// or false to handle them by Kodi itself | ||
| 274 | /// | ||
| 275 | /// | ||
| 276 | virtual bool OnClick(int controlId) { return false; } | ||
| 277 | //-------------------------------------------------------------------------- | ||
| 278 | |||
| 279 | //========================================================================== | ||
| 280 | /// | ||
| 281 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 282 | /// @brief OnAction method. | ||
| 283 | /// | ||
| 284 | /// @param[in] actionId The action id to perform, see | ||
| 285 | /// \ref kodi_key_action_ids to get list of | ||
| 286 | /// them | ||
| 287 | /// @return Return true if action was handled there | ||
| 288 | /// or false to handle them by Kodi itself | ||
| 289 | /// | ||
| 290 | /// | ||
| 291 | /// This method will receive all actions that the main program will send | ||
| 292 | /// to this window. | ||
| 293 | /// | ||
| 294 | /// @note | ||
| 295 | /// - By default, only the \c PREVIOUS_MENU and \c NAV_BACK actions are handled. | ||
| 296 | /// - Overwrite this method to let your code handle all actions. | ||
| 297 | /// - Don't forget to capture \c ACTION_PREVIOUS_MENU or \c ACTION_NAV_BACK, else the user can't close this window. | ||
| 298 | /// | ||
| 299 | /// | ||
| 300 | ///-------------------------------------------------------------------------- | ||
| 301 | /// | ||
| 302 | /// **Example:** | ||
| 303 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 304 | /// .. | ||
| 305 | /// /* Window used with parent / child way */ | ||
| 306 | /// bool cYOUR_CLASS::OnAction(int actionId) | ||
| 307 | /// { | ||
| 308 | /// switch (action) | ||
| 309 | /// { | ||
| 310 | /// case ACTION_PREVIOUS_MENU: | ||
| 311 | /// case ACTION_NAV_BACK: | ||
| 312 | /// printf("action recieved: previous"); | ||
| 313 | /// Close(); | ||
| 314 | /// return true; | ||
| 315 | /// case ACTION_SHOW_INFO: | ||
| 316 | /// printf("action recieved: show info"); | ||
| 317 | /// break; | ||
| 318 | /// case ACTION_STOP: | ||
| 319 | /// printf("action recieved: stop"); | ||
| 320 | /// break; | ||
| 321 | /// case ACTION_PAUSE: | ||
| 322 | /// printf("action recieved: pause"); | ||
| 323 | /// break; | ||
| 324 | /// default: | ||
| 325 | /// break; | ||
| 326 | /// } | ||
| 327 | /// return false; | ||
| 328 | /// } | ||
| 329 | /// .. | ||
| 330 | /// ~~~~~~~~~~~~~ | ||
| 331 | /// | ||
| 332 | virtual bool OnAction(int actionId) | ||
| 333 | { | ||
| 334 | switch (actionId) | ||
| 335 | { | ||
| 336 | case ACTION_PREVIOUS_MENU: | ||
| 337 | case ACTION_NAV_BACK: | ||
| 338 | Close(); | ||
| 339 | return true; | ||
| 340 | default: | ||
| 341 | break; | ||
| 342 | } | ||
| 343 | return false; | ||
| 344 | } | ||
| 345 | //-------------------------------------------------------------------------- | ||
| 346 | |||
| 347 | //========================================================================== | ||
| 348 | /// | ||
| 349 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 350 | /// @brief Get context menu buttons for list entry | ||
| 351 | /// | ||
| 352 | /// @param[in] itemNumber selected list item entry | ||
| 353 | /// @param[in] buttons list where context menus becomes added with his | ||
| 354 | /// identifier and name. | ||
| 355 | /// | ||
| 356 | virtual void GetContextButtons(int itemNumber, std::vector< std::pair<unsigned int, std::string> > &buttons) | ||
| 357 | { | ||
| 358 | } | ||
| 359 | //-------------------------------------------------------------------------- | ||
| 360 | |||
| 361 | //========================================================================== | ||
| 362 | /// | ||
| 363 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 364 | /// @brief Called after selection in context menu | ||
| 365 | /// | ||
| 366 | /// @param[in] itemNumber selected list item entry | ||
| 367 | /// @param[in] button the pressed button id | ||
| 368 | /// @return true if handled, otherwise false | ||
| 369 | /// | ||
| 370 | virtual bool OnContextButton(int itemNumber, unsigned int button) | ||
| 371 | { | ||
| 372 | return false; | ||
| 373 | } | ||
| 374 | //-------------------------------------------------------------------------- | ||
| 375 | |||
| 376 | //========================================================================== | ||
| 377 | /// | ||
| 378 | /// \ingroup cpp_kodi_gui_CWindow_callbacks | ||
| 379 | /// @brief **Set independent callbacks** | ||
| 380 | /// | ||
| 381 | /// If the class is used independent (with "new CWindow") and | ||
| 382 | /// not as parent (with "cCLASS_own : CWindow") from own must be the | ||
| 383 | /// callback from Kodi to add-on overdriven with own functions! | ||
| 384 | /// | ||
| 385 | /// @param[in] cbhdl The pointer to own handle data | ||
| 386 | /// structure / class | ||
| 387 | /// @param[in] CBOnInit Own defined window init function | ||
| 388 | /// @param[in] CBOnFocus Own defined focus function | ||
| 389 | /// @param[in] CBOnClick Own defined click function | ||
| 390 | /// @param[in] CBOnAction Own defined action function | ||
| 391 | /// @param[in] CBGetContextButtons [opt] To get context menu entries for | ||
| 392 | /// lists function | ||
| 393 | /// @param[in] CBOnContextButton [opt] Used context menu entry function | ||
| 394 | /// | ||
| 395 | /// | ||
| 396 | ///-------------------------------------------------------------------------- | ||
| 397 | /// | ||
| 398 | /// **Example:** | ||
| 399 | /// ~~~~~~~~~~~~~{.cpp} | ||
| 400 | /// ... | ||
| 401 | /// | ||
| 402 | /// bool OnInit(GUIHANDLE cbhdl) | ||
| 403 | /// { | ||
| 404 | /// ... | ||
| 405 | /// return true; | ||
| 406 | /// } | ||
| 407 | /// | ||
| 408 | /// bool OnFocus(GUIHANDLE cbhdl, int controlId) | ||
| 409 | /// { | ||
| 410 | /// ... | ||
| 411 | /// return true; | ||
| 412 | /// } | ||
| 413 | /// | ||
| 414 | /// bool OnClick(GUIHANDLE cbhdl, int controlId) | ||
| 415 | /// { | ||
| 416 | /// ... | ||
| 417 | /// return true; | ||
| 418 | /// } | ||
| 419 | /// | ||
| 420 | /// bool OnAction(GUIHANDLE cbhdl, int actionId) | ||
| 421 | /// { | ||
| 422 | /// ... | ||
| 423 | /// return true; | ||
| 424 | /// } | ||
| 425 | /// | ||
| 426 | /// ... | ||
| 427 | /// /* Somewhere where you create the window */ | ||
| 428 | /// CWindow myWindow = new CWindow; | ||
| 429 | /// myWindow->SetIndependentCallbacks(myWindow, OnInit, OnFocus, OnClick, OnAction); | ||
| 430 | /// ... | ||
| 431 | /// ~~~~~~~~~~~~~ | ||
| 432 | /// | ||
| 433 | void SetIndependentCallbacks( | ||
| 434 | GUIHANDLE cbhdl, | ||
| 435 | bool (*CBOnInit) (GUIHANDLE cbhdl), | ||
| 436 | bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), | ||
| 437 | bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), | ||
| 438 | bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId), | ||
| 439 | void (*CBGetContextButtons) (GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) = nullptr, | ||
| 440 | bool (*CBOnContextButton) (GUIHANDLE cbhdl, int itemNumber, unsigned int button) = nullptr) | ||
| 441 | { | ||
| 442 | if (!cbhdl || | ||
| 443 | !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction) | ||
| 444 | { | ||
| 445 | kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow::%s called with nullptr !!!", __FUNCTION__); | ||
| 446 | return; | ||
| 447 | } | ||
| 448 | |||
| 449 | m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, | ||
| 450 | CBOnInit, CBOnFocus, CBOnClick, CBOnAction, | ||
| 451 | CBGetContextButtons, CBOnContextButton); | ||
| 452 | } | ||
| 453 | //-------------------------------------------------------------------------- | ||
| 454 | //@} | ||
| 455 | |||
| 456 | private: | ||
| 457 | static bool CBOnInit(GUIHANDLE cbhdl) | ||
| 458 | { | ||
| 459 | return static_cast<CWindow*>(cbhdl)->OnInit(); | ||
| 460 | } | ||
| 461 | |||
| 462 | static bool CBOnFocus(GUIHANDLE cbhdl, int controlId) | ||
| 463 | { | ||
| 464 | return static_cast<CWindow*>(cbhdl)->OnFocus(controlId); | ||
| 465 | } | ||
| 466 | |||
| 467 | static bool CBOnClick(GUIHANDLE cbhdl, int controlId) | ||
| 468 | { | ||
| 469 | return static_cast<CWindow*>(cbhdl)->OnClick(controlId); | ||
| 470 | } | ||
| 471 | |||
| 472 | static bool CBOnAction(GUIHANDLE cbhdl, int actionId) | ||
| 473 | { | ||
| 474 | return static_cast<CWindow*>(cbhdl)->OnAction(actionId); | ||
| 475 | } | ||
| 476 | |||
| 477 | static void CBGetContextButtons(GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) | ||
| 478 | { | ||
| 479 | std::vector< std::pair<unsigned int, std::string> > buttonList; | ||
| 480 | static_cast<CWindow*>(cbhdl)->GetContextButtons(itemNumber, buttonList); | ||
| 481 | if (!buttonList.empty()) | ||
| 482 | { | ||
| 483 | unsigned int presentSize = buttonList.size(); | ||
| 484 | if (presentSize > *size) | ||
| 485 | kodi::Log(ADDON_LOG_WARNING, "GetContextButtons: More as allowed '%i' entries present!", *size); | ||
| 486 | else | ||
| 487 | *size = presentSize; | ||
| 488 | for (unsigned int i = 0; i < *size; ++i) | ||
| 489 | { | ||
| 490 | buttons[i].id = buttonList[i].first; | ||
| 491 | strncpy(buttons[i].name, buttonList[i].second.c_str(), ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH); | ||
| 492 | } | ||
| 493 | } | ||
| 494 | } | ||
| 495 | |||
| 496 | static bool CBOnContextButton(GUIHANDLE cbhdl, int itemNumber, unsigned int button) | ||
| 497 | { | ||
| 498 | return static_cast<CWindow*>(cbhdl)->OnContextButton(itemNumber, button); | ||
| 499 | } | ||
| 500 | }; | ||
| 501 | |||
| 502 | } /* namespace gui */ | ||
| 503 | } /* namespace kodi */ | ||
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h new file mode 100644 index 0000000..a4cf963 --- /dev/null +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h | |||
| @@ -0,0 +1,209 @@ | |||
| 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 <string> | ||
| 23 | #include <time.h> | ||
| 24 | |||
| 25 | /* | ||
| 26 | * Internal Structures to have "C"-Style data transfer | ||
| 27 | */ | ||
| 28 | extern "C" | ||
| 29 | { | ||
| 30 | |||
| 31 | typedef struct AddonToKodiFuncTable_kodi_gui_general | ||
| 32 | { | ||
| 33 | void (*lock)(); | ||
| 34 | void (*unlock)(); | ||
| 35 | int (*get_screen_height)(void* kodiBase); | ||
| 36 | int (*get_screen_width)(void* kodiBase); | ||
| 37 | int (*get_video_resolution)(void* kodiBase); | ||
| 38 | int (*get_current_window_dialog_id)(void* kodiBase); | ||
| 39 | int (*get_current_window_id)(void* kodiBase); | ||
| 40 | } AddonToKodiFuncTable_kodi_gui_general; | ||
| 41 | |||
| 42 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu | ||
| 43 | { | ||
| 44 | int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size); | ||
| 45 | } AddonToKodiFuncTable_kodi_gui_dialogContextMenu; | ||
| 46 | |||
| 47 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress | ||
| 48 | { | ||
| 49 | void* (*new_dialog)(void* kodiBase, const char *title); | ||
| 50 | void (*delete_dialog)(void* kodiBase, void* handle); | ||
| 51 | char* (*get_title)(void* kodiBase, void* handle); | ||
| 52 | void (*set_title)(void* kodiBase, void* handle, const char *title); | ||
| 53 | char* (*get_text)(void* kodiBase, void* handle); | ||
| 54 | void (*set_text)(void* kodiBase, void* handle, const char *text); | ||
| 55 | bool (*is_finished)(void* kodiBase, void* handle); | ||
| 56 | void (*mark_finished)(void* kodiBase, void* handle); | ||
| 57 | float (*get_percentage)(void* kodiBase, void* handle); | ||
| 58 | void (*set_percentage)(void* kodiBase, void* handle, float percentage); | ||
| 59 | void (*set_progress)(void* kodiBase, void* handle, int currentItem, int itemCount); | ||
| 60 | } AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress; | ||
| 61 | |||
| 62 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser | ||
| 63 | { | ||
| 64 | bool (*show_and_get_directory)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out, bool writeOnly); | ||
| 65 | bool (*show_and_get_file)(void* kodiBase, const char* shares, const char* mask, const char* heading, const char* path_in, char** path_out, bool use_thumbs, bool use_file_directories); | ||
| 66 | bool (*show_and_get_file_from_dir)(void* kodiBase, const char* directory, const char* mask, const char* heading, const char* path_in, char** path_out, bool use_thumbs, bool use_file_directories, bool singleList); | ||
| 67 | bool (*show_and_get_file_list)(void* kodiBase, const char* shares, const char* mask, const char* heading, char*** file_list, unsigned int* entries, bool use_thumbs, bool use_file_directories); | ||
| 68 | bool (*show_and_get_source)(void* kodiBase, const char* path_in, char** path_out, bool allow_network_shares, const char* additional_share, const char* type); | ||
| 69 | bool (*show_and_get_image)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out); | ||
| 70 | bool (*show_and_get_image_list)(void* kodiBase, const char* shares, const char* heading, char*** file_list, unsigned int* entries); | ||
| 71 | void (*clear_file_list)(void* kodiBase, char*** file_list, unsigned int entries); | ||
| 72 | } AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; | ||
| 73 | |||
| 74 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard | ||
| 75 | { | ||
| 76 | bool (*show_and_get_input_with_head)(void* kodiBase, const char* text_in, char** text_out, const char* heading, bool allow_empty_result, bool hiddenInput, unsigned int auto_close_ms); | ||
| 77 | bool (*show_and_get_input)(void* kodiBase, const char* text_in, char** text_out, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 78 | bool (*show_and_get_new_password_with_head)(void* kodiBase, const char* password_in, char** password_out, const char* heading, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 79 | bool (*show_and_get_new_password)(void* kodiBase, const char* password_in, char** password_out, unsigned int auto_close_ms); | ||
| 80 | bool (*show_and_verify_new_password_with_head)(void* kodiBase, char** password_out, const char* heading, bool allow_empty_result, unsigned int auto_close_ms); | ||
| 81 | bool (*show_and_verify_new_password)(void* kodiBase, char** password_out, unsigned int auto_close_ms); | ||
| 82 | int (*show_and_verify_password)(void* kodiBase, const char* password_in, char** password_out, const char* heading, int retries, unsigned int auto_close_ms); | ||
| 83 | bool (*show_and_get_filter)(void* kodiBase, const char* text_in, char** text_out, bool searching, unsigned int auto_close_ms); | ||
| 84 | bool (*send_text_to_active_keyboard)(void* kodiBase, const char* text, bool close_keyboard); | ||
| 85 | bool (*is_keyboard_activated)(void* kodiBase); | ||
| 86 | } AddonToKodiFuncTable_kodi_gui_dialogKeyboard; | ||
| 87 | |||
| 88 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogNumeric | ||
| 89 | { | ||
| 90 | bool (*show_and_verify_new_password)(void* kodiBase, char** password); | ||
| 91 | int (*show_and_verify_password)(void* kodiBase, const char* password, const char *heading, int retries); | ||
| 92 | bool (*show_and_verify_input)(void* kodiBase, const char* verify_in, char** verify_out, const char* heading, bool verify_input); | ||
| 93 | bool (*show_and_get_time)(void* kodiBase, tm *time, const char *heading); | ||
| 94 | bool (*show_and_get_date)(void* kodiBase, tm *date, const char *heading); | ||
| 95 | bool (*show_and_get_ip_address)(void* kodiBase, const char* ip_address_in, char** ip_address_out, const char *heading); | ||
| 96 | bool (*show_and_get_number)(void* kodiBase, const char* input_in, char** input_out, const char *heading, unsigned int auto_close_ms); | ||
| 97 | bool (*show_and_get_seconds)(void* kodiBase, const char* time_in, char** time_out, const char *heading); | ||
| 98 | } AddonToKodiFuncTable_kodi_gui_dialogNumeric; | ||
| 99 | |||
| 100 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogOK | ||
| 101 | { | ||
| 102 | void (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text); | ||
| 103 | void (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2); | ||
| 104 | } AddonToKodiFuncTable_kodi_gui_dialogOK; | ||
| 105 | |||
| 106 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogProgress | ||
| 107 | { | ||
| 108 | void* (*new_dialog)(void* kodiBase); | ||
| 109 | void (*delete_dialog)(void* kodiBase, void* handle); | ||
| 110 | void (*open)(void* kodiBase, void* handle); | ||
| 111 | void (*set_heading)(void* kodiBase, void* handle, const char* heading); | ||
| 112 | void (*set_line)(void* kodiBase, void* handle, unsigned int lineNo, const char* line); | ||
| 113 | void (*set_can_cancel)(void* kodiBase, void* handle, bool canCancel); | ||
| 114 | bool (*is_canceled)(void* kodiBase, void* handle); | ||
| 115 | void (*set_percentage)(void* kodiBase, void* handle, int percentage); | ||
| 116 | int (*get_percentage)(void* kodiBase, void* handle); | ||
| 117 | void (*show_progress_bar)(void* kodiBase, void* handle, bool pnOff); | ||
| 118 | void (*set_progress_max)(void* kodiBase, void* handle, int max); | ||
| 119 | void (*set_progress_advance)(void* kodiBase, void* handle, int nSteps); | ||
| 120 | bool (*abort)(void* kodiBase, void* handle); | ||
| 121 | } AddonToKodiFuncTable_kodi_gui_dialogProgress; | ||
| 122 | |||
| 123 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogSelect | ||
| 124 | { | ||
| 125 | int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, bool autoclose); | ||
| 126 | } AddonToKodiFuncTable_kodi_gui_dialogSelect; | ||
| 127 | |||
| 128 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer | ||
| 129 | { | ||
| 130 | void (*open)(void* kodiBase, const char *heading, const char *text); | ||
| 131 | } AddonToKodiFuncTable_kodi_gui_dialogTextViewer; | ||
| 132 | |||
| 133 | typedef struct AddonToKodiFuncTable_kodi_gui_dialogYesNo | ||
| 134 | { | ||
| 135 | bool (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text, bool *canceled, const char *noLabel, const char *yesLabel); | ||
| 136 | bool (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); | ||
| 137 | bool (*show_and_get_input_line_button_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2, bool *canceled, const char *noLabel, const char *yesLabel); | ||
| 138 | } AddonToKodiFuncTable_kodi_gui_dialogYesNo; | ||
| 139 | |||
| 140 | typedef struct AddonToKodiFuncTable_kodi_gui_listItem | ||
| 141 | { | ||
| 142 | void* (*create)(void* kodiBase, const char* label, const char* label2, const char* icon_image, const char* thumbnail_image, const char* path); | ||
| 143 | void (*destroy)(void* kodiBase, void* handle); | ||
| 144 | char* (*get_label)(void* kodiBase, void* handle); | ||
| 145 | void (*set_label)(void* kodiBase, void* handle, const char* label); | ||
| 146 | char* (*get_label2)(void* kodiBase, void* handle); | ||
| 147 | void (*set_label2)(void* kodiBase, void* handle, const char* label); | ||
| 148 | char* (*get_icon_image)(void* kodiBase, void* handle); | ||
| 149 | void (*set_icon_image)(void* kodiBase, void* handle, const char* image); | ||
| 150 | char* (*get_art)(void* kodiBase, void* handle, const char* type); | ||
| 151 | void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); | ||
| 152 | char* (*get_path)(void* kodiBase, void* handle); | ||
| 153 | void (*set_path)(void* kodiBase, void* handle, const char* path); | ||
| 154 | } AddonToKodiFuncTable_kodi_gui_listItem; | ||
| 155 | |||
| 156 | #define ADDON_MAX_CONTEXT_ENTRIES 20 | ||
| 157 | #define ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH 80 | ||
| 158 | typedef struct gui_context_menu_pair | ||
| 159 | { | ||
| 160 | unsigned int id; | ||
| 161 | char name[ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH]; | ||
| 162 | } gui_context_menu_pair; | ||
| 163 | |||
| 164 | typedef struct AddonToKodiFuncTable_kodi_gui_window | ||
| 165 | { | ||
| 166 | void* (*create)(void* kodiBase, const char* xml_filename, const char* default_skin, bool as_dialog, bool is_media); | ||
| 167 | void (*destroy)(void* kodiBase, void* handle); | ||
| 168 | void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, | ||
| 169 | bool (*)(void* handle), | ||
| 170 | bool (*)(void* handle, int), | ||
| 171 | bool (*)(void* handle, int), | ||
| 172 | bool (*)(void* handle, int), | ||
| 173 | void (*)(void* handle, int, gui_context_menu_pair*, unsigned int*), | ||
| 174 | bool (*)(void* handle, int, unsigned int)); | ||
| 175 | bool (*show)(void* kodiBase, void* handle); | ||
| 176 | bool (*close)(void* kodiBase, void* handle); | ||
| 177 | bool (*do_modal)(void* kodiBase, void* handle); | ||
| 178 | void (*clear_item_list)(void* kodiBase, void* handle); | ||
| 179 | void (*add_list_item)(void* kodiBase, void* handle, void* item, int item_position); | ||
| 180 | void* (*get_list_item)(void* kodiBase, void* handle, int listPos); | ||
| 181 | } AddonToKodiFuncTable_kodi_gui_window; | ||
| 182 | |||
| 183 | typedef struct AddonToKodiFuncTable_kodi_gui | ||
| 184 | { | ||
| 185 | AddonToKodiFuncTable_kodi_gui_general* general; | ||
| 186 | AddonToKodiFuncTable_kodi_gui_dialogContextMenu* dialogContextMenu; | ||
| 187 | AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress* dialogExtendedProgress; | ||
| 188 | AddonToKodiFuncTable_kodi_gui_dialogFileBrowser* dialogFileBrowser; | ||
| 189 | AddonToKodiFuncTable_kodi_gui_dialogKeyboard* dialogKeyboard; | ||
| 190 | AddonToKodiFuncTable_kodi_gui_dialogNumeric* dialogNumeric; | ||
| 191 | AddonToKodiFuncTable_kodi_gui_dialogOK* dialogOK; | ||
| 192 | AddonToKodiFuncTable_kodi_gui_dialogProgress* dialogProgress; | ||
| 193 | AddonToKodiFuncTable_kodi_gui_dialogSelect* dialogSelect; | ||
| 194 | AddonToKodiFuncTable_kodi_gui_dialogTextViewer* dialogTextViewer; | ||
| 195 | AddonToKodiFuncTable_kodi_gui_dialogYesNo* dialogYesNo; | ||
| 196 | AddonToKodiFuncTable_kodi_gui_listItem* listItem; | ||
| 197 | AddonToKodiFuncTable_kodi_gui_window* window; | ||
| 198 | } AddonToKodiFuncTable_kodi_gui; | ||
| 199 | |||
| 200 | } /* extern "C" */ | ||
| 201 | |||
| 202 | //============================================================================ | ||
| 203 | /// | ||
| 204 | /// \ingroup cpp_kodi_gui_CControlRendering_Defs cpp_kodi_gui_CWindow_Defs | ||
| 205 | /// @{ | ||
| 206 | /// @brief Handle to use as independent pointer for GUI | ||
| 207 | typedef void* GUIHANDLE; | ||
| 208 | /// @} | ||
| 209 | //---------------------------------------------------------------------------- | ||
