Fork for IVI: mesa fixing
[profile/ivi/uifw.git] / src / ui / controls / FUiCtrl_FastScrollEvent.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 * @file         FUiCtrl_FastScrollEvent.cpp
19 * @brief        This is the implementation for the _FastScrollEvent class.
20 */
21
22 // includes
23 #include <FUiCtrlIFastScrollListener.h>
24 #include <FBaseErrors.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_FastScrollEvent.h"
27 #include "FUiCtrl_FastScrollEventArg.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 const wchar_t* const FAST_SCROLL_SEARCH_ICON_INDEX_STRING = L"[SEARCH_ICON_INDEX]";
37
38 ////////////////////////////////////////////////////////////////////////////////
39 /// __ExpandableItemEvent class Lifecycle
40
41 _FastScrollEvent::_FastScrollEvent(void)
42         : __pSource(null)
43 {
44         // nothing
45 }
46
47 _FastScrollEvent::~_FastScrollEvent(void)
48 {
49         // nothing
50 }
51
52 result
53 _FastScrollEvent::Construct(const Tizen::Ui::Control& source)
54 {
55         result r = _Event::Initialize();
56
57         // set event source
58         if (r == E_SUCCESS)
59         {
60                 __pSource = const_cast <Control*>(&source);
61         }
62
63         return r;
64 }
65
66
67 ////////////////////////////////////////////////////////////////////////////////
68 /// __WindowEvent class Accessor
69
70 const Tizen::Ui::Control*
71 _FastScrollEvent::GetSource(void) const
72 {
73         return __pSource;
74 }
75
76 ////////////////////////////////////////////////////////////////////////////////
77 /// __ExpandableItemEvent class Operation
78
79 void
80 _FastScrollEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
81 {
82         // cast to IFastScrollListener
83         IFastScrollListener* pFastScrollListener = dynamic_cast <IFastScrollListener*>(&listener);
84         SysTryReturnVoidResult(NID_UI, pFastScrollListener, E_INVALID_ARG, "[E_INVALID_ARG] Listener type is invalid.");
85
86         // cast to __FastScrollEventArg
87         _FastScrollEventArg* pArg = (_FastScrollEventArg*) const_cast <IEventArg*>(&arg);
88         SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] Event argument type is invalid.");
89
90         Tizen::Base::String index = pArg->GetIndex();
91         pFastScrollListener->OnFastScrollIndexSelected(*pArg->GetSource(), index);
92 }
93 }}} // Tizen::Ui::Controls