Merge "Fix Ime Rotation" into tizen_2.1
[platform/framework/native/uifw.git] / inc / FUiTouch.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
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 /**
19  * @file        FUiTouch.h
20  * @brief       This is the header file for the %Touch class.
21  *
22  * This header file contains the declarations of the %Touch class.get
23  *
24  */
25
26 #ifndef _FUI_TOUCH_H_
27 #define _FUI_TOUCH_H_
28
29 #include <FBaseColIList.h>
30 #include <FUiTouchInfo.h>
31 #include <FUiTouchEventInfo.h>
32
33 namespace Tizen { namespace Ui
34 {
35
36 class Control;
37 /**
38  * @if OSPDEPREC
39  * @class       Touch
40  * @brief       <i> [Deprecated] </i> This class supports multi-point touch for %Touch devices.
41  *
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.
43  * @since       2.0
44  *
45  * @final        This class is not intended for extension.
46  *
47  * The %Touch class supports multi-point touch, and provides information about touch events.
48  *
49  * The following example demonstrates how to use the %Touch class.
50  * @code
51 // Sample code for TouchSample.h
52 #include <FUi.h>
53
54 class TouchSample
55         : public Tizen::Ui::Controls::Form
56         , public Tizen::Ui::ITouchEventListener
57 {
58 public:
59         bool Initialize(void);
60         virtual result OnInitializing(void);
61         void DisplayMultipointTouchInfo(const Tizen::Ui::Control &source);
62
63         // ITouchEventListener
64         virtual void OnTouchDoublePressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point &currentPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
65         virtual void OnTouchFocusIn(const Tizen::Ui::Control &source, const Tizen::Graphics::Point &currentPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
66         virtual void OnTouchFocusOut(const Tizen::Ui::Control &source, const Tizen::Graphics::Point &currentPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
67         virtual void OnTouchLongPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point &currentPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
68         virtual void OnTouchMoved(const Tizen::Ui::Control &source, const Tizen::Graphics::Point &currentPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
69         virtual void OnTouchPressed(const Tizen::Ui::Control &source, const Tizen::Graphics::Point &currentPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
70         virtual void OnTouchReleased(const Tizen::Ui::Control &source, const Tizen::Graphics::Point &currentPosition, const Tizen::Ui::TouchEventInfo &touchInfo);
71 };
72  *      @endcode
73  *
74  *      @code
75 // Sample code for TouchSample.cpp
76 #include <FBase.h>
77 #include <FGraphics.h>
78
79 #include "TouchSample.h"
80
81 using namespace Tizen::Base::Collection;
82 using namespace Tizen::Graphics;
83 using namespace Tizen::Ui;
84 using namespace Tizen::Ui::Controls;
85
86 bool
87 TouchSample::Initialize(void)
88 {
89         Construct(FORM_STYLE_NORMAL);
90         return true;
91 }
92
93 result
94 TouchSample::OnInitializing(void)
95 {
96         result r = E_SUCCESS;
97
98         // Creates an instance of Touch
99         Touch touch;
100         touch.SetMultipointEnabled(*this, true);
101         AddTouchEventListener(*this);
102
103         return r;
104 }
105
106 void
107 TouchSample::DisplayMultipointTouchInfo(const Control &source)
108 {
109         Touch touch;
110         IList *pList = touch.GetTouchInfoListN(source);
111         if (pList)
112         {
113                 for(int i = 0; i < pList->GetCount(); i++ )
114                 {
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);
117                 }
118                 pList->RemoveAll(true);
119                 delete pList;
120         }
121 }
122
123 // ITouchEventListeners implementation
124 void
125 TouchSample::OnTouchDoublePressed(const Control &source, const Point &currentPosition, const TouchEventInfo &touchInfo)
126 {
127         AppLog("OnTouchDoublePressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
128         DisplayMultipointTouchInfo(source);
129 }
130
131 void
132 TouchSample::OnTouchFocusIn(const Control &source, const Point &currentPosition, const TouchEventInfo &touchInfo)
133 {
134         AppLog("OnTouchFocusIn is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
135         DisplayMultipointTouchInfo(source);
136 }
137
138 void
139 TouchSample::OnTouchFocusOut(const Control &source, const Point &currentPosition, const TouchEventInfo &touchInfo)
140 {
141         AppLog("OnTouchFocusOut is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
142         DisplayMultipointTouchInfo(source);
143 }
144
145 void
146 TouchSample::OnTouchLongPressed(const Control &source, const Point &currentPosition, const TouchEventInfo &touchInfo)
147 {
148         AppLog("OnTouchLongPressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
149         DisplayMultipointTouchInfo(source);
150 }
151
152 void
153 TouchSample::OnTouchMoved(const Control &source, const Point &currentPosition, const TouchEventInfo &touchInfo)
154 {
155         AppLog("OnTouchMoved is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
156         DisplayMultipointTouchInfo(source);
157 }
158
159 void
160 TouchSample::OnTouchPressed(const Control &source, const Point &currentPosition, const TouchEventInfo &touchInfo)
161 {
162         AppLog("OnTouchPressed is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
163         DisplayMultipointTouchInfo(source);
164 }
165
166 void
167 TouchSample::OnTouchReleased(const Control &source, const Point &currentPosition, const TouchEventInfo &touchInfo)
168 {
169         AppLog("OnTouchReleased is called. [%d]%d,%d", touchInfo.GetPointId(), currentPosition.x, currentPosition.y);
170         DisplayMultipointTouchInfo(source);
171 }
172  * @endcode
173  * @endif
174  */
175 class _OSP_EXPORT_ Touch
176         : public Tizen::Base::Object
177 {
178 public:
179         /**
180          * @if OSPDEPREC
181          * This is the default constructor for this class.
182          *
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.
185          * @since               2.0
186          * @endif
187          */
188         Touch(void);
189
190         /**
191          * @if OSPDEPREC
192          * This destructor overrides Tizen::Base::Object::~Object().
193          *
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.
196          * @since               2.0
197          * @endif
198          */
199         virtual ~Touch(void);
200
201 public:
202         /**
203          * @if OSPDEPREC
204          * Enables or disables the multi-point touch of the Control.
205          *
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.
208          * @since                       2.0
209          *
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()
216          * @endif
217          */
218         result SetMultipointEnabled(const Tizen::Ui::Control& control, bool enable);
219
220         /**
221          * @if OSPDEPREC
222          * Checks whether the multi-point touch is enabled.
223          *
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.
226          * @since                       2.0
227          *
228          * @return              @c true if the multi-point touch is enabled, @n
229          *                              else @c false
230          * @see                 IsMultipointEnabled()
231          * @endif
232          */
233         bool IsMultipointEnabled(const Tizen::Ui::Control& control) const;
234
235
236         /**
237          * @if OSPDEPREC
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.
240          *
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.
244          * @since                       2.0
245          *
246          * @return              The coordinates of the touch
247          * @remarks             If an error occurs, this method returns Point(-1, -1).
248          * @endif
249          */
250         Tizen::Graphics::Point GetPosition(void) const;
251
252         /**
253          * @if OSPDEPREC
254          * Gets the touch position by ID.
255          *
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.
259          * @since                       2.0
260          *
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).
264          * @endif
265          */
266         Tizen::Graphics::Point GetPosition(unsigned long id) const;
267
268         /**
269          * @if OSPDEPREC
270          * Gets the touch position relative to the specified control.
271          *
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.
275          * @since                       2.0
276          *
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).
280          * @endif
281          */
282         Tizen::Graphics::Point GetPosition(const Tizen::Ui::Control& control) const;
283
284         /**
285          * @if OSPDEPREC
286          * Gets the touch position relative to the specified control by ID.
287          *
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.
291          * @since                       2.0
292          *
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).
297          * @endif
298          */
299         Tizen::Graphics::Point GetPosition(const Tizen::Ui::Control& control, unsigned long id) const;
300
301         /**
302         * @if OSPDEPREC
303         * Gets the status of the touch by ID.
304         *
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.
308         * @since                        2.0
309         *
310         * @param[in]            id              The ID of the touch
311         * @return               The touch status
312         * @endif
313         */
314         TouchStatus GetTouchStatus(unsigned long id) const;
315
316         /**
317          * @if OSPDEPREC
318          * Gets the list of the multi-point touches, each represented by TouchInfo.
319          *
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.
322          * @since                       2.0
323          *
324          * @return              A list of the TouchInfo instances
325          * @see                 Tizen::Ui::TouchInfo
326          * @endif
327          */
328         Tizen::Base::Collection::IList* GetTouchInfoListN(void) const;
329
330         /**
331          * @if OSPDEPREC
332          * Gets the list of the multi-point touch positions relative to the specified control, each represented by TouchInfo.
333          *
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.
336          * @since                       2.0
337          *
338          * @return              A list of the TouchInfo instances
339          * @param[in]           control         The source object for calculating the coordinates
340          * @see                 Tizen::Ui::TouchInfo
341          * @endif
342          */
343         Tizen::Base::Collection::IList* GetTouchInfoListN(const Tizen::Ui::Control& control) const;
344
345         /**
346         * @if OSPDEPREC
347         * Gets the count of the multi-point touches.
348         *
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.
351         * @since                        2.0
352         *
353         * @return               The number of the multi-point touches
354          * @endif
355         */
356         int GetPointCount(void) const;
357
358         /**
359          * @if OSPDEPREC
360          * Gets the point ID at the given index.
361          *
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.
365          * @since                       2.0
366          *
367          * @return              The touch point ID
368          * @param[in]           index   The index of the touch
369          * @endif
370          */
371         unsigned long GetPointId(int index) const;
372
373 private:
374         //
375         //  The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
376         //
377         Touch(const Touch&);
378
379         //
380         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
381         //
382         Touch& operator =(const Touch&);
383 };  // Touch
384
385 } } // Tizen::Ui
386
387 #endif // _FUI_TOUCH_H_