1 /* 2 * Copyright (C) 2005-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 #include "guilib/GUIDialog.h" 12 #include "threads/CriticalSection.h" 13 14 #include <vector> 15 16 #define CONTROL_CHOICES_START 10 17 #define CONTROL_NO_BUTTON CONTROL_CHOICES_START 18 #define CONTROL_YES_BUTTON CONTROL_CHOICES_START + 1 19 #define CONTROL_CUSTOM_BUTTON CONTROL_CHOICES_START + 2 20 #define CONTROL_PROGRESS_BAR 20 21 22 #define DIALOG_MAX_LINES 3 23 #define DIALOG_MAX_CHOICES 3 24 25 class CVariant; 26 27 class CGUIDialogBoxBase : 28 public CGUIDialog 29 { 30 public: 31 CGUIDialogBoxBase(int id, const std::string &xmlFile); 32 ~CGUIDialogBoxBase(void) override; 33 bool OnMessage(CGUIMessage& message) override; 34 bool IsConfirmed() const; 35 void SetLine(unsigned int iLine, const CVariant& line); 36 void SetText(const CVariant& text); 37 void SetHeading(const CVariant& heading); 38 void SetChoice(int iButton, const CVariant &choice); 39 protected: 40 std::string GetDefaultLabel(int controlId) const; 41 virtual int GetDefaultLabelID(int controlId) const; 42 /*! \brief Get a localized string from a variant 43 If the variant is already a string we return directly, else if it's an integer we return the corresponding 44 localized string. 45 \param var the variant to localize. 46 */ 47 std::string GetLocalized(const CVariant &var) const; 48 49 void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override; 50 void OnInitWindow() override; 51 void OnDeinitWindow(int nextWindowID) override; 52 53 bool m_bConfirmed; 54 bool m_hasTextbox; 55 56 // actual strings 57 CCriticalSection m_section; 58 std::string m_strHeading; 59 std::string m_text; 60 std::string m_strChoices[DIALOG_MAX_CHOICES]; 61 }; 62