2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrl_ScrollEvent.cpp
20 * @brief This is the implementation for the _ScrollEvent class.
23 #include <FUiCtrlIScrollEventListener.h>
24 #include <FUiCtrlIScrollEventListenerF.h>
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
27 #include "FUiCtrl_ScrollEvent.h"
28 #include "FUiCtrl_ScrollEventArg.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Runtime;
33 namespace Tizen { namespace Ui { namespace Controls
36 ////////////////////////////////////////////////////////////////////////////////
37 /// _ScrollEvent class Lifecycle
39 _ScrollEvent::_ScrollEvent(void)
45 _ScrollEvent::~_ScrollEvent(void)
51 _ScrollEvent::Construct(const Tizen::Ui::Control& source)
53 result r = _Event::Initialize();
58 __pSource = const_cast <Control*>(&source);
64 ////////////////////////////////////////////////////////////////////////////////
65 /// __WindowEvent class Accessor
68 _ScrollEvent::GetSource(void) const
73 ////////////////////////////////////////////////////////////////////////////////
74 /// _ScrollEvent class Operation
77 _ScrollEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
79 IScrollEventListener* pScrollEventListener = dynamic_cast <IScrollEventListener*>(&listener);
80 IScrollEventListenerF* pScrollEventListenerF = null;
81 if (pScrollEventListener == null)
83 pScrollEventListenerF = dynamic_cast <IScrollEventListenerF*>(&listener);
84 SysTryReturnVoidResult(NID_UI_CTRL, (pScrollEventListenerF != null), E_INVALID_ARG, "[%s] The invalid listener was given.", GetErrorMessage(E_INVALID_ARG));
87 const _ScrollEventArg* pArg = dynamic_cast <const _ScrollEventArg*>(&arg);
88 SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG, "[%s] The invalid Event Argument was given.", GetErrorMessage(E_INVALID_ARG));
90 switch (pArg->GetEventType())
92 case SCROLL_EVENT_ON_SCROLL_STOPPED:
93 if (pScrollEventListener != null)
95 pScrollEventListener->OnScrollStopped(*pArg->GetSource());
99 pScrollEventListenerF->OnScrollStopped(*pArg->GetSource());
102 case SCROLL_EVENT_ON_SCROLL_POSITION_CHANGED:
103 if (pScrollEventListener != null)
105 pScrollEventListener->OnScrollPositionChanged(*pArg->GetSource(), pArg->GetScrollPosition());
109 pScrollEventListenerF->OnScrollPositionChanged(*pArg->GetSource(), pArg->GetScrollPosition());
112 case SCROLL_EVENT_ON_SCROLL_END_REACHED:
113 if (pScrollEventListener != null)
115 pScrollEventListener->OnScrollEndReached(*pArg->GetSource(), pArg->GetScrollType());
119 pScrollEventListenerF->OnScrollEndReached(*pArg->GetSource(), pArg->GetScrollType());
123 SysTryReturnVoidResult(NID_UI_CTRL, false, E_INVALID_ARG, "[%s] The invalid Event Argument was given.", GetErrorMessage(E_INVALID_ARG));
128 }}} // Tizen::Ui::Controls