Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUi_UiTouchEvent.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  * @file        FUi_UiTouchEvent.h
19  * @brief       This is the header file for the _UiTouchEvent class.
20  *
21  * This header file contains the declarations of the %_UiTouchEvent class.
22  */
23
24 #ifndef _FUI_INTERNAL_UI_TOUCH_EVENT_H_
25 #define _FUI_INTERNAL_UI_TOUCH_EVENT_H_
26
27 #include <tr1/memory>
28 #include <FUiITouchEventListener.h>
29 #include "FUi_UiEvent.h"
30 #include "FUi_ITouchGestureEventListener.h"
31 #include "FUi_ITouchEventPreviewer.h"
32
33 namespace Tizen {namespace Ui
34 {
35
36 enum _TouchStatus
37 {
38         _TOUCH_PRESSED = TOUCH_PRESSED,                   /**< Touch pressed event type */
39         _TOUCH_LONG_PRESSED = TOUCH_LONG_PRESSED,         /**< Touch long pressed event type    */
40         _TOUCH_RELEASED = TOUCH_RELEASED,                 /**< Touch released event type        */
41         _TOUCH_MOVED = TOUCH_MOVED,                       /**< Touch moved event type   */
42         _TOUCH_DOUBLE_PRESSED = TOUCH_DOUBLE_PRESSED,     /**< Touch double pressed event type  */
43         _TOUCH_FOCUS_IN = TOUCH_FOCUS_IN,                 /**< Touch focus-in event type        */
44         _TOUCH_FOCUS_OUT = TOUCH_FOCUS_OUT,               /**< Touch focus-out event type       */
45         _TOUCH_CANCELED = TOUCH_CANCELED,               /**< Touch canceled event type  */
46 };
47
48 class _OSP_EXPORT_ _TouchInfo
49 {
50 public:
51         _TouchInfo(void);
52         _TouchInfo(unsigned long pointId, _TouchStatus status, const Tizen::Graphics::Point& current, const bool isFlick, long long timeStamp);
53         _TouchInfo(const _TouchInfo& rhs);
54         _TouchInfo& operator =(const _TouchInfo& rhs);
55         ~_TouchInfo(void);
56
57 public:
58         /**
59          * This method returns the touch status.
60          *
61          * @since               2.0
62          * @return  The touch status
63          */
64         _TouchStatus GetTouchStatus(void) const;
65
66         /**
67          * This method returns the current position of the touch event.
68          *
69          * @since               2.0
70          * @return      The current position of the touch event
71          */
72         Tizen::Graphics::Point GetCurrentPosition(void) const;
73
74         /**
75          * This method returns the touch pointId.
76          *
77          * @since 2.0
78          * @return  The touch pointId
79          */
80         unsigned long GetPointId(void) const;
81
82         bool IsFlicked(void) const;
83         long long GetTimeStamp(void) const;
84         void SetTouchInfo(unsigned long pointId, _TouchStatus status, Tizen::Graphics::Point& current, bool isFlick, long long timeStamp);
85
86 private:
87         unsigned long __pointId;
88         _TouchStatus __touchStatus;
89         Tizen::Graphics::Point __currentPosition;
90         bool __isFlicked;
91         long long __timeStamp;
92 }; // _TouchInfo
93
94 class _ITouchEventListener;
95 class _Control;
96
97 /**
98 * This is internal. If used in an application, the application can get rejected during the certification process.
99 * @class        _UiTouchEvent
100 * @brief        This class impliments _UiTouchEvent and
101 * fire the Window Event object of a Ui Control.
102 */
103 class _OSP_EXPORT_ _UiTouchEvent
104         : public _UiEvent
105 {
106 // Lifecycle
107 public:
108         /**
109         * This is the default class constructor.
110         *
111         */
112         _UiTouchEvent(const _UiObjectHandle& destination, const _TouchInfo& touchInfo, _UiEventRouteType routeType = _UI_EVENT_ROUTE_TUNNEL_BUBBLE, const _UiObjectHandle& source = _UiObjectHandle());
113         _UiTouchEvent(const _UiTouchEvent& rhs);
114
115         /**
116          * This is the default class destructor.
117          *
118          */
119         virtual ~_UiTouchEvent(void);
120
121 public:
122         _UiTouchEvent& operator =(const _UiTouchEvent& rhs);
123
124 public:
125         const _TouchInfo* GetTouchInfo(void) const;
126
127 private:
128         virtual _UiTouchEvent* CloneN(void) const;
129         virtual _UiEventType GetEventType(void) const;
130         virtual result OnPreviewEventProcessing(const _Control& control, bool& isFiltered);
131         virtual result OnEventProcessing(const _Control& control, bool& isFiltered);
132         virtual result OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered);
133         virtual result OnEventHandled(const _Control& control);
134
135 private:
136         result ProcessGesture(const _Control& control, bool& isFiltered);
137         result FireListener(const _ITouchEventListener* pListener, const _Control* pControl, bool isTouchEvent, bool& isFiltered);
138         result FirePreviewListener(const _ITouchEventPreviewer* pListener, const _Control* pControl, bool& isFiltered);
139         Tizen::Graphics::Point GetRelativePoint(const _Control& control, const Tizen::Graphics::Point& point) const;
140         result ResetTouchInfo(const _Control* pControl, const _TouchInfo& touchInfo);
141         bool ExistGlobalGesture(void);
142
143 private:
144         _TouchInfo __touchInfo;
145         std::tr1::shared_ptr<Tizen::Base::Collection::IListT<_Control*> > __pForcedGestureList;
146 }; // _UiTouchEvent
147
148 }} // Tizen::Ui
149
150 #endif //_FUI_INTERNAL_UI_TOUCH_EVENT_H_