2 // Open Service Platform
3 // Copyright (c) 2012-2013 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.
18 * @file FUiTouchEventInfo.cpp
19 * @brief This is the implementation file for TouchEventInfo class
22 * This file contains the implementation of TouchEventInfo class.
26 #include <FBaseResult.h>
27 #include <FUiTouchEventInfo.h>
28 #include "FUi_TouchEventInfoImpl.h"
29 #include "FUi_TouchEventArg.h"
30 #include "FUi_TouchManager.h"
31 #include "FUi_CoordinateSystemUtils.h"
33 using namespace Tizen::Base::Runtime;
34 using namespace Tizen::Graphics;
36 namespace Tizen { namespace Ui
39 TouchEventInfo::TouchEventInfo(void)
40 : __pTouchEventInfoImpl(null)
44 TouchEventInfo::~TouchEventInfo(void)
46 delete __pTouchEventInfoImpl;
47 __pTouchEventInfoImpl = null;
51 TouchEventInfo::Construct(const IEventArg& eventArg)
53 SysAssertf(__pTouchEventInfoImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
55 const _TouchEventArg* pTouchArg = dynamic_cast <const _TouchEventArg*>(&eventArg);
56 SysTryReturnResult(NID_UI, pTouchArg, E_INVALID_ARG, "[E_INVALID_ARG] pTouchArg is invalid.");
58 _TouchEventInfoImpl* pImpl = _TouchEventInfoImpl::CreateInstanceN(this);
59 result r = GetLastResult();
60 SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
62 __pTouchEventInfoImpl = pImpl;
64 _TouchInfo touchInfo(pTouchArg->GetPointId(), pTouchArg->GetTouchStatus(), pTouchArg->GetCurrentPosition(), pTouchArg->IsFlicked(), 0);
65 Point startPosition = _CoordinateSystemUtils::ConvertToInteger(pTouchArg->GetStartPosition());
67 __pTouchEventInfoImpl->SetTouchEventInfo(touchInfo, startPosition);
73 TouchEventInfo::GetPointId(void) const
75 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
77 return __pTouchEventInfoImpl->GetPointId();
82 TouchEventInfo::GetStartPosition(void) const
84 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
86 return __pTouchEventInfoImpl->GetStartPosition();
90 TouchEventInfo::GetStartPositionF(void) const
92 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
94 return __pTouchEventInfoImpl->GetStartPositionF();
98 TouchEventInfo::GetCurrentPosition(void) const
100 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
102 return __pTouchEventInfoImpl->GetCurrentPosition();
106 TouchEventInfo::GetCurrentPositionF(void) const
108 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
110 return __pTouchEventInfoImpl->GetCurrentPositionF();
115 TouchEventInfo::GetTouchStatus(void) const
117 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
119 TouchStatus status = TOUCH_PRESSED;
121 switch (__pTouchEventInfoImpl->GetTouchStatus())
124 status = TOUCH_PRESSED;
126 case _TOUCH_LONG_PRESSED:
127 status = TOUCH_LONG_PRESSED;
129 case _TOUCH_RELEASED:
130 status = TOUCH_RELEASED;
133 status = TOUCH_MOVED;
135 case _TOUCH_DOUBLE_PRESSED:
136 status = TOUCH_DOUBLE_PRESSED;
138 case _TOUCH_FOCUS_IN:
139 status = TOUCH_FOCUS_IN;
141 case _TOUCH_FOCUS_OUT:
142 status = TOUCH_FOCUS_OUT;
144 case _TOUCH_CANCELED:
145 status = TOUCH_CANCELED;
155 TouchEventInfo::IsFlicked(void) const
157 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
159 return __pTouchEventInfoImpl->IsFlicked();