Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_UiFastScrollEvent.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_UiFastScrollEvent.cpp
20 * @brief        This is the implementation for the _UiFastScrollEvent class.
21 */
22
23 // includes
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_UiFastScrollEvent.h"
26 #include "FUiCtrl_UiFastScrollEventArg.h"
27 #include "FUiCtrl_IFastScrollListener.h"
28
29 // using namespace
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Runtime;
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36 ////////////////////////////////////////////////////////////////////////////////
37 /// __ExpandableItemEvent class Lifecycle
38
39 _UiFastScrollEvent::_UiFastScrollEvent(void)
40         : __pSource(null)
41 {
42         // nothing
43 }
44
45 _UiFastScrollEvent::~_UiFastScrollEvent(void)
46 {
47         // nothing
48 }
49
50 result
51 _UiFastScrollEvent::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 ////////////////////////////////////////////////////////////////////////////////
66 /// __WindowEvent class Accessor
67
68 const Tizen::Ui::_Control*
69 _UiFastScrollEvent::GetSource(void) const
70 {
71         return __pSource;
72 }
73
74 ////////////////////////////////////////////////////////////////////////////////
75 /// __ExpandableItemEvent class Operation
76
77 void
78 _UiFastScrollEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
79 {
80         // cast to IFastScrollListener
81         _IUiFastScrollListener* pFastScrollListener = dynamic_cast <_IUiFastScrollListener*>(&listener);
82         SysTryReturnVoidResult(NID_UI, pFastScrollListener, E_INVALID_ARG, "[E_INVALID_ARG] listener type is invalid.");
83
84         // cast to __UiFastScrollEventArg
85         _UiFastScrollEventArg* pArg = (_UiFastScrollEventArg*) const_cast <IEventArg*>(&arg);
86         SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] Event argument type is invalid.");
87
88         pFastScrollListener->OnUiFastScrollIndexSelected(*pArg->GetSource(), const_cast <Tizen::Ui::Controls::_FastScrollIndex&>(pArg->GetIndex()));
89 }
90 }}}