Merge pull request #4630 from Red-F/gotham-resume-pvr-lastplayedposition
[vuplus_xbmc] / xbmc / dialogs / GUIDialogOK.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "GUIDialogOK.h"
22 #include "guilib/GUIWindowManager.h"
23
24 #define ID_BUTTON_OK   10
25
26 CGUIDialogOK::CGUIDialogOK(void)
27     : CGUIDialogBoxBase(WINDOW_DIALOG_OK, "DialogOK.xml")
28 {
29 }
30
31 CGUIDialogOK::~CGUIDialogOK(void)
32 {}
33
34 bool CGUIDialogOK::OnMessage(CGUIMessage& message)
35 {
36   if (message.GetMessage() == GUI_MSG_CLICKED)
37   {
38     int iControl = message.GetSenderId();
39     if (iControl == ID_BUTTON_OK)
40     {
41       m_bConfirmed = true;
42       Close();
43       return true;
44     }
45   }
46   return CGUIDialogBoxBase::OnMessage(message);
47 }
48
49 // \brief Show CGUIDialogOK dialog, then wait for user to dismiss it.
50 void CGUIDialogOK::ShowAndGetInput(const CVariant &heading, const CVariant &text)
51 {
52   CGUIDialogOK *dialog = (CGUIDialogOK *)g_windowManager.GetWindow(WINDOW_DIALOG_OK);
53   if (!dialog)
54     return;
55   dialog->SetHeading(heading);
56   dialog->SetText(text);
57   dialog->DoModal();
58 }
59
60 // \brief Show CGUIDialogOK dialog, then wait for user to dismiss it.
61 void CGUIDialogOK::ShowAndGetInput(const CVariant &heading, const CVariant &line0, const CVariant &line1, const CVariant &line2)
62 {
63   CGUIDialogOK *dialog = (CGUIDialogOK *)g_windowManager.GetWindow(WINDOW_DIALOG_OK);
64   if (!dialog) 
65     return;
66   dialog->SetHeading(heading);
67   dialog->SetLine(0, line0);
68   dialog->SetLine(1, line1);
69   dialog->SetLine(2, line2);
70   dialog->DoModal();
71 }
72
73 int CGUIDialogOK::GetDefaultLabelID(int controlId) const
74 {
75   if (controlId == ID_BUTTON_OK)
76     return 186;
77   return CGUIDialogBoxBase::GetDefaultLabelID(controlId);
78 }