2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
18 * @file FUi_DragDropEvent.cpp
19 * @brief This is the implementation file for _DragDropEvent class
22 * This file contains the implementation of %_DragDropEvent class.
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"
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Ui;
40 namespace Tizen { namespace Ui
42 _DragDropEvent::_DragDropEvent()
48 _DragDropEvent::~_DragDropEvent()
55 _DragDropEvent::Construct(const Control& source)
58 r = _Event::Initialize();
63 __pSource = const_cast <Control*>(&source);
73 _DragDropEvent::Filter(const Tizen::Base::Runtime::IEventArg& eventArg)
79 _DragDropEvent::AddListener(const Tizen::Base::Runtime::IEventListener& listener,
80 const Tizen::Base::Runtime::_EventDispatcher* pEventDispatcher)
87 _DragDropEvent::Wait(void)
94 _DragDropEvent::FireImpl(IEventListener* pListener, const IEventArg& arg)
96 SysTryReturnResult(NID_UI, pListener, E_INVALID_ARG, "The Invalid argument is given.");
98 IDragDropEventListener* pDragDropListener = dynamic_cast <IDragDropEventListener*>(pListener);
99 IDragDropEventListenerF* pDragDropListenerF = dynamic_cast <IDragDropEventListenerF*>(pListener);
101 SysTryReturnResult(NID_UI, pDragDropListener || pDragDropListenerF, E_INVALID_ARG, "The Invalid argument is given.");
103 const _DragDropEventArg* pArg = dynamic_cast <const _DragDropEventArg*>(&arg);
104 SysTryReturnResult(NID_UI, pArg, E_INVALID_ARG, "The invalid Event Argument is given.");
106 switch (pArg->GetDragDropStatus())
108 case DRAG_DROP_INDICATED:
111 case DRAG_DROP_PRESSED:
114 case DRAG_DROP_LONG_PRESSED:
117 case DRAG_DROP_RELEASED:
120 case DRAG_DROP_MOVED:
123 case DRAG_DROP_DOUBLE_PRESSED:
126 case DRAG_DROP_FOCUS_IN:
129 case DRAG_DROP_FOCUS_OUT:
132 case DRAG_DROP_FLICKED:
135 case DRAG_DROP_FLICK_HELD:
138 case DRAG_DROP_DRAGGED:
139 if (pDragDropListener)
141 pDragDropListener->OnTouchDragged(*pArg->GetSource(), _CoordinateSystemUtils::ConvertToInteger(pArg->GetStartPosition()), _CoordinateSystemUtils::ConvertToInteger(pArg->GetCurrentPosition()));
143 if (pDragDropListenerF)
145 pDragDropListenerF->OnTouchDraggedF(*pArg->GetSource(), pArg->GetStartPosition(), pArg->GetCurrentPosition());
149 case DRAG_DROP_DROPPED:
150 if (pDragDropListener)
152 pDragDropListener->OnTouchDropped(*pArg->GetSource(), _CoordinateSystemUtils::ConvertToInteger(pArg->GetStartPosition()), _CoordinateSystemUtils::ConvertToInteger(pArg->GetCurrentPosition()));
154 if (pDragDropListenerF)
156 pDragDropListenerF->OnTouchDroppedF(*pArg->GetSource(), pArg->GetStartPosition(), pArg->GetCurrentPosition());
166 const Tizen::Ui::Control*
167 _DragDropEvent::GetSource(void) const