2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an ”AS IS” BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_SlidableListImpl.cpp
20 * @brief This is the implementation file for the _SlidableListImpl class.
23 #include <FUiCtrlCustomListItem.h>
24 #include <FUiCtrlCustomListItemFormat.h>
25 #include "FUiCtrl_CustomListItemFormatImpl.h"
26 #include "FUiCtrl_CustomListItemImpl.h"
27 #include "FUiCtrl_SlidableListImpl.h"
28 #include "FUiCtrl_ListListener.h"
29 #include "FUi_ResourceSizeInfo.h"
30 #include "FUi_ResourceManager.h"
31 #include "FUiCtrl_ListItemBaseImpl.h"
32 #include "FUi_UiBuilder.h"
33 #include "FUiCtrl_TableViewItemProvider.h"
34 #include "FUiCtrl_TableViewPresenter.h"
35 #include "FUi_CoordinateSystemUtils.h"
38 using namespace Tizen::Base;
39 using namespace Tizen::Ui;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::App;
42 using namespace Tizen::Base;
43 using namespace Tizen::Ui;
44 using namespace Tizen::Ui::Controls;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Media;
47 using namespace Tizen::Base::Collection;
50 namespace Tizen { namespace Ui { namespace Controls
53 extern const int INVALID_INDEX;
55 _SlidableListItemProvider::_SlidableListItemProvider(_SlidableListImpl* pList)
57 , bottomListenerIndex(0)
63 topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1;
68 _SlidableListItemProvider::GetItemCount(void)
70 SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
72 if (__pListImpl->__slidableListenersList.GetCount() > 0)
74 if (firstTime == true)
76 _ListListener* pListenerData = null;
77 ISlidableListEventListener* pSlidableListener = null;
78 int listenerCount = 0;
80 for (listenerCount = 0; listenerCount < __pListImpl->__slidableListenersList.GetCount(); listenerCount++)
82 pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(listenerCount));
86 pSlidableListener = dynamic_cast<ISlidableListEventListener*>(pListenerData->pListener);
87 SysTryReturn(NID_UI_CTRL, (pSlidableListener != null), -1, E_SYSTEM,
88 "[E_SYSTEM] A system error has occurred. Failed to get EventListener.");
90 pSlidableListener->OnListPropertyRequested(__pListImpl->GetPublic());
97 return __pListImpl->__totalItemCount;
106 _SlidableListItemProvider::CallLoadToTopCb(int index)
108 _ListListener* pListenerData = null;
109 ISlidableListEventListener* pSlidableListener = null;
111 pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(topListenerIndex));
112 SysTryReturn(NID_UI_CTRL, pListenerData, E_SYSTEM, E_SYSTEM,
113 "[E_SYSTEM] A system error has occurred. Failed to get the listener.");
115 pSlidableListener = dynamic_cast<ISlidableListEventListener*>(pListenerData->pListener);
116 SysTryReturn(NID_UI_CTRL, pSlidableListener, E_SYSTEM, E_SYSTEM,
117 "[E_SYSTEM] A system error has occurred. Failed to get the listener.");
119 pSlidableListener->OnLoadToTopRequested(__pListImpl->GetPublic(), index, 1);
121 if (--topListenerIndex < 0)
123 topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1;
130 _SlidableListItemProvider::UpdateCheckStatus(int index)
132 if (__pListImpl->_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
134 if (__pListImpl->_currentRadioIndex == index)
136 _CheckElementModel* pOldCheckElement = __pListImpl->GetCheckElementAt(-1, __pListImpl->_currentRadioIndex - __pListImpl->__topIndex);
138 if (pOldCheckElement)
140 pOldCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED);
144 else if (__pListImpl->__pCheckedList)
146 Boolean* pChecked = dynamic_cast<Boolean*>(__pListImpl->__pCheckedList->GetAt(index));
147 _CheckElementModel* pCheckElement = __pListImpl->GetCheckElementAt(-1, index - __pListImpl->__topIndex);
149 if (pCheckElement && pChecked)
151 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)pChecked->ToBool());
158 _SlidableListItemProvider::LoadAtTop(int index)
160 _TableViewItemData* pTableViewItemData = null;
161 result r = E_SUCCESS;
163 r = CallLoadToTopCb(index);
164 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
166 __pListImpl->__topIndex = index;
168 pTableViewItemData = __pListImpl->GetTableViewItemAt(-1, 0);
170 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
172 r = UpdateCheckStatus(index);
173 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
175 return pTableViewItemData;
179 _SlidableListItemProvider::CallLoadToBottomCb(int index)
181 _ListListener* pListenerData = null;
182 ISlidableListEventListener* pSlidableListener = null;
184 pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(bottomListenerIndex));
185 SysTryReturn(NID_UI_CTRL, pListenerData, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the listener.");
187 pSlidableListener = dynamic_cast<ISlidableListEventListener*>(pListenerData->pListener);
188 SysTryReturn(NID_UI_CTRL, pSlidableListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the listener.");
190 pSlidableListener->OnLoadToBottomRequested(__pListImpl->GetPublic(), index, 1);
192 if (++bottomListenerIndex == __pListImpl->__slidableListenersList.GetCount())
194 bottomListenerIndex = 0;
201 _SlidableListItemProvider::LoadAtBottom(int index)
203 _TableViewItemData* pTableViewItemData = null;
204 result r = E_SUCCESS;
206 r = CallLoadToBottomCb(index);
207 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
209 pTableViewItemData = __pListImpl->GetTableViewItemAt(-1, __pListImpl->_itemsList.GetCount() - 1);
211 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
213 r = UpdateCheckStatus(index);
214 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
216 if (__pListImpl->_itemsList.GetCount() == 1)
218 __pListImpl->__topIndex = index;
220 return pTableViewItemData;
224 _SlidableListItemProvider::CreateItem(int index, int itemWidth)
226 SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
228 _TableViewItemData* pItem = null;
229 pItem = __pListImpl->GetTableViewItemAt(-1, index - __pListImpl->__topIndex);
231 result r = E_SUCCESS;
233 __pListImpl->__isCreating = true;
237 if (index < __pListImpl->__topIndex) // load at top
239 pItem = LoadAtTop(index);
241 else // load at bottom
243 pItem = LoadAtBottom(index);
246 SysTryReturn(NID_UI_CTRL, pItem, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
249 __pListImpl->__isCreating = false;
255 _SlidableListItemProvider::DeleteItem(int index, TableViewItem* pItem)
257 SysTryReturn(NID_UI_CTRL, __pListImpl, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
259 __pListImpl->CallUnloadItemCb(index);
261 result r = E_SUCCESS;
263 if (__pListImpl->__isForcedScroll == true)
265 r = __pListImpl->_itemsList.RemoveAt(0, true);
266 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
268 else if (__pListImpl->_itemsList.GetCount() >= __pListImpl->__itemCacheSize)
270 if (index <= __pListImpl->__topIndex)
272 r = __pListImpl->_itemsList.RemoveAt(0, true);
273 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
275 __pListImpl->__topIndex++;
279 r = __pListImpl->_itemsList.RemoveAt(__pListImpl->_itemsList.GetCount() - 1, true);
280 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
283 else if (__pListImpl->__isFullUpdate == true)
285 r = __pListImpl->_itemsList.RemoveAt(__pListImpl->_itemsList.GetCount() - 1, true);
286 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
289 _TableViewItemData* pTableViewItemData = dynamic_cast<_TableViewItemData*>(pItem);
290 delete pTableViewItemData;
296 _SlidableListItemProvider::UpdateItem(int itemIndex, TableViewItem* pItem)
302 _SlidableListItemProvider::GetDefaultItemHeight()
304 SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List instance must not be null.");
306 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(__pListImpl->_itemsList.GetAt(0));
310 _CustomListItemImpl* pCustomListItemImpl = null;
311 pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl;
312 SysTryReturn(NID_UI_CTRL, pCustomListItemImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null");
313 return pCustomListItemImpl->height;
317 return __pListImpl->LISTVIEW_ITEM_HEIGHT;
322 _SlidableListImpl::GetInstance(SlidableList& slidableList)
324 return static_cast<_SlidableListImpl*>(slidableList._pControlImpl);
327 const _SlidableListImpl*
328 _SlidableListImpl::GetInstance(const SlidableList& slidableList)
330 return static_cast<const _SlidableListImpl*>(slidableList._pControlImpl);
333 _SlidableListImpl::_SlidableListImpl(Control* pList, _TableView* pCore)
334 : _ListBaseImpl(pList, pCore)
335 , __pCheckedList(null)
336 , __totalItemCount(-1)
338 , __pItemProvider(null)
339 , __isFullUpdate(false)
340 , __isCreating(false)
342 , __isForcedScroll(false)
346 _SlidableListImpl::~_SlidableListImpl(void)
348 if (__pItemProvider && __pItemProvider->firstTime == true)
350 _itemsList.RemoveAll(true);
354 _itemsList.RemoveAll(false);
357 __slidableListenersList.RemoveAll(true);
358 __itemListenersList.RemoveAll(true);
362 __pCheckedList->RemoveAll(true);
363 delete __pCheckedList;
368 delete __pItemProvider;
369 __pItemProvider = null;
374 _SlidableListImpl::GetPublicClassName(void) const
376 return "Tizen::Ui::Controls::SlidableList";
380 _SlidableListImpl::GetPublic(void) const
382 return static_cast<const SlidableList&>(_ControlImpl::GetPublic());
386 _SlidableListImpl::GetPublic(void)
388 return static_cast<SlidableList&>(_ControlImpl::GetPublic());
392 _SlidableListImpl::GetCore(void) const
394 return static_cast<const _TableView&>(_ControlImpl::GetCore());
398 _SlidableListImpl::GetCore(void)
400 return static_cast<_TableView&>(_ControlImpl::GetCore());
404 _SlidableListImpl::CreateSlidableListImplN(SlidableList* pControl, const Rectangle& bounds, bool itemDivider)
406 result r = E_SUCCESS;
408 r = GET_SIZE_INFO(SlidableList).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
414 _TableView* pList = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_SIMPLE, itemDivider, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
416 SysTryReturn(NID_UI_CTRL, pList, null, r, "[%s] Failed to create ListView instance", GetErrorMessage(r));
418 _SlidableListImpl* pImpl = new (std::nothrow) _SlidableListImpl(pControl, pList);
419 SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
429 _SlidableListImpl::UpdateBounds(const Rectangle& rect)
431 result r = E_SUCCESS;
433 r = InitializeBoundsPropertiesF(GET_SIZE_INFO(SlidableList), _CoordinateSystemUtils::ConvertToFloat(rect), GetCore().GetOrientation());
434 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
440 _SlidableListImpl::AddSlidableListEventListener(const ISlidableListEventListener& listener)
442 _ListListener* pListenerData = new (std::nothrow) _ListListener;
443 SysTryReturnVoidResult(NID_UI_CTRL, pListenerData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
445 pListenerData->pListener = const_cast<ISlidableListEventListener*>(&listener);
446 __slidableListenersList.Add(*pListenerData);
450 _SlidableListImpl::RemoveSlidableListEventListener(const ISlidableListEventListener& listener)
452 _ListListener* pListenerData = null;
454 for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++)
456 pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount));
458 if ((pListenerData != null) && (pListenerData->pListener == &listener))
460 __slidableListenersList.RemoveAt(listenerCount, true);
467 _SlidableListImpl::AddCustomItemEventListener(const ICustomItemEventListener& listener)
469 _ListListener* pListenersList = new (std::nothrow) _ListListener;
470 SysTryReturnVoidResult(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
472 pListenersList->pListener = const_cast<Tizen::Ui::ICustomItemEventListener*>(&listener);
474 __itemListenersList.Add(*pListenersList);
478 _SlidableListImpl::AddItem(const CustomListItem& item, int itemId)
480 return InsertItemAt((_itemsList.GetCount() + __topIndex), item, itemId);
484 _SlidableListImpl::GetBottomDrawnItemIndex(void) const
488 result r = E_SUCCESS;
489 r = GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
490 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM,
491 "[E_SYSTEM] A system error has occurred. Failed to get the bottom drawn item index.");
497 _SlidableListImpl::GetFirstCheckedItemIndex(void) const
499 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM,
500 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
502 for (int itemIndex = 0; itemIndex < __totalItemCount; itemIndex++)
504 if (IsItemChecked(itemIndex))
506 SetLastResult(E_SUCCESS);
511 SetLastResult(E_SUCCESS);
512 return INVALID_INDEX;
516 _SlidableListImpl::GetFirstLoadedItemIndex(void) const
518 result r = E_SUCCESS;
522 r = GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
523 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r, "[%s] Propagating.", GetErrorMessage(r));
529 _SlidableListImpl::GetLastLoadedItemIndex(void) const
531 result r = E_SUCCESS;
535 r = GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
536 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r, "[%s] Propagating.", GetErrorMessage(r));
542 _SlidableListImpl::GetItemCount(void) const
544 return __totalItemCount;
548 _SlidableListImpl::GetItemIndexFromItemId(int itemId) const
550 _TableViewItemData* pTableViewItemData = null;
551 CustomListItem* pCustomListItem = null;
553 for (int index = 0; index < _itemsList.GetCount(); index++)
555 pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(index)));
556 SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM,
557 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", index);
559 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM,
560 "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
562 pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
563 SysTryReturn(NID_UI_CTRL, pTableViewItemData, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null.");
565 if ((pTableViewItemData != null) && (pCustomListItem->__pCustomListItemImpl->itemId == itemId))
567 SetLastResult(E_SUCCESS);
571 SetLastResult(E_SUCCESS);
572 return INVALID_INDEX;
576 _SlidableListImpl::GetItemIndexFromPosition(const Point& position) const
581 result r = GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
582 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
589 _SlidableListImpl::GetItemIndexFromPosition(int x, int y) const
594 result r = GetCore().GetItemIndexFromPosition(Tizen::Graphics::Point(x, y), groupIndex, itemIndex);
595 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
601 _SlidableListImpl::GetLastCheckedItemIndex(void) const
603 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM,
604 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
606 for (int itemIndex = __totalItemCount - 1; itemIndex > 0; itemIndex--)
608 if (IsItemChecked(itemIndex))
610 SetLastResult(E_SUCCESS);
614 SetLastResult(E_SUCCESS);
615 return INVALID_INDEX;
618 const CustomListItem*
619 _SlidableListImpl::GetLoadedItemAt(int index) const
621 SysTryReturn(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex), null, E_INVALID_ARG,
622 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, _itemsList.GetCount());
624 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(index - __topIndex)));
625 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM,
626 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex));
628 SetLastResult(E_SUCCESS);
629 return pCustomListItem;
633 _SlidableListImpl::GetLoadedItemIdAt(int index) const
635 SysTryReturn(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex), INVALID_INDEX, E_INVALID_ARG,
636 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, _itemsList.GetCount());
638 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(index - __topIndex)));
639 SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM,
640 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex));
642 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM,
643 "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
645 SetLastResult(E_SUCCESS);
646 return pCustomListItem->__pCustomListItemImpl->itemId;
650 _SlidableListImpl::GetNextCheckedItemIndexAfter(int index) const
652 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM,
653 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL.");
655 SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), INVALID_INDEX, E_INVALID_ARG,
656 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount);
658 for (int itemIndex = index + 1; itemIndex < __totalItemCount; itemIndex++)
660 if (IsItemChecked(itemIndex))
662 SetLastResult(E_SUCCESS);
666 SetLastResult(E_SUCCESS);
667 return INVALID_INDEX;
672 _SlidableListImpl::GetTopDrawnItemIndex(void) const
674 int topItemIndex = -1;
676 result r = E_SUCCESS;
678 r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex);
679 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM,
680 "[E_SYSTEM] A system error has occurred. Failed to get the top drawn item index.");
686 _SlidableListImpl::InsertItemAt(int index, const CustomListItem& item, int itemId)
688 SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (_itemsList.GetCount() + __topIndex)), E_INVALID_ARG,
689 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).",
690 index, (_itemsList.GetCount() + __topIndex));
692 _TableViewItemParams tableViewItemParams;
693 tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
694 tableViewItemParams.width = GetCore().GetBoundsF().width;
695 tableViewItemParams.itemIndex = index;
696 tableViewItemParams.groupIndex = -1;
697 tableViewItemParams.isDividerEnabled = _isDividerEnabled;
698 tableViewItemParams.pCheckBitmaps = _pCheckBitmaps;
699 tableViewItemParams.annexStyle = _annexStyle;
701 item.__pCustomListItemImpl->itemId = itemId;
703 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
704 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
705 "[%s] A system error has occurred. Failed to create an item.", GetErrorMessage(r));
707 r = InsertIntoItemsList(item, -1, index - __topIndex);
708 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
709 "[%s] A system error has occurred. Failed to insert an item at index %d.", GetErrorMessage(r), (index));
713 Boolean *pChecked = new (std::nothrow) Boolean(false);
714 SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
716 __pCheckedList->InsertAt(*pChecked, index);
719 if (GetCore().GetFirstDrawnFlag() == false)
721 r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
722 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
723 "[%s] A system error has occurred. Failed to insert an item at index %d.", GetErrorMessage(r), index);
731 RemoveFromItemsList(-1, index - __topIndex);
736 _SlidableListImpl::IsItemChecked(int groupIndex, int subIndex) const
738 return IsItemChecked(subIndex);
742 _SlidableListImpl::IsItemChecked(int index) const
746 case TABLE_VIEW_ANNEX_STYLE_MARK:
748 case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
750 Boolean* pChecked = dynamic_cast<Boolean*>(__pCheckedList->GetAt(index));
751 SysTryReturn(NID_UI_CTRL, (pChecked != null), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get boolean pointer at %d index.", index);
753 return pChecked->ToBool();
757 case TABLE_VIEW_ANNEX_STYLE_RADIO:
759 if (index == _currentRadioIndex)
770 case TABLE_VIEW_ANNEX_STYLE_NORMAL:
773 SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. This list style does not support Checked items");
774 SetLastResult(E_SYSTEM);
780 _SlidableListImpl::IsItemLoaded(int index) const
782 if (_itemsList.GetCount() == 0)
788 int min = ((__totalItemCount > __itemCacheSize) ? __itemCacheSize : __totalItemCount);
789 return (index >= __topIndex && index < __topIndex + min) ? true : false;
794 _SlidableListImpl::IsLoadedItemEnabled(int index) const
798 GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
799 int topDrawnItemIndex = itemIndex;
800 GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
801 int bottomDrawnItemIndex = itemIndex;
803 if (index < __topIndex || index > __topIndex + _itemsList.GetCount())
809 if ((index >= topDrawnItemIndex && index <= bottomDrawnItemIndex))
811 return GetCore().IsItemEnabled(0, index);
821 _SlidableListImpl::GetTopItemIndex(void)
827 _SlidableListImpl::LoadItemToBottom(const CustomListItem& item, int itemId)
829 SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS, "[E_SUCCESS] Not during creation. Can be ignored.");
831 _TableViewItemParams tableViewItemParams;
832 tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
833 tableViewItemParams.width = GetCore().GetBoundsF().width;
834 tableViewItemParams.itemIndex = _itemsList.GetCount() + __topIndex;
835 tableViewItemParams.groupIndex = -1;
836 tableViewItemParams.isDividerEnabled = _isDividerEnabled;
837 tableViewItemParams.pCheckBitmaps = _pCheckBitmaps;
838 tableViewItemParams.annexStyle = _annexStyle;
840 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
841 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
842 "[%s] A system error has occurred. Failed to create an item at index %d.", GetErrorMessage(r), (_itemsList.GetCount() + __topIndex));
843 item.__pCustomListItemImpl->itemId = itemId;
845 r = _itemsList.Add(item);
846 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
847 "[%s] A system error has occurred. Failed to insert an item at index 0.", GetErrorMessage(r));
853 _SlidableListImpl::LoadItemToTop(const CustomListItem& item, int itemId)
855 SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS, "[E_SUCCESS] Not during creation. Can be ignored.");
857 _TableViewItemParams tableViewItemParams;
858 tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
859 tableViewItemParams.width = GetCore().GetBoundsF().width;
860 tableViewItemParams.itemIndex = (__topIndex - 1);
861 tableViewItemParams.groupIndex = -1;
862 tableViewItemParams.isDividerEnabled = _isDividerEnabled;
863 tableViewItemParams.pCheckBitmaps = _pCheckBitmaps;
864 tableViewItemParams.annexStyle = _annexStyle;
866 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
867 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
868 "[%s] A system error has occurred. Failed to create an item at index %d.", GetErrorMessage(r), (__topIndex - 1));
869 item.__pCustomListItemImpl->itemId = itemId;
871 r = _itemsList.InsertAt(item, 0);
872 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
873 "[%s] A system error has occurred. Failed to insert an item at index 0.", GetErrorMessage(r));
879 _SlidableListImpl::SetItemCountAndHeight(int count, int listHeight)
881 SysTryReturnVoidResult(NID_UI_CTRL, (count > 0 && listHeight > 0), E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Count (%d) and listHeight (%d) must be greater than 0.",
883 result r = E_SUCCESS;
884 int prevCount = __totalItemCount;
885 __totalItemCount = count;
888 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)//(IsCheckedStyle() == true)
890 Boolean* pChecked = null;
891 r = __pCheckedList->SetCapacity(count);
892 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
894 for (int itemIndex = prevCount; itemIndex < count; itemIndex++)
896 pChecked = new (std::nothrow) Boolean(false);
897 SysTryReturnVoidResult(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
899 __pCheckedList->Add(*pChecked);
903 if (!(__pItemProvider && __pItemProvider->firstTime == true))
905 for (int itemIndex = prevCount - 1; itemIndex >= count; itemIndex--)
907 _itemsList.RemoveAt(itemIndex);
908 r = GetCore().RefreshTableView(0, itemIndex , TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
909 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
912 for (int itemIndex = prevCount; itemIndex < count; itemIndex++)
914 r = GetCore().RefreshTableView(0, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
915 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
924 _SlidableListImpl::GetLoadedItemIndexFromItemId(int itemId) const
926 _TableViewItemData* pTableViewItemData = null;
927 CustomListItem* pCustomListItem = null;
929 result r = E_SUCCESS;
930 int topItemIndex = -1;
931 int bottomItemIndex = -1;
934 r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex);
935 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r,
936 "[%s] Propagating. Failed to get the index of top item", GetErrorMessage(r));
937 r = GetCore().GetBottomDrawnItemIndex(groupIndex, bottomItemIndex);
938 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r,
939 "[%s]Propagating. Failed to get the index of bottom item", GetErrorMessage(r));
941 for (int index = 0; index < _itemsList.GetCount(); index++)
943 pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(index)));
944 SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM,
945 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", index);
947 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM,
948 "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
950 pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
951 SysTryReturn(NID_UI_CTRL, pTableViewItemData, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null.");
953 if ((pTableViewItemData != null) && (pCustomListItem->__pCustomListItemImpl->itemId == itemId))
955 SetLastResult(E_SUCCESS);
957 if ((index + __topIndex >= topItemIndex) && (index + __topIndex <= bottomItemIndex))
959 return index + __topIndex;
964 SetLastResult(E_SUCCESS);
965 return INVALID_INDEX;
969 _SlidableListImpl::UnloadAllItems(void)
971 SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM,
972 "[E_SYSTEM] A system error has occurred. SlidableListener not set.");
974 result r = E_SUCCESS;
976 for (int itemIndex = _itemsList.GetCount() - 1; itemIndex >= 0; itemIndex--)
978 r = RemoveFromItemsList(-1, itemIndex);
979 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
980 "[%s] A system error has occurred. Failed to remove item at index %d", GetErrorMessage(r), itemIndex);
982 r = GetCore().RefreshTableView(0, itemIndex + __topIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
983 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
984 "[%s] A system error has occurred. Failed to remove item at index %d", GetErrorMessage(r), (itemIndex + __topIndex));
989 r = __pCheckedList->RemoveAt(itemIndex + __topIndex, true);
990 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
991 "[%s] A system error has occurred. Failed to remove Check item at index %d", GetErrorMessage(r), (itemIndex + __topIndex));
994 if (GetCore().GetFirstDrawnFlag() == true)
996 CallUnloadItemCb(itemIndex + __topIndex);
1004 _SlidableListImpl::RefreshItem(int index)
1006 SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (__topIndex + _itemsList.GetCount())), E_INVALID_ARG,
1007 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).",
1008 index, (__topIndex + _itemsList.GetCount()));
1010 result r = E_SUCCESS;
1012 int topItemIndex = -1;
1013 int bottomItemIndex = -1;
1014 int groupIndex = -1;
1016 r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex);
1017 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
1018 "[%s] A system error has occurred. Failed to get the index of top item", GetErrorMessage(r));
1020 r = GetCore().GetBottomDrawnItemIndex(groupIndex, bottomItemIndex);
1021 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
1022 "[%s] A system error has occurred. Failed to get the index of bottom item", GetErrorMessage(r));
1024 SysTryReturnResult(NID_UI_CTRL, (index >= topItemIndex && index <= bottomItemIndex), E_OUT_OF_RANGE,
1025 "Index %d must be greater than or equal to top index %d and less than or equal to bottom index %d",
1026 index, topItemIndex, bottomItemIndex);
1028 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(_itemsList.GetAt(index - __topIndex));
1029 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM,
1030 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex));
1032 SysTryReturnResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM,
1033 "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
1036 _TableViewItemUpdateParams updateParams;
1037 updateParams.pItem = pCustomListItem;
1038 updateParams.isDividerEnabled = _isDividerEnabled;
1039 updateParams.pCheckBitmaps = _pCheckBitmaps;
1041 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
1042 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
1044 _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
1045 SysTryReturnResult(NID_UI_CTRL, (pTableViewItemData != null), E_SYSTEM,
1046 "[E_SYSTEM] A system error has occurred. ItemData must not be null.");
1048 pTableViewItemData->Invalidate(true);
1053 _SlidableListImpl::RemoveAllCheckedItems(int itemHeight)
1055 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM,
1056 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL.");
1057 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM,
1058 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_RADIO.");
1060 SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM,
1061 "[E_SYSTEM] A system error has occurred. SlidableListener not set.");
1063 result r = E_SUCCESS;
1065 Boolean* pChecked = null;
1067 for (itemIndex = _itemsList.GetCount() + __topIndex; itemIndex < __totalItemCount; itemIndex++)
1069 pChecked = dynamic_cast<Boolean*>(__pCheckedList->GetAt(itemIndex));
1070 if ((pChecked != null) && pChecked->ToBool() == true)
1072 __pCheckedList->RemoveAt(itemIndex, true);
1077 for (itemIndex = 0; itemIndex < __topIndex; itemIndex++)
1079 pChecked = dynamic_cast<Boolean*>(__pCheckedList->GetAt(itemIndex));
1080 if ((pChecked != null) && pChecked->ToBool() == true)
1082 __pCheckedList->RemoveAt(itemIndex, true);
1087 for (itemIndex = 0; itemIndex < _itemsList.GetCount(); itemIndex++)
1089 if (IsItemChecked(itemIndex + __topIndex) == true)
1091 r = RemoveFromItemsList(-1, itemIndex);
1092 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
1094 __pCheckedList->RemoveAt(itemIndex + __topIndex, true);
1096 r = GetCore().RefreshTableView(0, itemIndex + __topIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
1100 SysLog(NID_UI_CTRL, "[%s] Failed to remove item at index %d.", GetErrorMessage(r), itemIndex + __topIndex);
1103 if (GetCore().GetFirstDrawnFlag() == true)
1105 CallUnloadItemCb(itemIndex + __topIndex);
1117 _SlidableListImpl::RemoveAllItems(void)
1119 __totalItemCount = 0;
1121 __isFullUpdate = true;
1122 GetCore().UpdateTableView();
1123 __isFullUpdate = false;
1127 __pCheckedList->RemoveAll(true);
1134 _SlidableListImpl::RemoveCustomItemEventListener(const ICustomItemEventListener& listener)
1136 _ListListener* pListenerList = null;
1138 for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
1140 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1142 if ((pListenerList != null) && (pListenerList->pListener == &listener))
1144 __itemListenersList.RemoveAt(listenerCount, true);
1151 _SlidableListImpl::RemoveItemAt(int index, int itemHeight)
1153 result r = E_SUCCESS;
1155 if (!(index >= __topIndex && index < __topIndex + _itemsList.GetCount()))
1157 if (index >= 0 && index < __totalItemCount)
1166 r = RemoveFromItemsList(-1, (index - __topIndex));
1167 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
1168 "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
1170 r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
1171 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1172 "[%s] A system error has occurred. Failed to remove item at %d", GetErrorMessage(r), index);
1176 __pCheckedList->RemoveAt(index, true);
1181 if (GetCore().GetFirstDrawnFlag() == true)
1183 CallUnloadItemCb(index);
1190 _SlidableListImpl::ScrollToBottom(void)
1192 __isForcedScroll = true;
1194 result r = E_SUCCESS;
1196 r = GetCore().SetBottomDrawnItemIndex(0, __totalItemCount - 1);
1197 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1201 __isForcedScroll = false;
1205 _SlidableListImpl::ScrollToTop(int index)
1207 SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), E_INVALID_ARG, E_INVALID_ARG,
1208 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount);
1210 result r = E_SUCCESS;
1212 __isForcedScroll = true;
1214 r = GetCore().SetTopDrawnItemIndex(0, index);
1215 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1219 __isForcedScroll = false;
1225 _SlidableListImpl::ScrollToTop(void)
1227 result r = E_SUCCESS;
1229 __isForcedScroll = true;
1231 r = GetCore().SetTopDrawnItemIndex(0, 0);
1232 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1236 __isForcedScroll = false;
1240 _SlidableListImpl::SetAllItemsChecked(bool check)
1242 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM,
1243 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1244 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM,
1245 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_RADIO");
1247 CustomListItem* pCustomListItem = null;
1248 _TableViewItemData* pTableViewItemData = null;
1249 _CheckElementModel* pCheckElement = null;
1251 Boolean* pChecked = null;
1254 for (itemIndex = 0; itemIndex < __totalItemCount; itemIndex++)
1256 pChecked = new (std::nothrow) Boolean(check);
1257 SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1259 __pCheckedList->SetAt(*pChecked, itemIndex, true);
1262 for (int index = 0; index < _itemsList.GetCount(); index++)
1264 pCustomListItem = dynamic_cast<CustomListItem*>(_itemsList.GetAt(index));
1265 SysTryCatch(NID_UI_CTRL, pCustomListItem, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index %d.", index);
1267 SysTryCatch(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null");
1269 pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
1270 SysTryCatch(NID_UI_CTRL, pTableViewItemData != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null.");
1272 pCheckElement = pCustomListItem->__pCustomListItemImpl->GetCheckElement();
1273 SysTryCatch(NID_UI_CTRL, (pCheckElement != null), , E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null");
1277 pCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1281 pCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1293 _SlidableListImpl::SetItemAt(int index, const CustomListItem& item, int itemId)
1295 result r = E_SUCCESS;
1297 SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (__topIndex + _itemsList.GetCount())), E_INVALID_ARG,
1298 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).",
1299 index, (__topIndex + _itemsList.GetCount()));
1301 SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item already exists.");
1303 _CheckElementModel* pCheckElement = null;
1304 _CheckElementModel* pOldCheckElement = GetCheckElementAt(-1, index - __topIndex);
1305 _CheckBoxStatus oldCheckStatus = (pOldCheckElement) ? (pOldCheckElement->GetCheckBoxStatus()) : CHECK_BOX_UNCHECKED;
1307 item.__pCustomListItemImpl->itemId = itemId;
1308 item.__pCustomListItemImpl->__pTableViewItemData = GetTableViewItemAt(-1, index - __topIndex);
1310 r = _itemsList.SetAt(item, index, true);
1311 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1312 "[E_SYSTEM] A system error has occurred. Failed to set an item at index %d.", index);
1314 _TableViewItemUpdateParams updateParams;
1315 updateParams.pItem = (const_cast<CustomListItem*>(&item));;
1316 updateParams.isDividerEnabled = _isDividerEnabled;
1317 updateParams.pCheckBitmaps = _pCheckBitmaps;
1318 updateParams.annexStyle = _annexStyle;
1320 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
1321 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
1322 "[%s] A system error has occurred. Failed to update an item.", GetErrorMessage(r));
1324 if (GetCore().GetFirstDrawnFlag() == false)
1326 r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1327 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1330 pCheckElement = item.__pCustomListItemImpl->GetCheckElement();
1334 pCheckElement->SetCheckBoxStatus(oldCheckStatus);
1341 _SlidableListImpl::SetItemChecked(int groupindex, int index, bool check)
1343 return SetItemChecked(index, check);
1347 _SlidableListImpl::SetItemChecked(int index, bool check)
1349 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM,
1350 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1352 SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), E_INVALID_ARG,
1353 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount);
1355 if (IsItemChecked(index) == check)
1360 _CheckElementModel* pCheckElementModel = GetCheckElementAt(-1, index - __topIndex);
1361 SysTryReturnResult(NID_UI_CTRL, pCheckElementModel, E_SYSTEM,
1362 "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null.");
1364 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1366 if (_currentRadioIndex != -1)
1368 _CheckElementModel* pOldCheckElement = GetCheckElementAt(-1, _currentRadioIndex - __topIndex);
1370 if (pOldCheckElement)
1372 pOldCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1373 DrawItem(-1, _currentRadioIndex - __topIndex);
1375 _currentRadioIndex = index;
1379 _currentRadioIndex = -1;
1384 pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1385 _currentRadioIndex = index;
1389 pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1390 _currentRadioIndex = -1;
1395 Boolean* pChecked = new (std::nothrow) Boolean(check);
1396 SysTryReturnResult(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1398 __pCheckedList->SetAt(*pChecked, index, true);
1400 pCheckElementModel->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1403 DrawItem(-1, index - __topIndex);
1409 _SlidableListImpl::SetLoadedItemEnabled(int index, bool enable)
1411 result r = E_SUCCESS;
1413 SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex),
1414 E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).",
1415 index, _itemsList.GetCount());
1417 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(_itemsList.GetAt(index - __topIndex));
1418 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", index);
1420 _CustomListItemImpl* pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl;
1421 SysTryReturnResult(NID_UI_CTRL, pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
1423 _TableViewItemData* pTableViewItemData = pCustomListItemImpl->__pTableViewItemData;
1424 SysTryReturnResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", index);
1426 _CheckElementModel* pCheckElementModel = pCustomListItem->__pCustomListItemImpl->GetCheckElement();
1427 SysTryReturnResult(NID_UI_CTRL, pCheckElementModel, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null.");
1429 if (pCheckElementModel)
1433 if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_DISABLED)
1435 pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1440 if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_CHECKED)
1442 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
1444 pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_DISABLED);
1450 r = GetCore().SetItemEnabled(0, index, enable);
1451 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Failed to set an item enabled at index %d.", GetErrorMessage(r), index);
1453 pTableViewItemData->Invalidate(true);
1459 _SlidableListImpl::Initalize(void)
1461 result r = E_SUCCESS;
1463 r = GetCore().AddTableViewItemEventListener(*this);
1464 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add item event listener.", GetErrorMessage(r));
1466 __totalItemCount = 0;
1469 __itemCacheSize = GetCore().GetMaxItemCachingSize();
1471 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
1473 __pCheckedList = new (std::nothrow) ArrayList();
1474 SysTryReturnResult(NID_UI_CTRL, __pCheckedList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1476 __pCheckedList->Construct();
1483 _SlidableListImpl::CallUnloadItemCb(int index)
1485 _ListListener* pListenerData = null;
1486 ISlidableListEventListener* pSlidableListener = null;
1488 for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++)
1490 pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount));
1494 pSlidableListener = dynamic_cast<ISlidableListEventListener*>(pListenerData->pListener);
1495 SysTryReturnVoidResult(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM,
1496 "[E_SYSTEM] A system error has occurred. Failed to get EventListener");
1497 pSlidableListener->OnUnloadItemRequested(GetPublic(), index);
1505 _SlidableListImpl::IsCheckedStyle(void)
1507 if (((_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || _annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)))
1518 _SlidableListImpl::IsCheckedStyle(void) const
1520 if (((_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || _annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)))
1530 _SlidableListImpl::OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* itemTag, Tizen::Ui::Controls::TableViewItemStatus status)
1532 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(_itemsList.GetAt(itemIndex - __topIndex));
1533 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM,
1534 "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", (itemIndex - __topIndex));
1536 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null");
1538 _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
1539 SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewItemData != null), E_SYSTEM,
1540 "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", (itemIndex - __topIndex));
1542 ItemStatus itemStatus = ITEM_HIGHLIGHTED;
1546 case TABLE_VIEW_ITEM_STATUS_SELECTED:
1547 itemStatus = ITEM_SELECTED;
1549 case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED:
1550 itemStatus = ITEM_HIGHLIGHTED;
1552 case TABLE_VIEW_ITEM_STATUS_CHECKED:
1553 itemStatus = ITEM_CHECKED;
1555 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
1556 itemStatus = ITEM_UNCHECKED;
1559 SetLastResult(E_SYSTEM);
1563 if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL))
1565 bool isChecked = IsItemChecked(itemIndex);
1569 itemStatus = ITEM_UNCHECKED;
1573 itemStatus = ITEM_CHECKED;
1576 SetItemChecked(itemIndex, !isChecked);
1579 ProcessItemStateChange(0, itemIndex, itemStatus);
1584 _SlidableListImpl::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
1590 _SlidableListImpl::OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo)
1596 _SlidableListImpl::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1602 _SlidableListImpl::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1608 _SlidableListImpl::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
1614 _SlidableListImpl::OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo)
1620 _SlidableListImpl::OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1626 _SlidableListImpl::OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
1632 _SlidableListImpl::OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction)
1638 _SlidableListImpl::ProcessItemStateChange(int groupIndex, int index, int elementId, ItemStatus itemStatus)
1640 int itemId = GetLoadedItemIdAt(index);
1641 _ListListener* pListenerList = null;
1642 ICustomItemEventListener* pEventListener = null;
1644 int count = __itemListenersList.GetCount();
1645 for (int listenerCount = 0; listenerCount < count; listenerCount++)
1647 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1648 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Listener instance is not available.");
1650 pEventListener = dynamic_cast<ICustomItemEventListener*>(pListenerList->pListener);
1651 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Listener instance is not available.");
1653 pEventListener->OnItemStateChanged(GetPublic(), index, itemId, elementId, itemStatus);
1655 SetLastResult(E_SUCCESS);
1659 _SlidableListImpl::ProcessItemStateChange(int groupIndex, int index, ItemStatus itemStatus)
1661 int itemId = GetLoadedItemIdAt(index);
1662 _ListListener* pListenerList = null;
1663 ICustomItemEventListener* pEventListener = null;
1665 int count = __itemListenersList.GetCount();
1666 for (int listenerCount = 0; listenerCount < count; listenerCount++)
1668 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1669 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "Failed to get Listener.");
1671 pEventListener = dynamic_cast<ICustomItemEventListener*>(pListenerList->pListener);
1672 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "Failed to get Listener.");
1674 pEventListener->OnItemStateChanged(GetPublic(), index, itemId, itemStatus);
1676 SetLastResult(E_SUCCESS);
1680 _SlidableListImpl::CreateItemProvider(void)
1682 if (__pItemProvider == null)
1684 __pItemProvider = new (std::nothrow) _SlidableListItemProvider(this);
1685 SysTryReturnResult(NID_UI_CTRL, __pItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1687 TableViewStyle style = GetCore().GetTableViewStyle();
1688 SysTryCatch(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, , E_INVALID_OPERATION,
1689 "[E_INVALID_OPERATION] The current list cannot support the given style.");
1691 result r = E_SUCCESS;
1693 _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
1694 r = GetLastResult();
1695 SysTryCatch(NID_UI_CTRL, pItemProvider != null, , r, "[%s] Propagating.", GetErrorMessage(r));
1697 pItemProvider->SetSimpleStyleItemProvider(__pItemProvider);
1699 GetCore().SetItemProvider(pItemProvider);
1705 if (__pItemProvider)
1707 delete __pItemProvider;
1708 __pItemProvider = null;
1715 _SlidableListImpl::OnDraw(void)
1717 if (__pItemProvider == null)
1719 __pItemProvider = new (std::nothrow) _SlidableListItemProvider(this);
1720 SysTryReturnVoidResult(NID_UI_CTRL, __pItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1722 TableViewStyle style = GetCore().GetTableViewStyle();
1723 SysTryCatch(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, , E_INVALID_OPERATION,
1724 "[E_INVALID_OPERATION] The current list cannot support the given style.");
1726 _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
1727 result r = GetLastResult();
1728 SysTryCatch(NID_UI_CTRL, pItemProvider != null, , r, "[%s] Propagating.", GetErrorMessage(r));
1730 pItemProvider->SetSimpleStyleItemProvider(__pItemProvider);
1732 GetCore().SetItemProvider(pItemProvider);
1735 _ListBaseImpl::OnDraw();
1739 if (__pItemProvider)
1741 delete __pItemProvider;
1742 __pItemProvider = null;
1746 class _SlidableListMaker
1747 : public _UiBuilderControlMaker
1750 _SlidableListMaker(_UiBuilder* uibuilder)
1751 : _UiBuilderControlMaker(uibuilder){};
1752 virtual ~_SlidableListMaker(){};
1753 static _UiBuilderControlMaker*
1754 GetInstance(_UiBuilder* uibuilder)
1756 _SlidableListMaker* pSlidableListMaker = new (std::nothrow) _SlidableListMaker(uibuilder);
1757 return pSlidableListMaker;
1760 virtual Tizen::Ui::Control*
1761 Make(_UiBuilderControl* pControl)
1763 result r = E_SYSTEM;
1764 _UiBuilderControlLayout* pControlProperty = null;
1765 SlidableList* pSlidableList = null;
1766 Tizen::Graphics::Rectangle rect;
1767 Tizen::Graphics::Rectangle rectMin;
1770 Tizen::Ui::Controls::CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL;
1771 Tizen::Base::String elementString;
1772 bool isItemDivider = true;
1775 GetProperty(pControl, &pControlProperty);
1776 if (pControlProperty == null)
1781 pSlidableList = new (std::nothrow) SlidableList();
1782 if (pSlidableList == null)
1787 rect = pControlProperty->GetRect();
1789 Tizen::Base::String styleString;
1790 styleString = pControlProperty->GetStyle();
1793 if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false))
1795 style = CUSTOM_LIST_STYLE_NORMAL;
1797 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false))
1799 style = CUSTOM_LIST_STYLE_RADIO;
1801 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false))
1803 style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER;
1805 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false))
1807 style = CUSTOM_LIST_STYLE_MARK;
1809 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false))
1811 style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER;
1813 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false))
1815 style = CUSTOM_LIST_STYLE_ONOFF;
1817 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false))
1819 style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER;
1823 style = CUSTOM_LIST_STYLE_NORMAL;
1827 if (pControl->GetElement("itemDivider", elementString))
1829 if (elementString.Equals(L"true", false))
1831 isItemDivider = true;
1835 isItemDivider = false;
1839 r = pSlidableList->Construct(rect, style, isItemDivider);
1842 delete pSlidableList;
1846 if (pControl->GetElement("textOfEmptyList", elementString))
1848 pSlidableList->SetTextOfEmptyList(elementString);
1851 if (pControl->GetElement("colorOfEmptyListText", elementString))
1853 ConvertStringToColor(elementString, color);
1854 pSlidableList->SetTextColorOfEmptyList(color);
1857 GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin);
1858 rectMin = (pControl->GetAttribute(0))->GetRect();
1859 (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
1861 GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin);
1862 rectMin = (pControl->GetAttribute(1))->GetRect();
1863 (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
1865 return pSlidableList;
1872 _SlidableListRegister::_SlidableListRegister()
1874 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1876 if (pUiBuilderControlTableManager)
1878 pUiBuilderControlTableManager->RegisterControl(L"SlidableList", _SlidableListMaker::GetInstance);
1881 _SlidableListRegister::~_SlidableListRegister()
1883 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1885 if (pUiBuilderControlTableManager)
1887 pUiBuilderControlTableManager->UnregisterControl(L"SlidableList");
1890 static _SlidableListRegister SlidableListRegisterToUiBuilder;
1891 }}} // Tizen::Ui::Controls