3b78c240317aa40a57f9d0deaa8ca4ae5aba4f12
[apps/osp/Internet.git] / src / IntConfirmationPopup.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /*
19  * IntConfirmationPopup.cpp
20  *@file:        IntConfirmationPopup.cpp
21  *@brief:       Common popup to show delete confirmation
22  */
23
24 #include <FAppUiApp.h>
25 #include <FUi.h>
26
27 #include "IntCommonLib.h"
28 #include "IntConfirmationPopup.h"
29 #include "IntHistoryPresentationModel.h"
30 #include "IntSettingPresentationModel.h"
31
32
33 using namespace Tizen::Base;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui;
37 //
38 //static const int IDA_BUTTON_NO = 1000;
39 //static const int IDA_BUTTON_YES = 1001;
40
41
42 ConfirmationPopup::ConfirmationPopup(void)
43 {
44         __pPopupText = null;
45         __pYesButton = null;
46         __pNoButton = null;
47 }
48
49 ConfirmationPopup::~ConfirmationPopup(void)
50 {
51
52 }
53
54 bool
55 ConfirmationPopup::Initialize(void)
56 {
57         Button* pYesButton = null;
58         Button* pNoButton = null;
59         Popup::Construct(L"IDL_CONFIRMATION_POPUP");
60
61         __pYesButton = static_cast< Button* >(GetControl(L"IDC_BUTTON_OK", true));
62         if (__pYesButton)
63         {
64                 __pYesButton->SetActionId(IDA_BUTTON_YES);
65         }
66
67         __pNoButton = static_cast< Button* >(GetControl(L"IDC_BUTTON_CANCEL", true));
68         if (__pNoButton)
69         {
70                 __pNoButton->SetActionId(IDA_BUTTON_NO);
71         }
72
73         __pPopupText = static_cast< Label* >(GetControl(L"IDC_LABEL1", true));
74
75         SetPropagatedKeyEventListener(this);
76         return true;
77 }
78
79 result
80 ConfirmationPopup::OnTerminating(void)
81 {
82         return E_SUCCESS;
83 }
84
85 void
86 ConfirmationPopup::setMessage(String& str)
87 {
88         __message = str;
89         __pPopupText->SetText(str);
90 }
91
92 String
93 ConfirmationPopup::GetMessage(void)
94 {
95         return __message;
96 }
97
98 void
99 ConfirmationPopup::AddActionListener(IActionEventListener& listener)
100 {
101         __pYesButton->AddActionEventListener(listener);
102         __pNoButton->AddActionEventListener(listener);
103 }
104
105 void
106 ConfirmationPopup::RemoveActionListener(IActionEventListener& listener)
107 {
108         __pYesButton->RemoveActionEventListener(listener);
109         __pNoButton->RemoveActionEventListener(listener);
110 }
111
112 bool
113 ConfirmationPopup::OnKeyReleased (Control &source, const KeyEventInfo &keyEventInfo)
114 {
115         AppLog("ConfirmationPopup::OnKeyReleased %d",keyEventInfo.GetKeyCode());
116         if(keyEventInfo.GetKeyCode() == KEY_BACK)
117         {
118                 if(GetShowState() == true)
119                 {
120                         SetShowState(false);
121                 }
122         }
123         return false;
124 }