summaryrefslogtreecommitdiffstats
path: root/xbmc/dialogs/GUIDialogYesNo.h
blob: e8baac22ccc88841128f4d0cce3cf5c20a43f4e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 *  Copyright (C) 2005-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include "GUIDialogBoxBase.h"
#include "utils/Variant.h"

namespace KODI
{
  namespace MESSAGING
  {
    namespace HELPERS
    {
      struct DialogYesNoMessage;
    }
  }
}

class CGUIDialogYesNo :
      public CGUIDialogBoxBase
{
public:
  explicit CGUIDialogYesNo(int overrideId = -1);
  ~CGUIDialogYesNo(void) override;
  bool OnMessage(CGUIMessage& message) override;
  bool OnBack(int actionID) override;

  void Reset();
  int GetResult() const;

  enum TimeOut
  {
    NO_TIMEOUT = 0
  };

  /*! \brief Show a yes-no dialog, then wait for user to dismiss it.
   \param heading Localized label id or string for the heading of the dialog
   \param line0 Localized label id or string for line 1 of the dialog message
   \param line1 Localized label id or string for line 2 of the dialog message
   \param line2 Localized label id or string for line 3 of the dialog message
   \param bCanceled Holds true if the dialog was canceled otherwise false
   \return true if user selects Yes, otherwise false if user selects No.
   */
  static bool ShowAndGetInput(const CVariant& heading,
                              const CVariant& line0,
                              const CVariant& line1,
                              const CVariant& line2,
                              bool& bCanceled);

  /*! \brief Show a yes-no dialog, then wait for user to dismiss it.
   \param heading Localized label id or string for the heading of the dialog
   \param line0 Localized label id or string for line 1 of the dialog message
   \param line1 Localized label id or string for line 2 of the dialog message
   \param line2 Localized label id or string for line 3 of the dialog message
   \param iNoLabel Localized label id or string for the no button
   \param iYesLabel Localized label id or string for the yes button
   \return true if user selects Yes, otherwise false if user selects No.
   */
  static bool ShowAndGetInput(const CVariant& heading,
                              const CVariant& line0,
                              const CVariant& line1,
                              const CVariant& line2,
                              const CVariant& noLabel = "",
                              const CVariant& yesLabel = "");

  /*! \brief Show a yes-no dialog, then wait for user to dismiss it.
   \param heading Localized label id or string for the heading of the dialog
   \param line0 Localized label id or string for line 1 of the dialog message
   \param line1 Localized label id or string for line 2 of the dialog message
   \param line2 Localized label id or string for line 3 of the dialog message
   \param bCanceled Holds true if the dialog was canceled otherwise false
   \param iNoLabel Localized label id or string for the no button
   \param iYesLabel Localized label id or string for the yes button
   \param autoCloseTime Time in ms before the dialog becomes automatically closed
   \return true if user selects Yes, otherwise false if user selects No.
   */
  static bool ShowAndGetInput(const CVariant& heading,
                              const CVariant& line0,
                              const CVariant& line1,
                              const CVariant& line2,
                              bool& bCanceled,
                              const CVariant& noLabel,
                              const CVariant& yesLabel,
                              unsigned int autoCloseTime);

  /*! \brief Show a yes-no dialog, then wait for user to dismiss it.
   \param heading Localized label id or string for the heading of the dialog
   \param text Localized label id or string for the dialog message
   \return true if user selects Yes, otherwise false if user selects No.
   */
  static bool ShowAndGetInput(const CVariant& heading, const CVariant& text);

  /*! \brief Show a yes-no dialog, then wait for user to dismiss it.
   \param heading Localized label id or string for the heading of the dialog
   \param text Localized label id or string for the dialog message
   \param bCanceled Holds true if the dialog was canceled otherwise false
   \param iNoLabel Localized label id or string for the no button
   \param iYesLabel Localized label id or string for the yes button
   \param autoCloseTime Time in ms before the dialog becomes automatically closed
   \param defaultButtonId Specifies the default focused button
   \return true if user selects Yes, otherwise false if user selects No.
   */
  static bool ShowAndGetInput(const CVariant& heading,
                              const CVariant& text,
                              bool& bCanceled,
                              const CVariant& noLabel,
                              const CVariant& yesLabel,
                              unsigned int autoCloseTime,
                              int defaultButtonId = CONTROL_NO_BUTTON);

  /*! \brief Show a yes-no dialog with 3rd custom button, then wait for user to dismiss it.
  \param heading Localized label id or string for the heading of the dialog
  \param text Localized label id or string for the dialog message
  \param noLabel Localized label id or string for the no button
  \param yesLabel Localized label id or string for the yes button
  \param customLabel Localized label id or string for the custom button
  \param autoCloseTime Time in ms before the dialog becomes automatically closed
  \param defaultButtonId Specifies the default focused button
  \return -1 for cancelled, 0 for No, 1 for Yes and 2 for custom button
  */
  static int ShowAndGetInput(const CVariant& heading,
                             const CVariant& text,
                             const CVariant& noLabel,
                             const CVariant& yesLabel,
                             const CVariant& customLabel,
                             unsigned int autoCloseTime,
                             int defaultButtonId = CONTROL_NO_BUTTON);

  /*!
    \brief Open a Yes/No dialog and wait for input

    \param[in] options  a struct of type DialogYesNoMessage containing
                        the options to set for this dialog.

    \returns -1 for cancelled, 0 for No and 1 for Yes
    \sa KODI::MESSAGING::HELPERS::DialogYesNoMessage
  */
  int ShowAndGetInput(const KODI::MESSAGING::HELPERS::DialogYesNoMessage& options);

protected:
  void OnInitWindow() override;
  int GetDefaultLabelID(int controlId) const override;

  bool m_bCanceled;
  bool m_bCustom;
  int m_defaultButtonId;
};