modify license, permission and remove ^M char
[platform/framework/native/uifw.git] / src / ui / FUi_DragDropEvent.cpp
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  * @file                FUi_DragDropEvent.cpp
19  * @brief               This is the implementation file for _DragDropEvent class
20  * @since               2.0
21  *
22  * This file contains the implementation of %_DragDropEvent class.
23  *
24  */
25
26 #include <FBaseErrors.h>
27 #include <FUiIDragDropEventListener.h>
28 #include <FUiIDragDropEventListenerF.h>
29 #include <FUiControl.h>
30 #include <FBaseSysLog.h>
31 #include "FUi_CoordinateSystemUtils.h"
32 #include "FUi_DragDropEvent.h"
33 #include "FUi_DragDropEventArg.h"
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Ui;
39
40 namespace Tizen { namespace Ui
41 {
42 _DragDropEvent::_DragDropEvent()
43         : __pSource(null)
44 {
45         // NOTHING
46 }
47
48 _DragDropEvent::~_DragDropEvent()
49 {
50         // NOTHING
51 }
52
53
54 result
55 _DragDropEvent::Construct(const Control& source)
56 {
57         result r = E_SUCCESS;
58         r = _Event::Initialize();
59
60         // set event source
61         if (r == E_SUCCESS)
62         {
63                 __pSource = const_cast <Control*>(&source);
64         }
65
66         return (r);
67
68 }
69
70
71
72 bool
73 _DragDropEvent::Filter(const Tizen::Base::Runtime::IEventArg& eventArg)
74 {
75         return false;
76 }
77
78 result
79 _DragDropEvent::AddListener(const Tizen::Base::Runtime::IEventListener& listener,
80                                                         const Tizen::Base::Runtime::_EventDispatcher* pEventDispatcher)
81 {
82         result r = E_SUCCESS;
83         return r;
84 }
85
86 result
87 _DragDropEvent::Wait(void)
88 {
89         result r = E_SUCCESS;
90         return r;
91 }
92
93 result
94 _DragDropEvent::FireImpl(IEventListener* pListener, const IEventArg& arg)
95 {
96         SysTryReturnResult(NID_UI, pListener, E_INVALID_ARG, "The Invalid argument is given.");
97
98         IDragDropEventListener* pDragDropListener = dynamic_cast <IDragDropEventListener*>(pListener);
99         IDragDropEventListenerF* pDragDropListenerF = dynamic_cast <IDragDropEventListenerF*>(pListener);
100
101         SysTryReturnResult(NID_UI, pDragDropListener || pDragDropListenerF, E_INVALID_ARG, "The Invalid argument is given.");
102
103         const _DragDropEventArg* pArg = dynamic_cast <const _DragDropEventArg*>(&arg);
104         SysTryReturnResult(NID_UI, pArg, E_INVALID_ARG, "The invalid Event Argument is given.");
105
106         switch (pArg->GetDragDropStatus())
107         {
108         case DRAG_DROP_INDICATED:
109                 break;
110
111         case DRAG_DROP_PRESSED:
112                 break;
113
114         case DRAG_DROP_LONG_PRESSED:
115                 break;
116
117         case DRAG_DROP_RELEASED:
118                 break;
119
120         case DRAG_DROP_MOVED:
121                 break;
122
123         case DRAG_DROP_DOUBLE_PRESSED:
124                 break;
125
126         case DRAG_DROP_FOCUS_IN:
127                 break;
128
129         case DRAG_DROP_FOCUS_OUT:
130                 break;
131
132         case DRAG_DROP_FLICKED:
133                 break;
134
135         case DRAG_DROP_FLICK_HELD:
136                 break;
137
138         case DRAG_DROP_DRAGGED:
139                 if (pDragDropListener)
140                 {
141                         pDragDropListener->OnTouchDragged(*pArg->GetSource(), _CoordinateSystemUtils::ConvertToInteger(pArg->GetStartPosition()), _CoordinateSystemUtils::ConvertToInteger(pArg->GetCurrentPosition()));
142                 }
143                 if (pDragDropListenerF)
144                 {
145                         pDragDropListenerF->OnTouchDraggedF(*pArg->GetSource(), pArg->GetStartPosition(), pArg->GetCurrentPosition());
146                 }
147                 break;
148
149         case DRAG_DROP_DROPPED:
150                 if (pDragDropListener)
151                 {
152                         pDragDropListener->OnTouchDropped(*pArg->GetSource(), _CoordinateSystemUtils::ConvertToInteger(pArg->GetStartPosition()), _CoordinateSystemUtils::ConvertToInteger(pArg->GetCurrentPosition()));
153                 }
154                 if (pDragDropListenerF)
155                 {
156                         pDragDropListenerF->OnTouchDroppedF(*pArg->GetSource(), pArg->GetStartPosition(), pArg->GetCurrentPosition());
157                 }
158                 break;
159
160         default:
161                 return E_SYSTEM;
162         }
163         return E_SUCCESS;
164 }
165
166 const Tizen::Ui::Control*
167 _DragDropEvent::GetSource(void) const
168 {
169         return (__pSource);
170 }
171
172 };
173 };    // Tizen::Ui