merge with master
[apps/osp/Internet.git] / src / IntNotificationPanel.cpp
1 //\r
2 \r
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
4 //\r
5 // Licensed under the Flora License, Version 1.0 (the License);\r
6 // you may not use this file except in compliance with the License.\r
7 // You may obtain a copy of the License at\r
8 //\r
9 //     http://floralicense.org/license/\r
10 //\r
11 // Unless required by applicable law or agreed to in writing, software\r
12 // distributed under the License is distributed on an AS IS BASIS,\r
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 // See the License for the specific language governing permissions and\r
15 // limitations under the License.\r
16 //\r
17 \r
18 // !Internet\r
19 /*@file:    IntNotification.cpp\r
20  *@brief:       This defines the behaviour of the Notification Class\r
21  *\r
22  */\r
23 \r
24 #include <FAppUiApp.h>\r
25 #include <FUi.h>\r
26 \r
27 #include "IntNotificationPanel.h"\r
28 #include "IntSceneRegister.h"\r
29 \r
30 using namespace Tizen::App;\r
31 using namespace Tizen::Base;\r
32 using namespace Tizen::Base::Collection;\r
33 using namespace Tizen::Base::Runtime;\r
34 using namespace Tizen::Graphics;\r
35 using namespace Tizen::Ui;\r
36 using namespace Tizen::Ui::Controls;\r
37 using namespace Tizen::Ui::Scenes;\r
38 \r
39 \r
40 NotificationPanel::NotificationPanel(Form& aForm)\r
41 :__pTimer(null)\r
42 ,__pLabel(null)\r
43 ,__form(aForm)\r
44 ,__position(0)\r
45 {\r
46         Construct("IDL_NOTIFICATION_PANEL");\r
47 }\r
48 \r
49 NotificationPanel::~NotificationPanel()\r
50 {\r
51         if (__pTimer)\r
52         {\r
53                 __pTimer->Cancel();\r
54                 delete __pTimer;\r
55         }\r
56 }\r
57 \r
58 void\r
59 NotificationPanel::SetText(Tizen::Base::String& message)\r
60 {\r
61         __pLabel = static_cast<Label*>(GetControl(L"IDC_NOTIFICATION_LABEL"));\r
62         if (__pLabel == null)\r
63         {\r
64                 return;\r
65         }\r
66         __pLabel->SetText(message);\r
67 }\r
68 \r
69 void\r
70 NotificationPanel::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)\r
71 {\r
72         SetShowState(false);\r
73         Invalidate(true);\r
74 }\r
75 \r
76 void\r
77 NotificationPanel::ShowNotification(void)\r
78 {\r
79         SceneManager* pSceneManager = null;\r
80         if ( __pLabel != NULL)\r
81         {\r
82                 AddControl(*__pLabel);\r
83                 __pLabel->SetBackgroundColor(CUSTOM_COLOR_INFO_LABEL);\r
84         }\r
85         __form.AddControl(*this);\r
86 \r
87         SceneId sceneId = pSceneManager->GetInstance()->GetCurrentSceneId();\r
88 \r
89         if (sceneId == IDSCN_EDIT_HISTORY_LIST || sceneId == IDSCN_EDIT_BOOKMARK_LIST /*|| sceneId == IDSCN_SETTINGS*/)\r
90         {\r
91         SetPosition(0,__form.GetClientAreaBounds().height - GetHeight());\r
92         SetSize(__form.GetWidth(),GetHeight());\r
93         }\r
94         else\r
95     {\r
96                 // Since there is a footer panel for the Main form need to subtract __position which is equal to footer panel height.\r
97                 SetPosition(0,__form.GetClientAreaBounds().height -__position - GetHeight());\r
98         }\r
99         Invalidate(true);\r
100 \r
101         __pTimer = new (std::nothrow) Timer;\r
102         if (__pTimer != NULL)\r
103         {\r
104                 __pTimer->Construct(*this);\r
105                 __pTimer->Start(2000);\r
106         }\r
107 \r
108 }\r
109 \r
110 void\r
111 NotificationPanel::SetPositionDiff(int pos)\r
112 {\r
113         __position = pos ;\r
114 }\r