Tizen 2.0 Release
[apps/osp/Internet.git] / src / IntNotificationPanel.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (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 // !Internet
19 /*@file:    IntNotification.cpp
20  *@brief:       This defines the behaviour of the Notification Class
21  *
22  */
23
24 #include <FAppUiApp.h>
25 #include <FUi.h>
26
27 #include "IntNotificationPanel.h"
28 #include "IntSceneRegister.h"
29
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Base::Runtime;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39
40 NotificationPanel::NotificationPanel(Form& aForm)
41 :__pTimer(null)
42 ,__pLabel(null)
43 ,__form(aForm)
44 ,__position(0)
45 {
46         Construct("IDL_NOTIFICATION_PANEL");
47 }
48
49 NotificationPanel::~NotificationPanel()
50 {
51         if (__pTimer)
52         {
53                 __pTimer->Cancel();
54                 delete __pTimer;
55         }
56 }
57
58 void
59 NotificationPanel::SetText(Tizen::Base::String& message)
60 {
61         __pLabel = static_cast<Label*>(GetControl(L"IDC_NOTIFICATION_LABEL"));
62         if (__pLabel == null)
63         {
64                 return;
65         }
66         __pLabel->SetText(message);
67 }
68
69 void
70 NotificationPanel::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
71 {
72         SetShowState(false);
73         Invalidate(true);
74 }
75
76 void
77 NotificationPanel::ShowNotification(void)
78 {
79         SceneManager* pSceneManager = null;
80         if ( __pLabel != NULL)
81         {
82                 AddControl(*__pLabel);
83                 __pLabel->SetBackgroundColor(CUSTOM_COLOR_INFO_LABEL);
84         }
85         __form.AddControl(*this);
86
87         SceneId sceneId = pSceneManager->GetInstance()->GetCurrentSceneId();
88
89         if (sceneId == IDSCN_EDIT_HISTORY_LIST || sceneId == IDSCN_EDIT_BOOKMARK_LIST /*|| sceneId == IDSCN_SETTINGS*/)
90         {
91         SetPosition(0,__form.GetClientAreaBounds().height - GetHeight());
92         SetSize(__form.GetWidth(),GetHeight());
93         }
94         else
95     {
96                 // Since there is a footer panel for the Main form need to subtract __position which is equal to footer panel height.
97                 SetPosition(0,__form.GetClientAreaBounds().height -__position - GetHeight());
98         }
99         Invalidate(true);
100
101         __pTimer = new (std::nothrow) Timer;
102         if (__pTimer != NULL)
103         {
104                 __pTimer->Construct(*this);
105                 __pTimer->Start(2000);
106         }
107
108 }
109
110 void
111 NotificationPanel::SetPositionDiff(int pos)
112 {
113         __position = pos ;
114 }