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_ListItemEvent.cpp
20 * @brief This is the implementation file for _ListItemEvent class.
22 * This file contains the implementation of _ListItemEvent class.
25 #include <FUiCtrlIListViewItemEventListener.h>
26 #include <FUiCtrlIGroupedListViewItemEventListener.h>
27 #include <FUiCtrlListView.h>
28 #include <FUiCtrlGroupedListView.h>
29 #include <FBaseSysLog.h>
30 #include "FUiCtrl_ListItemEvent.h"
31 #include "FUiCtrl_ListItemEventArg.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Runtime;
37 namespace Tizen { namespace Ui { namespace Controls
40 _ListItemEvent::_ListItemEvent(void)
42 , __invokeListViewItemCallback(true)
43 , __invokeGroupedListViewItemCallback(true)
44 , __className(CLASSNAME_NONE)
49 _ListItemEvent::~_ListItemEvent(void)
55 _ListItemEvent::Construct(Control& source, ListClassName name)
65 _ListItemEvent::GetSource(void) const
71 _ListItemEvent::GetListClassName(void) const
77 _ListItemEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
79 // cast to _ItemEventArg
80 _ListItemEventArg* pEventArg = dynamic_cast<_ListItemEventArg*>(const_cast<IEventArg*>(&arg));
81 SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, E_INVALID_ARG,
82 ("[E_INVALID_ARG] event argument is invalid type."));
89 pEventArg->GetEventArgs(index1, index2, index3, index4);
91 bool tempInvokeListViewItemCallback = __invokeListViewItemCallback;
92 __invokeListViewItemCallback = true;
94 bool tempInvokeGroupedListViewItemCallback = __invokeGroupedListViewItemCallback;
95 __invokeGroupedListViewItemCallback = true;
97 if (__className == CLASSNAME_LISTVIEW) // ListView
99 IListViewItemEventListener* pItemListener = dynamic_cast<IListViewItemEventListener*>(&listener);
100 SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG,
101 ("[E_INVALID_ARG] invalid listener type."));
103 ListView* pListView = dynamic_cast<ListView*>(GetSource());
104 SysAssertf(pListView != null, "Not yet constructed. Construct() should be called before use.");
111 switch (pEventArg->GetNotifyType())
113 case NOTIFY_TYPE_SELECTED_ITEM:
114 if (tempInvokeListViewItemCallback == true)
116 pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_SELECTED);
120 case NOTIFY_TYPE_HIGHLIGHED_ITEM:
121 if (tempInvokeListViewItemCallback == true)
123 pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_HIGHLIGHTED);
127 case NOTIFY_TYPE_ANNEX_CHECK:
128 if (tempInvokeListViewItemCallback == true)
130 pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_CHECKED);
134 case NOTIFY_TYPE_ANNEX_UNCHECK:
135 if (tempInvokeListViewItemCallback == true)
137 pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_UNCHECKED);
141 case NOTIFY_TYPE_ANNEX_MORE:
142 if (tempInvokeListViewItemCallback == true)
144 pItemListener->OnListViewItemStateChanged(*pListView, index1, index2, LIST_ITEM_STATUS_MORE);
148 case NOTIFY_TYPE_SELCTED_CONTEXT_ITEM:
149 if (tempInvokeListViewItemCallback == true)
151 pItemListener->OnListViewContextItemStateChanged(*pListView, index1, index2, LIST_CONTEXT_ITEM_STATUS_SELECTED);
155 case NOTIFY_TYPE_SWEPT_ITEM:
156 if (tempInvokeListViewItemCallback == true)
158 if (index2 == SWEEP_DIRECTION_LEFT)
160 pItemListener->OnListViewItemSwept(*pListView, index1, SWEEP_DIRECTION_LEFT);
164 pItemListener->OnListViewItemSwept(*pListView, index1, SWEEP_DIRECTION_RIGHT);
169 case NOTIFY_TYPE_LONG_PRESSED_ITEM:
170 pItemListener->OnListViewItemLongPressed(*pListView, index1, index2, __invokeListViewItemCallback);
173 case NOTIFY_TYPE_REORDERED_ITEM:
174 if (tempInvokeListViewItemCallback == true)
176 pItemListener->OnListViewItemReordered(*pListView, index1, index2);
185 else if (__className == CLASSNAME_GROUPEDLISTVIEW) // GroupedListView
187 IGroupedListViewItemEventListener* pItemListener = dynamic_cast<IGroupedListViewItemEventListener*>(&listener);
188 SysTryReturnVoidResult(NID_UI_CTRL, pItemListener != null, E_INVALID_ARG,
189 ("[E_INVALID_ARG] invalid listener type."));
191 GroupedListView* pGroupedListView = dynamic_cast<GroupedListView*>(GetSource());
192 SysAssertf(pGroupedListView != null, "Not yet constructed. Construct() should be called before use.");
199 switch (pEventArg->GetNotifyType())
201 case NOTIFY_TYPE_SELECTED_ITEM:
202 if (tempInvokeGroupedListViewItemCallback == true)
206 pItemListener->OnGroupedListViewGroupItemSelected(*pGroupedListView, index1);
210 pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_SELECTED);
214 case NOTIFY_TYPE_HIGHLIGHED_ITEM:
215 if (tempInvokeGroupedListViewItemCallback == true)
217 pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_HIGHLIGHTED);
221 case NOTIFY_TYPE_ANNEX_CHECK:
222 if (tempInvokeGroupedListViewItemCallback == true)
224 pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_CHECKED);
228 case NOTIFY_TYPE_ANNEX_UNCHECK:
229 if (tempInvokeGroupedListViewItemCallback == true)
231 pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_UNCHECKED);
235 case NOTIFY_TYPE_ANNEX_MORE:
236 if (tempInvokeGroupedListViewItemCallback == true)
238 pItemListener->OnGroupedListViewItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_ITEM_STATUS_MORE);
242 case NOTIFY_TYPE_SELCTED_CONTEXT_ITEM:
243 if (tempInvokeGroupedListViewItemCallback == true)
245 pItemListener->OnGroupedListViewContextItemStateChanged(*pGroupedListView, index1, index2, index3, LIST_CONTEXT_ITEM_STATUS_SELECTED);
249 case NOTIFY_TYPE_SWEPT_ITEM:
250 if (tempInvokeGroupedListViewItemCallback == true)
252 if (index3 == SWEEP_DIRECTION_LEFT)
254 pItemListener->OnGroupedListViewItemSwept(*pGroupedListView, index1, index2, SWEEP_DIRECTION_LEFT);
258 pItemListener->OnGroupedListViewItemSwept(*pGroupedListView, index1, index2, SWEEP_DIRECTION_RIGHT);
263 case NOTIFY_TYPE_LONG_PRESSED_ITEM:
266 pItemListener->OnGroupedListViewItemLongPressed(*pGroupedListView, index1, index2, index3, __invokeGroupedListViewItemCallback);
270 case NOTIFY_TYPE_REORDERED_ITEM:
271 if (tempInvokeListViewItemCallback == true)
273 pItemListener->OnGroupedListViewItemReordered(*pGroupedListView, index1, index2, index3, index4);
283 }}} // Tizen::Ui::Controls