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