2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_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"
37 using namespace Tizen::Base;
38 using namespace Tizen::Ui;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Controls;
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Media;
46 using namespace Tizen::Base::Collection;
49 namespace Tizen { namespace Ui { namespace Controls
52 extern const int INVALID_INDEX;
54 _SlidableListItemProvider::_SlidableListItemProvider(_SlidableListImpl* pList)
56 , bottomListenerIndex(0)
62 topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1;
67 _SlidableListItemProvider::GetItemCount(void)
69 SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
71 if (__pListImpl->__slidableListenersList.GetCount() > 0)
73 if (firstTime == true)
75 _ListListener* pListenerData = null;
76 ISlidableListEventListener* pSlidableListener = null;
77 int listenerCount = 0;
79 for (listenerCount = 0; listenerCount < __pListImpl->__slidableListenersList.GetCount(); listenerCount++)
81 pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(listenerCount));
85 pSlidableListener = dynamic_cast<ISlidableListEventListener*>(pListenerData->pListener);
86 SysTryReturn(NID_UI_CTRL, (pSlidableListener != null), -1, E_SYSTEM,
87 "[E_SYSTEM] A system error has occurred. Failed to get EventListener.");
89 pSlidableListener->OnListPropertyRequested(__pListImpl->GetPublic());
96 return __pListImpl->__totalItemCount;
105 _SlidableListItemProvider::CallLoadToTopCb(int index)
107 _ListListener* pListenerData = null;
108 ISlidableListEventListener* pSlidableListener = null;
110 pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(topListenerIndex));
111 SysTryReturn(NID_UI_CTRL, pListenerData, E_SYSTEM, E_SYSTEM,
112 "[E_SYSTEM] A system error has occurred. Failed to get the listener.");
114 pSlidableListener = dynamic_cast<ISlidableListEventListener*>(pListenerData->pListener);
115 SysTryReturn(NID_UI_CTRL, pSlidableListener, E_SYSTEM, E_SYSTEM,
116 "[E_SYSTEM] A system error has occurred. Failed to get the listener.");
118 pSlidableListener->OnLoadToTopRequested(__pListImpl->GetPublic(), index, 1);
120 if (--topListenerIndex < 0)
122 topListenerIndex = __pListImpl->__slidableListenersList.GetCount() - 1;
129 _SlidableListItemProvider::UpdateCheckStatus(_TableViewItemData* pTableViewItemData, int index)
131 if (pTableViewItemData && __pListImpl->__pCheckedList)
133 Boolean* pChecked = dynamic_cast<Boolean*>(__pListImpl->__pCheckedList->GetAt(index));
134 SysTryReturn(NID_UI_CTRL, pChecked, E_SYSTEM, E_SYSTEM,
135 "[E_SYSTEM] A system error has occurred. Failed to get Check status");
137 _CheckElementModel* pCheckElement = __pListImpl->GetCheckElementAt(-1, index - __pListImpl->__topIndex);
138 SysTryReturn(NID_UI_CTRL, pCheckElement, E_SYSTEM, E_SYSTEM,
139 "[E_SYSTEM] A system error has occurred. Failed to get CheckElement. ");
141 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)pChecked->ToBool());
148 _SlidableListItemProvider::LoadAtTop(int index)
150 _TableViewItemData* pTableViewItemData = null;
151 result r = E_SUCCESS;
153 r = CallLoadToTopCb(index);
154 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
156 __pListImpl->__topIndex = index;
158 pTableViewItemData = __pListImpl->GetTableViewItemAt(-1, 0);
160 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
162 r = UpdateCheckStatus(pTableViewItemData, index);
163 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
165 return pTableViewItemData;
169 _SlidableListItemProvider::CallLoadToBottomCb(int index)
171 _ListListener* pListenerData = null;
172 ISlidableListEventListener* pSlidableListener = null;
174 pListenerData = dynamic_cast<_ListListener*>(__pListImpl->__slidableListenersList.GetAt(bottomListenerIndex));
175 SysTryReturn(NID_UI_CTRL, pListenerData, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the listener.");
177 pSlidableListener = dynamic_cast<ISlidableListEventListener*>(pListenerData->pListener);
178 SysTryReturn(NID_UI_CTRL, pSlidableListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get the listener.");
180 pSlidableListener->OnLoadToBottomRequested(__pListImpl->GetPublic(), index, 1);
182 if (++bottomListenerIndex == __pListImpl->__slidableListenersList.GetCount())
184 bottomListenerIndex = 0;
191 _SlidableListItemProvider::LoadAtBottom(int index)
193 _TableViewItemData* pTableViewItemData = null;
194 result r = E_SUCCESS;
196 r = CallLoadToBottomCb(index);
197 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
199 if (__pListImpl->_itemsList.GetCount() > __pListImpl->__itemCacheSize)
201 __pListImpl->__topIndex++;
203 else if (__pListImpl->_itemsList.GetCount() == 1)
205 __pListImpl->__topIndex = index;
208 pTableViewItemData = __pListImpl->GetTableViewItemAt(-1, __pListImpl->_itemsList.GetCount() - 1);
210 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
212 r = UpdateCheckStatus(pTableViewItemData, index);
213 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
215 return pTableViewItemData;
219 _SlidableListItemProvider::CreateItem(int index, int itemWidth)
221 SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
223 _TableViewItemData* pItem = null;
224 pItem = __pListImpl->GetTableViewItemAt(-1, index - __pListImpl->__topIndex);
226 result r = E_SUCCESS;
228 __pListImpl->__isCreating = true;
232 if (index < __pListImpl->__topIndex) // load at top
234 pItem = LoadAtTop(index);
236 else // load at bottom
238 pItem = LoadAtBottom(index);
241 SysTryReturn(NID_UI_CTRL, pItem, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
244 __pListImpl->__isCreating = false;
250 _SlidableListItemProvider::DeleteItem(int index, TableViewItem* pItem)
252 SysTryReturn(NID_UI_CTRL, __pListImpl, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
254 result r = E_SUCCESS;
256 if (__pListImpl->__isDirectDelete == true)
258 r = __pListImpl->_itemsList.RemoveAt(0, true);
259 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
261 else if (__pListImpl->_itemsList.GetCount() >= __pListImpl->__itemCacheSize)
263 if (index <= __pListImpl->__topIndex)
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.");
270 r = __pListImpl->_itemsList.RemoveAt(__pListImpl->_itemsList.GetCount() - 1, true);
271 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
275 __pListImpl->CallUnloadItemCb(index);
277 _TableViewItemData* pTableViewItemData = dynamic_cast<_TableViewItemData*>(pItem);
278 delete pTableViewItemData;
284 _SlidableListItemProvider::UpdateItem(int itemIndex, TableViewItem* pItem)
290 _SlidableListItemProvider::GetDefaultItemHeight()
292 SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List instance must not be null.");
294 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(__pListImpl->_itemsList.GetAt(0));
298 _CustomListItemImpl* pCustomListItemImpl = null;
299 pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl;
300 SysTryReturn(NID_UI_CTRL, pCustomListItemImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null");
301 return pCustomListItemImpl->height;
305 return __pListImpl->LISTVIEW_ITEM_HEIGHT;
310 _SlidableListImpl::GetInstance(SlidableList& slidableList)
312 return static_cast<_SlidableListImpl*>(slidableList._pControlImpl);
315 const _SlidableListImpl*
316 _SlidableListImpl::GetInstance(const SlidableList& slidableList)
318 return static_cast<const _SlidableListImpl*>(slidableList._pControlImpl);
321 _SlidableListImpl::_SlidableListImpl(Control* pList, _TableView* pCore)
322 : _ListBaseImpl(pList, pCore)
323 , __pCheckedList(null)
324 , __totalItemCount(-1)
326 , __pItemProvider(null)
327 , __isDirectDelete(false)
328 , __isCreating(false)
333 _SlidableListImpl::~_SlidableListImpl(void)
335 if (__pItemProvider && __pItemProvider->firstTime == true)
337 _itemsList.RemoveAll(true);
341 _itemsList.RemoveAll(false);
344 __slidableListenersList.RemoveAll(true);
345 __itemListenersList.RemoveAll(true);
349 __pCheckedList->RemoveAll(true);
350 delete __pCheckedList;
355 delete __pItemProvider;
356 __pItemProvider = null;
361 _SlidableListImpl::GetPublicClassName(void) const
363 return "Tizen::Ui::Controls::SlidableList";
367 _SlidableListImpl::GetPublic(void) const
369 return static_cast<const SlidableList&>(_ControlImpl::GetPublic());
373 _SlidableListImpl::GetPublic(void)
375 return static_cast<SlidableList&>(_ControlImpl::GetPublic());
379 _SlidableListImpl::GetCore(void) const
381 return static_cast<const _TableView&>(_ControlImpl::GetCore());
385 _SlidableListImpl::GetCore(void)
387 return static_cast<_TableView&>(_ControlImpl::GetCore());
391 _SlidableListImpl::CreateSlidableListImplN(SlidableList* pControl, const Rectangle& bounds, bool itemDivider)
393 result r = E_SUCCESS;
395 r = GET_SIZE_INFO(SlidableList).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
401 _TableView* pList = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_SIMPLE, itemDivider, TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL);
403 SysTryReturn(NID_UI_CTRL, pList, null, r, "[%s] Failed to create ListView instance", GetErrorMessage(r));
405 _SlidableListImpl* pImpl = new (std::nothrow) _SlidableListImpl(pControl, pList);
406 SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
416 _SlidableListImpl::UpdateBounds(const Rectangle& rect)
418 result r = E_SUCCESS;
420 r = InitializeBoundsProperties(GET_SIZE_INFO(SlidableList), rect, GetCore().GetOrientation());
421 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
427 _SlidableListImpl::AddSlidableListEventListener(const ISlidableListEventListener& listener)
429 _ListListener* pListenerData = new (std::nothrow) _ListListener;
430 SysTryReturnVoidResult(NID_UI_CTRL, pListenerData, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
432 pListenerData->pListener = const_cast<ISlidableListEventListener*>(&listener);
433 __slidableListenersList.Add(*pListenerData);
437 _SlidableListImpl::RemoveSlidableListEventListener(const ISlidableListEventListener& listener)
439 _ListListener* pListenerData = null;
441 for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++)
443 pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount));
445 if ((pListenerData != null) && (pListenerData->pListener == &listener))
447 __slidableListenersList.RemoveAt(listenerCount, true);
454 _SlidableListImpl::AddCustomItemEventListener(const ICustomItemEventListener& listener)
456 _ListListener* pListenersList = new (std::nothrow) _ListListener;
457 SysTryReturnVoidResult(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
459 pListenersList->pListener = const_cast<Tizen::Ui::ICustomItemEventListener*>(&listener);
461 __itemListenersList.Add(*pListenersList);
465 _SlidableListImpl::AddItem(const CustomListItem& item, int itemId)
467 return InsertItemAt((_itemsList.GetCount() + __topIndex), item, itemId);
471 _SlidableListImpl::GetBottomDrawnItemIndex(void) const
475 result r = E_SUCCESS;
476 r = GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
477 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM,
478 "[E_SYSTEM] A system error has occurred. Failed to get the bottom drawn item index.");
484 _SlidableListImpl::GetFirstCheckedItemIndex(void) const
486 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM,
487 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
489 for (int itemIndex = 0; itemIndex < __totalItemCount; itemIndex++)
491 if (IsItemChecked(itemIndex))
493 SetLastResult(E_SUCCESS);
498 SetLastResult(E_SUCCESS);
499 return INVALID_INDEX;
503 _SlidableListImpl::GetFirstLoadedItemIndex(void) const
505 result r = E_SUCCESS;
509 r = GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
510 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r, "[%s] Propagating.", GetErrorMessage(r));
516 _SlidableListImpl::GetLastLoadedItemIndex(void) const
518 result r = E_SUCCESS;
522 r = GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
523 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r, "[%s] Propagating.", GetErrorMessage(r));
529 _SlidableListImpl::GetItemCount(void) const
531 return __totalItemCount;
535 _SlidableListImpl::GetItemIndexFromItemId(int itemId) const
537 _TableViewItemData* pTableViewItemData = null;
538 CustomListItem* pCustomListItem = null;
540 for (int index = 0; index < _itemsList.GetCount(); index++)
542 pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(index)));
543 SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM,
544 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", index);
546 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM,
547 "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
549 pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
550 SysTryReturn(NID_UI_CTRL, pTableViewItemData, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null.");
552 if ((pTableViewItemData != null) && (pCustomListItem->__pCustomListItemImpl->itemId == itemId))
554 SetLastResult(E_SUCCESS);
558 SetLastResult(E_SUCCESS);
559 return INVALID_INDEX;
563 _SlidableListImpl::GetItemIndexFromPosition(const Point& position) const
568 result r = GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
569 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
576 _SlidableListImpl::GetItemIndexFromPosition(int x, int y) const
581 result r = GetCore().GetItemIndexFromPosition(Tizen::Graphics::Point(x, y), groupIndex, itemIndex);
582 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
588 _SlidableListImpl::GetLastCheckedItemIndex(void) const
590 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM,
591 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
593 for (int itemIndex = __totalItemCount - 1; itemIndex > 0; itemIndex--)
595 if (IsItemChecked(itemIndex))
597 SetLastResult(E_SUCCESS);
601 SetLastResult(E_SUCCESS);
602 return INVALID_INDEX;
605 const CustomListItem*
606 _SlidableListImpl::GetLoadedItemAt(int index) const
608 SysTryReturn(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex), null, E_INVALID_ARG,
609 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, _itemsList.GetCount());
611 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(index - __topIndex)));
612 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM,
613 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex));
615 SetLastResult(E_SUCCESS);
616 return pCustomListItem;
620 _SlidableListImpl::GetLoadedItemIdAt(int index) const
622 SysTryReturn(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex), INVALID_INDEX, E_INVALID_ARG,
623 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, _itemsList.GetCount());
625 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(index - __topIndex)));
626 SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM,
627 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex));
629 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM,
630 "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
632 SetLastResult(E_SUCCESS);
633 return pCustomListItem->__pCustomListItemImpl->itemId;
637 _SlidableListImpl::GetNextCheckedItemIndexAfter(int index) const
639 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM,
640 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL.");
642 SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), INVALID_INDEX, E_INVALID_ARG,
643 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount);
645 for (int itemIndex = index + 1; itemIndex < __totalItemCount; itemIndex++)
647 if (IsItemChecked(itemIndex))
649 SetLastResult(E_SUCCESS);
653 SetLastResult(E_SUCCESS);
654 return INVALID_INDEX;
657 Tizen::Graphics::Color
658 _SlidableListImpl::GetTextColorOfEmptyList(void) const
660 return GetCore().GetTextColorOfEmptyTableView();
664 _SlidableListImpl::GetTopDrawnItemIndex(void) const
666 int topItemIndex = -1;
668 result r = E_SUCCESS;
670 r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex);
671 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, E_SYSTEM,
672 "[E_SYSTEM] A system error has occurred. Failed to get the top drawn item index.");
678 _SlidableListImpl::InsertItemAt(int index, const CustomListItem& item, int itemId)
680 SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (_itemsList.GetCount() + __topIndex)), E_INVALID_ARG,
681 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).",
682 index, (_itemsList.GetCount() + __topIndex));
684 _TableViewItemParams tableViewItemParams;
685 tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
686 tableViewItemParams.width = GetCore().GetBounds().width;
687 tableViewItemParams.itemIndex = index;
688 tableViewItemParams.groupIndex = -1;
689 tableViewItemParams.isDividerEnabled = _isDividerEnabled;
690 tableViewItemParams.pCheckBitmaps = _pCheckBitmaps;
691 tableViewItemParams.annexStyle = _annexStyle;
693 item.__pCustomListItemImpl->itemId = itemId;
695 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
696 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
697 "[%s] A system error has occurred. Failed to create an item.", GetErrorMessage(r));
699 r = InsertIntoItemsList(item, -1, index - __topIndex);
700 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
701 "[%s] A system error has occurred. Failed to insert an item at index %d.", GetErrorMessage(r), (index));
705 Boolean *pChecked = new (std::nothrow) Boolean(false);
706 SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
708 __pCheckedList->InsertAt(*pChecked, index);
711 if (GetCore().GetFirstDrawnFlag() == false)
713 r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
714 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM,
715 "[%s] A system error has occurred. Failed to insert an item at index %d.", GetErrorMessage(r), index);
723 RemoveFromItemsList(-1, index - __topIndex);
728 _SlidableListImpl::IsItemChecked(int groupIndex, int subIndex) const
730 return IsItemChecked(subIndex);
734 _SlidableListImpl::IsItemChecked(int index) const
738 case TABLE_VIEW_ANNEX_STYLE_MARK:
740 case TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING:
742 Boolean* pChecked = dynamic_cast<Boolean*>(__pCheckedList->GetAt(index));
743 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);
745 return pChecked->ToBool();
749 case TABLE_VIEW_ANNEX_STYLE_RADIO:
751 if (index == _currentRadioIndex)
762 case TABLE_VIEW_ANNEX_STYLE_NORMAL:
765 SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. This list style does not support Checked items");
766 SetLastResult(E_SYSTEM);
772 _SlidableListImpl::IsItemLoaded(int index) const
774 if (_itemsList.GetCount() == 0)
780 int min = ((__totalItemCount > __itemCacheSize) ? __itemCacheSize : __totalItemCount);
781 return (index >= __topIndex && index < __topIndex + min) ? true : false;
786 _SlidableListImpl::IsLoadedItemEnabled(int index) const
790 GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
791 int topDrawnItemIndex = itemIndex;
792 GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
793 int bottomDrawnItemIndex = itemIndex;
795 if (index < __topIndex || index > __topIndex + _itemsList.GetCount())
801 if ((index >= topDrawnItemIndex && index <= bottomDrawnItemIndex))
803 return GetCore().IsItemEnabled(0, index);
813 _SlidableListImpl::GetTopItemIndex(void)
819 _SlidableListImpl::LoadItemToBottom(const CustomListItem& item, int itemId)
821 SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS, "[E_SUCCESS] Not during creation. Can be ignored.");
823 _TableViewItemParams tableViewItemParams;
824 tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
825 tableViewItemParams.width = GetCore().GetBounds().width;
826 tableViewItemParams.itemIndex = _itemsList.GetCount() + __topIndex;
827 tableViewItemParams.groupIndex = -1;
828 tableViewItemParams.isDividerEnabled = _isDividerEnabled;
829 tableViewItemParams.pCheckBitmaps = _pCheckBitmaps;
830 tableViewItemParams.annexStyle = _annexStyle;
832 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
833 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
834 "[%s] A system error has occurred. Failed to create an item at index %d.", GetErrorMessage(r), (_itemsList.GetCount() + __topIndex));
835 item.__pCustomListItemImpl->itemId = itemId;
837 r = _itemsList.Add(item);
838 // r = InsertIntoItemsList(item, -1, _itemsList.GetCount());
839 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
840 "[%s] A system error has occurred. Failed to insert an item at index 0.", GetErrorMessage(r));
846 _SlidableListImpl::LoadItemToTop(const CustomListItem& item, int itemId)
848 SysTryReturn(NID_UI_CTRL, __isCreating == true, E_SUCCESS, E_SUCCESS, "[E_SUCCESS] Not during creation. Can be ignored.");
850 _TableViewItemParams tableViewItemParams;
851 tableViewItemParams.pItem = (const_cast<CustomListItem*>(&item));
852 tableViewItemParams.width = GetCore().GetBounds().width;
853 tableViewItemParams.itemIndex = (__topIndex - 1);
854 tableViewItemParams.groupIndex = -1;
855 tableViewItemParams.isDividerEnabled = _isDividerEnabled;
856 tableViewItemParams.pCheckBitmaps = _pCheckBitmaps;
857 tableViewItemParams.annexStyle = _annexStyle;
859 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
860 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
861 "[%s] A system error has occurred. Failed to create an item at index %d.", GetErrorMessage(r), (__topIndex - 1));
862 item.__pCustomListItemImpl->itemId = itemId;
864 // r = InsertIntoItemsList(item, -1, 0);
865 r = _itemsList.InsertAt(item, 0);
866 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
867 "[%s] A system error has occurred. Failed to insert an item at index 0.", GetErrorMessage(r));
873 _SlidableListImpl::SetItemCountAndHeight(int count, int listHeight)
875 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.",
878 __totalItemCount = count;
882 __pCheckedList->RemoveAll(true);
883 delete __pCheckedList;
884 __pCheckedList = null;
887 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)//(IsCheckedStyle() == true)
889 __pCheckedList = new (std::nothrow) ArrayList();
890 SysTryReturnVoidResult(NID_UI_CTRL, __pCheckedList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
892 __pCheckedList->Construct(count);
894 Boolean* pChecked = null;
896 for (int itemIndex = 0; itemIndex < count; itemIndex++)
898 pChecked = new (std::nothrow) Boolean(false);
899 SysTryCatch(NID_UI_CTRL, pChecked, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
901 __pCheckedList->Add(*pChecked);
905 if (!(__pItemProvider && __pItemProvider->firstTime == true))
907 _itemsList.RemoveAll(true);
909 result r = GetCore().UpdateTableView();
910 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
918 __pCheckedList->RemoveAll(true);
919 delete __pCheckedList;
920 __pCheckedList = null;
922 _itemsList.RemoveAll(true);
926 _SlidableListImpl::GetLoadedItemIndexFromItemId(int itemId) const
928 _TableViewItemData* pTableViewItemData = null;
929 CustomListItem* pCustomListItem = null;
931 result r = E_SUCCESS;
932 int topItemIndex = -1;
933 int bottomItemIndex = -1;
936 r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex);
937 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r,
938 "[%s] Propagating. Failed to get the index of top item", GetErrorMessage(r));
939 r = GetCore().GetBottomDrawnItemIndex(groupIndex, bottomItemIndex);
940 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, INVALID_INDEX, r,
941 "[%s]Propagating. Failed to get the index of bottom item", GetErrorMessage(r));
943 for (int index = 0; index < _itemsList.GetCount(); index++)
945 pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(index)));
946 SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM,
947 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", index);
949 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, INVALID_INDEX, E_SYSTEM,
950 "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
952 pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
953 SysTryReturn(NID_UI_CTRL, pTableViewItemData, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null.");
955 if ((pTableViewItemData != null) && (pCustomListItem->__pCustomListItemImpl->itemId == itemId))
957 SetLastResult(E_SUCCESS);
959 if ((index + __topIndex >= topItemIndex) && (index + __topIndex <= bottomItemIndex))
961 return index + __topIndex;
966 SetLastResult(E_SUCCESS);
967 return INVALID_INDEX;
971 _SlidableListImpl::UnloadAllItems(void)
973 SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM,
974 "[E_SYSTEM] A system error has occurred. SlidableListener not set.");
976 result r = E_SUCCESS;
978 for (int itemIndex = _itemsList.GetCount() - 1; itemIndex >= 0; itemIndex--)
980 r = RemoveFromItemsList(-1, itemIndex);
981 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
982 "[%s] A system error has occurred. Failed to remove item at index %d", GetErrorMessage(r), itemIndex);
984 r = GetCore().RefreshTableView(0, itemIndex + __topIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
985 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
986 "[%s] A system error has occurred. Failed to remove item at index %d", GetErrorMessage(r), (itemIndex + __topIndex));
991 r = __pCheckedList->RemoveAt(itemIndex + __topIndex, true);
992 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
993 "[%s] A system error has occurred. Failed to remove Check item at index %d", GetErrorMessage(r), (itemIndex + __topIndex));
996 CallUnloadItemCb(itemIndex + __topIndex);
1003 _SlidableListImpl::RefreshItem(int index)
1005 SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (__topIndex + _itemsList.GetCount())), E_INVALID_ARG,
1006 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).",
1007 index, (__topIndex + _itemsList.GetCount()));
1009 result r = E_SUCCESS;
1011 int topItemIndex = -1;
1012 int bottomItemIndex = -1;
1013 int groupIndex = -1;
1015 r = GetCore().GetTopDrawnItemIndex(groupIndex, topItemIndex);
1016 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
1017 "[%s] A system error has occurred. Failed to get the index of top item", GetErrorMessage(r));
1019 r = GetCore().GetBottomDrawnItemIndex(groupIndex, bottomItemIndex);
1020 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
1021 "[%s] A system error has occurred. Failed to get the index of bottom item", GetErrorMessage(r));
1023 SysTryReturnResult(NID_UI_CTRL, (index >= topItemIndex && index <= bottomItemIndex), E_OUT_OF_RANGE,
1024 "Index %d must be greater than or equal to top index %d and less than or equal to bottom index %d",
1025 index, topItemIndex, bottomItemIndex);
1027 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(_itemsList.GetAt(index - __topIndex));
1028 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM,
1029 "[E_SYSTEM] A system error has occurred. Failed to get the Customlist item at index %d.", (index - __topIndex));
1031 SysTryReturnResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM,
1032 "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
1035 _TableViewItemUpdateParams updateParams;
1036 updateParams.pItem = pCustomListItem;
1037 updateParams.isDividerEnabled = _isDividerEnabled;
1038 updateParams.pCheckBitmaps = _pCheckBitmaps;
1040 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
1041 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
1043 _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
1044 SysTryReturnResult(NID_UI_CTRL, (pTableViewItemData != null), E_SYSTEM,
1045 "[E_SYSTEM] A system error has occurred. ItemData must not be null.");
1047 pTableViewItemData->Invalidate(true);
1052 _SlidableListImpl::RemoveAllCheckedItems(int itemHeight)
1054 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM,
1055 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL.");
1056 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM,
1057 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_RADIO.");
1059 SysTryReturn(NID_UI_CTRL, __pItemProvider, E_SYSTEM, E_SYSTEM,
1060 "[E_SYSTEM] A system error has occurred. SlidableListener not set.");
1062 result r = E_SUCCESS;
1064 Boolean* pChecked = null;
1066 for (itemIndex = _itemsList.GetCount() + __topIndex; itemIndex < __totalItemCount; itemIndex++)
1068 pChecked = dynamic_cast<Boolean*>(__pCheckedList->GetAt(itemIndex));
1069 if ((pChecked != null) && pChecked->ToBool() == true)
1071 __pCheckedList->RemoveAt(itemIndex, true);
1076 for (itemIndex = 0; itemIndex < __topIndex; itemIndex++)
1078 pChecked = dynamic_cast<Boolean*>(__pCheckedList->GetAt(itemIndex));
1079 if ((pChecked != null) && pChecked->ToBool() == true)
1081 __pCheckedList->RemoveAt(itemIndex, true);
1086 for (itemIndex = 0; itemIndex < _itemsList.GetCount(); itemIndex++)
1088 if (IsItemChecked(itemIndex) == true)
1090 r = RemoveFromItemsList(-1, itemIndex);
1091 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
1093 __pCheckedList->RemoveAt(itemIndex, true);
1095 r = GetCore().RefreshTableView(0, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
1099 SysLog(NID_UI_CTRL, "[%s] Failed to remove item at index %d.", GetErrorMessage(r), itemIndex);
1102 CallUnloadItemCb(itemIndex);
1112 _SlidableListImpl::RemoveAllItems(void)
1114 __totalItemCount = 0;
1115 _itemsList.RemoveAll(true);
1117 GetCore().UpdateTableView();
1121 __pCheckedList->RemoveAll(true);
1128 _SlidableListImpl::RemoveCustomItemEventListener(const ICustomItemEventListener& listener)
1130 _ListListener* pListenerList = null;
1132 for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
1134 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1136 if ((pListenerList != null) && (pListenerList->pListener == &listener))
1138 __itemListenersList.RemoveAt(listenerCount, true);
1145 _SlidableListImpl::RemoveItemAt(int index, int itemHeight)
1147 result r = E_SUCCESS;
1149 if (!(index >= __topIndex && index < __topIndex + _itemsList.GetCount()))
1151 if (index >= 0 && index < __totalItemCount)
1161 r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
1162 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1163 "[%s] A system error has occurred. Failed to remove item at %d", GetErrorMessage(r), index);
1165 r = RemoveFromItemsList(-1, (index - __topIndex));
1166 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM,
1167 "[E_SYSTEM] A system error has occurred. Failed to remove an item.");
1171 __pCheckedList->RemoveAt(index, true);
1176 CallUnloadItemCb(index);
1182 _SlidableListImpl::ScrollToBottom(void)
1184 __isDirectDelete = true;
1186 result r = E_SUCCESS;
1188 r = GetCore().SetBottomDrawnItemIndex(0, __totalItemCount - 1);
1189 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1193 __isDirectDelete = false;
1197 _SlidableListImpl::ScrollToTop(int index)
1199 SysTryReturn(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), E_INVALID_ARG, E_INVALID_ARG,
1200 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount);
1202 result r = E_SUCCESS;
1204 __isDirectDelete = true;
1206 r = GetCore().SetTopDrawnItemIndex(0, index);
1207 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1211 __isDirectDelete = false;
1217 _SlidableListImpl::ScrollToTop(void)
1219 result r = E_SUCCESS;
1221 __isDirectDelete = true;
1223 r = GetCore().SetTopDrawnItemIndex(0, 0);
1224 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1228 __isDirectDelete = false;
1232 _SlidableListImpl::SetAllItemsChecked(bool check)
1234 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM,
1235 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1236 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM,
1237 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_RADIO");
1239 CustomListItem* pCustomListItem = null;
1240 _TableViewItemData* pTableViewItemData = null;
1241 _CheckElementModel* pCheckElement = null;
1243 Boolean* pChecked = null;
1246 for (itemIndex = 0; itemIndex < __totalItemCount; itemIndex++)
1248 pChecked = new (std::nothrow) Boolean(check);
1249 SysTryReturn(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1251 __pCheckedList->SetAt(*pChecked, itemIndex, true);
1254 for (int index = 0; index < _itemsList.GetCount(); index++)
1256 pCustomListItem = dynamic_cast<CustomListItem*>(_itemsList.GetAt(index));
1257 SysTryCatch(NID_UI_CTRL, pCustomListItem, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index %d.", index);
1259 SysTryCatch(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null");
1261 pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
1262 SysTryCatch(NID_UI_CTRL, pTableViewItemData != null, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. ItemData must not be null.");
1264 pCheckElement = pCustomListItem->__pCustomListItemImpl->GetCheckElement();
1265 SysTryCatch(NID_UI_CTRL, (pCheckElement != null), , E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null");
1269 pCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1273 pCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1285 _SlidableListImpl::SetItemAt(int index, const CustomListItem& item, int itemId)
1287 result r = E_SUCCESS;
1289 SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index <= (__topIndex + _itemsList.GetCount())), E_INVALID_ARG,
1290 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than or equal to (%d).",
1291 index, (__topIndex + _itemsList.GetCount()));
1293 SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item already exists.");
1295 _CheckElementModel* pCheckElement = null;
1296 _CheckElementModel* pOldCheckElement = GetCheckElementAt(-1, index - __topIndex);
1297 _CheckBoxStatus oldCheckStatus = (pOldCheckElement) ? (pOldCheckElement->GetCheckBoxStatus()) : CHECK_BOX_UNCHECKED;
1299 item.__pCustomListItemImpl->itemId = itemId;
1300 item.__pCustomListItemImpl->__pTableViewItemData = GetTableViewItemAt(-1, index - __topIndex);
1302 r = _itemsList.SetAt(item, index, true);
1303 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM,
1304 "[E_SYSTEM] A system error has occurred. Failed to set an item at index %d.", index);
1306 _TableViewItemUpdateParams updateParams;
1307 updateParams.pItem = (const_cast<CustomListItem*>(&item));;
1308 updateParams.isDividerEnabled = _isDividerEnabled;
1309 updateParams.pCheckBitmaps = _pCheckBitmaps;
1310 updateParams.annexStyle = _annexStyle;
1312 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
1313 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM,
1314 "[%s] A system error has occurred. Failed to update an item.", GetErrorMessage(r));
1316 if (GetCore().GetFirstDrawnFlag() == false)
1318 r = GetCore().RefreshTableView(0, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1319 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1322 pCheckElement = item.__pCustomListItemImpl->GetCheckElement();
1326 pCheckElement->SetCheckBoxStatus(oldCheckStatus);
1333 _SlidableListImpl::SetItemChecked(int groupindex, int index, bool check)
1335 return SetItemChecked(index, check);
1339 _SlidableListImpl::SetItemChecked(int index, bool check)
1341 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM,
1342 "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1344 SysTryReturnResult(NID_UI_CTRL, (index >= 0 && index < __totalItemCount), E_INVALID_ARG,
1345 "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).", index, __totalItemCount);
1347 if (IsItemChecked(index) == check)
1352 _CheckElementModel* pCheckElementModel = GetCheckElementAt(-1, index - __topIndex);
1353 SysTryReturnResult(NID_UI_CTRL, pCheckElementModel, E_SYSTEM,
1354 "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null.");
1356 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1358 if (_currentRadioIndex != -1)
1360 _CheckElementModel* pOldCheckElement = GetCheckElementAt(-1, _currentRadioIndex - __topIndex);
1361 SysTryReturnResult(NID_UI_CTRL, pOldCheckElement, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null.");
1363 pOldCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1364 DrawItem(-1, _currentRadioIndex);
1366 _currentRadioIndex = index;
1370 _currentRadioIndex = -1;
1375 pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1376 _currentRadioIndex = index;
1380 pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1381 _currentRadioIndex = -1;
1386 Boolean* pChecked = new (std::nothrow) Boolean(check);
1387 SysTryReturnResult(NID_UI_CTRL, pChecked, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1389 __pCheckedList->SetAt(*pChecked, index, true);
1391 pCheckElementModel->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1394 DrawItem(-1, index);
1400 _SlidableListImpl::SetLoadedItemEnabled(int index, bool enable)
1402 result r = E_SUCCESS;
1404 SysTryReturnResult(NID_UI_CTRL, (index >= __topIndex && index < _itemsList.GetCount() + __topIndex),
1405 E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. Index (%d) must be greater than or equal to 0 and less than (%d).",
1406 index, _itemsList.GetCount());
1408 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(_itemsList.GetAt(index - __topIndex));
1409 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", index);
1411 _CustomListItemImpl* pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl;
1412 SysTryReturnResult(NID_UI_CTRL, pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null.");
1414 _TableViewItemData* pTableViewItemData = pCustomListItemImpl->__pTableViewItemData;
1415 SysTryReturnResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", index);
1417 _CheckElementModel* pCheckElementModel = pCustomListItem->__pCustomListItemImpl->GetCheckElement();
1418 SysTryReturnResult(NID_UI_CTRL, pCheckElementModel, E_SYSTEM, "[E_SYSTEM] A system error has occurred. CheckElement instance must not be null.");
1420 if (pCheckElementModel)
1424 if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_DISABLED)
1426 pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1431 if (pCheckElementModel->GetCheckBoxStatus() == CHECK_BOX_CHECKED)
1433 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
1435 pCheckElementModel->SetCheckBoxStatus(CHECK_BOX_DISABLED);
1441 r = GetCore().SetItemEnabled(0, index, enable);
1442 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Failed to set an item enabled at index %d.", GetErrorMessage(r), index);
1444 pTableViewItemData->Invalidate(true);
1450 _SlidableListImpl::SetTextColorOfEmptyList(const Color& color)
1452 result r = GetCore().SetTextColorOfEmptyTableView(color);
1453 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1457 _SlidableListImpl::SetTextOfEmptyList(const String& text)
1459 result r = GetCore().SetTextOfEmptyTableView(text);
1460 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1464 _SlidableListImpl::Initalize(void)
1466 result r = E_SUCCESS;
1468 r = GetCore().AddTableViewItemEventListener(*this);
1469 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to add item event listener.", GetErrorMessage(r));
1471 __totalItemCount = 0;
1474 __itemCacheSize = GetCore().GetMaxItemCachingSize();
1480 _SlidableListImpl::CallUnloadItemCb(int index)
1482 _ListListener* pListenerData = null;
1483 ISlidableListEventListener* pSlidableListener = null;
1485 for (int listenerCount = 0; listenerCount < __slidableListenersList.GetCount(); listenerCount++)
1487 pListenerData = dynamic_cast<_ListListener*>(__slidableListenersList.GetAt(listenerCount));
1491 pSlidableListener = dynamic_cast<ISlidableListEventListener*>(pListenerData->pListener);
1492 SysTryReturnVoidResult(NID_UI_CTRL, (pSlidableListener != null), E_SYSTEM,
1493 "[E_SYSTEM] A system error has occurred. Failed to get EventListener");
1494 pSlidableListener->OnUnloadItemRequested(GetPublic(), index);
1502 _SlidableListImpl::IsCheckedStyle(void)
1504 if (((_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || _annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)))
1515 _SlidableListImpl::IsCheckedStyle(void) const
1517 if (((_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING || _annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)))
1527 _SlidableListImpl::OnTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* itemTag, Tizen::Ui::Controls::TableViewItemStatus status)
1529 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(_itemsList.GetAt(itemIndex - __topIndex));
1530 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM,
1531 "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", (itemIndex - __topIndex));
1533 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item instance must not be null");
1535 _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
1536 SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewItemData != null), E_SYSTEM,
1537 "[E_SYSTEM] A system error has occurred. Failed to get an item at %d index.", (itemIndex - __topIndex));
1539 ItemStatus itemStatus = ITEM_HIGHLIGHTED;
1543 case TABLE_VIEW_ITEM_STATUS_SELECTED:
1544 itemStatus = ITEM_SELECTED;
1546 case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED:
1547 itemStatus = ITEM_HIGHLIGHTED;
1549 case TABLE_VIEW_ITEM_STATUS_CHECKED:
1550 itemStatus = ITEM_CHECKED;
1552 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
1553 itemStatus = ITEM_UNCHECKED;
1556 SetLastResult(E_SYSTEM);
1560 if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL))
1562 bool isChecked = IsItemChecked(itemIndex + __topIndex);
1566 itemStatus = ITEM_UNCHECKED;
1570 itemStatus = ITEM_CHECKED;
1573 SetItemChecked(itemIndex, !isChecked);
1576 ProcessItemStateChange(0, itemIndex, itemStatus);
1581 _SlidableListImpl::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
1587 _SlidableListImpl::OnTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int itemIndexFrom, int itemIndexTo)
1593 _SlidableListImpl::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1599 _SlidableListImpl::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1605 _SlidableListImpl::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
1611 _SlidableListImpl::OnGroupedTableViewItemReordered(Tizen::Ui::Controls::_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo)
1617 _SlidableListImpl::OnSectionTableViewItemStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1623 _SlidableListImpl::OnSectionTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::_TableView& tableView, int sectionIndex, int itemIndex, Tizen::Ui::Controls::_TableViewItem* pContextItem, bool activated)
1629 _SlidableListImpl::OnTableViewItemSwept(Tizen::Ui::Controls::_TableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewSweepDirection direction)
1635 _SlidableListImpl::ProcessItemStateChange(int groupIndex, int index, int elementId, ItemStatus itemStatus)
1637 int itemId = GetLoadedItemIdAt(index);
1638 _ListListener* pListenerList = null;
1639 ICustomItemEventListener* pEventListener = null;
1641 int count = __itemListenersList.GetCount();
1642 for (int listenerCount = 0; listenerCount < count; listenerCount++)
1644 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1645 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Listener instance is not available.");
1647 pEventListener = dynamic_cast<ICustomItemEventListener*>(pListenerList->pListener);
1648 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Listener instance is not available.");
1650 pEventListener->OnItemStateChanged(GetPublic(), index, itemId, elementId, itemStatus);
1652 SetLastResult(E_SUCCESS);
1656 _SlidableListImpl::ProcessItemStateChange(int groupIndex, int index, ItemStatus itemStatus)
1658 int itemId = GetLoadedItemIdAt(index);
1659 _ListListener* pListenerList = null;
1660 ICustomItemEventListener* pEventListener = null;
1662 int count = __itemListenersList.GetCount();
1663 for (int listenerCount = 0; listenerCount < count; listenerCount++)
1665 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1666 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "Failed to get Listener.");
1668 pEventListener = dynamic_cast<ICustomItemEventListener*>(pListenerList->pListener);
1669 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "Failed to get Listener.");
1671 pEventListener->OnItemStateChanged(GetPublic(), index, itemId, itemStatus);
1673 SetLastResult(E_SUCCESS);
1677 _SlidableListImpl::CreateItemProvider(void)
1679 if (__pItemProvider == null)
1681 __pItemProvider = new (std::nothrow) _SlidableListItemProvider(this);
1682 SysTryReturnResult(NID_UI_CTRL, __pItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1684 TableViewStyle style = GetCore().GetTableViewStyle();
1685 SysTryCatch(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, , E_INVALID_OPERATION,
1686 "[E_INVALID_OPERATION] The current list cannot support the given style.");
1688 result r = E_SUCCESS;
1690 _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
1691 r = GetLastResult();
1692 SysTryCatch(NID_UI_CTRL, pItemProvider != null, , r, "[%s] Propagating.", GetErrorMessage(r));
1694 pItemProvider->SetSimpleStyleItemProvider(__pItemProvider);
1696 GetCore().SetItemProvider(pItemProvider);
1702 if (__pItemProvider)
1704 delete __pItemProvider;
1705 __pItemProvider = null;
1712 _SlidableListImpl::OnDraw(void)
1714 if (__pItemProvider == null)
1716 __pItemProvider = new (std::nothrow) _SlidableListItemProvider(this);
1717 SysTryReturnVoidResult(NID_UI_CTRL, __pItemProvider, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1719 TableViewStyle style = GetCore().GetTableViewStyle();
1720 SysTryCatch(NID_UI_CTRL, style == TABLE_VIEW_STYLE_SIMPLE, , E_INVALID_OPERATION,
1721 "[E_INVALID_OPERATION] The current list cannot support the given style.");
1723 _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
1724 result r = GetLastResult();
1725 SysTryCatch(NID_UI_CTRL, pItemProvider != null, , r, "[%s] Propagating.", GetErrorMessage(r));
1727 pItemProvider->SetSimpleStyleItemProvider(__pItemProvider);
1729 GetCore().SetItemProvider(pItemProvider);
1732 _ListBaseImpl::OnDraw();
1736 if (__pItemProvider)
1738 delete __pItemProvider;
1739 __pItemProvider = null;
1743 class _SlidableListMaker
1744 : public _UiBuilderControlMaker
1747 _SlidableListMaker(_UiBuilder* uibuilder)
1748 : _UiBuilderControlMaker(uibuilder){};
1749 virtual ~_SlidableListMaker(){};
1750 static _UiBuilderControlMaker*
1751 GetInstance(_UiBuilder* uibuilder)
1753 _SlidableListMaker* pSlidableListMaker = new (std::nothrow) _SlidableListMaker(uibuilder);
1754 return pSlidableListMaker;
1757 virtual Tizen::Ui::Control*
1758 Make(_UiBuilderControl* pControl)
1760 result r = E_SYSTEM;
1761 _UiBuilderControlLayout* pControlProperty = null;
1762 SlidableList* pSlidableList = null;
1763 Tizen::Graphics::Rectangle rect;
1764 Tizen::Graphics::Rectangle rectMin;
1767 Tizen::Ui::Controls::CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL;
1768 Tizen::Base::String elementString;
1769 bool isItemDivider = true;
1772 GetProperty(pControl, &pControlProperty);
1773 if (pControlProperty == null)
1778 pSlidableList = new (std::nothrow) SlidableList();
1779 if (pSlidableList == null)
1784 rect = pControlProperty->GetRect();
1786 Tizen::Base::String styleString;
1787 styleString = pControlProperty->GetStyle();
1790 if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false))
1792 style = CUSTOM_LIST_STYLE_NORMAL;
1794 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false))
1796 style = CUSTOM_LIST_STYLE_RADIO;
1798 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false))
1800 style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER;
1802 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false))
1804 style = CUSTOM_LIST_STYLE_MARK;
1806 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false))
1808 style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER;
1810 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false))
1812 style = CUSTOM_LIST_STYLE_ONOFF;
1814 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false))
1816 style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER;
1820 style = CUSTOM_LIST_STYLE_NORMAL;
1824 if (pControl->GetElement("itemDivider", elementString))
1826 if (elementString.Equals(L"true", false))
1828 isItemDivider = true;
1832 isItemDivider = false;
1836 r = pSlidableList->Construct(rect, style, isItemDivider);
1839 delete pSlidableList;
1843 if (pControl->GetElement("textOfEmptyList", elementString))
1845 pSlidableList->SetTextOfEmptyList(elementString);
1848 if (pControl->GetElement("colorOfEmptyListText", elementString))
1850 ConvertStringToColor(elementString, color);
1851 pSlidableList->SetTextColorOfEmptyList(color);
1854 GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin);
1855 rectMin = (pControl->GetAttribute(0))->GetRect();
1856 (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
1858 GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin);
1859 rectMin = (pControl->GetAttribute(1))->GetRect();
1860 (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
1862 return pSlidableList;
1869 _SlidableListRegister::_SlidableListRegister()
1871 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1873 if (pUiBuilderControlTableManager)
1875 pUiBuilderControlTableManager->RegisterControl(L"SlidableList", _SlidableListMaker::GetInstance);
1878 _SlidableListRegister::~_SlidableListRegister()
1880 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
1882 if (pUiBuilderControlTableManager)
1884 pUiBuilderControlTableManager->UnregisterControl(L"SlidableList");
1887 static _SlidableListRegister SlidableListRegisterToUiBuilder;
1888 }}} // Tizen::Ui::Controls