Fixed Nabi issues N_SE-49016, N_SE-48879, N_SE-48597, N_SE-48815, N_SE-48813, N_SE...
[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.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 // !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         __pLabel->SetTextConfig(32, LABEL_TEXT_STYLE_BOLD);
68         __pLabel->Invalidate(true);
69 }
70
71 void
72 NotificationPanel::OnTimerExpired(Tizen::Base::Runtime::Timer& timer)
73 {
74         SetShowState(false);
75         Invalidate(true);
76 }
77
78 void
79 NotificationPanel::ShowNotification(void)
80 {
81         SceneManager* pSceneManager = SceneManager::GetInstance();
82         if ( __pLabel != NULL)
83         {
84                 AddControl(__pLabel);
85                 __pLabel->SetBackgroundColor(CUSTOM_COLOR_INFO_LABEL);
86         }
87         __form.AddControl(this);
88
89         SceneId sceneId = pSceneManager->GetInstance()->GetCurrentSceneId();
90
91         if (sceneId == IDSCN_EDIT_HISTORY_LIST || sceneId == IDSCN_EDIT_BOOKMARK_LIST /*|| sceneId == IDSCN_SETTINGS*/)
92         {
93         SetPosition(0,__form.GetClientAreaBounds().height - GetHeight());
94         SetSize(__form.GetWidth(),GetHeight());
95         }
96         else
97     {
98                 // Since there is a footer panel for the Main form need to subtract __position which is equal to footer panel height.
99                 SetPosition(0,__form.GetClientAreaBounds().height -__position - GetHeight());
100         }
101         Invalidate(true);
102
103         __pTimer = new (std::nothrow) Timer;
104         if (__pTimer != NULL)
105         {
106                 __pTimer->Construct(*this);
107                 __pTimer->Start(2000);
108         }
109
110 }
111
112 void
113 NotificationPanel::SetPositionDiff(int pos)
114 {
115         __position = pos ;
116 }
117
118 void
119 NotificationPanel::OrientationChanged()
120 {
121         SceneManager* pSceneManager = SceneManager::GetInstance();
122         SceneId sceneId = pSceneManager->GetInstance()->GetCurrentSceneId();
123
124         if (sceneId == IDSCN_EDIT_HISTORY_LIST || sceneId == IDSCN_EDIT_BOOKMARK_LIST /*|| sceneId == IDSCN_SETTINGS*/)
125         {
126                 SetPosition(0,__form.GetClientAreaBounds().height - GetHeight());
127                 SetSize(__form.GetWidth(),GetHeight());
128         }
129         else
130         {
131                 // Since there is a footer panel for the Main form need to subtract __position which is equal to footer panel height.
132                 SetPosition(0,__form.GetClientAreaBounds().height -__position - GetHeight());
133         }
134         Invalidate(true);
135 }