Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_SlidableGroupedListImpl.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_SlidableGroupedListImpl.cpp
20  * @brief       This is the implementation file for the _SlidableGroupedListImpl class.
21  */
22
23 #include <FUiCtrlCustomListItem.h>
24 #include <FUiCtrlCustomListItemFormat.h>
25 #include "FUiCtrl_CustomListItemFormatImpl.h"
26 #include "FUiCtrl_CustomListItemImpl.h"
27 #include "FUiCtrl_SlidableGroupedListImpl.h"
28 #include "FUi_ResourceManager.h"
29 #include "FUiCtrl_ListListener.h"
30 #include "FUi_UiBuilder.h"
31 #include "FUiCtrl_TableViewPresenter.h"
32 #include "FUiCtrl_FastScroll.h"
33 #include "FUiCtrl_FastScrollIndex.h"
34 #include "FUi_ResourceSizeInfo.h"
35
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Base::Runtime;
40 using namespace Tizen::Base::Utility;
41
42 namespace Tizen { namespace Ui { namespace Controls {
43
44 static const int ID_FORMAT_STRING = 1;
45 static const int ID_FORMAT_MARGIN = 2;
46 extern const int INVALID_INDEX;
47
48 _SlidableGroupedListItemProvider::_SlidableGroupedListItemProvider(_SlidableGroupedListImpl* pListImpl)
49         : firstTime(true)
50         , __pListImpl(pListImpl)
51         , __bottomListenerIndex(0)
52         , __topListenerIndex(0)
53 {
54         if (__pListImpl != null)
55         {
56                 __topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1;
57         }
58 }
59
60 int
61 _SlidableGroupedListItemProvider::GetGroupCount(void)
62 {
63         if (__pListImpl == null)
64         {
65                 return 0;
66         }
67
68         if (__pListImpl->__slidableListenersList.GetCount() > 0)
69         {
70                 if (firstTime == true)
71                 {
72                         _ListListener* pListenerData = null;
73                         ISlidableGroupedListEventListener* pSlidableGroupedListener = null;
74                         int listenerCount = 0;
75
76                         for (listenerCount = 0; listenerCount < __pListImpl->__slidableListenersList.GetCount(); listenerCount++)
77                         {
78                                 pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(listenerCount));
79                                 SysTryReturn(NID_UI_CTRL, (pListenerData != null), -1, E_SYSTEM,
80                                                 "[E_SYSTEM] A system error has occurred. Failed to get _ListListener");
81
82                                 pSlidableGroupedListener = dynamic_cast<ISlidableGroupedListEventListener*>(pListenerData->pListener);
83                                 SysTryReturn(NID_UI_CTRL, (pSlidableGroupedListener != null), -1, E_SYSTEM,
84                                                 "[E_SYSTEM] A system error has occurred. Failed to get ISlidableGroupedListEventListener");
85
86                                 pSlidableGroupedListener->OnListPropertyRequested(__pListImpl->GetPublic());
87                         }
88
89                         firstTime = false;
90                 }
91         }
92
93         return __pListImpl->GetGroupCount();
94 }
95
96 int
97 _SlidableGroupedListItemProvider::GetItemCount(int groupIndex)
98 {
99         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex));
100         SysTryReturn(NID_UI_CTRL, pGroupObject, 0, E_SYSTEM,
101                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
102
103         return pGroupObject->__itemCount;
104 }
105
106 TableViewGroupItem*
107 _SlidableGroupedListItemProvider::CreateGroupItem(int groupIndex, int itemWidth)
108 {
109         result r = E_SUCCESS;
110
111         _TableViewItemParams tableViewItemParams;
112         tableViewItemParams.pItem = __pListImpl->GetCustomListItemAt(groupIndex, -1);
113         tableViewItemParams.width = itemWidth;
114         tableViewItemParams.itemId = -1;
115         tableViewItemParams.groupIndex = groupIndex;
116         tableViewItemParams.itemIndex = -1;
117         tableViewItemParams.isDividerEnabled = false;
118         tableViewItemParams.pCheckBitmaps = null;
119         tableViewItemParams.annexStyle = __pListImpl->_annexStyle;
120
121         r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
122         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
123
124         return __pListImpl->GetTableViewGroupItemAt(groupIndex);
125 }
126
127 bool
128 _SlidableGroupedListItemProvider::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
129 {
130         if (__pListImpl->__directDelete == false)
131         {
132                 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1);
133                 pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData = null;
134         }
135
136         delete pItem;
137
138         return true;
139 }
140
141 bool
142 _SlidableGroupedListItemProvider::IsReorderable(int groupIndexFrom, int groupIndexTo)
143 {
144         return false;
145 }
146
147 int
148 _SlidableGroupedListItemProvider::GetDefaultGroupItemHeight(void)
149 {
150         return __pListImpl->__groupItemHeight;
151 }
152
153 int
154 _SlidableGroupedListItemProvider::GetDefaultItemHeight(void)
155 {
156         CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(0, 0);
157
158         if (!pCustomListItem)
159         {
160                 return __pListImpl->_defaultItemHeight;
161         }
162         else
163         {
164                 return pCustomListItem->__pCustomListItemImpl->height;
165         }
166 }
167
168 void
169 _SlidableGroupedListItemProvider::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem)
170 {
171 }
172
173 void
174 _SlidableGroupedListItemProvider::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem)
175 {
176         _TableViewItemUpdateParams updateParams;
177         updateParams.pItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex);
178         updateParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
179         updateParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
180         updateParams.annexStyle = __pListImpl->_annexStyle;
181
182         result r = E_SUCCESS;
183
184         r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
185         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
186
187         pItem->SetEnabled(true);
188 }
189
190 result
191 _SlidableGroupedListItemProvider::CallLoadToTopCb(int groupIndex, int itemIndex)
192 {
193         _ListListener* pListenerData = null;
194         ISlidableGroupedListEventListener* pSlidableListener = null;
195
196         pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(__topListenerIndex));
197         SysTryReturn(NID_UI_CTRL, (pListenerData != null), E_SYSTEM, E_SYSTEM,
198                         "[E_SYSTEM] A system error has occurred. Failed to get _ListListener at index (%d)", __topListenerIndex);
199
200         pSlidableListener = dynamic_cast<ISlidableGroupedListEventListener*>(pListenerData->pListener);
201         SysTryReturn(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM, E_SYSTEM,
202                         "[E_SYSTEM] A system error has occurred. Failed to get ISlidableGroupedListEventListener");
203
204         pSlidableListener->OnLoadToTopRequested(__pListImpl->GetPublic(), groupIndex, itemIndex, 1);
205
206         if (--__topListenerIndex < 0)
207         {
208                 __topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1;
209         }
210
211         return E_SUCCESS;
212 }
213
214 result
215 _SlidableGroupedListItemProvider::UpdateCheckStatus(_TableViewItemData* pTableViewItemData, int groupIndex, int itemIndex)
216 {
217         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex));
218         SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM,
219                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
220
221         if (pTableViewItemData && pGroupObject->__pCheckedList)
222         {
223                 Boolean* pChecked = dynamic_cast<Boolean*>(pGroupObject->__pCheckedList->GetAt(itemIndex));
224                 SysTryReturn(NID_UI_CTRL, pChecked, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
225
226                 _CheckElementModel* pCheckElement = __pListImpl->GetCheckElementAt(groupIndex, 0);
227                 SysTryReturn(NID_UI_CTRL, pCheckElement, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get check element");
228
229                 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)pChecked->ToBool());
230         }
231
232         return E_SUCCESS;
233 }
234
235 result
236 _SlidableGroupedListItemProvider::ModifyIndicesAfterTopLoad(void)
237 {
238         if (__pListImpl->GetCurrentLoadedCount() > __pListImpl->__itemCacheSize)
239         {
240                 int subItemCount = __pListImpl->GetSubItemCountAt(__pListImpl->__bottomGroup);
241
242                 result r = E_SUCCESS;
243                 r = __pListImpl->RemoveFromItemsList(__pListImpl->__bottomGroup, subItemCount - 1);
244                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
245
246                 __pListImpl->CallUnloadItemCb(__pListImpl->__bottomGroup, subItemCount - 1);
247
248                 if ((subItemCount == 1) && (__pListImpl->__bottomGroup > 0))
249                 {
250                         __pListImpl->__bottomGroup--;
251                 }
252         }
253
254         if (__pListImpl->GetCurrentLoadedCount() == 2)
255         {
256                 for (int index = __pListImpl->__topGroup + 1; index < __pListImpl->__groupsList.GetCount(); index++)
257                 {
258                         _SlidableGroupObject* pTempGroup = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(index));
259                         SysTryReturn(NID_UI_CTRL, (pTempGroup != null), E_SYSTEM, E_SYSTEM,
260                                         "[E_SYSTEM] A system error has occurred. Failed to get SlidableGroupObject at index (%d).", index);
261
262                         pTempGroup->__topIndex = 0;
263                 }
264         }
265         return E_SUCCESS;
266 }
267
268 _TableViewItemData*
269 _SlidableGroupedListItemProvider::LoadAtTop(int groupIndex, int itemIndex)
270 {
271         _TableViewItemData* pTableViewItemData = null;
272
273         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex));
274         SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM,
275                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
276
277         __pListImpl->__topGroup = groupIndex;
278
279         result r = E_SUCCESS;
280         CustomListItem* pCustomListItem = null;
281
282         if (itemIndex >= pGroupObject->__topIndex)
283         {
284                 pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex);
285         }
286
287         pGroupObject->__topIndex = itemIndex;
288
289         if (!pCustomListItem)
290         {
291                 r = CallLoadToTopCb(groupIndex, itemIndex);
292                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
293         }
294         else
295         {
296                 _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(__pListImpl->__topGroup));
297                 SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM,
298                                 "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __pListImpl->__topGroup);
299
300                 _TableViewItemParams tableViewItemParams;
301                 tableViewItemParams.pItem = (const_cast<CustomListItem*>(pCustomListItem));
302                 tableViewItemParams.width = __pListImpl->GetCore().GetBounds().width;
303                 tableViewItemParams.itemIndex = pGroupObject->__topIndex;
304                 tableViewItemParams.groupIndex = __pListImpl->__topGroup;
305                 tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
306                 tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
307                 tableViewItemParams.annexStyle = __pListImpl->_annexStyle;
308
309                 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
310                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
311         }
312
313         pTableViewItemData = __pListImpl->GetTableViewItemAt(groupIndex, 0);
314         r = GetLastResult();
315         SysTryReturn(NID_UI_CTRL, pTableViewItemData, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
316
317         r = UpdateCheckStatus(pTableViewItemData, groupIndex, pGroupObject->__topIndex);
318         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
319
320         r = ModifyIndicesAfterTopLoad();
321         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
322
323         return pTableViewItemData;
324 }
325
326 result
327 _SlidableGroupedListItemProvider::CallLoadToBottomCb(int groupIndex, int itemIndex)
328 {
329         _ListListener* pListenerData = null;
330         ISlidableGroupedListEventListener* pSlidableListener = null;
331
332         pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(__bottomListenerIndex));
333         SysTryReturn(NID_UI_CTRL, (pListenerData != null), E_SYSTEM, E_SYSTEM,
334                         "[E_SYSTEM] A system error has occurred. Failed to get _ListListener at index (%d)", __bottomListenerIndex);
335
336         pSlidableListener = dynamic_cast<ISlidableGroupedListEventListener*>(pListenerData->pListener);
337         SysTryReturn(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM, E_SYSTEM,
338                         "[E_SYSTEM] A system error has occurred. Failed to get ISlidableGroupedListEventListener");
339
340         pSlidableListener->OnLoadToBottomRequested(__pListImpl->GetPublic(), groupIndex, itemIndex, 1);
341
342         if (++__bottomListenerIndex == __pListImpl->__slidableListenersList.GetCount())
343         {
344                 __bottomListenerIndex = 0;
345         }
346
347         return E_SUCCESS;
348 }
349
350 result
351 _SlidableGroupedListItemProvider::ModifyIndicesAfterBottomLoad(int groupIndex, int itemIndex)
352 {
353         if (__pListImpl->GetCurrentLoadedCount() > __pListImpl->__itemCacheSize)
354         {
355                 _SlidableGroupObject* pTopGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(__pListImpl->__topGroup));
356                 SysTryReturn(NID_UI_CTRL, pTopGroupObject, E_SYSTEM, E_SYSTEM,
357                                 "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __pListImpl->__topGroup);
358
359                 if (__pListImpl->__topGroup != __pListImpl->__bottomGroup)
360                 {
361                         pTopGroupObject->__topIndex++;
362                 }
363
364                 if (__pListImpl->GetSubItemCountAt(__pListImpl->__topGroup) == 0)
365                 {
366                         __pListImpl->__topGroup++;
367                 }
368         }
369         else if (__pListImpl->GetCurrentLoadedCount() == 1)
370         {
371                 __pListImpl->__topGroup = groupIndex;
372                 __pListImpl->__bottomGroup = groupIndex;
373
374                 _SlidableGroupObject* pTopGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(__pListImpl->__topGroup));
375                 SysTryReturn(NID_UI_CTRL, pTopGroupObject, E_SYSTEM, E_SYSTEM,
376                                 "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __pListImpl->__topGroup);
377
378                 pTopGroupObject->__topIndex = itemIndex;
379
380                 for (int index = 0; index < groupIndex; index++)
381                 {
382                         _SlidableGroupObject* pTempGroup = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(index));
383                         SysTryReturn(NID_UI_CTRL, (pTempGroup != null), E_SYSTEM, E_SYSTEM,
384                                         "[E_SYSTEM] A system error has occurred. Failed to get SlidableGroupObject at index (%d).", index);
385
386                         pTempGroup->__topIndex = pTempGroup->__itemCount - 1;
387                 }
388         }
389
390         return E_SUCCESS;
391 }
392
393 _TableViewItemData*
394 _SlidableGroupedListItemProvider::LoadAtBottom(int groupIndex, int itemIndex)
395 {
396         _TableViewItemData* pTableViewItemData = null;
397         result r = E_SUCCESS;
398
399         __pListImpl->__bottomGroup = groupIndex;
400
401         CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex - __pListImpl->GetTopItemIndex(groupIndex));
402
403         if (!pCustomListItem)
404         {
405                 r = CallLoadToBottomCb(groupIndex, itemIndex);
406                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
407         }
408         else
409         {
410                 _TableViewItemParams tableViewItemParams;
411                 tableViewItemParams.pItem = (const_cast<CustomListItem*>(pCustomListItem));
412                 tableViewItemParams.width = __pListImpl->GetCore().GetBounds().width;
413                 tableViewItemParams.groupIndex = __pListImpl->__bottomGroup;
414                 tableViewItemParams.itemIndex = itemIndex;
415                 tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
416                 tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
417                 tableViewItemParams.annexStyle = __pListImpl->_annexStyle;
418
419                 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
420                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
421         }
422
423         int subItemCount = __pListImpl->GetSubItemCountAt(groupIndex);
424
425         if (subItemCount > __pListImpl->__itemCacheSize)
426         {
427                 _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex));
428                 SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM,
429                                 "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
430
431                 pGroupObject->__topIndex++;
432         }
433
434         pTableViewItemData = __pListImpl->GetTableViewItemAt(groupIndex, subItemCount - 1);
435         r = GetLastResult();
436         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
437
438         r = UpdateCheckStatus(pTableViewItemData, groupIndex, subItemCount - 1);
439         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
440
441         r = ModifyIndicesAfterBottomLoad(groupIndex, itemIndex);
442         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
443
444         return pTableViewItemData;
445 }
446
447 TableViewItem*
448 _SlidableGroupedListItemProvider::CreateItem(int groupIndex, int itemIndex, int itemWidth)
449 {
450         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex));
451         SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM,
452                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
453
454         _TableViewItemData* pTableViewItem = null;
455         result r = E_SUCCESS;
456
457         if (groupIndex == __pListImpl->__topGroup)
458         {
459                 pTableViewItem = __pListImpl->GetTableViewItemAt(groupIndex, itemIndex - pGroupObject->__topIndex);
460         }
461         else
462         {
463                 pTableViewItem = __pListImpl->GetTableViewItemAt(groupIndex, itemIndex);
464         }
465
466         __pListImpl->__isCreating = true;
467
468         if (pTableViewItem == null)
469         {
470                 // load at top
471                 if (groupIndex <= __pListImpl->__topGroup && itemIndex <= pGroupObject->__topIndex)
472                 {
473                         pTableViewItem = LoadAtTop(groupIndex, itemIndex);
474                 }
475                 else // load at bottom
476                 {
477                         pTableViewItem = LoadAtBottom(groupIndex, itemIndex);
478                 }
479
480                 SysTryReturn(NID_UI_CTRL, pTableViewItem, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
481         }
482
483         __pListImpl->__isCreating = false;
484
485         return pTableViewItem;
486 }
487
488 bool
489 _SlidableGroupedListItemProvider::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
490 {
491         if (__pListImpl->__directDelete == false)
492         {
493                 if (((groupIndex == __pListImpl->__topGroup) && (itemIndex <= __pListImpl->GetTopItemIndex(__pListImpl->__topGroup))) || (__pListImpl->__forceScroll == true))
494                 {
495                         __pListImpl->RemoveFromItemsList(groupIndex, 0);
496                 }
497                 else
498                 {
499                         __pListImpl->RemoveFromItemsList(groupIndex, itemIndex);
500                 }
501
502                 __pListImpl->CallUnloadItemCb(groupIndex, itemIndex);
503
504                 _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__pListImpl->__groupsList.GetAt(groupIndex));
505                 SysTryReturn(NID_UI_CTRL, pGroupObject, false, E_SYSTEM,
506                                 "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
507
508                 // adjust top/bottom group indices
509                 if (__pListImpl->GetSubItemCountAt(groupIndex) == 0)
510                 {
511                         if (groupIndex <= __pListImpl->__topGroup)
512                         {
513                                 if (__pListImpl->__topGroup < __pListImpl->__bottomGroup)
514                                 {
515                                         __pListImpl->__topGroup++;
516                                 }
517                         }
518                         else
519                         {
520                                 if (__pListImpl->__bottomGroup > __pListImpl->__topGroup)
521                                 {
522                                         __pListImpl->__bottomGroup--;
523                                 }
524                         }
525                 }
526         }
527
528         delete pItem;
529         pItem = null;
530
531         return true;
532 }
533
534 _SlidableGroupObject::_SlidableGroupObject(void)
535         : __itemCount(0)
536         , __groupHeight(0)
537         , __topIndex(0)
538         , __pCheckedList(null)
539 {
540 }
541
542 _SlidableGroupObject::~_SlidableGroupObject(void)
543 {
544         if (__pCheckedList)
545         {
546                 __pCheckedList->RemoveAll(true);
547                 delete __pCheckedList;
548                 __pCheckedList = null;
549         }
550 }
551
552 _SlidableGroupedListImpl*
553 _SlidableGroupedListImpl::GetInstance(SlidableGroupedList& slidableGroupedList)
554 {
555         return static_cast<_SlidableGroupedListImpl*>(slidableGroupedList._pControlImpl);
556 }
557
558 const _SlidableGroupedListImpl*
559 _SlidableGroupedListImpl::GetInstance(const SlidableGroupedList& slidableGroupedList)
560 {
561         return static_cast<const _SlidableGroupedListImpl*>(slidableGroupedList._pControlImpl);
562 }
563
564 _SlidableGroupedListImpl::_SlidableGroupedListImpl(Control* pList, _TableView* pCore)
565         : _ListBaseImpl(pList, pCore)
566         , __pFastScrollListener(null)
567         , __bottomGroup(0)
568         , __topGroup(0)
569         , __loadedCount(0)
570         , __pItemProvider(null)
571         , __directDelete(false)
572         , __forceScroll(false)
573         , __isCreating(false)
574         , __groupItemTextFont(0)
575         , __groupItemHeight(0)
576         , __itemCacheSize(0)
577         , __pItemFormat(null)
578 {
579 }
580
581 _SlidableGroupedListImpl::~_SlidableGroupedListImpl(void)
582 {
583         if (__pItemProvider && __pItemProvider->firstTime == true)
584         {
585                 for (int groupIndex = 0; groupIndex < __groupsList.GetCount(); groupIndex++)
586                 {
587                         RemoveFromSubItemsList(groupIndex);
588                 }
589         }
590
591         RemoveAllFromItemsList();
592
593         __groupsList.RemoveAll(true);
594         __slidableListenersList.RemoveAll(true);
595         __itemListenersList.RemoveAll(true);
596
597         delete __pItemProvider;
598
599         delete __pItemFormat;
600 }
601
602 _SlidableGroupedListImpl*
603 _SlidableGroupedListImpl::CreateSlidableGroupedListImplN(SlidableGroupedList* pControl, bool itemDivider, bool fastScroll)
604 {
605         TableViewScrollBarStyle scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_NONE;
606
607         if (fastScroll == true)
608         {
609                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL;
610         }
611         else
612         {
613                 scrollStyle = TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT;
614         }
615
616         _TableView* pTableView = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_GROUPED, itemDivider, scrollStyle);
617         result r = GetLastResult();
618         SysTryReturn(NID_UI_CTRL, pTableView, null, r, "[%s] Propagating.", GetErrorMessage(r));
619
620         _SlidableGroupedListImpl* pImpl = new (std::nothrow) _SlidableGroupedListImpl(pControl, pTableView);
621         SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
622
623         return pImpl;
624
625 CATCH:
626         delete pTableView;
627         return null;
628 }
629
630 void
631 _SlidableGroupedListImpl::AddSlidableGroupedListEventListener(ISlidableGroupedListEventListener& listener)
632 {
633         _ListListener* pSlidableListener = new (std::nothrow) _ListListener();
634         SysTryReturnVoidResult(NID_UI_CTRL, pSlidableListener, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
635
636         pSlidableListener->pListener = &listener;
637         __slidableListenersList.Add(*pSlidableListener);
638 }
639
640 void
641 _SlidableGroupedListImpl::RemoveSlidableGroupedListEventListener(ISlidableGroupedListEventListener& listener)
642 {
643         _ListListener* pListenerData = null;
644
645         IEventListener* pEventListener = dynamic_cast<IEventListener*>(&listener);
646         SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM,
647                         "[E_SYSTEM] A system error has occurred. Failed to get IEventListener.");
648
649         ISlidableGroupedListEventListener* pSlidableListener = null;
650
651         for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++)
652         {
653                 pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount));
654                 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerData != null), E_SYSTEM,
655                                 "[E_SYSTEM] A system error has occurred. Failed to get _ListListener at index (%d).", listenerCount);
656
657                 pSlidableListener = dynamic_cast<ISlidableGroupedListEventListener*>(pListenerData->pListener);
658                 SysTryReturnVoidResult(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM,
659                                 "[E_SYSTEM] A system error has occurred. Failed to get ISlidableGroupedListEventListener.");
660
661                 if (pSlidableListener == pEventListener)
662                 {
663                         __slidableListenersList.RemoveAt(listenerCount, true);
664                         break;
665                 }
666         }
667
668         RemoveAllGroups();
669 }
670
671 void
672 _SlidableGroupedListImpl::AddFastScrollEventListener(IFastScrollEventListener& listener)
673 {
674         __pFastScrollListener = &listener;
675
676         GetCore().AddFastScrollListener(*this);
677 }
678
679 result
680 _SlidableGroupedListImpl::AddGroup(const String& text, const Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId)
681 {
682         return InsertGroupAt(GetGroupCount(), text, pBackgroundBitmap, itemCount, groupHeight, groupId);
683 }
684
685 void
686 _SlidableGroupedListImpl::AddGroupedItemEventListener(IGroupedItemEventListener& listener)
687 {
688         _ListListener* pListenersList = new (std::nothrow) _ListListener();
689         SysTryReturnVoidResult(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
690
691         pListenersList->pListener = &listener;
692
693         __itemListenersList.Add(*pListenersList);
694 }
695
696 result
697 _SlidableGroupedListImpl::AddItem(int groupIndex, const CustomListItem& item, int itemId)
698 {
699         SysTryReturnResult(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
700                                 E_INVALID_ARG, "Invalid argument is used. groupIndex (%d)", groupIndex);
701
702         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
703         SysTryReturnResult(NID_UI_CTRL, (pGroupObject != null), E_SYSTEM,
704                         "A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
705
706         return InsertItemAt(groupIndex, GetTopItemIndex(groupIndex) + GetSubItemCountAt(groupIndex), item, itemId);
707 }
708
709 result
710 _SlidableGroupedListImpl::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
711 {
712         return GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
713 }
714
715 result
716 _SlidableGroupedListImpl::GetFirstCheckedItemIndex(int& groupIndex, int& itemIndex) const
717 {
718         SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM,
719                         "A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL.");
720
721         _SlidableGroupObject* pGroupObject = null;
722         Boolean* pChecked = null;
723
724         for (int groupCount = 0; groupCount < GetGroupCount(); groupCount++)
725         {
726                 pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupCount)));
727                 SysTryReturnResult(NID_UI_CTRL, (pGroupObject != null), E_SYSTEM,
728                                 "A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupCount);
729
730                 for (int checkCount = 0; checkCount < pGroupObject->__pCheckedList->GetCount(); checkCount++)
731                 {
732                         pChecked = dynamic_cast<Boolean*>(const_cast<Object*>(pGroupObject->__pCheckedList->GetAt(checkCount)));
733                         SysTryReturnResult(NID_UI_CTRL, (pChecked != null), E_SYSTEM, "A system error has occurred.");
734
735                         if (pChecked->ToBool())
736                         {
737                                 groupIndex = groupCount;
738                                 itemIndex = checkCount;
739                                 return E_SUCCESS;
740                         }
741                 }
742         }
743
744         return E_SYSTEM;
745 }
746
747 int
748 _SlidableGroupedListImpl::GetGroupIdAt(int groupIndex) const
749 {
750         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
751                                 INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d)", groupIndex);
752
753         const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1);
754         SysTryReturn(NID_UI_CTRL, pCustomListItem, 0, E_SYSTEM,
755                         "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at index (%d).", groupIndex);
756
757         return pCustomListItem->__pCustomListItemImpl->itemId;
758 }
759
760 int
761 _SlidableGroupedListImpl::GetGroupIndexFromGroupId(int groupId) const
762 {
763         for (int groupCount = 0; groupCount < __groupsList.GetCount(); groupCount++)
764         {
765                 const CustomListItem* pCustomItem = GetCustomListItemAt(groupCount, -1);
766                 SysTryReturn(NID_UI_CTRL, pCustomItem, INVALID_INDEX, E_SYSTEM,
767                                 "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at index (%d).", groupCount);
768
769                 if (pCustomItem->__pCustomListItemImpl->itemId == groupId)
770                 {
771                         return groupCount;
772                 }
773         }
774
775         return INVALID_INDEX;
776 }
777
778 result
779 _SlidableGroupedListImpl::GetFirstLoadedItemIndex(int& groupIndex, int& itemIndex) const
780 {
781         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(__topGroup)));
782         SysTryReturnResult(NID_UI_CTRL, pGroupObject, E_SYSTEM,
783                         "A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __topGroup);
784
785         groupIndex = __topGroup;
786         itemIndex = pGroupObject->__topIndex;
787
788         return E_SUCCESS;
789 }
790
791 result
792 _SlidableGroupedListImpl::GetLastLoadedItemIndex(int& groupIndex, int& itemIndex) const
793 {
794         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(__bottomGroup)));
795         SysTryReturnResult(NID_UI_CTRL, pGroupObject, E_SYSTEM,
796                         "A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __bottomGroup);
797
798         itemIndex = GetSubItemCountAt(__bottomGroup) - 1 + pGroupObject->__topIndex;
799         groupIndex = __bottomGroup;
800
801         return E_SUCCESS;
802 }
803
804 result
805 _SlidableGroupedListImpl::SetFastScrollMainIndex(const String& text)
806 {
807         SysTryReturn(NID_UI_CTRL, (text.GetLength() > 0), E_SYSTEM, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Text is empty.");
808
809         SysTryReturn(NID_UI_CTRL, (GetCore().GetScrollStyle() == TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Scroll bar not enabled");
810
811         result r = GetCore().SetFastScrollIndex(text, false);
812         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
813
814         __mainScrollIndex = text;
815
816         return E_SUCCESS;
817 }
818
819
820 result
821 _SlidableGroupedListImpl::SetFastScrollSubIndex(const String& text, FastScrollIndexDigit indexDigit)
822 {
823         SysTryReturn(NID_UI_CTRL, (text.GetLength() > 0), E_SYSTEM, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Text is empty.");
824
825         SysTryReturn(NID_UI_CTRL, (indexDigit == SCROLL_INDEX_DIGIT_NUM_1), E_SYSTEM, E_INVALID_ARG,
826                         "[E_INVALID_ARG] Invalid argument is used. indexDigit is not SCROLL_INDEX_DIGIT_NUM_1.");
827
828         _FastScroll* pFastScroll = GetCore().GetFastScrollBar();
829         SysTryReturn(NID_UI_CTRL, pFastScroll, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get FastScroll Object.");
830
831         SysTryReturn(NID_UI_CTRL, (__mainScrollIndex.GetLength() > 0), E_SYSTEM, E_SYSTEM,
832                         "[E_SYSTEM] A system error has occurred. Main index of the fast scroll is not set.");
833
834         _FastScrollIndex* pRootIndex = pFastScroll->GetIndex();
835         SysTryReturn(NID_UI_CTRL, pRootIndex, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get rootIndex.");
836
837         int subIndexDigit = 1;
838         String delim(L",");
839         StringTokenizer strTok(text, delim);
840         String token;
841         int i = 0;
842
843         while (strTok.HasMoreTokens())
844         {
845                 strTok.GetNextToken(token);
846                 _FastScrollIndex* pSecondaryIndex = pRootIndex->GetChildIndex(i++);
847                 if (pSecondaryIndex != null)
848                 {
849                         pSecondaryIndex->AddChildTextIndexArray(0, token.GetPointer(), subIndexDigit, token.GetLength());
850                 }
851         }
852
853         pFastScroll->UpdateIndex();
854         return E_SUCCESS;
855 }
856
857
858 result
859 _SlidableGroupedListImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const
860 {
861         return GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
862 }
863
864 result
865 _SlidableGroupedListImpl::GetItemIndexFromPosition(int x, int y, int& groupIndex, int& itemIndex) const
866 {
867         return GetCore().GetItemIndexFromPosition(Point(x, y), groupIndex, itemIndex);
868 }
869
870 CustomListItem*
871 _SlidableGroupedListImpl::CreateGroupItemN(const String& text, const Bitmap* pBackgroundBitmap, int groupId)
872 {
873         CustomListItem* pCustomListItem = new (std::nothrow) CustomListItem();
874         SysTryReturn(NID_UI_CTRL, pCustomListItem != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
875
876         pCustomListItem->Construct(__groupItemHeight);
877         pCustomListItem->SetItemFormat(*__pItemFormat);
878         pCustomListItem->SetElement(ID_FORMAT_STRING, text);
879         pCustomListItem->SetElement(ID_FORMAT_MARGIN, "");
880
881         if (pBackgroundBitmap != null)
882         {
883                 pCustomListItem->SetNormalItemBackgroundBitmap(*pBackgroundBitmap);
884         }
885
886         pCustomListItem->__pCustomListItemImpl->itemId = groupId;
887
888         return pCustomListItem;
889 }
890
891 result
892 _SlidableGroupedListImpl::CreateGroupObject(int groupIndex, int itemCount, int groupHeight)
893 {
894         _SlidableGroupObject* pGroupObject = new (std::nothrow) _SlidableGroupObject();
895         SysTryReturn(NID_UI_CTRL, pGroupObject != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
896
897         __groupsList.InsertAt(*pGroupObject, groupIndex);
898
899         if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || _annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
900         {
901                 pGroupObject->__pCheckedList = new (std::nothrow) ArrayList();
902                 SysTryReturn(NID_UI_CTRL, pGroupObject->__pCheckedList, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed");
903
904                 pGroupObject->__pCheckedList->Construct(itemCount);
905
906                 Boolean* pChecked = null;
907
908                 for (int count = 0; count < itemCount; count++)
909                 {
910                         pChecked = new (std::nothrow) Boolean(false);
911                         SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed");
912                         pGroupObject->__pCheckedList->Add(*pChecked);
913                 }
914         }
915
916         pGroupObject->__groupHeight = groupHeight;
917         pGroupObject->__itemCount = itemCount;
918
919         return E_SUCCESS;
920 }
921
922 result
923 _SlidableGroupedListImpl::InsertGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int itemCount, int groupHeight, int groupId)
924 {
925         result r = E_SUCCESS;
926
927         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex <= __groupsList.GetCount()),
928                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d)", groupIndex);
929
930         r = CreateGroupObject(groupIndex, itemCount, groupHeight);
931         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
932
933         CustomListItem* pCustomListItem = CreateGroupItemN(text, pBackgroundBitmap, groupId);
934         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
935
936         r = InsertIntoItemsList(*pCustomListItem, groupIndex, -1);
937         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
938
939         __loadedCount += itemCount;
940
941         if (__slidableListenersList.GetCount() == 0)
942         {
943                 return E_SUCCESS;
944         }
945
946         if (groupIndex <= __topGroup)
947         {
948                 __topGroup++;
949                 __bottomGroup++;
950         }
951
952         if (__pItemProvider == null)
953         {
954                 r = CreateItemProvider();
955                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
956
957                 _ListBaseImpl::OnDraw();
958         }
959         else
960         {
961                 r = GetCore().RefreshTableView(groupIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
962                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert a group.");
963         }
964
965         return E_SUCCESS;
966 }
967
968 result
969 _SlidableGroupedListImpl::GetLastCheckedItemIndex(int& groupIndex, int& itemIndex) const
970 {
971         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM,
972                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL.");
973
974         for (int groupCount = __groupsList.GetCount() - 1; groupCount >= 0; groupCount--)
975         {
976                 int subItemCount = GetSubItemCountAt(groupCount);
977
978                 for (int itemCount = subItemCount - 1; itemCount >= 0; itemCount--)
979                 {
980                         if (IsItemChecked(groupCount, itemCount))
981                         {
982                                 itemIndex = itemCount;
983                                 groupIndex = groupCount;
984                                 return E_SUCCESS;
985                         }
986                 }
987         }
988
989         return E_SYSTEM;
990 }
991
992 const CustomListItem*
993 _SlidableGroupedListImpl::GetLoadedItemAt(int groupIndex, int index) const
994 {
995         SysTryReturn(NID_UI_CTRL, (groupIndex >= __topGroup && groupIndex <= __bottomGroup), null, E_INVALID_ARG,
996                         "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d) is not loaded or invalid.", groupIndex);
997
998         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
999         SysTryReturn(NID_UI_CTRL, pGroupObject, null, E_SYSTEM,
1000                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1001
1002         SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetSubItemCountAt(groupIndex)),
1003                                 null, E_INVALID_ARG, "[E_INVALID_ARG] invalid index(%d)", index);
1004
1005         const CustomListItem* pSubListItem = GetCustomListItemAt(groupIndex, index);
1006         SysTryReturn(NID_UI_CTRL, pSubListItem, null, E_SYSTEM,
1007                         "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at index (%d).", index);
1008
1009         return pSubListItem;
1010 }
1011
1012 int
1013 _SlidableGroupedListImpl::GetLoadedItemIdAt(int groupIndex, int index) const
1014 {
1015         const CustomListItem* pCustomListItem = GetLoadedItemAt(groupIndex, index - GetTopItemIndex(groupIndex));
1016         SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. ");
1017
1018         return pCustomListItem->__pCustomListItemImpl->itemId;
1019 }
1020
1021 result
1022 _SlidableGroupedListImpl::GetNextCheckedItemIndexAfter(int& groupIndex, int& index) const
1023 {
1024         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM,
1025                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL.");
1026
1027         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()), E_SYSTEM, E_INVALID_ARG,
1028                         "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1029
1030         int subItemCount = GetSubItemCountAt(groupIndex);
1031
1032         SysTryReturn(NID_UI_CTRL, (index >= 0 && index < subItemCount),
1033                                 E_SYSTEM, E_SYSTEM, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index);
1034
1035         int itemStart = 0;
1036
1037         for (int groupCount = groupIndex; groupCount < __groupsList.GetCount(); groupCount++)
1038         {
1039                 if (groupCount == groupIndex)
1040                 {
1041                         itemStart = index + 1;
1042                 }
1043                 else
1044                 {
1045                         itemStart = 0;
1046                 }
1047
1048                 subItemCount = GetSubItemCountAt(groupIndex);
1049                 for (int checkCount = itemStart; checkCount < subItemCount; checkCount++)
1050                 {
1051                         if (IsItemChecked(groupCount, checkCount))
1052                         {
1053                                 groupIndex = groupCount;
1054                                 index = checkCount;
1055                                 return E_SUCCESS;
1056                         }
1057                 }
1058
1059                 itemStart = 0;
1060         }
1061
1062         return E_SUCCESS;
1063 }
1064
1065 Color
1066 _SlidableGroupedListImpl::GetTextColorOfEmptyList(void) const
1067 {
1068         return GetCore().GetTextColorOfEmptyTableView();
1069 }
1070
1071 result
1072 _SlidableGroupedListImpl::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
1073 {
1074         return GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
1075 }
1076
1077 bool
1078 _SlidableGroupedListImpl::IsItemChecked(int groupIndex, int index) const
1079 {
1080         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), false, E_SYSTEM,
1081                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL.");
1082
1083         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1084                                 false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1085
1086         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
1087         SysTryReturn(NID_UI_CTRL, pGroupObject, false, E_SYSTEM,
1088                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1089
1090         SysTryReturn(NID_UI_CTRL, (index >= 0 && index < GetSubItemCountAt(groupIndex)),
1091                                 false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index);
1092
1093         Boolean* pChecked = dynamic_cast<Boolean*>(const_cast<Object*>(pGroupObject->__pCheckedList->GetAt(index)));
1094         SysTryReturn(NID_UI_CTRL, pChecked, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
1095
1096         return pChecked->ToBool();
1097 }
1098
1099 bool
1100 _SlidableGroupedListImpl::IsItemLoaded(int groupIndex, int itemIndex) const
1101 {
1102         if (groupIndex < __topGroup || groupIndex > __bottomGroup)
1103         {
1104                 return false;
1105         }
1106
1107         else if (groupIndex == __topGroup)
1108         {
1109                 _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
1110                 SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1111                                 "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1112
1113                 if (itemIndex >= pGroupObject->__topIndex && itemIndex <= pGroupObject->__itemCount)
1114                 {
1115                         return true;
1116                 }
1117
1118                 return false;
1119         }
1120         else if (groupIndex == __bottomGroup)
1121         {
1122                 _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
1123                 SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1124                                 "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1125
1126                 if (itemIndex >= 0 && itemIndex < pGroupObject->__itemCount)
1127                 {
1128                         return true;
1129                 }
1130
1131                 return false;
1132         }
1133
1134         return true;
1135 }
1136
1137 result
1138 _SlidableGroupedListImpl::RemoveAllGroups(void)
1139 {
1140         for (int groupCount = __groupsList.GetCount() - 1; groupCount >= 0; groupCount--)
1141         {
1142                 RemoveGroupAt(groupCount);
1143         }
1144
1145         return E_SUCCESS;
1146 }
1147
1148 result
1149 _SlidableGroupedListImpl::InsertItemAt(int groupIndex, int index, const CustomListItem& item, int itemId)
1150 {
1151         result r = E_SUCCESS;
1152
1153         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1154                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1155
1156         SysTryReturn(NID_UI_CTRL, (index >= 0 && index <= GetSubItemCountAt(groupIndex)), E_INVALID_ARG, E_INVALID_ARG,
1157                         "[E_INVALID_ARG] Invalid argument is used. index (%d).", index);
1158
1159         item.__pCustomListItemImpl->itemId = itemId;
1160
1161         r = InsertIntoItemsList(item, groupIndex, index);
1162         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1163
1164         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
1165         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1166                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1167
1168         pGroupObject->__itemCount++;
1169
1170         if (pGroupObject->__pCheckedList)
1171         {
1172                 Boolean* pChecked = new (std::nothrow) Boolean(false);
1173                 SysTryCatch(NID_UI_CTRL, pChecked, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1174
1175                 pGroupObject->__pCheckedList->InsertAt(*pChecked, index);
1176         }
1177
1178         if (GetCore().GetFirstDrawnFlag() == false)
1179         {
1180                 r = GetCore().RefreshTableView(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
1181                 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , E_SYSTEM,
1182                                 "[E_SYSTEM] A system error has occurred. Failed to perform InsertItemAt groupIndex (%d), index (%d).", groupIndex, index);
1183         }
1184
1185         return E_SUCCESS;
1186
1187 CATCH:
1188         if (pGroupObject->__pCheckedList)
1189         {
1190                 pGroupObject->__pCheckedList->RemoveAt(index, true);
1191         }
1192         RemoveFromItemsList(groupIndex, index);
1193
1194         return E_SYSTEM;
1195 }
1196
1197 int
1198 _SlidableGroupedListImpl::GetItemCountAt(int groupIndex) const
1199 {
1200         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1201                                 0, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1202
1203         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
1204         SysTryReturn(NID_UI_CTRL, pGroupObject, 0, E_SYSTEM,
1205                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1206         return pGroupObject->__itemCount;
1207 }
1208
1209 result
1210 _SlidableGroupedListImpl::RefreshItem(int groupIndex, int index)
1211 {
1212         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1213                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1214
1215         int topItemIndex = -1;
1216         int bottomItemIndex = -1;
1217         int groupTopIndex = -1;
1218
1219         GetCore().GetTopDrawnItemIndex(groupTopIndex, topItemIndex);
1220         GetCore().GetBottomDrawnItemIndex(groupTopIndex, bottomItemIndex);
1221
1222         SysTryReturn(NID_UI_CTRL, (index >= topItemIndex && index <= bottomItemIndex), E_INVALID_OPERATION, E_INVALID_OPERATION,
1223                         "Index (%d) should be within drawn item range.", index);
1224
1225         result r = E_SUCCESS;
1226
1227         _TableViewItemUpdateParams updateParams;
1228         updateParams.pItem = GetCustomListItemAt(groupIndex, index);
1229         updateParams.isDividerEnabled = _isDividerEnabled;
1230         updateParams.pCheckBitmaps = _pCheckBitmaps;
1231         updateParams.annexStyle = _annexStyle;
1232
1233         r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
1234         SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM,
1235                         "A system error has occurred. Failed to perform RefreshItem at groupIndex (%d), index (%d).", groupIndex, index);
1236
1237         DrawItem(groupIndex, index);
1238
1239         return E_SUCCESS;
1240 }
1241
1242 result
1243 _SlidableGroupedListImpl::RefreshGroup(int groupIndex)
1244 {
1245         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1246                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1247
1248         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1249         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1250                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1251
1252         int topIndex = GetTopItemIndex(groupIndex);
1253         int subItemCount = GetSubItemCountAt(groupIndex);
1254
1255         for (int itemCount = topIndex; itemCount < topIndex + subItemCount; itemCount++)
1256         {
1257                 RefreshItem(groupIndex, itemCount);
1258         }
1259
1260         return E_SUCCESS;
1261
1262 }
1263
1264 bool
1265 _SlidableGroupedListImpl::IsLoadedItemEnabled(int groupIndex, int index) const
1266 {
1267         if (IsItemLoaded(groupIndex, index) == false)
1268         {
1269                 return false;
1270         }
1271
1272         return GetCore().IsItemEnabled(groupIndex, index);
1273 }
1274
1275 result
1276 _SlidableGroupedListImpl::LoadItemToBottom(const CustomListItem& item, int itemId)
1277 {
1278         SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS,
1279                         "[E_SUCCESS] This operation is ignored during creation of list.");
1280
1281         int itemIndex  = GetSubItemCountAt(__bottomGroup);
1282
1283         _TableViewItemParams tableViewItemParams;
1284         tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
1285         tableViewItemParams.width = GetCore().GetBounds().width;
1286         tableViewItemParams.groupIndex = __bottomGroup;
1287         tableViewItemParams.itemIndex = itemIndex;
1288         tableViewItemParams.isDividerEnabled = _isDividerEnabled;
1289         tableViewItemParams.pCheckBitmaps = _pCheckBitmaps;
1290         tableViewItemParams.itemId = itemId;
1291         tableViewItemParams.annexStyle = _annexStyle;
1292
1293         result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
1294         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1295
1296         item.__pCustomListItemImpl->itemId = itemId;
1297
1298         r = InsertIntoItemsList(item, __bottomGroup, itemIndex, false);
1299         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
1300
1301         return E_SUCCESS;
1302 }
1303
1304 result
1305 _SlidableGroupedListImpl::LoadItemToTop(const CustomListItem& item, int itemId)
1306 {
1307         SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS,
1308                         "[E_SUCCESS] This operation is ignored during creation of list.");
1309
1310         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(__topGroup));
1311         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1312                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __topGroup);
1313
1314         _TableViewItemParams tableViewItemParams;
1315         tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
1316         tableViewItemParams.width = GetCore().GetBounds().width;
1317         tableViewItemParams.itemId = itemId;
1318         tableViewItemParams.itemIndex = pGroupObject->__topIndex;
1319         tableViewItemParams.groupIndex = __topGroup;
1320         tableViewItemParams.isDividerEnabled = _isDividerEnabled;
1321         tableViewItemParams.pCheckBitmaps = _pCheckBitmaps;
1322         tableViewItemParams.annexStyle = _annexStyle;
1323
1324         result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
1325         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1326
1327         item.__pCustomListItemImpl->itemId = itemId;
1328
1329         r = InsertIntoItemsList(item, __topGroup, 0, false);
1330         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
1331
1332         return E_SUCCESS;
1333 }
1334
1335 result
1336 _SlidableGroupedListImpl::GetLoadedItemIndexFromItemId(int itemId, int& groupIndex, int& itemIndex) const
1337 {
1338         for (int groupCount = __topGroup; groupCount <= __bottomGroup; groupCount++)
1339         {
1340                 for (int itemCount = 0; itemCount < GetSubItemCountAt(groupCount); itemCount++)
1341                 {
1342                         const CustomListItem* pItem = GetCustomListItemAt(groupCount, itemCount);
1343                         if (!pItem)
1344                         {
1345                                 continue;
1346                         }
1347
1348                         if (pItem->__pCustomListItemImpl->itemId == itemId)
1349                         {
1350                                 groupIndex = groupCount;
1351                                 itemIndex = itemCount;
1352                                 return E_SUCCESS;
1353                         }
1354                 }
1355         }
1356
1357         groupIndex = -1;
1358         itemIndex = -1;
1359
1360         return E_SYSTEM;
1361 }
1362
1363 result
1364 _SlidableGroupedListImpl::UnloadAllItems(void)
1365 {
1366         result r = E_SUCCESS;
1367         int itemCount = 0;
1368         int groupCount = 0;
1369         int itemIndex = 0;
1370
1371         SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM,
1372                                 "[E_SYSTEM] A system error has occurred. ISlidableGroupedListEventListener not set.");
1373
1374         __directDelete = true;
1375
1376         for (groupCount = __groupsList.GetCount() - 1; groupCount >= 0; groupCount--)
1377         {
1378                 itemCount = GetSubItemCountAt(groupCount);
1379
1380                 for (itemIndex = itemCount - 1; itemIndex >= 0; itemIndex--)
1381                 {
1382                         RemoveFromItemsList(groupCount, itemIndex);
1383
1384                         r = GetCore().RefreshTableView(groupCount, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
1385                         if (r != E_SUCCESS)
1386                         {
1387                                 SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupCount);
1388                         }
1389
1390                         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupCount));
1391                         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1392                                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupCount);
1393
1394                         if (pGroupObject->__pCheckedList != null)
1395                         {
1396                                 pGroupObject->__pCheckedList->RemoveAt(itemIndex, true);
1397                         }
1398
1399                         CallUnloadItemCb(groupCount, itemIndex);
1400                 }
1401         }
1402
1403         __directDelete = false;
1404
1405         return E_SUCCESS;
1406 }
1407
1408 result
1409 _SlidableGroupedListImpl::RemoveAllCheckedItemsAt(int groupIndex, int itemHeight)
1410 {
1411         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM,
1412                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL.");
1413         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM,
1414                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_RADIO.");
1415
1416         SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM,
1417                                 "[E_SYSTEM] A system error has occurred. ISlidableGroupedListEventListener not set.");
1418
1419         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1420                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1421
1422         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1423         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1424                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1425
1426         result r = E_SUCCESS;
1427         Boolean* pChecked = null;
1428         int itemIndex = 0;
1429
1430         for (; itemIndex < pGroupObject->__itemCount; itemIndex++)
1431         {
1432                 pChecked = dynamic_cast<Boolean*>(const_cast<Object*>(pGroupObject->__pCheckedList->GetAt(itemIndex)));
1433                 SysTryReturn(NID_UI_CTRL, pChecked, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
1434
1435                 if (pChecked->ToBool() == true)
1436                 {
1437                         r = RemoveItemAt(groupIndex, itemIndex, itemHeight);
1438                         if (r != E_SUCCESS)
1439                         {
1440                                 SysLog(NID_UI_CTRL, "Failed to remove the itme at groupIndex (%d), itemIndex (%d).", groupIndex, itemIndex);
1441                         }
1442                         itemIndex--;
1443                 }
1444         }
1445
1446         return E_SUCCESS;
1447 }
1448
1449 result
1450 _SlidableGroupedListImpl::RemoveAllCheckedItems(int itemHeight)
1451 {
1452         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM,
1453                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL.");
1454         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM,
1455                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_RADIO.");
1456
1457         SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM,
1458                                 "[E_SYSTEM] A system error has occurred. ISlidableGroupedListEventListener not set.");
1459
1460         int groupCount = 0;
1461
1462         for (; groupCount < __groupsList.GetCount(); groupCount++)
1463         {
1464                 RemoveAllCheckedItemsAt(groupCount, itemHeight);
1465         }
1466
1467         return E_SUCCESS;
1468 }
1469
1470 result
1471 _SlidableGroupedListImpl::RemoveAllItemsAt(int groupIndex)
1472 {
1473         result r = E_SUCCESS;
1474
1475         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1476                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1477
1478         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1479         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1480                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1481
1482         __directDelete = true;
1483
1484         for (int itemCount = 0; itemCount < GetSubItemCountAt(groupIndex);)
1485         {
1486                 r = RemoveItemAt(groupIndex, 0, 0);
1487                 if (r != E_SUCCESS)
1488                 {
1489                         SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupIndex);
1490                 }
1491         }
1492
1493         __directDelete = false;
1494
1495         if (pGroupObject->__pCheckedList != null)
1496         {
1497                 pGroupObject->__pCheckedList->RemoveAll(true);
1498         }
1499
1500         pGroupObject->__itemCount = 0;
1501
1502         return E_SUCCESS;
1503 }
1504
1505 result
1506 _SlidableGroupedListImpl::RemoveAllItems(void)
1507 {
1508         SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM,
1509                                 "[E_SYSTEM] A system error has occurred. ISlidableGroupedListEventListener not set.");
1510
1511         int groupCount = 0;
1512
1513         for (groupCount = 0; groupCount < __groupsList.GetCount(); groupCount++)
1514         {
1515                 RemoveAllItemsAt(groupCount);
1516         }
1517
1518         __pItemProvider->firstTime = true;
1519
1520         return E_SUCCESS;
1521 }
1522
1523 void
1524 _SlidableGroupedListImpl::RemoveFastScrollEventListener(IFastScrollEventListener& listener)
1525 {
1526         __pFastScrollListener = null;
1527 }
1528
1529 void
1530 _SlidableGroupedListImpl::RemoveGroupedItemEventListener(IGroupedItemEventListener& listener)
1531 {
1532         _ListListener* pListenerList = null;
1533
1534         for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
1535         {
1536                 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1537
1538                 if ((pListenerList != null) && (pListenerList->pListener == &listener))
1539                 {
1540                         __itemListenersList.RemoveAt(listenerCount, true);
1541                         break;
1542                 }
1543         }
1544 }
1545
1546 result
1547 _SlidableGroupedListImpl::RemoveItemAt(int groupIndex, int index, int itemHeight)
1548 {
1549         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1550                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1551
1552         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1553         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1554                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1555
1556         int subItemCount = GetSubItemCountAt(groupIndex);
1557
1558         SysTryReturn(NID_UI_CTRL, (index >= 0 && index < subItemCount),
1559                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index);
1560
1561         if (!(index < pGroupObject->__topIndex + subItemCount))
1562         {
1563                 pGroupObject->__itemCount--;
1564                 return E_SUCCESS;
1565         }
1566
1567         __directDelete = true;
1568
1569         RemoveFromItemsList(groupIndex, index);
1570
1571         result r = GetCore().RefreshTableView(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
1572         if (r != E_SUCCESS)
1573         {
1574                 SysLog(NID_UI_CTRL, "Group item with index %d not removed successFully.", groupIndex);
1575         }
1576
1577         if (pGroupObject->__pCheckedList != null)
1578         {
1579                 pGroupObject->__pCheckedList->RemoveAt(index, true);
1580         }
1581
1582         __directDelete = false;
1583
1584         CallUnloadItemCb(groupIndex, index);
1585         pGroupObject->__itemCount--;
1586
1587         return E_SUCCESS;
1588 }
1589
1590 result
1591 _SlidableGroupedListImpl::RemoveGroupAt(int groupIndex)
1592 {
1593         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1594                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1595
1596         result r = E_SUCCESS;
1597
1598         r = RemoveFromSubItemsList(groupIndex);
1599         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
1600
1601         r = RemoveFromItemsList(groupIndex, -1);
1602         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
1603
1604         __groupsList.RemoveAt(groupIndex, true);
1605
1606         __directDelete = true;
1607
1608         if (GetCore().GetFirstDrawnFlag() == false)
1609         {
1610                 r = GetCore().RefreshTableView(groupIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
1611                 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
1612         }
1613
1614         __directDelete = false;
1615
1616         return E_SUCCESS;
1617 }
1618
1619 void
1620 _SlidableGroupedListImpl::ScrollToBottom(void)
1621 {
1622         SysTryReturnVoidResult(NID_UI_CTRL, (__slidableListenersList.GetCount() > 0), E_SYSTEM,
1623                         "[E_SYSTEM] A system error has occurred. No listeners available.");
1624
1625         __forceScroll = true;
1626
1627         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(__groupsList.GetCount() - 1));
1628         SysTryReturnVoidResult(NID_UI_CTRL, pGroupObject, E_SYSTEM,
1629                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", __groupsList.GetCount() - 1);
1630
1631         result r = GetCore().SetBottomDrawnItemIndex(__groupsList.GetCount() - 1, pGroupObject->__itemCount - 1);
1632         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1633
1634         __forceScroll = false;
1635
1636         GetCore().Draw();
1637 }
1638
1639 result
1640 _SlidableGroupedListImpl::ScrollToTop(int groupIndex)
1641 {
1642         SysTryReturnResult(NID_UI_CTRL, (__slidableListenersList.GetCount() > 0), E_SYSTEM,
1643                         "[E_SYSTEM] A system error has occurred. No listeners available.");
1644
1645         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1646                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1647
1648         result r = E_SUCCESS;
1649
1650         __forceScroll = true;
1651
1652         r = GetCore().SetTopDrawnItemIndex(groupIndex, -1);
1653         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1654
1655         GetCore().Draw();
1656
1657         __forceScroll = false;
1658
1659         return E_SUCCESS;
1660 }
1661
1662 result
1663 _SlidableGroupedListImpl::ScrollToTop(int groupIndex, int itemIndex)
1664 {
1665         SysTryReturnResult(NID_UI_CTRL, (__slidableListenersList.GetCount() > 0), E_SYSTEM,
1666                         "[E_SYSTEM] A system error has occurred. No listeners available.");
1667
1668         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1669                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1670
1671         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1672         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1673                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at index (%d).", groupIndex);
1674
1675         SysTryReturn(NID_UI_CTRL, (itemIndex >= 0 && itemIndex < pGroupObject->__itemCount),
1676                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. itemIndex (%d).", itemIndex);
1677
1678         result r = E_SUCCESS;
1679
1680         __forceScroll = true;
1681
1682         r = GetCore().SetTopDrawnItemIndex(groupIndex, itemIndex);
1683         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1684
1685         GetCore().Draw();
1686
1687         __forceScroll = false;
1688
1689         return E_SUCCESS;
1690 }
1691
1692 void
1693 _SlidableGroupedListImpl::ScrollToTop(void)
1694 {
1695         SysTryReturnVoidResult(NID_UI_CTRL, (__slidableListenersList.GetCount() > 0), E_SYSTEM,
1696                         "[E_SYSTEM] A system error has occurred. No listeners available.");
1697
1698         __forceScroll = true;
1699
1700         result r = GetCore().SetTopDrawnItemIndex(0, -1);
1701         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1702
1703         GetCore().Draw();
1704
1705         __forceScroll = false;
1706 }
1707
1708 result
1709 _SlidableGroupedListImpl::SetAllItemsChecked(int groupIndex, bool check)
1710 {
1711         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM,
1712                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL.");
1713         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, E_SYSTEM,
1714                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_RADIO.");
1715
1716         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < GetGroupCount()),
1717                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1718
1719         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1720         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM, "[E_SYSTEM]");
1721
1722         for (int indexItem = 0; indexItem < pGroupObject->__itemCount; indexItem++)
1723         {
1724                 Boolean* pChecked = new (std::nothrow) Boolean(check);
1725                 SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed");
1726
1727                 pGroupObject->__pCheckedList->SetAt(*pChecked, indexItem, true);
1728
1729                 _CheckElementModel*pCheckElement = GetCheckElementAt(groupIndex, indexItem);
1730                 SysTryReturnResult(NID_UI_CTRL, (pCheckElement != null), E_SYSTEM, "A system error has occurred.");
1731
1732                 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1733         }
1734
1735         GetCore().Invalidate(true);
1736
1737         return E_SUCCESS;
1738 }
1739
1740 result
1741 _SlidableGroupedListImpl::SetItemAt(int groupIndex, int itemIndex, const CustomListItem& item, int itemId)
1742 {
1743         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1744                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1745
1746         SysTryReturn(NID_UI_CTRL, ((itemIndex >= 0) && (itemIndex < GetSubItemCountAt(groupIndex))),
1747                         E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. itemIndex (%d).", itemIndex);
1748
1749         SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item already exists.");
1750
1751         _CheckElementModel* pOldCheckElement = GetCheckElementAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex));
1752         _CheckElementModel* pNewCheckElement = item.__pCustomListItemImpl->GetCheckElement();
1753
1754         if (pNewCheckElement && pOldCheckElement)
1755         {
1756                 pNewCheckElement->SetCheckBoxStatus(pOldCheckElement->GetCheckBoxStatus());
1757         }
1758
1759         item.__pCustomListItemImpl->__pTableViewItemData = GetTableViewItemAt(groupIndex, itemIndex);
1760         item.__pCustomListItemImpl->itemId = itemId;
1761
1762         result r = SetInItemsList(item, groupIndex, itemIndex);
1763         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1764
1765         r = GetCore().RefreshTableView(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1766         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1767
1768         return E_SUCCESS;
1769 }
1770
1771 result
1772 _SlidableGroupedListImpl::UpdateCheckedList(int groupIndex, int index, bool check)
1773 {
1774         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1775         SysTryReturn(NID_UI_CTRL, (pGroupObject != null), E_SYSTEM, E_SYSTEM,
1776                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex);
1777
1778         SysTryReturn(NID_UI_CTRL, (pGroupObject->__pCheckedList != null), E_SYSTEM, E_SYSTEM,
1779                                 "[E_SYSTEM] A system error has occurred. Failed to get checked list at groupIndex (%d).", groupIndex);
1780
1781         Boolean* pChecked = new (std::nothrow) Boolean(check);
1782         SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1783         pGroupObject->__pCheckedList->SetAt(*pChecked, index, true);
1784
1785         return E_SUCCESS;
1786 }
1787
1788 result
1789 _SlidableGroupedListImpl::SetItemCheckedRadio(int groupIndex, int index, bool check)
1790 {
1791         if (check)
1792         {
1793                 if (_currentRadioIndex != -1)
1794                 {
1795                         _CheckElementModel* pOldCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex);
1796                         SysTryReturnResult(NID_UI_CTRL, (pOldCheckElement != null), E_SYSTEM, "A system error has occurred.");
1797
1798                         pOldCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1799
1800                         UpdateCheckedList(_currentRadioGroupIndex, _currentRadioIndex, false);
1801
1802                         DrawItem(_currentRadioGroupIndex, _currentRadioIndex);
1803                 }
1804
1805                 _currentRadioGroupIndex = groupIndex;
1806                 _currentRadioIndex = index;
1807
1808                 UpdateCheckedList(groupIndex, index, true);
1809         }
1810         else
1811         {
1812                 UpdateCheckedList(groupIndex, index, false);
1813
1814                 _currentRadioGroupIndex = -1;
1815                 _currentRadioIndex = -1;
1816         }
1817
1818         DrawItem(groupIndex, index);
1819
1820         return E_SUCCESS;
1821 }
1822
1823 result
1824 _SlidableGroupedListImpl::SetItemCheckedMarkOnOff(int groupIndex, int index, bool check)
1825 {
1826         _CheckElementModel* pCheckElement = GetCheckElementAt(groupIndex, index);
1827         SysTryReturnResult(NID_UI_CTRL, (pCheckElement != null), E_SYSTEM, "A system error has occurred.");
1828
1829         pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1830
1831         UpdateCheckedList(groupIndex, index, check);
1832
1833         DrawItem(groupIndex, index);
1834
1835         return E_SUCCESS;
1836 }
1837
1838 result
1839 _SlidableGroupedListImpl::SetItemChecked(int groupIndex, int index, bool check)
1840 {
1841         SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, E_SYSTEM,
1842                         "[E_SYSTEM] A system error has occurred. The list style is CUSTOM_LIST_STYLE_NORMAL.");
1843
1844         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1845                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1846
1847         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1848         SysTryReturn(NID_UI_CTRL, (pGroupObject != null), E_SYSTEM, E_SYSTEM,
1849                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex);
1850
1851         SysTryReturn(NID_UI_CTRL, (index >= 0 && index < pGroupObject->__itemCount),
1852                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index);
1853
1854         if (IsItemChecked(groupIndex, index) == check)
1855         {
1856                 return E_SUCCESS;
1857         }
1858
1859         SysTryReturnResult(NID_UI_CTRL, (GetCore().IsItemEnabled(groupIndex, index)), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The list item is not enabled.");
1860
1861         if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1862         {
1863                 return SetItemCheckedRadio(groupIndex, index, check);
1864         }
1865         else
1866         {
1867                 return SetItemCheckedMarkOnOff(groupIndex, index, check);
1868         }
1869 }
1870
1871 result
1872 _SlidableGroupedListImpl::SetLoadedItemEnabled(int groupIndex, int index, bool enable)
1873 {
1874         SysTryReturn(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1875                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. groupIndex (%d).", groupIndex);
1876
1877         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1878         SysTryReturn(NID_UI_CTRL, pGroupObject, E_SYSTEM, E_SYSTEM,
1879                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex);
1880
1881         SysTryReturn(NID_UI_CTRL, (index >= 0 && index < pGroupObject->__itemCount),
1882                                 E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. index (%d).", index);
1883
1884         return GetCore().SetItemEnabled(groupIndex, index, enable);
1885 }
1886
1887 void
1888 _SlidableGroupedListImpl::SetTextColorOfEmptyList(const Color& color)
1889 {
1890         GetCore().SetTextColorOfEmptyTableView(color);
1891 }
1892
1893 void
1894 _SlidableGroupedListImpl::SetTextOfEmptyList(const String& text)
1895 {
1896         GetCore().SetTextOfEmptyTableView(text);
1897 }
1898
1899 result
1900 _SlidableGroupedListImpl::SetGroupAt(int groupIndex, const String& text, const Bitmap* pBackgroundBitmap, int groupId)
1901 {
1902         result r = E_SUCCESS;
1903
1904         SysTryReturnResult(NID_UI_CTRL, (groupIndex >= 0 && groupIndex < __groupsList.GetCount()),
1905                                 E_INVALID_ARG, "Invalid argument is used. groupIndex (%d).", groupIndex);
1906
1907         _SlidableGroupObject* pOldGroup = dynamic_cast<_SlidableGroupObject*>(__groupsList.GetAt(groupIndex));
1908         SysTryReturn(NID_UI_CTRL, pOldGroup, E_SYSTEM, E_SYSTEM,
1909                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex);
1910
1911         CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1);
1912         SysTryReturn(NID_UI_CTRL, (pCustomListItem), E_SYSTEM, E_SYSTEM,
1913                         "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at groupIndex (%d).", groupIndex);
1914
1915         pCustomListItem->SetElement(ID_FORMAT_STRING, text);
1916
1917         if (pBackgroundBitmap != null)
1918         {
1919                 pCustomListItem->SetNormalItemBackgroundBitmap(*pBackgroundBitmap);
1920         }
1921
1922         pCustomListItem->__pCustomListItemImpl->itemId = groupId;
1923
1924         _TableViewItemUpdateParams updateParams;
1925         updateParams.pItem = pCustomListItem;
1926         updateParams.isDividerEnabled = _isDividerEnabled;
1927         updateParams.pCheckBitmaps = _pCheckBitmaps;
1928         updateParams.annexStyle = _annexStyle;
1929
1930         r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
1931         SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to update an item.");
1932
1933         return E_SUCCESS;
1934 }
1935
1936 void
1937 _SlidableGroupedListImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1938 {
1939         return;
1940 }
1941
1942 void
1943 _SlidableGroupedListImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated)
1944 {
1945         return;
1946 }
1947
1948 void
1949 _SlidableGroupedListImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo)
1950 {
1951         return;
1952 }
1953
1954 void
1955 _SlidableGroupedListImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem, TableViewItemStatus status)
1956 {
1957         return;
1958 }
1959
1960 void
1961 _SlidableGroupedListImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1962 {
1963         CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex));
1964         SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at itemIndex (%d).", itemIndex);
1965
1966         CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL;
1967         ItemStatus itemStatus = ITEM_HIGHLIGHTED;
1968
1969         switch (status)
1970         {
1971         case TABLE_VIEW_ITEM_STATUS_SELECTED:
1972                 itemStatus = ITEM_SELECTED;
1973                 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED;
1974                 break;
1975         case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED:
1976                 itemStatus = ITEM_HIGHLIGHTED;
1977                 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED;
1978                 break;
1979         case TABLE_VIEW_ITEM_STATUS_CHECKED:
1980                 itemStatus = ITEM_CHECKED;
1981                 break;
1982         case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
1983                 itemStatus = ITEM_UNCHECKED;
1984                 break;
1985         default:
1986                 SetLastResult(E_INVALID_ARG);
1987                 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument is used. ListItemStatus is invalid");
1988                 return;
1989         }
1990
1991         LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements;
1992         _ElementBaseModel* pElementBase = null;
1993
1994         for (int i = 0; i < pElements->GetCount(); i++)
1995         {
1996                 pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i));
1997                 SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "Invalid element.");
1998
1999                 if ((_isDividerEnabled && pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX) || (!_isDividerEnabled))
2000                 {
2001                         pElementBase->HandleElementEvent(customListItemStatus);
2002                 }
2003         }
2004
2005         if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL))
2006         {
2007                 bool isChecked = IsItemChecked(groupIndex, itemIndex);
2008
2009                 if (isChecked)
2010                 {
2011                         itemStatus = ITEM_UNCHECKED;
2012                 }
2013                 else
2014                 {
2015                         itemStatus = ITEM_CHECKED;
2016                 }
2017
2018                 SetItemChecked(groupIndex, itemIndex, !isChecked);
2019         }
2020
2021         ProcessItemStateChange(groupIndex, itemIndex, itemStatus);
2022
2023         GetCore().Draw();
2024         return;
2025 }
2026
2027 void
2028 _SlidableGroupedListImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pContextItem, bool activated)
2029 {
2030         return;
2031 }
2032
2033 void
2034 _SlidableGroupedListImpl::OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo)
2035 {
2036         return;
2037 }
2038
2039 void
2040 _SlidableGroupedListImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
2041 {
2042         return;
2043 }
2044
2045 void
2046 _SlidableGroupedListImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pContextItem, bool activated)
2047 {
2048         return;
2049 }
2050
2051 void
2052 _SlidableGroupedListImpl::OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction)
2053 {
2054         return;
2055 }
2056
2057 void
2058 _SlidableGroupedListImpl::OnDraw(void)
2059 {
2060         if (__pItemProvider == null)
2061         {
2062                 result r = E_SUCCESS;
2063
2064                 r = CreateItemProvider();
2065                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
2066         }
2067
2068         _ListBaseImpl::OnDraw();
2069 }
2070
2071 result
2072 _SlidableGroupedListImpl::CreateItemProvider(void)
2073 {
2074         if (__pItemProvider == null)
2075         {
2076                 __pItemProvider = new (std::nothrow) _SlidableGroupedListItemProvider(this);
2077                 SysTryReturnResult(NID_UI_CTRL, __pItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2078
2079                 TableViewStyle style = GetCore().GetTableViewStyle();
2080                 SysTryReturnResult(NID_UI_CTRL, style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION,
2081                                 "[E_INVALID_OPERATION] The style of TableView is not TABLE_VIEW_STYLE_GROUPED");
2082
2083                 _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
2084                 result r = GetLastResult();
2085                 SysTryReturnResult(NID_UI_CTRL, pItemProvider != null, r, "[%s] Propagating.", GetErrorMessage(r));
2086
2087                 pItemProvider->SetGroupedStyleItemProvider(__pItemProvider);
2088
2089                 GetCore().SetItemProvider(pItemProvider);
2090         }
2091
2092         return E_SUCCESS;
2093 }
2094
2095 void
2096 _SlidableGroupedListImpl::Initialize(void)
2097 {
2098         GetCore().AddGroupedTableViewItemEventListener(*this);
2099         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_HEIGHT, GetCore().GetOrientation(), __groupItemHeight);
2100         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_DEFAULT_FONT_SIZE, GetCore().GetOrientation(), __groupItemTextFont);
2101
2102         __itemCacheSize = GetCore().GetMaxItemCachingSize();
2103
2104         __pItemFormat = new (std::nothrow) CustomListItemFormat();
2105         SysTryReturnVoidResult(NID_UI_CTRL, __pItemFormat, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
2106
2107         __pItemFormat->Construct();
2108
2109         int leftMargin = 0;
2110         GET_SHAPE_CONFIG(TABLEVIEW::GROUPITEM_INDEX_BAR_LEFT_MARGIN, GetCore().GetOrientation(), leftMargin);
2111
2112         __pItemFormat->AddElement(ID_FORMAT_MARGIN, Rectangle(0, 0, leftMargin, __groupItemHeight), __groupItemTextFont);
2113         __pItemFormat->AddElement(ID_FORMAT_STRING, Rectangle(leftMargin, 0, GetCore().GetBounds().width, __groupItemHeight), __groupItemTextFont);
2114
2115         __pItemFormat->SetElementEventEnabled(ID_FORMAT_MARGIN, true);
2116         __pItemFormat->SetElementEventEnabled(ID_FORMAT_STRING, true);
2117
2118         return;
2119 }
2120
2121 void
2122 _SlidableGroupedListImpl::OnUiFastScrollIndexSelected(_Control& source, _FastScrollIndex& index)
2123 {
2124         int groupIndex = 0;
2125         mchar mch = L' ';
2126         String* pIndexText = index.GetIndexText();
2127         if (pIndexText != null)
2128         {
2129                 pIndexText->GetCharAt(0, mch);
2130                 result r = __mainScrollIndex.IndexOf(*pIndexText, 0, groupIndex);
2131                 if (!IsFailed(r))
2132                 {
2133                         const Control& control = GetPublic();
2134                         _FastScrollIndex* pMainIndex = index.GetParentIndex();
2135                         if (pMainIndex == GetCore().GetFastScrollBar()->GetIndex())
2136                         {
2137                                 Character mainIndex(mch);
2138                                 __pFastScrollListener->OnMainIndexChanged(control, mainIndex);
2139                         }
2140                         else
2141                         {
2142                                 Character subIndex(mch);
2143                                 pIndexText = pMainIndex->GetIndexText();
2144                                 if (pIndexText != null)
2145                                 {
2146                                         pIndexText->GetCharAt(0, mch);
2147                                         Character mainIndex(mch);
2148                                         __pFastScrollListener->OnSubIndexChanged(control, mainIndex, subIndex);
2149                                 }
2150                         }
2151                 }
2152         }
2153         SetLastResult(E_SUCCESS);
2154 }
2155
2156 const char*
2157 _SlidableGroupedListImpl::GetPublicClassName(void) const
2158 {
2159         return "SlidableGroupedList";
2160 }
2161
2162 const SlidableGroupedList&
2163 _SlidableGroupedListImpl::GetPublic(void) const
2164 {
2165         return static_cast<const SlidableGroupedList&>(_ControlImpl::GetPublic());
2166 }
2167
2168 SlidableGroupedList&
2169 _SlidableGroupedListImpl::GetPublic(void)
2170 {
2171         return static_cast<SlidableGroupedList&>(_ControlImpl::GetPublic());
2172 }
2173
2174 const _TableView&
2175 _SlidableGroupedListImpl::GetCore(void) const
2176 {
2177         return static_cast<const _TableView&>(_ControlImpl::GetCore());
2178 }
2179
2180 _TableView&
2181 _SlidableGroupedListImpl::GetCore(void)
2182 {
2183         return static_cast<_TableView&>(_ControlImpl::GetCore());
2184 }
2185
2186 void
2187 _SlidableGroupedListImpl::ProcessItemStateChange(int groupIndex, int itemIndex, int elementId, ItemStatus itemStatus)
2188 {
2189         CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex));
2190         SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at itemIndex (%d).", itemIndex);
2191
2192         int itemId = pCustomListItem->__pCustomListItemImpl->itemId;
2193
2194         _ListListener* pListenerList = null;
2195         IGroupedItemEventListener* pEventListener = null;
2196
2197         for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
2198         {
2199                 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
2200                 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM,
2201                                 "[E_SYSTEM] A system error has occurred. Failed to get _ListListener.");
2202
2203                 pEventListener = dynamic_cast<IGroupedItemEventListener*>(pListenerList->pListener);
2204                 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM,
2205                                 "[E_SYSTEM] A system error has occurred. Failed to get IGroupedItemEventListener.");
2206
2207                 pEventListener->OnItemStateChanged(GetPublic(), groupIndex, itemIndex, itemId, elementId, itemStatus);
2208         }
2209 }
2210
2211 void
2212 _SlidableGroupedListImpl::ProcessItemStateChange(int groupIndex, int itemIndex, ItemStatus itemStatus)
2213 {
2214         CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex));
2215         SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get CustomListItem at itemIndex (%d).", itemIndex);
2216
2217         int itemId = pCustomListItem->__pCustomListItemImpl->itemId;
2218
2219         _ListListener* pListenerList = null;
2220         IGroupedItemEventListener* pEventListener = null;
2221
2222         for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
2223         {
2224                 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
2225                 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM,
2226                                 "[E_SYSTEM] A system error has occurred. Failed to get _ListListener.");
2227
2228                 pEventListener = dynamic_cast<IGroupedItemEventListener*>(pListenerList->pListener);
2229                 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM,
2230                                 "[E_SYSTEM] A system error has occurred. Failed to get IGroupedItemEventListener.");
2231
2232                 pEventListener->OnItemStateChanged(GetPublic(), groupIndex, itemIndex, itemId, itemStatus);
2233         }
2234 }
2235
2236 void
2237 _SlidableGroupedListImpl::CallUnloadItemCb(int groupIndex, int itemIndex)
2238 {
2239         _ListListener* pListenerData = null;
2240         ISlidableGroupedListEventListener* pSlidableListener = null;
2241
2242         for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++)
2243         {
2244                 pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount));
2245                 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerData != null), E_SYSTEM,
2246                                 "[E_SYSTEM] A system error has occurred. Failed to get _ListListener.");
2247
2248                 pSlidableListener = dynamic_cast<ISlidableGroupedListEventListener*>(pListenerData->pListener);
2249                 SysTryReturnVoidResult(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM,
2250                                 "[E_SYSTEM] A system error has occurred. Failed to get IGroupedItemEventListener.");
2251
2252                 pSlidableListener->OnUnloadItemRequested(GetPublic(), groupIndex, itemIndex);
2253         }
2254 }
2255
2256 int
2257 _SlidableGroupedListImpl::GetCurrentLoadedCount(void)
2258 {
2259         int count = 0;
2260
2261         for (int groupIndex = __topGroup; groupIndex <= __bottomGroup; groupIndex++)
2262         {
2263                 _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(groupIndex);
2264
2265                 if (pTableViewGroupItemData)
2266                 {
2267                         count++;
2268                 }
2269
2270                 count += GetSubItemCountAt(groupIndex);
2271         }
2272
2273         return count;
2274 }
2275
2276 int
2277 _SlidableGroupedListImpl::GetTopItemIndex(int groupIndex) const
2278 {
2279         _SlidableGroupObject* pGroupObject = dynamic_cast<_SlidableGroupObject*>(const_cast<Object*>(__groupsList.GetAt(groupIndex)));
2280         SysTryReturn(NID_UI_CTRL, pGroupObject, INVALID_INDEX, E_SYSTEM,
2281                         "[E_SYSTEM] A system error has occurred. Failed to get _SlidableGroupObject at groupIndex (%d).", groupIndex);
2282
2283         return pGroupObject->__topIndex;
2284 }
2285
2286 class _SlidableGroupedListMaker
2287         : public _UiBuilderControlMaker
2288 {
2289 public:
2290         _SlidableGroupedListMaker(_UiBuilder* uibuilder)
2291                 : _UiBuilderControlMaker(uibuilder){};
2292         virtual ~_SlidableGroupedListMaker(){};
2293         static _UiBuilderControlMaker*
2294         GetInstance(_UiBuilder* uibuilder)
2295         {
2296                 _SlidableGroupedListMaker* pSlidableListMaker = new (std::nothrow) _SlidableGroupedListMaker(uibuilder);
2297                 return pSlidableListMaker;
2298         };
2299 protected:
2300         virtual Tizen::Ui::Control*
2301         Make(_UiBuilderControl* pControl)
2302         {
2303                 result r = E_SYSTEM;
2304                 _UiBuilderControlLayout* pControlProperty = null;
2305                 SlidableGroupedList* pSlidableGroupedList = null;
2306                 Tizen::Graphics::Rectangle rect;
2307                 Tizen::Graphics::Rectangle rectMin;
2308                 Dimension dimMin;
2309                 Tizen::Base::String elementString;
2310                 CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL;
2311                 bool isItemDivider = true;
2312                 Color color;
2313
2314                 GetProperty(pControl, &pControlProperty);
2315                 if (pControlProperty == null)
2316                 {
2317                         return null;
2318                 }
2319
2320                 pSlidableGroupedList = new (std::nothrow) SlidableGroupedList();
2321                 if (pSlidableGroupedList == null)
2322                 {
2323                         return null;
2324                 }
2325
2326                 rect = pControlProperty->GetRect();
2327
2328                 Tizen::Base::String styleString;
2329                 styleString = pControlProperty->GetStyle();
2330
2331                 if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false))
2332                 {
2333                         style = CUSTOM_LIST_STYLE_NORMAL;
2334                 }
2335                 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false))
2336                 {
2337                         style = CUSTOM_LIST_STYLE_RADIO;
2338                 }
2339                 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false))
2340                 {
2341                         style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER;
2342                 }
2343                 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false))
2344                 {
2345                         style = CUSTOM_LIST_STYLE_MARK;
2346                 }
2347                 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false))
2348                 {
2349                         style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER;
2350                 }
2351                 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false))
2352                 {
2353                         style = CUSTOM_LIST_STYLE_ONOFF;
2354                 }
2355                 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false))
2356                 {
2357                         style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER;
2358                 }
2359                 else
2360                 {
2361                         style = CUSTOM_LIST_STYLE_NORMAL;
2362                 }
2363
2364                 //Construct
2365                 if (pControl->GetElement(L"itemDivider", elementString))
2366                 {
2367                         if (elementString.Equals(L"true", false))
2368                         {
2369                                 isItemDivider = true;
2370                         }
2371                         else
2372                         {
2373                                 isItemDivider = false;
2374                         }
2375                 }
2376
2377                 r = pSlidableGroupedList->Construct(rect, style, isItemDivider);
2378                 if (r != E_SUCCESS)
2379                 {
2380                         delete pSlidableGroupedList;
2381                         return null;
2382                 }
2383
2384                 if (pControl->GetElement(L"textOfEmptyList", elementString))
2385                 {
2386                         pSlidableGroupedList->SetTextOfEmptyList(elementString);
2387                 }
2388
2389                 if (pControl->GetElement(L"colorOfEmptyListText", elementString))
2390                 {
2391                         ConvertStringToColor(elementString, color);
2392                         pSlidableGroupedList->SetTextColorOfEmptyList(color);
2393                 }
2394
2395                 GET_DIMENSION_CONFIG(LIST::GROUPEDLIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin);
2396                 rectMin = (pControl->GetAttribute(0))->GetRect();
2397                 (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
2398
2399                 GET_DIMENSION_CONFIG(LIST::GROUPEDLIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin);
2400                 rectMin = (pControl->GetAttribute(1))->GetRect();
2401                 (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
2402
2403                 return pSlidableGroupedList;
2404         }
2405
2406 private:
2407 };
2408
2409 _SlidableGroupedListRegister::_SlidableGroupedListRegister()
2410 {
2411         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2412         if (pUiBuilderControlTableManager)
2413         {
2414                 pUiBuilderControlTableManager->RegisterControl(L"SlidableGroupedList", _SlidableGroupedListMaker::GetInstance);
2415         }
2416 }
2417 _SlidableGroupedListRegister::~_SlidableGroupedListRegister()
2418 {
2419         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2420         if (pUiBuilderControlTableManager)
2421         {
2422                 pUiBuilderControlTableManager->UnregisterControl(L"SlidableGroupedList");
2423         }
2424 }
2425 static _SlidableGroupedListRegister SlidableGroupedListRegisterToUiBuilder;
2426 }}} //Tizen::Ui::Controls