modify license, permission and remove ^M char
[platform/framework/native/uifw.git] / src / ui / FUiTouchLongPressGestureDetector.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
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  * @file                        FUiTouchLongPressGestureDetector.cpp
19  * @brief               This is the implementation file for %TouchLongPressGestureDetector class
20  * @version     2.0
21  *
22  * This file contains the implementation of %TouchLongPressGestureDetector class.
23  *
24  */
25
26 #include <FBaseSysLog.h>
27 #include <FGrpPoint.h>
28 #include <FUiITouchLongPressGestureEventListener.h>
29 #include "FUi_TouchLongPressGestureDetectorImpl.h"
30
31 namespace Tizen { namespace Ui
32 {
33 TouchLongPressGestureDetector::TouchLongPressGestureDetector(void)
34 {
35 }
36
37 TouchLongPressGestureDetector::~TouchLongPressGestureDetector(void)
38 {
39 }
40
41 result
42 TouchLongPressGestureDetector::Construct(void)
43 {
44         SysAssertf(__pTouchGestureDetectorImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
45
46         _TouchGestureDetectorImpl* pImpl =  _TouchLongPressGestureDetectorImpl::CreateInstanceN(this);
47         result r = GetLastResult();
48         SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
49
50         __pTouchGestureDetectorImpl = pImpl;
51
52         return E_SUCCESS;
53 }
54
55 result
56 TouchLongPressGestureDetector::AddLongPressGestureEventListener(ITouchLongPressGestureEventListener& listener)
57 {
58         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
59
60         return __pTouchGestureDetectorImpl->AddGestureEventListener(listener);
61 }
62
63 result
64 TouchLongPressGestureDetector::RemoveLongPressGestureEventListener(ITouchLongPressGestureEventListener& listener)
65 {
66         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
67
68         return __pTouchGestureDetectorImpl->RemoveGestureEventListener(listener);
69 }
70
71 result
72 TouchLongPressGestureDetector::SetDuration(int duration)
73 {
74         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
75
76         _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this);
77         SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
78
79         return pTouchLongPressGestureDetectorImpl->SetDuration(duration);
80 }
81
82 int
83 TouchLongPressGestureDetector::GetDuration(void) const
84 {
85         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
86
87         const _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this);
88         SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
89
90         return pTouchLongPressGestureDetectorImpl->GetDuration();
91 }
92
93 result
94 TouchLongPressGestureDetector::SetMoveAllowance(int allowance)
95 {
96         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
97
98         _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this);
99         SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
100
101         return pTouchLongPressGestureDetectorImpl->SetMoveAllowance(allowance);
102 }
103
104 result
105 TouchLongPressGestureDetector::SetMoveAllowance(float allowance)
106 {
107         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
108
109         _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this);
110         SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
111
112         return pTouchLongPressGestureDetectorImpl->SetMoveAllowance(allowance);
113 }
114
115 int
116 TouchLongPressGestureDetector::GetMoveAllowance(void) const
117 {
118         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
119
120         const _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this);
121         SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
122
123         return pTouchLongPressGestureDetectorImpl->GetMoveAllowance();
124 }
125
126 float
127 TouchLongPressGestureDetector::GetMoveAllowanceF(void) const
128 {
129         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
130
131         const _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this);
132         SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
133
134         return pTouchLongPressGestureDetectorImpl->GetMoveAllowanceF();
135 }
136
137 result
138 TouchLongPressGestureDetector::SetTouchCount(int count)
139 {
140         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
141
142         _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this);
143         SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
144
145         return pTouchLongPressGestureDetectorImpl->SetTouchCount(count);
146 }
147
148 int
149 TouchLongPressGestureDetector::GetTouchCount(void) const
150 {
151         SysAssertf(__pTouchGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
152
153         const _TouchLongPressGestureDetectorImpl* pTouchLongPressGestureDetectorImpl = _TouchLongPressGestureDetectorImpl::GetInstance(*this);
154         SysAssertf(pTouchLongPressGestureDetectorImpl != null, "Not yet constructed. Construct() should be called before used.");
155
156         return pTouchLongPressGestureDetectorImpl->GetTouchCount();
157 }
158
159 }} // Tizen::Ui