xbmc
GUIDialogBoxBase.h
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 
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  bool HasText() const;
38  void SetHeading(const CVariant& heading);
39  bool HasHeading() const;
40  void SetChoice(int iButton, const CVariant &choice);
41 protected:
42  std::string GetDefaultLabel(int controlId) const;
43  virtual int GetDefaultLabelID(int controlId) const;
49  std::string GetLocalized(const CVariant &var) const;
50 
51  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
52  void OnInitWindow() override;
53  void OnDeinitWindow(int nextWindowID) override;
54 
55  bool m_bConfirmed;
56  bool m_hasTextbox;
57 
58  // actual strings
59  mutable CCriticalSection m_section;
60  std::string m_strHeading;
61  std::string m_text;
62  std::string m_strChoices[DIALOG_MAX_CHOICES];
63 };
std::string GetLocalized(const CVariant &var) const
Get a localized string from a variant If the variant is already a string we return directly...
Definition: GUIDialogBoxBase.cpp:181
Definition: Variant.h:31
void OnInitWindow() override
Called on window open.
Definition: GUIDialogBoxBase.cpp:145
Definition: GUIDialog.h:35
Definition: GUIMessage.h:365
Definition: GUIDialogBoxBase.h:27