2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FWebCtrl_WebNotificationHandler.cpp
20 * @brief The file contains the definition of _WebNotificationHandler class.
23 #include "FWebCtrl_WebNotification.h"
24 #include "FWebCtrl_WebNotificationHandler.h"
25 #include <FBaseSysLog.h>
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Controls;
32 namespace Tizen { namespace Web { namespace Controls
35 _WebNotificationHandler::_WebNotificationHandler(void)
36 : __pNotification(null)
37 , __state(NOTIFCATION_STATE_NORMAL)
41 _WebNotificationHandler::~_WebNotificationHandler(void)
47 _WebNotificationHandler::Construct(_WebNotification* pNotification)
50 SysTryReturnResult(NID_WEB_CTRL, pNotification != null, E_INVALID_ARG, "Notification instancce cannot be null.");
52 __pNotification = pNotification;
53 __pallete[NOTIFCATION_COLOR_BG_NORMAL] = NOTIFCATION_NORMAL_BLACKGROUND_COLOR;
54 __pallete[NOTIFCATION_COLOR_FG_NORMAL] = NOTIFCATION_NORMAL_FOREGROUND_COLOR;
56 __bounds = __pNotification->GetBounds();
62 _WebNotificationHandler::GetState(void) const
69 _WebNotificationHandler::SetState(int newState)
76 _WebNotificationHandler::OnPreviewTouchMoved(Control &source, const TouchEventInfo &touchEventInfo)
83 _WebNotificationHandler::OnPreviewTouchPressed(Control &source, const TouchEventInfo &touchEventInfo)
90 _WebNotificationHandler::OnPreviewTouchReleased(Control &source, const TouchEventInfo &touchEventInfo)
97 _WebNotificationHandler::OnTouchCanceled(Control &source, const TouchEventInfo &touchEventInfo)
99 if (GetState() == NOTIFCATION_STATE_PRESSED)
101 SetState(NOTIFCATION_STATE_NORMAL);
102 __pNotification->Invalidate(false);
109 _WebNotificationHandler::OnTouchMoved(Control &source, const TouchEventInfo &touchEventInfo)
116 _WebNotificationHandler::OnTouchPressed(Control &source, const TouchEventInfo &touchEventInfo)
118 if (GetState() == NOTIFCATION_STATE_NORMAL)
120 SetState(NOTIFCATION_STATE_PRESSED);
121 __pNotification->Invalidate(false);
128 _WebNotificationHandler::OnTouchReleased(Control &source, const TouchEventInfo &touchEventInfo)
130 if (GetState() == NOTIFCATION_STATE_PRESSED)
132 SetState(NOTIFCATION_STATE_NORMAL);
133 __pNotification->Invalidate(false);
135 __pNotification->OnClicked();
142 _WebNotificationHandler::DrawNotification(Canvas& canvas)
145 canvas.SetBackgroundColor(Color(0, 0, 0, 0));
147 canvas.FillRoundRectangle(__pallete[NOTIFCATION_COLOR_BG_NORMAL], Rectangle(0, 0 , __bounds.width, __bounds.height), Dimension(5, 5));
149 EnrichedText enriched;
150 enriched.Construct(Dimension(__bounds.width, __bounds.height));
151 enriched.SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
152 enriched.SetHorizontalAlignment(TEXT_ALIGNMENT_CENTER);
155 element.Construct(__text);
156 // element.SetTextColor(__pallete[NOTIFCATION_COLOR_FG_NORMAL]);
158 enriched.Add(element);
159 canvas.DrawText(Point(0, 0), enriched);
160 enriched.RemoveAll(false);
167 _WebNotificationHandler::GetText(void) const
174 _WebNotificationHandler::SetText(const String& text)