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.
20 * @brief This is the header file for the %Touch class.
22 * This header file contains the declarations of the %Touch class.get
29 #include <FBaseColIList.h>
30 #include <FUiTouchInfo.h>
31 #include <FUiTouchEventInfo.h>
33 namespace Tizen { namespace Ui
40 * @brief <i> [Deprecated] </i> This class supports multi-point touch for %Touch devices.
42 * @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.
45 * @final This class is not intended for extension.
47 * The %Touch class supports multi-point touch, and provides information about touch events.
49 * The following example demonstrates how to use the %Touch class.
51 // Sample code for TouchSample.h
55 : public Tizen::Ui::Controls::Form
56 , public Tizen::Ui::ITouchEventListener
59 bool Initialize(void);
60 virtual result OnInitializing(void);
61 void DisplayMultipointTouchInfo(const Tizen::Ui::Control &source);
63 // ITouchEventListener
64 virtual void OnTouchDoublePressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
65 virtual void OnTouchFocusIn(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
66 virtual void OnTouchFocusOut(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
67 virtual void OnTouchLongPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
68 virtual void OnTouchMoved(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
69 virtual void OnTouchPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
70 virtual void OnTouchReleased(const Tizen::Ui::Control &source, const Tizen::Graphics::Point ¤tPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
75 // Sample code for TouchSample.cpp
77 #include <FGraphics.h>
79 #include "TouchSample.h"
81 using namespace Tizen::Base::Collection;
82 using namespace Tizen::Graphics;
83 using namespace Tizen::Ui;
84 using namespace Tizen::Ui::Controls;
87 TouchSample::Initialize(void)
89 Construct(FORM_STYLE_NORMAL);
94 TouchSample::OnInitializing(void)
98 // Creates an instance of Touch
100 touch.SetMultipointEnabled(*this, true);
101 AddTouchEventListener(*this);
107 TouchSample::DisplayMultipointTouchInfo(const Control &source)
110 IList *pList = touch.GetTouchInfoListN(source);
113 for(int i = 0; i < pList->GetCount(); i++ )
115 TouchInfo *pTouchInfo = static_cast<TouchInfo *>(pList->GetAt(i));
116 AppLog("OnTouchMoved : [%d]%d,%d - %d", pTouchInfo->id, pTouchInfo->position.x, pTouchInfo->position.y, pTouchInfo->status);
118 pList->RemoveAll(true);
123 // ITouchEventListeners implementation
125 TouchSample::OnTouchDoublePressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
127 AppLog("OnTouchDoublePressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
128 DisplayMultipointTouchInfo(source);
132 TouchSample::OnTouchFocusIn(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
134 AppLog("OnTouchFocusIn is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
135 DisplayMultipointTouchInfo(source);
139 TouchSample::OnTouchFocusOut(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
141 AppLog("OnTouchFocusOut is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
142 DisplayMultipointTouchInfo(source);
146 TouchSample::OnTouchLongPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
148 AppLog("OnTouchLongPressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
149 DisplayMultipointTouchInfo(source);
153 TouchSample::OnTouchMoved(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
155 AppLog("OnTouchMoved is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
156 DisplayMultipointTouchInfo(source);
160 TouchSample::OnTouchPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
162 AppLog("OnTouchPressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
163 DisplayMultipointTouchInfo(source);
167 TouchSample::OnTouchReleased(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
169 AppLog("OnTouchReleased is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
170 DisplayMultipointTouchInfo(source);
175 class _OSP_EXPORT_ Touch
176 : public Tizen::Base::Object
181 * This is the default constructor for this class.
183 * @brief <i> [Deprecated] </i>
184 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager class.
192 * This destructor overrides Tizen::Base::Object::~Object().
194 * @brief <i> [Deprecated] </i>
195 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager class.
199 virtual ~Touch(void);
204 * Enables or disables the multi-point touch of the Control.
206 * @brief <i> [Deprecated] </i>
207 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::Control::SetMultipointTouchEnabled() method.
210 * @return An error code
211 * @param[in] control The control
212 * @param[in] enable A Boolean flag indicating whether to enable to the multi-point touch
213 * @exception E_SUCCESS The method is successful.
214 * @exception E_SYSTEM A system error has occurred.
215 * @see IsMultipointEnabled()
218 result SetMultipointEnabled(const Tizen::Ui::Control& control, bool enable);
222 * Checks whether the multi-point touch is enabled.
224 * @brief <i> [Deprecated] </i>
225 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::Control::IsMultipointTouchEnabled() method.
228 * @return @c true if the multi-point touch is enabled, @n
230 * @see IsMultipointEnabled()
233 bool IsMultipointEnabled(const Tizen::Ui::Control& control) const;
238 * Gets the touch position. @n
239 * 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.
241 * @brief <i> [Deprecated] </i>
242 * @deprecated This method is deprecated because the %Touch class is not supported any more.
243 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method.
246 * @return The coordinates of the touch
247 * @remarks If an error occurs, this method returns Point(-1, -1).
250 Tizen::Graphics::Point GetPosition(void) const;
254 * Gets the touch position by ID.
256 * @brief <i> [Deprecated] </i>
257 * @deprecated This method is deprecated because the %Touch class is not supported any more.
258 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method.
261 * @return The coordinates of the touch
262 * @param[in] id The ID of the touch
263 * @remarks If an error occurs, this method returns Point(-1, -1).
266 Tizen::Graphics::Point GetPosition(unsigned long id) const;
270 * Gets the touch position relative to the specified control.
272 * @brief <i> [Deprecated] </i>
273 * @deprecated This method is deprecated because the %Touch class is not supported any more.
274 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method.
277 * @return The coordinates of the touch
278 * @param[in] control The source control
279 * @remarks If an error occurs, this method returns Point(-1, -1).
282 Tizen::Graphics::Point GetPosition(const Tizen::Ui::Control& control) const;
286 * Gets the touch position relative to the specified control by ID.
288 * @brief <i> [Deprecated] </i>
289 * @deprecated This method is deprecated because the %Touch class is not supported any more.
290 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetCurrentPosition() method.
293 * @return The coordinates of the touch
294 * @param[in] control The source control
295 * @param[in] id The ID of the touch
296 * @remarks If an error occurs, this method returns Point(-1, -1).
299 Tizen::Graphics::Point GetPosition(const Tizen::Ui::Control& control, unsigned long id) const;
303 * Gets the status of the touch by ID.
305 * @brief <i> [Deprecated] </i>
306 * @deprecated This method is deprecated because the %Touch class is not supported any more.
307 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetTouchStatus() method.
310 * @param[in] id The ID of the touch
311 * @return The touch status
314 TouchStatus GetTouchStatus(unsigned long id) const;
318 * Gets the list of the multi-point touches, each represented by TouchInfo.
320 * @brief <i> [Deprecated] </i>
321 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method.
324 * @return A list of the TouchInfo instances
325 * @see Tizen::Ui::TouchInfo
328 Tizen::Base::Collection::IList* GetTouchInfoListN(void) const;
332 * Gets the list of the multi-point touch positions relative to the specified control, each represented by TouchInfo.
334 * @brief <i> [Deprecated] </i>
335 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, use the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method.
338 * @return A list of the TouchInfo instances
339 * @param[in] control The source object for calculating the coordinates
340 * @see Tizen::Ui::TouchInfo
343 Tizen::Base::Collection::IList* GetTouchInfoListN(const Tizen::Ui::Control& control) const;
347 * Gets the count of the multi-point touches.
349 * @brief <i> [Deprecated] </i>
350 * @deprecated This method is deprecated because the %Touch class is not supported any more. Instead, get the count of Tizen::Ui::TouchEventManager::GetTouchInfoListN() method.
353 * @return The number of the multi-point touches
356 int GetPointCount(void) const;
360 * Gets the point ID at the given index.
362 * @brief <i> [Deprecated] </i>
363 * @deprecated This method is deprecated because the %Touch class is not supported any more.
364 * Instead, get the Tizen::Ui::TouchEventManager::GetTouchInfoListN() method and use the Tizen::Ui::TouchEventInfo::GetPointId() method.
367 * @return The touch point ID
368 * @param[in] index The index of the touch
371 unsigned long GetPointId(int index) const;
375 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
380 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
382 Touch& operator =(const Touch&);
387 #endif // _FUI_TOUCH_H_