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.
21 * @brief This is the header file for the %Touch class.
23 * This header file contains the declarations of the %Touch class.get
30 #include <FBaseColIList.h>
31 #include <FUiTouchInfo.h>
32 #include <FUiTouchEventInfo.h>
34 namespace Tizen { namespace Ui
41 * @brief <i> [Deprecated] </i> This class supports multi-point touch for %Touch devices.
43 * @deprecated This class is deprecated because the use of %Touch is no longer recommended. Instead of using this class, use the Tizen::Ui::TouchEventManager class.
46 * @final This class is not intended for extension.
48 * The %Touch class supports multi-point touch, and provides information about touch events.
50 * The following example demonstrates how to use the %Touch class.
52 // Sample code for TouchSample.h
56 : public Tizen::Ui::Controls::Form
57 , public Tizen::Ui::ITouchEventListener
60 bool Initialize(void);
61 virtual result OnInitializing(void);
62 void DisplayMultipointTouchInfo(const Tizen::Ui::Control &source);
64 // ITouchEventListener
65 virtual void OnTouchDoublePressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
66 virtual void OnTouchFocusIn(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
67 virtual void OnTouchFocusOut(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
68 virtual void OnTouchLongPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
69 virtual void OnTouchMoved(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
70 virtual void OnTouchPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
71 virtual void OnTouchReleased(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
76 // Sample code for TouchSample.cpp
78 #include <FGraphics.h>
80 #include "TouchSample.h"
82 using namespace Tizen::Base::Collection;
83 using namespace Tizen::Graphics;
84 using namespace Tizen::Ui;
85 using namespace Tizen::Ui::Controls;
88 TouchSample::Initialize(void)
90 Construct(FORM_STYLE_NORMAL);
95 TouchSample::OnInitializing(void)
99 // Creates an instance of Touch
101 touch.SetMultipointEnabled(*this, true);
102 AddTouchEventListener(*this);
108 TouchSample::DisplayMultipointTouchInfo(const Control &source)
111 IList *pList = touch.GetTouchInfoListN(source);
114 for(int i = 0; i < pList->GetCount(); i++ )
116 TouchInfo *pTouchInfo = static_cast<TouchInfo *>(pList->GetAt(i));
117 AppLog("OnTouchMoved : [%d]%d,%d - %d", pTouchInfo->id, pTouchInfo->position.x, pTouchInfo->position.y, pTouchInfo->status);
119 pList->RemoveAll(true);
124 // ITouchEventListeners implementation
126 TouchSample::OnTouchDoublePressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
128 AppLog("OnTouchDoublePressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
129 DisplayMultipointTouchInfo(source);
133 TouchSample::OnTouchFocusIn(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
135 AppLog("OnTouchFocusIn is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
136 DisplayMultipointTouchInfo(source);
140 TouchSample::OnTouchFocusOut(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
142 AppLog("OnTouchFocusOut is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
143 DisplayMultipointTouchInfo(source);
147 TouchSample::OnTouchLongPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
149 AppLog("OnTouchLongPressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
150 DisplayMultipointTouchInfo(source);
154 TouchSample::OnTouchMoved(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
156 AppLog("OnTouchMoved is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
157 DisplayMultipointTouchInfo(source);
161 TouchSample::OnTouchPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
163 AppLog("OnTouchPressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
164 DisplayMultipointTouchInfo(source);
168 TouchSample::OnTouchReleased(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
170 AppLog("OnTouchReleased is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
171 DisplayMultipointTouchInfo(source);
176 class _OSP_EXPORT_ Touch
177 : public Tizen::Base::Object
182 * This is the default constructor for this class.
184 * @brief <i> [Deprecated] </i>
185 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager class.
193 * This destructor overrides Tizen::Base::Object::~Object().
195 * @brief <i> [Deprecated] </i>
196 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager class.
200 virtual ~Touch(void);
205 * Enables or disables the multi-point touch of the Control.
207 * @brief <i> [Deprecated] </i>
208 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::Control::SetMultipointTouchEnabled() method.
211 * @return An error code
212 * @param[in] control The control
213 * @param[in] enable A Boolean flag indicating whether to enable to the multi-point touch
214 * @exception E_SUCCESS The method is successful.
215 * @exception E_SYSTEM A system error has occurred.
216 * @see IsMultipointEnabled()
219 result SetMultipointEnabled(const Tizen::Ui::Control& control, bool enable);
223 * Checks whether the multi-point touch is enabled.
225 * @brief <i> [Deprecated] </i>
226 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::Control::IsMultipointTouchEnabled() method.
229 * @return @c true if the multi-point touch is enabled, @n
231 * @see IsMultipointEnabled()
234 bool IsMultipointEnabled(const Tizen::Ui::Control& control) const;
239 * Gets the touch position. @n
240 * If there is only a single touch, that is returned. If there are multi-point touches, then the position of the last touch is returned.
242 * @brief <i> [Deprecated] </i>
243 * @deprecated This method is deprecated because the %Touch class is not supported any more.
244 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method.
247 * @return The coordinates of the touch
248 * @remarks If an error occurs, this method returns Point(-1, -1).
251 Tizen::Graphics::Point GetPosition(void) const;
255 * Gets the touch position by ID.
257 * @brief <i> [Deprecated] </i>
258 * @deprecated This method is deprecated because the %Touch class is not supported any more.
259 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method.
262 * @return The coordinates of the touch
263 * @param[in] id The ID of the touch
264 * @remarks If an error occurs, this method returns Point(-1, -1).
267 Tizen::Graphics::Point GetPosition(unsigned long id) const;
271 * Gets the touch position relative to the specified control.
273 * @brief <i> [Deprecated] </i>
274 * @deprecated This method is deprecated because the %Touch class is not supported any more.
275 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method.
278 * @return The coordinates of the touch
279 * @param[in] control The source control
280 * @remarks If an error occurs, this method returns Point(-1, -1).
283 Tizen::Graphics::Point GetPosition(const Tizen::Ui::Control& control) const;
287 * Gets the touch position relative to the specified control by ID.
289 * @brief <i> [Deprecated] </i>
290 * @deprecated This method is deprecated because the %Touch class is not supported any more.
291 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method.
294 * @return The coordinates of the touch
295 * @param[in] control The source control
296 * @param[in] id The ID of the touch
297 * @remarks If an error occurs, this method returns Point(-1, -1).
300 Tizen::Graphics::Point GetPosition(const Tizen::Ui::Control& control, unsigned long id) const;
304 * Gets the status of the touch by ID.
306 * @brief <i> [Deprecated] </i>
307 * @deprecated This method is deprecated because the %Touch class is not supported any more.
308 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetTouchStatus() method.
311 * @param[in] id The ID of the touch
312 * @return The touch status
315 TouchStatus GetTouchStatus(unsigned long id) const;
319 * Gets the list of the multi-point touches, each represented by TouchInfo.
321 * @brief <i> [Deprecated] </i>
322 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method.
325 * @return A list of the TouchInfo instances
326 * @see Tizen::Ui::TouchInfo
329 Tizen::Base::Collection::IList* GetTouchInfoListN(void) const;
333 * Gets the list of the multi-point touch positions relative to the specified control, each represented by TouchInfo.
335 * @brief <i> [Deprecated] </i>
336 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method.
339 * @return A list of the TouchInfo instances
340 * @param[in] control The source object for calculating the coordinates
341 * @see Tizen::Ui::TouchInfo
344 Tizen::Base::Collection::IList* GetTouchInfoListN(const Tizen::Ui::Control& control) const;
348 * Gets the count of the multi-point touches.
350 * @brief <i> [Deprecated] </i>
351 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, get the count of Tizen::Ui::TouchEventManager::GetTouchInfoListN() method.
354 * @return The number of the multi-point touches
357 int GetPointCount(void) const;
361 * Gets the point ID at the given index.
363 * @brief <i> [Deprecated] </i>
364 * @deprecated This method is deprecated because the %Touch class is not supported any more.
365 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetPointId() method.
368 * @return The touch point ID
369 * @param[in] index The index of the touch
372 unsigned long GetPointId(int index) const;
376 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
381 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
383 Touch& operator =(const Touch&);
388 #endif // _FUI_TOUCH_H_