Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_IconListViewItemEvent.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
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_IconListViewItemEvent.cpp
20  * @brief               This is the implementation file for the _IconListViewItemEvent class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FUiCtrlIconListView.h>
25 #include <FUiCtrlIIconListViewItemEventListener.h>
26
27 #include "FUiCtrl_IconListViewItemEvent.h"
28 #include "FUiCtrl_IconListViewItemEventArg.h"
29
30 namespace Tizen
31 {
32 namespace Ui
33 {
34 namespace Controls
35 {
36
37 _IconListViewItemEvent::_IconListViewItemEvent(void)
38         : __pSource(null)
39 {
40         // Do nothing
41 }
42
43 _IconListViewItemEvent::~_IconListViewItemEvent(void)
44 {
45         // Do nothing
46 }
47
48 result
49 _IconListViewItemEvent::Construct(const IconListView& source)
50 {
51         result r = _Event::Initialize();
52
53         // set event source
54         if (r == E_SUCCESS)
55         {
56                 __pSource = const_cast <IconListView*>(&source);
57         }
58
59         return r;
60 }
61
62 const IconListView*
63 _IconListViewItemEvent::GetSource(void) const
64 {
65         return __pSource;
66 }
67
68 void
69 _IconListViewItemEvent::FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg)
70 {
71         // cast to IIconListViewItemEventListener
72         IIconListViewItemEventListener* pItemListener = dynamic_cast <IIconListViewItemEventListener*>(&listener);
73         SysTryReturnVoidResult(NID_UI_CTRL, (pItemListener != null), E_INVALID_ARG, "[E_INVALID_ARG] Invalid listener is used.");
74
75         // cast to _IconListViewItemEventArg
76         const _IconListViewItemEventArg* pItemEventArg = dynamic_cast <const _IconListViewItemEventArg*>(&arg);
77         SysTryReturnVoidResult(NID_UI_CTRL, (pItemEventArg != null), E_INVALID_ARG, "[E_INVALID_ARG] Invalid event argument is used.");
78
79         switch (pItemEventArg->GetEventType())
80         {
81         case EVENT_TYPE_ITEM_SELECTED:
82                 pItemListener->OnIconListViewItemStateChanged(
83                                 const_cast<IconListView&>(*GetSource()), pItemEventArg->GetIndex(), pItemEventArg->GetStatus());
84                 break;
85         case EVENT_TYPE_OVERLAY_BITMAP_SELECTED:
86                 pItemListener->OnIconListViewOverlayBitmapSelected(
87                                 const_cast<IconListView&>(*GetSource()), pItemEventArg->GetIndex(),     pItemEventArg->GetOverlayBitmapId());
88                 break;
89         case EVENT_TYPE_ITEM_REORDERED:
90                 pItemListener->OnIconListViewItemReordered(
91                                 const_cast<IconListView&>(*GetSource()), pItemEventArg->GetFromIndex(), pItemEventArg->GetToIndex());
92                 break;
93
94         default:
95                 SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid event argument is used.");
96                 return;
97         }
98
99         SetLastResult(E_SUCCESS);
100 }
101
102 }}}   // Tizen::Ui::Controls
103