2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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"
32 using namespace Tizen::Base::Runtime;
33 using namespace Tizen::Graphics;
35 namespace Tizen { namespace Ui
38 TouchEventInfo::TouchEventInfo(void)
39 : __pTouchEventInfoImpl(null)
43 TouchEventInfo::~TouchEventInfo(void)
45 delete __pTouchEventInfoImpl;
46 __pTouchEventInfoImpl = null;
50 TouchEventInfo::Construct(const IEventArg& eventArg)
52 SysAssertf(__pTouchEventInfoImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
54 const _TouchEventArg* pTouchArg = dynamic_cast <const _TouchEventArg*>(&eventArg);
55 SysTryReturnResult(NID_UI, pTouchArg, E_INVALID_ARG, "[E_INVALID_ARG] pTouchArg is invalid.");
57 _TouchEventInfoImpl* pImpl = _TouchEventInfoImpl::CreateInstanceN(this);
58 result r = GetLastResult();
59 SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
61 __pTouchEventInfoImpl = pImpl;
63 _TouchInfo touchInfo(pTouchArg->GetPointId(), pTouchArg->GetTouchStatus(), pTouchArg->GetCurrentPosition(), pTouchArg->IsFlicked(), 0);
64 Point startPosition = pTouchArg->GetStartPosition();
66 __pTouchEventInfoImpl->SetTouchEventInfo(touchInfo, startPosition);
72 TouchEventInfo::GetPointId(void) const
74 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
76 return __pTouchEventInfoImpl->GetPointId();
81 TouchEventInfo::GetStartPosition(void) const
83 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
85 return __pTouchEventInfoImpl->GetStartPosition();
89 TouchEventInfo::GetCurrentPosition(void) const
91 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
93 return __pTouchEventInfoImpl->GetCurrentPosition();
98 TouchEventInfo::GetTouchStatus(void) const
100 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
102 TouchStatus status = TOUCH_PRESSED;
104 switch (__pTouchEventInfoImpl->GetTouchStatus())
107 status = TOUCH_PRESSED;
109 case _TOUCH_LONG_PRESSED:
110 status = TOUCH_LONG_PRESSED;
112 case _TOUCH_RELEASED:
113 status = TOUCH_RELEASED;
116 status = TOUCH_MOVED;
118 case _TOUCH_DOUBLE_PRESSED:
119 status = TOUCH_DOUBLE_PRESSED;
121 case _TOUCH_FOCUS_IN:
122 status = TOUCH_FOCUS_IN;
124 case _TOUCH_FOCUS_OUT:
125 status = TOUCH_FOCUS_OUT;
127 case _TOUCH_CANCELED:
128 status = TOUCH_CANCELED;
138 TouchEventInfo::IsFlicked(void) const
140 SysAssertf(__pTouchEventInfoImpl != null, "Not yet constructed. Construct() should be called before used.");
142 return __pTouchEventInfoImpl->IsFlicked();