Revert " modify license, permission and remove ^M char"
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_ScrollEvent.cpp
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 /**
19 * @file         FUiCtrl_ScrollEvent.cpp
20 * @brief        This is the implementation for the _ScrollEvent class.
21 */
22
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"
29
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Runtime;
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36 ////////////////////////////////////////////////////////////////////////////////
37 /// _ScrollEvent class Lifecycle
38
39 _ScrollEvent::_ScrollEvent(void)
40         : __pSource(null)
41 {
42         // nothing
43 }
44
45 _ScrollEvent::~_ScrollEvent(void)
46 {
47         // nothing
48 }
49
50 result
51 _ScrollEvent::Construct(const Tizen::Ui::Control& source)
52 {
53         result r = _Event::Initialize();
54
55         // set event source
56         if (r == E_SUCCESS)
57         {
58                 __pSource = const_cast <Control*>(&source);
59         }
60
61         return r;
62 }
63
64 ////////////////////////////////////////////////////////////////////////////////
65 /// __WindowEvent class Accessor
66
67 Tizen::Ui::Control*
68 _ScrollEvent::GetSource(void) const
69 {
70         return __pSource;
71 }
72
73 ////////////////////////////////////////////////////////////////////////////////
74 /// _ScrollEvent class Operation
75
76 void
77 _ScrollEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
78 {
79         IScrollEventListener* pScrollEventListener = dynamic_cast <IScrollEventListener*>(&listener);
80         IScrollEventListenerF* pScrollEventListenerF = null;
81         if (pScrollEventListener == null)
82         {
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));
85         }
86
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));
89
90         switch (pArg->GetEventType())
91         {
92         case SCROLL_EVENT_ON_SCROLL_STOPPED:
93                 if (pScrollEventListener != null)
94                 {
95                         pScrollEventListener->OnScrollStopped(*pArg->GetSource());
96                 }
97                 else
98                 {
99                         pScrollEventListenerF->OnScrollStopped(*pArg->GetSource());
100                 }
101                 break;
102         case SCROLL_EVENT_ON_SCROLL_POSITION_CHANGED:
103                 if (pScrollEventListener != null)
104                 {
105                         pScrollEventListener->OnScrollPositionChanged(*pArg->GetSource(), pArg->GetScrollPosition());
106                 }
107                 else
108                 {
109                         pScrollEventListenerF->OnScrollPositionChanged(*pArg->GetSource(), pArg->GetScrollPosition());
110                 }
111                 break;
112         case SCROLL_EVENT_ON_SCROLL_END_REACHED:
113                 if (pScrollEventListener != null)
114                 {
115                         pScrollEventListener->OnScrollEndReached(*pArg->GetSource(), pArg->GetScrollType());
116                 }
117                 else
118                 {
119                         pScrollEventListenerF->OnScrollEndReached(*pArg->GetSource(), pArg->GetScrollType());
120                 }
121                 break;
122         default:
123                 SysTryReturnVoidResult(NID_UI_CTRL, false, E_INVALID_ARG, "[%s] The invalid Event Argument was given.", GetErrorMessage(E_INVALID_ARG));
124                 break;
125         }
126 }
127
128 }}}     // Tizen::Ui::Controls