From f44ecaa4f27e7538ddcad66d40e543bffa2d2d86 Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 4 Jun 2017 16:57:49 +0200 Subject: sync with upstream --- .../include/kodi/gui/DialogContextMenu.h | 95 ++++ .../include/kodi/gui/DialogExtendedProgress.h | 244 ++++++++++ .../include/kodi/gui/DialogFileBrowser.h | 293 ++++++++++++ .../include/kodi/gui/DialogKeyboard.h | 416 +++++++++++++++++ .../include/kodi/gui/DialogNumeric.h | 366 +++++++++++++++ .../kodi-addon-dev-kit/include/kodi/gui/DialogOK.h | 104 +++++ .../include/kodi/gui/DialogProgress.h | 249 ++++++++++ .../include/kodi/gui/DialogSelect.h | 101 +++++ .../include/kodi/gui/DialogTextViewer.h | 115 +++++ .../include/kodi/gui/DialogYesNo.h | 187 ++++++++ .../kodi-addon-dev-kit/include/kodi/gui/General.h | 156 +++++++ .../kodi-addon-dev-kit/include/kodi/gui/ListItem.h | 336 ++++++++++++++ .../kodi-addon-dev-kit/include/kodi/gui/Window.h | 503 +++++++++++++++++++++ .../include/kodi/gui/definitions.h | 209 +++++++++ 14 files changed, 3374 insertions(+) create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogContextMenu.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogExtendedProgress.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogFileBrowser.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogKeyboard.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogNumeric.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogOK.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogProgress.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogSelect.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogTextViewer.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/DialogYesNo.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/General.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/ListItem.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/Window.h create mode 100644 xbmc/addons/kodi-addon-dev-kit/include/kodi/gui/definitions.h (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/gui') 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_DialogContextMenu Dialog Context Menu + /// \ingroup cpp_kodi_gui + /// @brief \cpp_namespace{ kodi::gui::DialogContextMenu } + /// **Context menu dialog** + /// + /// The function listed below permits the call of a dialogue as context menu to + /// select of an entry as a key + /// + /// It has the header \ref DialogContextMenu.h "#include " + /// be included to enjoy it. + /// + /// + namespace DialogContextMenu + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogContextMenu + /// @brief Show a context menu dialog about given parts. + /// + /// @param[in] heading Dialog heading name + /// @param[in] entries String list about entries + /// @return The selected entry, if return -1 was nothing selected or canceled + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// const std::vector entries + /// { + /// "Test 1", + /// "Test 2", + /// "Test 3", + /// "Test 4", + /// "Test 5" + /// }; + /// + /// int selected = kodi::gui::DialogContextMenu::Show("Test selection", entries); + /// if (selected < 0) + /// fprintf(stderr, "Item selection canceled\n"); + /// else + /// fprintf(stderr, "Selected item is: %i\n", selected); + /// ~~~~~~~~~~~~~ + /// + inline int Show(const std::string& heading, const std::vector& entries) + { + using namespace ::kodi::addon; + unsigned int size = entries.size(); + const char** cEntries = static_cast(malloc(size*sizeof(const char**))); + for (unsigned int i = 0; i < size; ++i) + { + cEntries[i] = entries[i].c_str(); + } + int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogContextMenu->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size); + free(cEntries); + return ret; + } + //-------------------------------------------------------------------------- + }; + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_CDialogExtendedProgress Dialog Extended Progress + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::CDialogExtendedProgress } + /// **Progress dialog shown for background work** + /// + /// The with \ref DialogExtendedProgress.h "#include " + /// given class are basically used to create Kodi's extended progress. + /// + /// + /// -------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// kodi::gui::CDialogExtendedProgress *ext_progress = new kodi::gui::CDialogExtendedProgress("Test Extended progress"); + /// ext_progress->SetText("Test progress"); + /// for (unsigned int i = 0; i < 50; i += 10) + /// { + /// ext_progress->SetProgress(i, 100); + /// sleep(1); + /// } + /// + /// ext_progress->SetTitle("Test Extended progress - Second round"); + /// ext_progress->SetText("Test progress - Step 2"); + /// + /// for (unsigned int i = 50; i < 100; i += 10) + /// { + /// ext_progress->SetProgress(i, 100); + /// sleep(1); + /// } + /// delete ext_progress; + /// ~~~~~~~~~~~~~ + /// + class CDialogExtendedProgress + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// Construct a new dialog + /// + /// @param[in] title Title string + /// + CDialogExtendedProgress(const std::string& title = "") + { + using namespace ::kodi::addon; + m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase, title.c_str()); + if (!m_DialogHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogExtendedProgress can't create window class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// Destructor + /// + ~CDialogExtendedProgress() + { + using namespace ::kodi::addon; + if (m_DialogHandle) + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief Get the used title + /// + /// @return Title string + /// + std::string Title() const + { + using namespace ::kodi::addon; + std::string text; + char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + text = strMsg; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); + } + return text; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief To set the title of dialog + /// + /// @param[in] title Title string + /// + void SetTitle(const std::string& title) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_title(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, title.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief Get the used text information string + /// + /// @return Text string + /// + std::string Text() const + { + using namespace ::kodi::addon; + std::string text; + char* strMsg = CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + if (strMsg != nullptr) + { + if (std::strlen(strMsg)) + text = strMsg; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, strMsg); + } + return text; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief To set the used text information string + /// + /// @param[in] text information text to set + /// + void SetText(const std::string& text) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_text(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief To ask dialog is finished + /// + /// @return True if on end + /// + bool IsFinished() const + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->is_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief Mark progress finished + /// + void MarkFinished() + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->mark_finished(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief Get the current progress position as percent + /// + /// @return Position + /// + float Percentage() const + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief To set the current progress position as percent + /// + /// @param[in] percentage Position to use from 0.0 to 100.0 + /// + void SetPercentage(float percentage) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogExtendedProgress + /// @brief To set progress position with predefined places + /// + /// @param[in] currentItem Place position to use + /// @param[in] itemCount Amount of used places + /// + void SetProgress(int currentItem, int itemCount) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogExtendedProgress->set_progress(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, currentItem, itemCount); + } + //-------------------------------------------------------------------------- + + private: + void* m_DialogHandle; + }; + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_DialogFileBrowser Dialog File Browser + /// \ingroup cpp_kodi_gui + /// @brief \cpp_namespace{ kodi::gui::DialogFileBrowser } + /// **File browser dialog** + /// + /// The functions listed below of the class "DialogFileBrowser" offer + /// the possibility to select to a file by the user of the add-on. + /// + /// It allows all the options that are possible in Kodi itself and offers all + /// support file types. + /// + /// It has the header \ref DialogFileBrowser.h "#include " + /// be included to enjoy it. + /// + namespace DialogFileBrowser + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogFileBrowser + /// @brief Directory selection dialog + /// + /// @param[in] shares With Shares becomes the available start folders + /// be set. + /// @param[in] heading Dialog header name + /// @param[in,out] path As in the path to start and return value about + /// selected directory + /// @param[in] writeOnly If set only writeable folders are shown. + /// @return False if selection becomes canceled. + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// /* + /// * Example show directory selection dialog with on 'share' (first value) + /// * defined directory types. + /// * + /// * If this becomes leaved empty and 'directory' is empty goes it to the + /// * base path of the hard disk. + /// * + /// * Also can be with path written to 'directory' before the dialog forced + /// * to a start place. + /// */ + /// std::string directory; + /// bool ret = kodi::gui::DialogFileBrowser::ShowAndGetDirectory("local|network|removable", + /// "Test directory selection", + /// directory, + /// false); + /// fprintf(stderr, "Selected directory is : %s and was %s\n", directory.c_str(), ret ? "OK" : "Canceled"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetDirectory(const std::string& shares, const std::string& heading, std::string& path, bool writeOnly = false) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_directory(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), heading.c_str(), path.c_str(), &retString, writeOnly); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogFileBrowser + /// @brief File selection dialog + /// + /// @param[in] shares With Shares becomes the available start + /// folders be set. + /// @param[in] mask The mask to filter visible files, e.g. + /// ".m3u|.pls|.b4s|.wpl". + /// @param[in] heading Dialog header name + /// @param[in,out] path As in the path to start and Return value + /// about selected file + /// @param[in] useThumbs If set show thumbs if possible on dialog. + /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are + /// handled as directories. + /// @return False if selection becomes canceled. + /// + inline bool ShowAndGetFile(const std::string& shares, const std::string& mask, const std::string& heading, + std::string& path, bool useThumbs = false, bool useFileDirectories = false) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), mask.c_str(), heading.c_str(), path.c_str(), &retString, + useThumbs, useFileDirectories); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogFileBrowser + /// @brief File selection from a directory + /// + /// @param[in] directory The directory name where the dialog + /// start, possible are normal names and + /// kodi's special names. + /// @param[in] mask The mask to filter visible files, e.g. + /// ".m3u|.pls|.b4s|.wpl". + /// @param[in] heading Dialog header name + /// @param[in,out] path As in the path to start and Return value + /// about selected file + /// @param[in] useThumbs If set show thumbs if possible on dialog. + /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are + /// handled as directories. + /// @param[in] singleList + /// @return False if selection becomes canceled. + /// + inline bool ShowAndGetFileFromDir(const std::string& directory, const std::string& mask, const std::string& heading, std::string& path, + bool useThumbs = false, bool useFileDirectories = false, bool singleList = false) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_from_dir(CAddonBase::m_interface->toKodi->kodiBase, + directory.c_str(), mask.c_str(), heading.c_str(), + path.c_str(), &retString, useThumbs, + useFileDirectories, singleList); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogFileBrowser + /// @brief File selection dialog to get several in to a list + /// + /// @param[in] shares With Shares becomes the available start + /// folders be set. + /// @param[in] mask The mask to filter visible files, e.g. + /// ".m3u|.pls|.b4s|.wpl". + /// @param[in] heading Dialog header name + /// @param[out] fileList Return value about selected files + /// @param[in] useThumbs If set show thumbs if possible on dialog. + /// @param[in] useFileDirectories If set also packages (e.g. *.zip) are + /// handled as directories. + /// @return False if selection becomes canceled. + /// + inline bool ShowAndGetFileList(const std::string& shares, const std::string& mask, const std::string& heading, + std::vector& fileList, bool useThumbs = false, bool useFileDirectories = false) + { + using namespace ::kodi::addon; + char** list = nullptr; + unsigned int listSize = 0; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_file_list(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), mask.c_str(), heading.c_str(), &list, &listSize, + useThumbs, useFileDirectories); + if (ret) + { + for (unsigned int i = 0; i < listSize; ++i) + fileList.push_back(list[i]); + CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogFileBrowser + /// @brief Source selection dialog + /// + /// @param[in,out] path As in the path to start and Return value + /// about selected source + /// @param[in] allowNetworkShares Allow also access to network + /// @param[in] additionalShare With additionalShare becomes the available + /// start folders be set (optional). + /// @param[in] type + /// @return False if selection becomes canceled. + /// + inline bool ShowAndGetSource(std::string& path, bool allowNetworkShares, const std::string& additionalShare = "", const std::string& type = "") + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_source(CAddonBase::m_interface->toKodi->kodiBase, path.c_str(), &retString, + allowNetworkShares, additionalShare.c_str(), type.c_str()); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogFileBrowser + /// @brief Image selection dialog + /// + /// @param[in] shares With Shares becomes the available start folders be + /// set. + /// @param[in] heading Dialog header name + /// @param[out] path Return value about selected image + /// @return False if selection becomes canceled. + /// + inline bool ShowAndGetImage(const std::string& shares, const std::string& heading, std::string& path) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), heading.c_str(), path.c_str(), &retString); + if (retString != nullptr) + { + if (std::strlen(retString)) + path = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogFileBrowser + /// @brief Image selection dialog to get several in to a list + /// + /// @param[in] shares With Shares becomes the available start folders + /// be set. + /// @param[in] heading Dialog header name + /// @param[out] file_list Return value about selected images + /// @return False if selection becomes canceled. + /// + inline bool ShowAndGetImageList(const std::string& shares, const std::string& heading, std::vector& file_list) + { + using namespace ::kodi::addon; + char** list = nullptr; + unsigned int listSize = 0; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->show_and_get_image_list(CAddonBase::m_interface->toKodi->kodiBase, + shares.c_str(), heading.c_str(), &list, &listSize); + if (ret) + { + for (unsigned int i = 0; i < listSize; ++i) + file_list.push_back(list[i]); + CAddonBase::m_interface->toKodi->kodi_gui->dialogFileBrowser->clear_file_list(CAddonBase::m_interface->toKodi->kodiBase, &list, listSize); + } + return ret; + } + //-------------------------------------------------------------------------- + }; + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_DialogKeyboard Dialog Keyboard + /// \ingroup cpp_kodi_gui + /// @brief \cpp_namespace{ kodi::gui::DialogKeyboard } + /// **Keyboard dialogs** + /// + /// The functions listed below have to be permitted by the user for the + /// representation of a keyboard around an input. + /// + /// The class supports several kinds, from an easy text choice up to the + /// passport Word production and their confirmation for add-on. + /// + /// It has the header \ref DialogKeyboard.h "#include " + /// be included to enjoy it. + /// + namespace DialogKeyboard + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Show keyboard with initial value `text` and replace with result + /// string. + /// + /// @param[in,out] text Overwritten with user input if return=true. + /// @param[in] heading String shown on dialog title. + /// @param[in] allowEmptyResult Whether a blank password is valid or not. + /// @param[in] hiddenInput The inserted input is not shown as text. + /// @param[in] autoCloseMs To close the dialog after a specified + /// time, in milliseconds, default is 0 which + /// keeps the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// /* + /// * The example shows the display of keyboard call dialog at Kodi from the add-on. + /// * Below all values are set, however, can last two (hidden input = false and autoCloseMs = 0) + /// * to be released if not needed. + /// */ + /// std::string text = "Please change me to them want you want"; /*< It can be leaved empty or a + /// entry text added */ + /// bool bRet = ::kodi::gui::DialogKeyboard::ShowAndGetInput(text, + /// "Demonstration text entry", + /// true, + /// false, + /// 0); + /// fprintf(stderr, "Written keyboard input is : '%s' and was %s\n", + /// text.c_str(), bRet ? "OK" : "Canceled"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetInput(std::string& text, const std::string& heading, bool allowEmptyResult, bool hiddenInput = false, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input_with_head(CAddonBase::m_interface->toKodi->kodiBase, + text.c_str(), &retString, heading.c_str(), allowEmptyResult, + hiddenInput, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + text = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief The example shows the display of keyboard call dialog at Kodi + /// from the add-on. + /// + /// @param[out] text Overwritten with user input if return=true. + /// @param[in] allowEmptyResult If set to true keyboard can also exited + /// without entered text. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndGetInput(std::string& text, bool allowEmptyResult, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_input(CAddonBase::m_interface->toKodi->kodiBase, + text.c_str(), &retString, + allowEmptyResult, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + text = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Shows keyboard and prompts for a password. Differs from + /// `ShowAndVerifyNewPassword()` in that no second verification + /// + /// @param[in,out] newPassword Overwritten with user input if return=true. + /// @param[in] heading String shown on dialog title. + /// @param[in] allowEmptyResult Whether a blank password is valid or not. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndGetNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, + newPassword.c_str(), &retString, heading.c_str(), + allowEmptyResult, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + newPassword = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Shows keyboard and prompts for a password. Differs from + /// `ShowAndVerifyNewPassword()` in that no second verification + /// + /// @param[in,out] newPassword Overwritten with user input if return=true. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndGetNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_new_password(CAddonBase::m_interface->toKodi->kodiBase, + newPassword.c_str(), &retString, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + newPassword = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Show keyboard twice to get and confirm a user-entered password + /// string. + /// + /// @param[out] newPassword Overwritten with user input if return=true. + /// @param[in] heading String shown on dialog title. + /// @param[in] allowEmptyResult + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// #include + /// + /// /* + /// * The example below shows the complete use of keyboard dialog for password + /// * check. If only one check from add-on needed can be function with retries + /// * set to '0' called alone. + /// * + /// * The use of MD5 translated password is always required for the check on Kodi! + /// */ + /// + /// int maxretries = 3; + /// /* + /// * Password names need to be send as md5 sum to kodi. + /// */ + /// std::string password; + /// kodi::GetMD5("kodi", password); + /// + /// /* + /// * To the loop about password checks. + /// */ + /// int ret; + /// for (unsigned int i = 0; i < maxretries; i++) + /// { + /// /* + /// * Ask the user about the password. + /// */ + /// ret = ::kodi::gui::DialogKeyboard::ShowAndVerifyPassword(password, "Demo password call for PW 'kodi'", i, 0); + /// if (ret == 0) + /// { + /// fprintf(stderr, "Password successfull confirmed after '%i' tries\n", i+1); + /// break; + /// } + /// else if (ret < 0) + /// { + /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); + /// break; + /// } + /// else /* if (ret > 0) */ + /// { + /// fprintf(stderr, "Wrong password entered on try '%i'\n", i+1); + /// } + /// } + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndVerifyNewPassword(std::string& newPassword, const std::string& heading, bool allowEmptyResult, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password_with_head(CAddonBase::m_interface->toKodi->kodiBase, + &retString, heading.c_str(), allowEmptyResult, + autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + newPassword = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Show keyboard twice to get and confirm a user-entered password + /// string. + /// + /// @param[out] newPassword Overwritten with user input if return=true. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndVerifyNewPassword(std::string& newPassword, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, + &retString, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + newPassword = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Show keyboard and verify user input against `password`. + /// + /// @param[in,out] password Value to compare against user input. + /// @param[in] heading String shown on dialog title. + /// @param[in] retries If greater than 0, shows "Incorrect + /// password, %d retries left" on dialog line 2, + /// else line 2 is blank. + /// @param[in] autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return 0 if successful display and user input. 1 if + /// unsuccessful input. -1 if no user input or + /// canceled editing. + /// + inline int ShowAndVerifyPassword(std::string& password, const std::string& heading, int retries, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, + password.c_str(), &retString, heading.c_str(), + retries, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + password = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Shows a filter related keyboard + /// + /// @param[in,out] text Overwritten with user input if return=true. + /// @param[in] searching Use dialog for search and send our search + /// message in safe way (only the active window + /// needs it) + /// - header name if true is "Enter search string" + /// - header name if false is "Enter value" + /// @param autoCloseMs To close the dialog after a specified time, + /// in milliseconds, default is 0 which keeps + /// the dialog open indefinitely. + /// @return true if successful display and user input. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndGetFilter(std::string& text, bool searching, unsigned int autoCloseMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->show_and_get_filter(CAddonBase::m_interface->toKodi->kodiBase, + text.c_str(), &retString, searching, autoCloseMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + text = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Send a text to a visible keyboard + /// + /// @param[in] text Overwritten with user input if return=true. + /// @param[in] closeKeyboard The open dialog is if also closed on 'true'. + /// @return true if successful done, false if + /// unsuccessful or keyboard not present. + /// + inline bool SendTextToActiveKeyboard(const std::string& text, bool closeKeyboard = false) + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->send_text_to_active_keyboard(CAddonBase::m_interface->toKodi->kodiBase, + text.c_str(), closeKeyboard); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogKeyboard + /// @brief Check for visible keyboard on GUI + /// + /// @return true if keyboard present, false if not present + /// + inline bool IsKeyboardActivated() + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogKeyboard->is_keyboard_activated(CAddonBase::m_interface->toKodi->kodiBase); + } + //-------------------------------------------------------------------------- + }; + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_DialogNumeric Dialog Numeric + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::DialogNumeric } + /// **Numeric dialogs** + /// + /// The functions listed below have to be permitted by the user for the + /// representation of a numeric keyboard around an input. + /// + /// The class supports several kinds, from an easy number choice up to the + /// passport Word production and their confirmation for add-on. + /// + /// It has the header \ref DialogNumeric.h "#include " + /// be included to enjoy it. + /// + namespace DialogNumeric + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogNumeric + /// @brief Use dialog to get numeric new password + /// + /// @param[out] newPassword String to preload into the keyboard + /// accumulator. Overwritten with user input + /// if return=true. Returned in MD5 format. + /// @return true if successful display and user + /// input entry/re-entry. + /// false if unsuccessful display, no user + /// input, or canceled editing. + /// + inline bool ShowAndVerifyNewPassword(std::string& newPassword) + { + using namespace ::kodi::addon; + char* pw = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_new_password(CAddonBase::m_interface->toKodi->kodiBase, &pw); + if (pw != nullptr) + { + if (std::strlen(pw)) + newPassword = pw; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, pw); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogNumeric + /// @brief Use dialog to verify numeric password. + /// + /// @param[in] password Password to compare with user input, need + /// in MD5 format. + /// @param[in] heading Heading to display + /// @param[in] retries If greater than 0, shows "Incorrect + /// password, %d retries left" on dialog + /// line 2, else line 2 is blank. + /// @return Possible values: + /// - 0 if successful display and user input. + /// - 1 if unsuccessful input. + /// - -1 if no user input or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include /* fprintf */ + /// #include + /// #include + /// + /// /* + /// * The example below shows the complete use of keyboard dialog for password + /// * check. If only one check from add-on needed can be function with retries + /// * set to '0' called alone. + /// * + /// * The use of MD5 translated password is always required for the check on Kodi! + /// */ + /// + /// int maxretries = 3; + /// + /// /* + /// * Password names need to be send as md5 sum to kodi. + /// */ + /// std::string password = kodi::GetMD5("1234"); + /// + /// /* + /// * To the loop about password checks. + /// */ + /// int ret; + /// for (unsigned int i = 0; i < maxretries; i++) + /// { + /// /* + /// * Ask the user about the password. + /// */ + /// ret = kodi::gui::DialogNumeric::ShowAndVerifyPassword(password, "Demo numeric password call for PW '1234'", i); + /// if (ret == 0) + /// { + /// fprintf(stderr, "Numeric password successfull confirmed after '%i' tries\n", i+1); + /// break; + /// } + /// else if (ret < 0) + /// { + /// fprintf(stderr, "Canceled editing on try '%i'\n", i+1); + /// break; + /// } + /// else /* if (ret > 0) */ + /// { + /// fprintf(stderr, "Wrong numeric password entered on try '%i'\n", i+1); + /// } + /// } + /// ~~~~~~~~~~~~~ + /// + inline int ShowAndVerifyPassword(const std::string& password, const std::string& heading, int retries) + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_password(CAddonBase::m_interface->toKodi->kodiBase, + password.c_str(), heading.c_str(), retries); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogNumeric + /// @brief Use dialog to verify numeric password + /// + /// @param[in,out] toVerify Value to compare against user input. + /// @param[in] heading Heading to display + /// @param[in] verifyInput If set as true we verify the users input + /// versus toVerify. + /// @return true if successful display and user + /// input. false if unsuccessful display, no + /// user input, or canceled editing. + /// + inline bool ShowAndVerifyInput(std::string& toVerify, const std::string& heading, bool verifyInput) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_verify_input(CAddonBase::m_interface->toKodi->kodiBase, + toVerify.c_str(), &retString, heading.c_str(), verifyInput); + if (retString != nullptr) + { + if (std::strlen(retString)) + toVerify = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogNumeric + /// @brief Use dialog to get time value. + /// + /// @param[out] time Overwritten with user input if + /// return=true and time inserted. + /// @param[in] heading Heading to display. + /// @return true if successful display and user + /// input. false if unsuccessful display, no + /// user input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include /* printf */ + /// #include /* time_t, struct tm, time, localtime, strftime */ + /// #include + /// + /// time_t rawtime; + /// struct tm * timeinfo; + /// char buffer [10]; + /// + /// time (&rawtime); + /// timeinfo = localtime(&rawtime); + /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetTime(*timeinfo, "Selected time test call"); + /// strftime(buffer, sizeof(buffer), "%H:%M.", timeinfo); + /// printf("Selected time it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetTime(tm& time, const std::string& heading) + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_time(CAddonBase::m_interface->toKodi->kodiBase, &time, heading.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogNumeric + /// @brief Use dialog to get date value. + /// + /// @param[in,out] date Overwritten with user input if + /// return=true and date inserted. + /// @param[in] heading Heading to display + /// @return true if successful display and user + /// input. false if unsuccessful display, no + /// user input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include /* printf */ + /// #include /* time_t, struct tm, time, localtime, strftime */ + /// #include + /// + /// time_t rawtime; + /// struct tm * timeinfo; + /// char buffer [20]; + /// + /// time (&rawtime); + /// timeinfo = localtime(&rawtime); + /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetDate(*timeinfo, "Selected date test call"); + /// strftime(buffer, sizeof(buffer), "%Y-%m-%d", timeinfo); + /// printf("Selected date it's %s and was on Dialog %s\n", buffer, bRet ? "OK" : "Canceled"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetDate(tm& date, const std::string& heading) + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_date(CAddonBase::m_interface->toKodi->kodiBase, &date, heading.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogNumeric + /// @brief Use dialog to get a IP + /// + /// @param[in,out] ipAddress Overwritten with user input if + /// return=true and IP address inserted. + /// @param[in] heading Heading to display. + /// @return true if successful display and + /// user input. false if unsuccessful + /// display, no user input, or canceled + /// editing. + /// + inline bool ShowAndGetIPAddress(std::string& ipAddress, const std::string& heading) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_ip_address(CAddonBase::m_interface->toKodi->kodiBase, + ipAddress.c_str(), &retString, heading.c_str()); + if (retString != nullptr) + { + if (std::strlen(retString)) + ipAddress = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogNumeric + /// @brief Use dialog to get normal number. + /// + /// @param[in,out] input Overwritten with user input if + /// return=true and time in seconds inserted + /// @param[in] heading Heading to display + /// @param[in] autoCloseTimeoutMs To close the dialog after a specified + /// time, in milliseconds, default is 0 + /// which keeps the dialog open + /// indefinitely. + /// @return true if successful display and user + /// input. false if unsuccessful display, no + /// user input, or canceled editing. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include /* printf */ + /// #include /* strtoull (C++11) */ + /// #include + /// + /// std::string number; + /// bool bRet = kodi::gui::DialogNumeric::ShowAndGetNumber(number, "Number test call"); + /// printf("Written number input is : %llu and was %s\n", + /// strtoull(number.c_str(), nullptr, 0), bRet ? "OK" : "Canceled"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetNumber(std::string& input, const std::string& heading, unsigned int autoCloseTimeoutMs = 0) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_number(CAddonBase::m_interface->toKodi->kodiBase, + input.c_str(), &retString, heading.c_str(), autoCloseTimeoutMs); + if (retString != nullptr) + { + if (std::strlen(retString)) + input = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogNumeric + /// @brief Show numeric keypad to get seconds. + /// + /// @param[in,out] time Overwritten with user input if return=true and + /// time in seconds inserted. + /// @param[in] heading Heading to display + /// @return true if successful display and user input. false + /// if unsuccessful display, no user input, or + /// canceled editing. + /// + inline bool ShowAndGetSeconds(std::string& time, const std::string& heading) + { + using namespace ::kodi::addon; + char* retString = nullptr; + bool ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogNumeric->show_and_get_seconds(CAddonBase::m_interface->toKodi->kodiBase, + time.c_str(), &retString, heading.c_str()); + if (retString != nullptr) + { + if (std::strlen(retString)) + time = retString; + CAddonBase::m_interface->toKodi->free_string(CAddonBase::m_interface->toKodi->kodiBase, retString); + } + return ret; + } + //-------------------------------------------------------------------------- + }; + /// @} + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../AddonBase.h" +#include "definitions.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_DialogOK Dialog OK + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::DialogOK } + /// **OK dialog** + /// + /// The functions listed below permit the call of a dialogue of information, a + /// confirmation of the user by press from OK required. + /// + /// It has the header \ref DialogOK.h "#include " + /// be included to enjoy it. + /// + namespace DialogOK + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogOK + /// @brief Use dialog to inform user with text and confirmation with OK with continued string. + /// + /// @param[in] heading Dialog heading. + /// @param[in] text Multi-line text. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// ... + /// kodi::gui::DialogOK::ShowAndGetInput("Test dialog", "Hello World!\nI'm a call from add-on\n :) :D"); + /// ~~~~~~~~~~~~~ + /// + inline void ShowAndGetInput(const std::string& heading, const std::string& text) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, + heading.c_str(), text.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogOK + /// @brief Use dialog to inform user with text and confirmation with OK with strings separated to the lines. + /// + /// @param[in] heading Dialog heading. + /// @param[in] line0 Line #1 text. + /// @param[in] line1 Line #2 text. + /// @param[in] line2 Line #3 text. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// ... + /// kodi::gui::DialogOK::ShowAndGetInput("Test dialog", "Hello World!", "I'm a call from add-on", " :) :D"); + /// ~~~~~~~~~~~~~ + /// + inline void ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, const std::string& line2) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogOK->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, + heading.c_str(), line0.c_str(), line1.c_str(), + line2.c_str()); + } + //-------------------------------------------------------------------------- + } + /// @} + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_CDialogProgress Dialog Progress + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::CDialogProgress } + /// **Progress dialog shown in center** + /// + /// The with \ref DialogProgress.h "#include " + /// given class are basically used to create Kodi's progress dialog with named + /// text fields. + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// kodi::gui::CDialogProgress *progress = new kodi::gui::CDialogProgress; + /// progress->SetHeading("Test progress"); + /// progress->SetLine(1, "line 1"); + /// progress->SetLine(2, "line 2"); + /// progress->SetLine(3, "line 3"); + /// progress->SetCanCancel(true); + /// progress->ShowProgressBar(true); + /// progress->Open(); + /// for (unsigned int i = 0; i < 100; i += 10) + /// { + /// progress->SetPercentage(i); + /// sleep(1); + /// } + /// delete progress; + /// ~~~~~~~~~~~~~ + /// + class CDialogProgress + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief Construct a new dialog + /// + CDialogProgress() + { + using namespace ::kodi::addon; + m_DialogHandle = CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->new_dialog(CAddonBase::m_interface->toKodi->kodiBase); + if (!m_DialogHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CDialogProgress can't create window class from Kodi !!!"); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief Destructor + /// + ~CDialogProgress() + { + using namespace ::kodi::addon; + if (m_DialogHandle) + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->delete_dialog(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief To open the dialog + /// + void Open() + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->open(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief Set the heading title of dialog + /// + /// @param[in] heading Title string to use + /// + void SetHeading(const std::string& heading) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_heading(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, heading.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief To set the line text field on dialog from 0 - 2 + /// + /// @param[in] iLine Line number + /// @param[in] line Text string + /// + void SetLine(unsigned int iLine, const std::string& line) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_line(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, iLine, line.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief To enable and show cancel button on dialog + /// + /// @param[in] canCancel if true becomes it shown + /// + void SetCanCancel(bool canCancel) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_can_cancel(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, canCancel); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief To check dialog for clicked cancel button + /// + /// @return True if canceled + /// + bool IsCanceled() const + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->is_canceled(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief Get the current progress position as percent + /// + /// @param[in] percentage Position to use from 0 to 100 + /// + void SetPercentage(int percentage) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, percentage); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief To set the current progress position as percent + /// + /// @return Current Position used from 0 to 100 + /// + int GetPercentage() const + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->get_percentage(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief To show or hide progress bar dialog + /// + /// @param[in] onOff If true becomes it shown + /// + void ShowProgressBar(bool onOff) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->show_progress_bar(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, onOff); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief Set the maximum position of progress, needed if `SetProgressAdvance(...)` is used + /// + /// @param[in] max Biggest usable position to use + /// + void SetProgressMax(int max) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_max(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, max); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief To increase progress bar by defined step size until reach of maximum position + /// + /// @param[in] steps Step size to increase, default is 1 + /// + void SetProgressAdvance(int steps=1) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->set_progress_advance(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle, steps); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CDialogProgress + /// @brief To check progress was canceled on work + /// + /// @return True if aborted + /// + bool Abort() + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogProgress->abort(CAddonBase::m_interface->toKodi->kodiBase, m_DialogHandle); + } + //-------------------------------------------------------------------------- + + private: + void* m_DialogHandle; + }; + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_DialogSelect Dialog Select + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::DialogSelect } + /// **Selection dialog** + /// + /// The function listed below permits the call of a dialogue to select of an + /// entry as a key + /// + /// It has the header \ref DialogSelect.h "#include " + /// be included to enjoy it. + /// + /// + namespace DialogSelect + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogSelect + /// @brief Show a selection dialog about given parts. + /// + /// @param[in] heading Dialog heading name + /// @param[in] entries String list about entries + /// @param[in] selected [opt] Predefined selection (default is + /// -1 for the first) + /// @param[in] autoclose [opt] To close dialog automatic after a time + /// @return The selected entry, if return -1 was + /// nothing selected or canceled + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// const std::vector entries + /// { + /// "Test 1", + /// "Test 2", + /// "Test 3", + /// "Test 4", + /// "Test 5" + /// }; + /// + /// int selected = kodi::gui::DialogSelect::Show("Test selection", entries, -1); + /// if (selected < 0) + /// fprintf(stderr, "Item selection canceled\n"); + /// else + /// fprintf(stderr, "Selected item is: %i\n", selected); + /// ~~~~~~~~~~~~~ + /// + inline int Show(const std::string& heading, const std::vector& entries, int selected = -1, bool autoclose = false) + { + using namespace ::kodi::addon; + unsigned int size = entries.size(); + const char** cEntries = (const char**)malloc(size*sizeof(const char**)); + for (unsigned int i = 0; i < size; ++i) + { + cEntries[i] = entries[i].c_str(); + } + int ret = CAddonBase::m_interface->toKodi->kodi_gui->dialogSelect->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), cEntries, size, selected, autoclose); + free(cEntries); + return ret; + } + //-------------------------------------------------------------------------- + }; + /// @} + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2015-2016 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_DialogTextViewer Dialog Text Viewer + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::DialogTextViewer } + /// **Text viewer dialog** + /// + /// The text viewer dialog can be used to display descriptions, help texts or + /// other larger texts. + /// + /// In order to achieve a line break is a \\n directly in the text or + /// in the "./resources/language/resource.language.??_??/strings.po" + /// to call with std::string kodi::general::GetLocalizedString(...);. + /// + /// It has the header \ref DialogTextViewer.h "#include " + /// be included to enjoy it. + /// + namespace DialogTextViewer + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogTextViewer + /// @brief Show info text dialog + /// + /// @param[in] heading Small heading text + /// @param[in] text Showed text on dialog + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// kodi::gui::DialogTextViewer::Show("The Wizard of Oz (1939 film)", + /// "The Wizard of Oz is a 1939 American musical comedy-drama fantasy film " + /// "produced by Metro-Goldwyn-Mayer, and the most well-known and commercially " + /// "successful adaptation based on the 1900 novel The Wonderful Wizard of Oz " + /// "by L. Frank Baum. The film stars Judy Garland as Dorothy Gale. The film" + /// "co-stars Terry the dog, billed as Toto; Ray Bolger, Jack Haley, Bert Lahr, " + /// "Frank Morgan, Billie Burke, Margaret Hamilton, with Charley Grapewin and " + /// "Clara Blandick, and the Singer Midgets as the Munchkins.\n" + /// "\n" + /// "Notable for its use of Technicolor, fantasy storytelling, musical score and " + /// "unusual characters, over the years it has become an icon of American popular " + /// "culture. It was nominated for six Academy Awards, including Best Picture but " + /// "lost to Gone with the Wind. It did win in two other categories including Best " + /// "Original Song for \"Over the Rainbow\". However, the film was a box office " + /// "disappointment on its initial release, earning only $3,017,000 on a $2,777,000 " + /// "budget, despite receiving largely positive reviews. It was MGM's most " + /// "expensive production at that time, and did not completely recoup the studio's " + /// "investment and turn a profit until theatrical re-releases starting in 1949.\n" + /// "\n" + /// "The 1956 broadcast television premiere of the film on CBS re-introduced the " + /// "film to the wider public and eventually made the presentation an annual " + /// "tradition, making it one of the most known films in cinema history. The " + /// "film was named the most-viewed motion picture on television syndication by " + /// "the Library of Congress who also included the film in its National Film " + /// "Registry in its inaugural year in 1989. Designation on the registry calls " + /// "for efforts to preserve it for being \"culturally, historically, and " + /// "aesthetically significant\". It is also one of the few films on UNESCO's " + /// "Memory of the World Register.\n" + /// "\n" + /// "The Wizard of Oz is often ranked on best-movie lists in critics' and public " + /// "polls. It is the source of many quotes referenced in modern popular culture. " + /// "It was directed primarily by Victor Fleming (who left production to take " + /// "over direction on the troubled Gone with the Wind production). Noel Langley, " + /// "Florence Ryerson and Edgar Allan Woolf received credit for the screenplay, " + /// "but there were uncredited contributions by others. The songs were written " + /// "by Edgar \"Yip\" Harburg (lyrics) and Harold Arlen (music). The incidental " + /// "music, based largely on the songs, was composed by Herbert Stothart, with " + /// "interspersed renderings from classical composers.\n"); + /// ~~~~~~~~~~~~~ + /// + inline void Show(const std::string& heading, const std::string& text) + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->dialogTextViewer->open(CAddonBase::m_interface->toKodi->kodiBase, heading.c_str(), text.c_str()); + } + //-------------------------------------------------------------------------- + }; + /// @} + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "definitions.h" +#include "../AddonBase.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_DialogYesNo Dialog Yes/No + /// \ingroup cpp_kodi_gui + /// @{ + /// @brief \cpp_namespace{ kodi::gui::DialogYesNo } + /// **Yes / No dialog** + /// + /// The Yes / No dialog can be used to inform the user about questions and get + /// the answer. + /// + /// In order to achieve a line break is a \\n directly in the text or + /// in the "./resources/language/resource.language.??_??/strings.po" + /// to call with std::string kodi::general::GetLocalizedString(...);. + /// + /// It has the header \ref DialogYesNo.h "#include " + /// be included to enjoy it. + /// + /// + namespace DialogYesNo + { + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogYesNo + /// @brief Use dialog to get numeric new password with one text string shown + /// everywhere and cancel return field + /// + /// @param[in] heading Dialog heading + /// @param[in] text Multi-line text + /// @param[out] canceled Return value about cancel button + /// @param[in] noLabel [opt] label to put on the no button + /// @param[in] yesLabel [opt] label to put on the yes button + /// @return Returns True if 'Yes' was pressed, else False + /// + /// @note It is preferred to only use this as it is actually a multi-line text. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// bool canceled; + /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( + /// "Yes / No test call", /* The Header */ + /// "You has opened Yes / No dialog for test\n\nIs this OK for you?", + /// canceled, /* return value about cancel button */ + /// "Not really", /* No label, is optional and if empty "No" */ + /// "Ohhh yes"); /* Yes label, also optional and if empty "Yes" */ + /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", + /// ret ? "yes" : "no", + /// canceled ? "canceled" : "not canceled"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetInput(const std::string& heading, const std::string& text, + bool& canceled, const std::string& noLabel = "", + const std::string& yesLabel = "") + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_single_text(CAddonBase::m_interface->toKodi->kodiBase, + heading.c_str(), text.c_str(), &canceled, + noLabel.c_str(), yesLabel.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogYesNo + /// @brief Use dialog to get numeric new password with separated line strings + /// + /// @param[in] heading Dialog heading + /// @param[in] line0 Line #0 text + /// @param[in] line1 Line #1 text + /// @param[in] line2 Line #2 text + /// @param[in] noLabel [opt] label to put on the no button. + /// @param[in] yesLabel [opt] label to put on the yes button. + /// @return Returns True if 'Yes' was pressed, else False. + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( + /// "Yes / No test call", // The Header + /// "You has opened Yes / No dialog for test", + /// "", + /// "Is this OK for you?", + /// "Not really", // No label, is optional and if empty "No" + /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" + /// fprintf(stderr, "You has called Yes/No, returned '%s'\n", + /// ret ? "yes" : "no"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, + const std::string& line2, const std::string& noLabel = "", + const std::string& yesLabel = "") + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_text(CAddonBase::m_interface->toKodi->kodiBase, + heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), + noLabel.c_str(), yesLabel.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_DialogYesNo + /// @brief Use dialog to get numeric new password with separated line strings and cancel return field + /// + /// @param[in] heading Dialog heading + /// @param[in] line0 Line #0 text + /// @param[in] line1 Line #1 text + /// @param[in] line2 Line #2 text + /// @param[out] canceled Return value about cancel button + /// @param[in] noLabel [opt] label to put on the no button + /// @param[in] yesLabel [opt] label to put on the yes button + /// @return Returns True if 'Yes' was pressed, else False + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// #include + /// + /// bool canceled; + /// bool ret = kodi::gui::DialogYesNo::ShowAndGetInput( + /// "Yes / No test call", // The Header + /// "You has opened Yes / No dialog for test", + /// "", + /// "Is this OK for you?", + /// canceled, // return value about cancel button + /// "Not really", // No label, is optional and if empty "No" + /// "Ohhh yes"); // Yes label, also optional and if empty "Yes" + /// fprintf(stderr, "You has called Yes/No, returned '%s' and was %s\n", + /// ret ? "yes" : "no", + /// canceled ? "canceled" : "not canceled"); + /// ~~~~~~~~~~~~~ + /// + inline bool ShowAndGetInput(const std::string& heading, const std::string& line0, const std::string& line1, + const std::string& line2, bool& canceled, const std::string& noLabel = "", + const std::string& yesLabel = "") + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->dialogYesNo->show_and_get_input_line_button_text(CAddonBase::m_interface->toKodi->kodiBase, + heading.c_str(), line0.c_str(), line1.c_str(), line2.c_str(), + &canceled, noLabel.c_str(), yesLabel.c_str()); + } + //-------------------------------------------------------------------------- + }; + /// @} + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../AddonBase.h" +#include "definitions.h" + +namespace kodi +{ +namespace gui +{ + + //============================================================================ + /// + // \defgroup cpp_kodi_gui ::general + /// \addtogroup cpp_kodi_gui + /// @{ + /// @brief **Allow use of binary classes and function to use on add-on's** + /// + /// Permits the use of the required functions of the add-on to Kodi. This class + /// also contains some functions to the control. + /// + /// These are pure functions them no other initialization need. + /// + /// It has the header \ref kodi/gui/General.h "#include " be included + /// to enjoy it. + /// + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui + /// @brief Performs a graphical lock of rendering engine + /// + inline void Lock() + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->general->lock(); + } + + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui + /// @brief Performs a graphical unlock of previous locked rendering engine + /// + inline void Unlock() + { + using namespace ::kodi::addon; + CAddonBase::m_interface->toKodi->kodi_gui->general->unlock(); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui + /// @brief Return the the current screen height with pixel + /// + inline int GetScreenHeight() + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_height(CAddonBase::m_interface->toKodi->kodiBase); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui + /// @brief Return the the current screen width with pixel + /// + inline int GetScreenWidth() + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->general->get_screen_width(CAddonBase::m_interface->toKodi->kodiBase); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui + /// @brief Return the the current screen rendering resolution + /// + inline int GetVideoResolution() + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->general->get_video_resolution(CAddonBase::m_interface->toKodi->kodiBase); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui + /// @brief Returns the id for the current 'active' dialog as an integer. + /// + /// @return The currently active dialog Id + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// .. + /// int wid = kodi::gui::GetCurrentWindowDialogId() + /// .. + /// ~~~~~~~~~~~~~ + /// + inline int GetCurrentWindowDialogId() + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_dialog_id(CAddonBase::m_interface->toKodi->kodiBase); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui + /// @brief Returns the id for the current 'active' window as an integer. + /// + /// @return The currently active window Id + /// + /// + ///------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// .. + /// int wid = kodi::gui::GetCurrentWindowId() + /// .. + /// ~~~~~~~~~~~~~ + /// + inline int GetCurrentWindowId() + { + using namespace ::kodi::addon; + return CAddonBase::m_interface->toKodi->kodi_gui->general->get_current_window_id(CAddonBase::m_interface->toKodi->kodiBase); + } + //-------------------------------------------------------------------------- + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../AddonBase.h" +#include "definitions.h" + +#include + +namespace kodi +{ +namespace gui +{ + + class CWindow; + + class CAddonGUIControlBase + { + public: + GUIHANDLE GetControlHandle() const { return m_controlHandle; } + + protected: + CAddonGUIControlBase(CAddonGUIControlBase* window) + : m_controlHandle(nullptr), + m_interface(::kodi::addon::CAddonBase::m_interface->toKodi), + m_Window(window) {} + + virtual ~CAddonGUIControlBase() = default; + + friend class CWindow; + + GUIHANDLE m_controlHandle; + AddonToKodiFuncTable_Addon* m_interface; + CAddonGUIControlBase* m_Window; + + private: + CAddonGUIControlBase() = delete; + CAddonGUIControlBase(const CAddonGUIControlBase&) = delete; + CAddonGUIControlBase &operator=(const CAddonGUIControlBase&) = delete; + }; + + class CListItem; + typedef std::shared_ptr ListItemPtr; + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_CListItem List Item + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::CListItem } + /// **Selectable window list item** + /// + /// The list item control is used for creating item lists in Kodi + /// + /// The with \ref ListItem.h "#include " given + /// class is used to create a item entry for a list on window and to support it's + /// control. + /// + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_CListItem_Defs Definitions, structures and enumerators + /// \ingroup cpp_kodi_gui_CListItem + /// @brief **Library definition values** + /// + + class CListItem : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Class constructor with parameters + /// + /// @param[in] label Item label + /// @param[in] label2 Second Item label (if needed) + /// @param[in] iconImage Item icon image (if needed) + /// @param[in] thumbnailImage Thumbnail Image of item (if needed) + /// @param[in] path Path to where item is defined + /// + CListItem( + const std::string& label = "", + const std::string& label2 = "", + const std::string& iconImage = "", + const std::string& thumbnailImage = "", + const std::string& path = "") + : CAddonGUIControlBase(nullptr) + { + m_controlHandle = m_interface->kodi_gui->listItem->create(m_interface->kodiBase, label.c_str(), + label2.c_str(), iconImage.c_str(), + thumbnailImage.c_str(), path.c_str()); + } + + /* + * Constructor used for parts given by list items from addon window + * + * Related to call of "ListItemPtr kodi::gui::CWindow::GetListItem(int listPos)" + * Not needed for addon development itself + */ + CListItem(GUIHANDLE listItemHandle) + : CAddonGUIControlBase(nullptr) + { + m_controlHandle = listItemHandle; + } + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Class destructor + /// + virtual ~CListItem() + { + m_interface->kodi_gui->listItem->destroy(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Returns the listitem label. + /// + /// @return Label of item + /// + std::string GetLabel() + { + std::string label; + char* ret = m_interface->kodi_gui->listItem->get_label(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Sets the listitem label. + /// + /// @param[in] label string or unicode - text string. + /// + void SetLabel(const std::string& label) + { + m_interface->kodi_gui->listItem->set_label(m_interface->kodiBase, m_controlHandle, label.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Returns the second listitem label. + /// + /// @return Second label of item + /// + std::string GetLabel2() + { + std::string label; + char* ret = m_interface->kodi_gui->listItem->get_label2(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + label = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return label; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Sets the listitem's label2. + /// + /// @param[in] label string or unicode - text string. + /// + void SetLabel2(const std::string& label) + { + m_interface->kodi_gui->listItem->set_label2(m_interface->kodiBase, m_controlHandle, label.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief To get current icon image of entry + /// + /// @return The current icon image path (if present) + /// + std::string GetIconImage() + { + std::string image; + char* ret = m_interface->kodi_gui->listItem->get_icon_image(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + image = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return image; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief To set icon image of entry + /// + /// @param image The image to use for. + /// + /// @note Alternative can be \ref SetArt used + /// + /// + void SetIconImage(const std::string& image) + { + m_interface->kodi_gui->listItem->set_icon_image(m_interface->kodiBase, m_controlHandle, image.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Sets the listitem's art + /// + /// @param[in] type Type of Art to set + /// - Some default art values (any string possible): + /// | value (type) | Type | + /// |:-------------:|:--------------------------------------------------| + /// | thumb | string - image filename + /// | poster | string - image filename + /// | banner | string - image filename + /// | fanart | string - image filename + /// | clearart | string - image filename + /// | clearlogo | string - image filename + /// | landscape | string - image filename + /// | icon | string - image filename + /// @return The url to use for Art + /// + std::string GetArt(const std::string& type) + { + std::string strReturn; + char* ret = m_interface->kodi_gui->listItem->get_art(m_interface->kodiBase, m_controlHandle, type.c_str()); + if (ret != nullptr) + { + if (std::strlen(ret)) + strReturn = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return strReturn; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Sets the listitem's art + /// + /// @param[in] type Type of Art to set + /// @param[in] url The url to use for Art + /// - Some default art values (any string possible): + /// | value (type) | Type | + /// |:-------------:|:--------------------------------------------------| + /// | thumb | string - image filename + /// | poster | string - image filename + /// | banner | string - image filename + /// | fanart | string - image filename + /// | clearart | string - image filename + /// | clearlogo | string - image filename + /// | landscape | string - image filename + /// | icon | string - image filename + /// + void SetArt(const std::string& type, const std::string& url) + { + m_interface->kodi_gui->listItem->set_art(m_interface->kodiBase, m_controlHandle, type.c_str(), url.c_str()); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Returns the path / filename of this listitem. + /// + /// @return Path string + /// + std::string GetPath() + { + std::string strReturn; + char* ret = m_interface->kodi_gui->listItem->get_path(m_interface->kodiBase, m_controlHandle); + if (ret != nullptr) + { + if (std::strlen(ret)) + strReturn = ret; + m_interface->free_string(m_interface->kodiBase, ret); + } + return strReturn; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CListItem + /// @brief Sets the listitem's path. + /// + /// @param[in] path string or unicode - path, activated when + /// item is clicked. + /// + /// @note You can use the above as keywords for arguments. + /// + void SetPath(const std::string& path) + { + m_interface->kodi_gui->listItem->set_path(m_interface->kodiBase, m_controlHandle, path.c_str()); + } + //-------------------------------------------------------------------------- + + }; + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team Kodi + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "../AddonBase.h" +#include "ListItem.h" + +#ifdef BUILD_KODI_ADDON +#include "../ActionIDs.h" +#else +#include "input/ActionIDs.h" +#endif + +namespace kodi +{ +namespace gui +{ + + class CListItem; + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_CWindow Window + /// \ingroup cpp_kodi_gui + /// @brief \cpp_class{ kodi::gui::CWindow } + /// **Main window control class** + /// + /// The with \ref Window.h "#include " + /// included file brings support to create a window or dialog on Kodi. + /// + /// -------------------------------------------------------------------------- + /// + /// On functions defined input variable controlId (GUI control identifier) + /// is the on window.xml defined value behind type added with id="..." and + /// used to identify for changes there and on callbacks. + /// + /// ~~~~~~~~~~~~~{.xml} + /// + /// Title Label + /// ... + /// + /// + /// progress control + /// ... + /// + /// ~~~~~~~~~~~~~ + /// + /// + + //============================================================================ + /// + /// \defgroup cpp_kodi_gui_CWindow_Defs Definitions, structures and enumerators + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Library definition values + /// + + class CWindow : public CAddonGUIControlBase + { + public: + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Class constructor with needed values for window / dialog. + /// + /// Creates a new Window class. + /// + /// @param[in] xmlFilename XML file for the skin + /// @param[in] defaultSkin default skin to use if needed not available + /// @param[in] asDialog Use window as dialog if set + /// @param[in] isMedia [opt] bool - if False, create a regular window. + /// if True, create a mediawindow. + /// (default=false) + /// @note only usable for windows not for dialogs. + /// + /// + CWindow(const std::string& xmlFilename, const std::string& defaultSkin, bool asDialog, bool isMedia = false) + : CAddonGUIControlBase(nullptr) + { + m_controlHandle = m_interface->kodi_gui->window->create(m_interface->kodiBase, xmlFilename.c_str(), + defaultSkin.c_str(), asDialog, isMedia); + if (!m_controlHandle) + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow can't create window class from Kodi !!!"); + m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, this, + CBOnInit, CBOnFocus, CBOnClick, CBOnAction, + CBGetContextButtons, CBOnContextButton); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup CWindow + /// @brief Class destructor + /// + /// + /// + virtual ~CWindow() + { + if (m_controlHandle) + m_interface->kodi_gui->window->destroy(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Show this window. + /// + /// Shows this window by activating it, calling close() after it wil activate the + /// current window again. + /// + /// @note If your Add-On ends this window will be closed to. To show it forever, + /// make a loop at the end of your Add-On or use doModal() instead. + /// + /// @return Return true if call and show is successed, + /// if false was something failed to get needed + /// skin parts. + /// + bool Show() + { + return m_interface->kodi_gui->window->show(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Closes this window. + /// + /// Closes this window by activating the old window. + /// @note The window is not deleted with this method. + /// + void Close() + { + m_interface->kodi_gui->window->close(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Display this window until close() is called. + /// + void DoModal() + { + m_interface->kodi_gui->window->do_modal(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief Function delete all entries in integrated list. + /// + /// + /// + void ClearList() + { + m_interface->kodi_gui->window->clear_item_list(m_interface->kodiBase, m_controlHandle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To add a list item in the on window integrated list. + /// + /// @param[in] item List item to add + /// @param[in] itemPosition [opt] The position for item, default is on end + /// + /// + void AddListItem(ListItemPtr item, int itemPosition = -1) + { + m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, item->m_controlHandle, itemPosition); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To add a list item based upon string in the on window integrated list. + /// + /// @param[in] item List item to add + /// @param[in] itemPosition [opt] The position for item, default is on end + /// + /// + void AddListItem(const std::string item, int itemPosition = -1) + { + m_interface->kodi_gui->window->add_list_item(m_interface->kodiBase, m_controlHandle, std::make_shared(item)->m_controlHandle, itemPosition); + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow + /// @brief To get list item control class on wanted position. + /// + /// @param[in] listPos Position from where control is needed + /// @return The list item control class or null if not found + /// + /// @warning Function returns a new generated **CListItem** class! + /// + ListItemPtr GetListItem(int listPos) + { + GUIHANDLE handle = m_interface->kodi_gui->window->get_list_item(m_interface->kodiBase, m_controlHandle, listPos); + if (!handle) + return ListItemPtr(); + + return std::make_shared(handle); + } + //-------------------------------------------------------------------------- + + //========================================================================== + // + /// @defgroup cpp_kodi_gui_CWindow_callbacks Callback functions from Kodi to add-on + /// \ingroup cpp_kodi_gui_CWindow + //@{ + /// @brief GUI window callback functions. + /// + /// Functions to handle control callbacks from Kodi + /// + /// ------------------------------------------------------------------------ + /// + /// @link cpp_kodi_gui_CWindow Go back to normal functions from CWindow@endlink + // + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow_callbacks + /// @brief OnInit method. + /// + /// @return Return true if initialize was done successful + /// + /// + virtual bool OnInit() { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow_callbacks + /// @brief OnFocus method. + /// + /// @param[in] controlId GUI control identifier + /// @return Return true if focus condition was handled there or false to handle them by Kodi itself + /// + /// + virtual bool OnFocus(int controlId) { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow_callbacks + /// @brief OnClick method. + /// + /// @param[in] controlId GUI control identifier + /// @return Return true if click was handled there + /// or false to handle them by Kodi itself + /// + /// + virtual bool OnClick(int controlId) { return false; } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow_callbacks + /// @brief OnAction method. + /// + /// @param[in] actionId The action id to perform, see + /// \ref kodi_key_action_ids to get list of + /// them + /// @return Return true if action was handled there + /// or false to handle them by Kodi itself + /// + /// + /// This method will receive all actions that the main program will send + /// to this window. + /// + /// @note + /// - By default, only the \c PREVIOUS_MENU and \c NAV_BACK actions are handled. + /// - Overwrite this method to let your code handle all actions. + /// - Don't forget to capture \c ACTION_PREVIOUS_MENU or \c ACTION_NAV_BACK, else the user can't close this window. + /// + /// + ///-------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// .. + /// /* Window used with parent / child way */ + /// bool cYOUR_CLASS::OnAction(int actionId) + /// { + /// switch (action) + /// { + /// case ACTION_PREVIOUS_MENU: + /// case ACTION_NAV_BACK: + /// printf("action recieved: previous"); + /// Close(); + /// return true; + /// case ACTION_SHOW_INFO: + /// printf("action recieved: show info"); + /// break; + /// case ACTION_STOP: + /// printf("action recieved: stop"); + /// break; + /// case ACTION_PAUSE: + /// printf("action recieved: pause"); + /// break; + /// default: + /// break; + /// } + /// return false; + /// } + /// .. + /// ~~~~~~~~~~~~~ + /// + virtual bool OnAction(int actionId) + { + switch (actionId) + { + case ACTION_PREVIOUS_MENU: + case ACTION_NAV_BACK: + Close(); + return true; + default: + break; + } + return false; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow_callbacks + /// @brief Get context menu buttons for list entry + /// + /// @param[in] itemNumber selected list item entry + /// @param[in] buttons list where context menus becomes added with his + /// identifier and name. + /// + virtual void GetContextButtons(int itemNumber, std::vector< std::pair > &buttons) + { + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow_callbacks + /// @brief Called after selection in context menu + /// + /// @param[in] itemNumber selected list item entry + /// @param[in] button the pressed button id + /// @return true if handled, otherwise false + /// + virtual bool OnContextButton(int itemNumber, unsigned int button) + { + return false; + } + //-------------------------------------------------------------------------- + + //========================================================================== + /// + /// \ingroup cpp_kodi_gui_CWindow_callbacks + /// @brief **Set independent callbacks** + /// + /// If the class is used independent (with "new CWindow") and + /// not as parent (with "cCLASS_own : CWindow") from own must be the + /// callback from Kodi to add-on overdriven with own functions! + /// + /// @param[in] cbhdl The pointer to own handle data + /// structure / class + /// @param[in] CBOnInit Own defined window init function + /// @param[in] CBOnFocus Own defined focus function + /// @param[in] CBOnClick Own defined click function + /// @param[in] CBOnAction Own defined action function + /// @param[in] CBGetContextButtons [opt] To get context menu entries for + /// lists function + /// @param[in] CBOnContextButton [opt] Used context menu entry function + /// + /// + ///-------------------------------------------------------------------------- + /// + /// **Example:** + /// ~~~~~~~~~~~~~{.cpp} + /// ... + /// + /// bool OnInit(GUIHANDLE cbhdl) + /// { + /// ... + /// return true; + /// } + /// + /// bool OnFocus(GUIHANDLE cbhdl, int controlId) + /// { + /// ... + /// return true; + /// } + /// + /// bool OnClick(GUIHANDLE cbhdl, int controlId) + /// { + /// ... + /// return true; + /// } + /// + /// bool OnAction(GUIHANDLE cbhdl, int actionId) + /// { + /// ... + /// return true; + /// } + /// + /// ... + /// /* Somewhere where you create the window */ + /// CWindow myWindow = new CWindow; + /// myWindow->SetIndependentCallbacks(myWindow, OnInit, OnFocus, OnClick, OnAction); + /// ... + /// ~~~~~~~~~~~~~ + /// + void SetIndependentCallbacks( + GUIHANDLE cbhdl, + bool (*CBOnInit) (GUIHANDLE cbhdl), + bool (*CBOnFocus) (GUIHANDLE cbhdl, int controlId), + bool (*CBOnClick) (GUIHANDLE cbhdl, int controlId), + bool (*CBOnAction) (GUIHANDLE cbhdl, int actionId), + void (*CBGetContextButtons) (GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) = nullptr, + bool (*CBOnContextButton) (GUIHANDLE cbhdl, int itemNumber, unsigned int button) = nullptr) + { + if (!cbhdl || + !CBOnInit || !CBOnFocus || !CBOnClick || !CBOnAction) + { + kodi::Log(ADDON_LOG_FATAL, "kodi::gui::CWindow::%s called with nullptr !!!", __FUNCTION__); + return; + } + + m_interface->kodi_gui->window->set_callbacks(m_interface->kodiBase, m_controlHandle, cbhdl, + CBOnInit, CBOnFocus, CBOnClick, CBOnAction, + CBGetContextButtons, CBOnContextButton); + } + //-------------------------------------------------------------------------- + //@} + + private: + static bool CBOnInit(GUIHANDLE cbhdl) + { + return static_cast(cbhdl)->OnInit(); + } + + static bool CBOnFocus(GUIHANDLE cbhdl, int controlId) + { + return static_cast(cbhdl)->OnFocus(controlId); + } + + static bool CBOnClick(GUIHANDLE cbhdl, int controlId) + { + return static_cast(cbhdl)->OnClick(controlId); + } + + static bool CBOnAction(GUIHANDLE cbhdl, int actionId) + { + return static_cast(cbhdl)->OnAction(actionId); + } + + static void CBGetContextButtons(GUIHANDLE cbhdl, int itemNumber, gui_context_menu_pair* buttons, unsigned int* size) + { + std::vector< std::pair > buttonList; + static_cast(cbhdl)->GetContextButtons(itemNumber, buttonList); + if (!buttonList.empty()) + { + unsigned int presentSize = buttonList.size(); + if (presentSize > *size) + kodi::Log(ADDON_LOG_WARNING, "GetContextButtons: More as allowed '%i' entries present!", *size); + else + *size = presentSize; + for (unsigned int i = 0; i < *size; ++i) + { + buttons[i].id = buttonList[i].first; + strncpy(buttons[i].name, buttonList[i].second.c_str(), ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH); + } + } + } + + static bool CBOnContextButton(GUIHANDLE cbhdl, int itemNumber, unsigned int button) + { + return static_cast(cbhdl)->OnContextButton(itemNumber, button); + } + }; + +} /* namespace gui */ +} /* 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 @@ +#pragma once +/* + * Copyright (C) 2005-2017 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include +#include + +/* + * Internal Structures to have "C"-Style data transfer + */ +extern "C" +{ + +typedef struct AddonToKodiFuncTable_kodi_gui_general +{ + void (*lock)(); + void (*unlock)(); + int (*get_screen_height)(void* kodiBase); + int (*get_screen_width)(void* kodiBase); + int (*get_video_resolution)(void* kodiBase); + int (*get_current_window_dialog_id)(void* kodiBase); + int (*get_current_window_id)(void* kodiBase); +} AddonToKodiFuncTable_kodi_gui_general; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogContextMenu +{ + int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size); +} AddonToKodiFuncTable_kodi_gui_dialogContextMenu; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress +{ + void* (*new_dialog)(void* kodiBase, const char *title); + void (*delete_dialog)(void* kodiBase, void* handle); + char* (*get_title)(void* kodiBase, void* handle); + void (*set_title)(void* kodiBase, void* handle, const char *title); + char* (*get_text)(void* kodiBase, void* handle); + void (*set_text)(void* kodiBase, void* handle, const char *text); + bool (*is_finished)(void* kodiBase, void* handle); + void (*mark_finished)(void* kodiBase, void* handle); + float (*get_percentage)(void* kodiBase, void* handle); + void (*set_percentage)(void* kodiBase, void* handle, float percentage); + void (*set_progress)(void* kodiBase, void* handle, int currentItem, int itemCount); +} AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogFileBrowser +{ + bool (*show_and_get_directory)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out, bool writeOnly); + 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); + 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); + 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); + 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); + bool (*show_and_get_image)(void* kodiBase, const char* shares, const char* heading, const char* path_in, char** path_out); + bool (*show_and_get_image_list)(void* kodiBase, const char* shares, const char* heading, char*** file_list, unsigned int* entries); + void (*clear_file_list)(void* kodiBase, char*** file_list, unsigned int entries); +} AddonToKodiFuncTable_kodi_gui_dialogFileBrowser; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogKeyboard +{ + 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); + bool (*show_and_get_input)(void* kodiBase, const char* text_in, char** text_out, bool allow_empty_result, unsigned int auto_close_ms); + 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); + bool (*show_and_get_new_password)(void* kodiBase, const char* password_in, char** password_out, unsigned int auto_close_ms); + 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); + bool (*show_and_verify_new_password)(void* kodiBase, char** password_out, unsigned int auto_close_ms); + int (*show_and_verify_password)(void* kodiBase, const char* password_in, char** password_out, const char* heading, int retries, unsigned int auto_close_ms); + bool (*show_and_get_filter)(void* kodiBase, const char* text_in, char** text_out, bool searching, unsigned int auto_close_ms); + bool (*send_text_to_active_keyboard)(void* kodiBase, const char* text, bool close_keyboard); + bool (*is_keyboard_activated)(void* kodiBase); +} AddonToKodiFuncTable_kodi_gui_dialogKeyboard; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogNumeric +{ + bool (*show_and_verify_new_password)(void* kodiBase, char** password); + int (*show_and_verify_password)(void* kodiBase, const char* password, const char *heading, int retries); + bool (*show_and_verify_input)(void* kodiBase, const char* verify_in, char** verify_out, const char* heading, bool verify_input); + bool (*show_and_get_time)(void* kodiBase, tm *time, const char *heading); + bool (*show_and_get_date)(void* kodiBase, tm *date, const char *heading); + bool (*show_and_get_ip_address)(void* kodiBase, const char* ip_address_in, char** ip_address_out, const char *heading); + bool (*show_and_get_number)(void* kodiBase, const char* input_in, char** input_out, const char *heading, unsigned int auto_close_ms); + bool (*show_and_get_seconds)(void* kodiBase, const char* time_in, char** time_out, const char *heading); +} AddonToKodiFuncTable_kodi_gui_dialogNumeric; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogOK +{ + void (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text); + void (*show_and_get_input_line_text)(void* kodiBase, const char *heading, const char *line0, const char *line1, const char *line2); +} AddonToKodiFuncTable_kodi_gui_dialogOK; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogProgress +{ + void* (*new_dialog)(void* kodiBase); + void (*delete_dialog)(void* kodiBase, void* handle); + void (*open)(void* kodiBase, void* handle); + void (*set_heading)(void* kodiBase, void* handle, const char* heading); + void (*set_line)(void* kodiBase, void* handle, unsigned int lineNo, const char* line); + void (*set_can_cancel)(void* kodiBase, void* handle, bool canCancel); + bool (*is_canceled)(void* kodiBase, void* handle); + void (*set_percentage)(void* kodiBase, void* handle, int percentage); + int (*get_percentage)(void* kodiBase, void* handle); + void (*show_progress_bar)(void* kodiBase, void* handle, bool pnOff); + void (*set_progress_max)(void* kodiBase, void* handle, int max); + void (*set_progress_advance)(void* kodiBase, void* handle, int nSteps); + bool (*abort)(void* kodiBase, void* handle); +} AddonToKodiFuncTable_kodi_gui_dialogProgress; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogSelect +{ + int (*open)(void* kodiBase, const char *heading, const char *entries[], unsigned int size, int selected, bool autoclose); +} AddonToKodiFuncTable_kodi_gui_dialogSelect; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogTextViewer +{ + void (*open)(void* kodiBase, const char *heading, const char *text); +} AddonToKodiFuncTable_kodi_gui_dialogTextViewer; + +typedef struct AddonToKodiFuncTable_kodi_gui_dialogYesNo +{ + bool (*show_and_get_input_single_text)(void* kodiBase, const char *heading, const char *text, bool *canceled, const char *noLabel, const char *yesLabel); + 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); + 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); +} AddonToKodiFuncTable_kodi_gui_dialogYesNo; + +typedef struct AddonToKodiFuncTable_kodi_gui_listItem +{ + void* (*create)(void* kodiBase, const char* label, const char* label2, const char* icon_image, const char* thumbnail_image, const char* path); + void (*destroy)(void* kodiBase, void* handle); + char* (*get_label)(void* kodiBase, void* handle); + void (*set_label)(void* kodiBase, void* handle, const char* label); + char* (*get_label2)(void* kodiBase, void* handle); + void (*set_label2)(void* kodiBase, void* handle, const char* label); + char* (*get_icon_image)(void* kodiBase, void* handle); + void (*set_icon_image)(void* kodiBase, void* handle, const char* image); + char* (*get_art)(void* kodiBase, void* handle, const char* type); + void (*set_art)(void* kodiBase, void* handle, const char* type, const char* image); + char* (*get_path)(void* kodiBase, void* handle); + void (*set_path)(void* kodiBase, void* handle, const char* path); +} AddonToKodiFuncTable_kodi_gui_listItem; + +#define ADDON_MAX_CONTEXT_ENTRIES 20 +#define ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH 80 +typedef struct gui_context_menu_pair +{ + unsigned int id; + char name[ADDON_MAX_CONTEXT_ENTRY_NAME_LENGTH]; +} gui_context_menu_pair; + +typedef struct AddonToKodiFuncTable_kodi_gui_window +{ + void* (*create)(void* kodiBase, const char* xml_filename, const char* default_skin, bool as_dialog, bool is_media); + void (*destroy)(void* kodiBase, void* handle); + void (*set_callbacks)(void* kodiBase, void* handle, void* clienthandle, + bool (*)(void* handle), + bool (*)(void* handle, int), + bool (*)(void* handle, int), + bool (*)(void* handle, int), + void (*)(void* handle, int, gui_context_menu_pair*, unsigned int*), + bool (*)(void* handle, int, unsigned int)); + bool (*show)(void* kodiBase, void* handle); + bool (*close)(void* kodiBase, void* handle); + bool (*do_modal)(void* kodiBase, void* handle); + void (*clear_item_list)(void* kodiBase, void* handle); + void (*add_list_item)(void* kodiBase, void* handle, void* item, int item_position); + void* (*get_list_item)(void* kodiBase, void* handle, int listPos); +} AddonToKodiFuncTable_kodi_gui_window; + +typedef struct AddonToKodiFuncTable_kodi_gui +{ + AddonToKodiFuncTable_kodi_gui_general* general; + AddonToKodiFuncTable_kodi_gui_dialogContextMenu* dialogContextMenu; + AddonToKodiFuncTable_kodi_gui_dialogExtendedProgress* dialogExtendedProgress; + AddonToKodiFuncTable_kodi_gui_dialogFileBrowser* dialogFileBrowser; + AddonToKodiFuncTable_kodi_gui_dialogKeyboard* dialogKeyboard; + AddonToKodiFuncTable_kodi_gui_dialogNumeric* dialogNumeric; + AddonToKodiFuncTable_kodi_gui_dialogOK* dialogOK; + AddonToKodiFuncTable_kodi_gui_dialogProgress* dialogProgress; + AddonToKodiFuncTable_kodi_gui_dialogSelect* dialogSelect; + AddonToKodiFuncTable_kodi_gui_dialogTextViewer* dialogTextViewer; + AddonToKodiFuncTable_kodi_gui_dialogYesNo* dialogYesNo; + AddonToKodiFuncTable_kodi_gui_listItem* listItem; + AddonToKodiFuncTable_kodi_gui_window* window; +} AddonToKodiFuncTable_kodi_gui; + +} /* extern "C" */ + +//============================================================================ +/// +/// \ingroup cpp_kodi_gui_CControlRendering_Defs cpp_kodi_gui_CWindow_Defs +/// @{ +/// @brief Handle to use as independent pointer for GUI +typedef void* GUIHANDLE; +/// @} +//---------------------------------------------------------------------------- -- cgit v1.2.3