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