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_ExpandableListImpl.cpp
20 * @brief This file contains implementation of _ExpandableListImpl class
23 #include <FBaseSysLog.h>
24 #include <FGrp_BitmapImpl.h>
25 #include "FUiCtrl_CustomListItemImpl.h"
26 #include "FUiCtrl_CustomListItemFormatImpl.h"
27 #include "FUiCtrl_ExpandableListImpl.h"
28 #include "FUiCtrl_ListListener.h"
29 #include "FUi_ResourceSizeInfo.h"
30 #include "FUi_ResourceManager.h"
31 #include "FUiCtrl_ListItemBaseImpl.h"
32 #include "FUiCtrl_CustomListImpl.h"
33 #include "FUi_UiBuilder.h"
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Base::Collection;
40 namespace Tizen { namespace Ui { namespace Controls
43 extern const int INVALID_INDEX;
45 static const int _EXPANDABLE_ARROW_X_POSITION = 5;
46 static const int _EXPANDABLE_ARROW_Y_POSITION = 20;
47 static const char* ARROW_ELEMENT_NAME = "Arrow";
49 _ExpandableListItemDataProvider::_ExpandableListItemDataProvider(_ExpandableListImpl* pList)
54 _ExpandableListItemDataProvider::~_ExpandableListItemDataProvider(void)
60 _ExpandableListItemDataProvider::GetGroupCount(void)
62 SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
63 return __pListImpl->GetGroupCount();
67 _ExpandableListItemDataProvider::GetItemCount(int groupIndex)
69 SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
71 return __pListImpl->GetSubItemCountAt(groupIndex);
75 _ExpandableListItemDataProvider::CreateGroupItem(int groupIndex, int itemWidth)
77 SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
79 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1);
80 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
82 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
84 _TableViewItemParams tableViewItemParams;
85 tableViewItemParams.pItem = pCustomListItem;
86 tableViewItemParams.width = itemWidth;
87 tableViewItemParams.itemId = pCustomListItem->__pCustomListItemImpl->itemId;
88 tableViewItemParams.groupIndex = groupIndex;
89 tableViewItemParams.itemIndex = -1;
90 tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
91 tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
92 tableViewItemParams.annexStyle = __pListImpl->_annexStyle;
94 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
95 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
97 pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData->AddTouchEventListener(*__pListImpl);
99 if (__pListImpl->GetSubItemCountAt(groupIndex) > 0)
101 r = __pListImpl->CreateArrowIcon(groupIndex);
102 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
105 return pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData;
109 _ExpandableListItemDataProvider::CreateItem(int groupIndex, int itemIndex, int itemWidth)
111 SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Invalid data structure.");
113 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex);
114 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
116 _TableViewItemParams tableViewItemParams;
117 tableViewItemParams.pItem = pCustomListItem;
118 tableViewItemParams.width = itemWidth;
119 tableViewItemParams.itemId = pCustomListItem->__pCustomListItemImpl->itemId;
120 tableViewItemParams.groupIndex = groupIndex;
121 tableViewItemParams.itemIndex = itemIndex;
122 tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
123 tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
124 tableViewItemParams.annexStyle = __pListImpl->_annexStyle;
126 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
127 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
129 pCustomListItem->__pCustomListItemImpl->__pTableViewItemData->AddTouchEventListener(*__pListImpl);
131 if (__pListImpl->GetSubItemCountAt(groupIndex) == 1)
133 r = __pListImpl->CreateArrowIcon(groupIndex);
134 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
137 return pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
141 _ExpandableListItemDataProvider::GetDefaultGroupItemHeight(void)
143 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(0, -1);
144 SysTryReturn(NID_UI_CTRL, pCustomListItem, __pListImpl->_defaultItemHeight, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get first item");
146 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, __pListImpl->_defaultItemHeight, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get first item");
148 return pCustomListItem->__pCustomListItemImpl->height;
152 _ExpandableListItemDataProvider::GetDefaultItemHeight(void)
154 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(0, 0);
156 if (!pCustomListItem)
158 return __pListImpl->_defaultItemHeight;
162 return pCustomListItem->__pCustomListItemImpl->height;
167 _ExpandableListItemDataProvider::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
171 if (__pListImpl->__directDelete == false)
173 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex);
174 pCustomListItem->__pCustomListItemImpl->__pTableViewItemData = null;
181 _ExpandableListItemDataProvider::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
185 if (__pListImpl->__directDelete == false)
187 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1);
188 pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData = null;
195 _ExpandableListItemDataProvider::IsReorderable(int groupIndexFrom, int groupIndexTo)
201 _ExpandableListItemDataProvider::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem)
203 CustomListItem* pGroupCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1);
204 SysTryReturnVoidResult(NID_UI_CTRL, pGroupCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
206 _TableViewItemUpdateParams updateParams;
207 updateParams.pItem = pGroupCustomListItem;
208 updateParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
209 updateParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
210 updateParams.annexStyle = __pListImpl->_annexStyle;
212 result r = E_SUCCESS;
214 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
215 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
217 SysTryReturnVoidResult(NID_UI_CTRL, pGroupCustomListItem->__pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
219 _TableViewItemData* pTableViewItemData = pGroupCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
220 SysTryReturnVoidResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex);
222 pTableViewItemData->SetEnabled(true);
227 _ExpandableListItemDataProvider::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem)
229 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex);
230 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex);
232 _TableViewItemUpdateParams updateParams;
233 updateParams.pItem = pCustomListItem;
234 updateParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
235 updateParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
236 updateParams.annexStyle = __pListImpl->_annexStyle;
238 result r = E_SUCCESS;
240 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
241 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
243 _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
244 SysTryReturnVoidResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex);
246 pTableViewItemData->SetEnabled(true);
251 _ExpandableListArrowBitmap::_ExpandableListArrowBitmap(void)
252 : __pNormalBitmap(null)
253 , __pEffectBitmap(null)
257 _ExpandableListArrowBitmap::~_ExpandableListArrowBitmap(void)
262 _ExpandableListArrowBitmap::SetBitmap(const Bitmap &pNormalBitmap, const Bitmap *pEffectBitmap)
264 __pNormalBitmap = &pNormalBitmap;
265 __pEffectBitmap = pEffectBitmap;
271 _ExpandableListArrowBitmap::OnDraw(void)
273 SysTryReturn(NID_UI_CTRL, (__pNormalBitmap), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Normal Arrow bitmap is null.");
275 result r = E_SUCCESS;
277 Canvas* pCanvas = null;
278 pCanvas = GetCanvasN();
281 SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
283 const Rectangle bounds = GetBounds();
285 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pNormalBitmap))
287 r = pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, bounds.width, bounds.height), *__pNormalBitmap);
291 r = pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *__pNormalBitmap);
294 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
296 if (__pEffectBitmap != null)
298 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pEffectBitmap))
300 r = pCanvas->DrawNinePatchedBitmap(Rectangle(0, 0, bounds.width, bounds.height), *__pEffectBitmap);
305 r = pCanvas->DrawBitmap(Rectangle(0, 0, bounds.width, bounds.height), *__pEffectBitmap);
308 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
320 _ExpandableListImpl::GetInstance(ExpandableList& expandableList)
322 return static_cast<_ExpandableListImpl*>(expandableList._pControlImpl);
325 const _ExpandableListImpl*
326 _ExpandableListImpl::GetInstance(const ExpandableList& expandableList)
328 return static_cast<const _ExpandableListImpl*>(expandableList._pControlImpl);
331 _ExpandableListImpl::_ExpandableListImpl(Control* pList, _TableView* pCore)
332 : _ListBaseImpl(pList, pCore)
333 , __pOpenedImage(null)
334 , __pClosedImage(null)
335 , __pEffectClosedImage(null)
336 , __pEffectOpenedImage(null)
337 , __pItemProvider(null)
338 , __directDelete(false)
339 , __groupExpandStateList(DeleteExpandStateFlag)
343 _ExpandableListImpl::~_ExpandableListImpl(void)
345 GetCore().SetItemProvider(null);
347 int count = GetItemCount();
349 for (int index = 0; index < count; index++)
351 RemoveFromSubItemsList(index);
354 RemoveAllFromItemsList();
356 __groupExpandStateList.RemoveAll(true);
358 __itemListenersList.RemoveAll(true);
360 delete __pOpenedImage;
361 __pOpenedImage = null;
363 delete __pClosedImage;
364 __pClosedImage = null;
366 delete __pItemProvider;
367 __pItemProvider = null;
369 delete __pEffectOpenedImage;
370 __pEffectOpenedImage = null;
372 delete __pEffectClosedImage;
373 __pEffectClosedImage = null;
375 delete __pOpenedDisabledImage;
376 __pOpenedDisabledImage = null;
378 delete __pOpenedPressedImage;
379 __pOpenedPressedImage = null;
381 delete __pClosedDisabledImage;
382 __pClosedDisabledImage = null;
384 delete __pClosedPressedImage;
385 __pClosedPressedImage = null;
390 _ExpandableListImpl::GetPublicClassName(void) const
392 return "ExpandableList";
395 const ExpandableList&
396 _ExpandableListImpl::GetPublic(void) const
398 return static_cast<const ExpandableList&>(_ControlImpl::GetPublic());
402 _ExpandableListImpl::GetPublic(void)
404 return static_cast<ExpandableList&>(_ControlImpl::GetPublic());
408 _ExpandableListImpl::GetCore(void) const
410 return static_cast<const _TableView&>(_ControlImpl::GetCore());
414 _ExpandableListImpl::GetCore(void)
416 return static_cast<_TableView&>(_ControlImpl::GetCore());
420 _ExpandableListImpl::CreateExpandableListImplN(ExpandableList* pControl, const Rectangle& bounds, bool itemDivider)
422 result r = E_SUCCESS;
424 r = GET_SIZE_INFO(ExpandableList).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
425 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
427 _TableView* pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_GROUPED, true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
430 SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r));
432 _ExpandableListImpl* pImpl = new (std::nothrow) _ExpandableListImpl(pControl, pCore);
433 SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
435 pCore->SetItemDividerEnabled(itemDivider);
437 r = pCore->SetScrollStyle(TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
438 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
450 _ExpandableListImpl::UpdateBounds(const Rectangle& rect)
452 result r = E_SUCCESS;
454 r = InitializeBoundsProperties(GET_SIZE_INFO(CustomList), rect, GetCore().GetOrientation());
455 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
461 _ExpandableListImpl::Initialize(void)
463 result r = E_SUCCESS;
465 __pItemProvider = new (std::nothrow) _ExpandableListItemDataProvider(this);
466 SysTryReturnResult(NID_UI_CTRL, (__pItemProvider != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
468 TableViewStyle style = GetCore().GetTableViewStyle();
469 SysTryReturnResult(NID_UI_CTRL, style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION, "The style of TableView is not TABLE_VIEW_STYLE_GROUPED");
471 _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
472 SysTryReturnResult(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
474 r = pItemProvider->SetGroupedStyleItemProvider(__pItemProvider);
478 delete pItemProvider;
479 SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
482 r = GetCore().SetItemProvider(pItemProvider);
483 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
485 r = GetCore().AddGroupedTableViewItemEventListener(*this);
486 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
488 r = LoadArrowBitmap();
489 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
491 GET_COLOR_CONFIG(LIST::EXPANDABLELIST_SUB_ITEM_BG_COLOR, __subItemBgColor);
497 _ExpandableListImpl::CreateArrowIcon(int groupIndex)
499 int size = __pOpenedImage->GetWidth();
500 result r = E_SUCCESS;
502 bool isEnabled = true;
504 isEnabled = IsItemEnabled(groupIndex);
506 _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(groupIndex);
507 SysTryReturnResult(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, "A system error has occurred. Failed to get GroupItemData at %d index.", groupIndex);
509 _ExpandableListArrowBitmap* pArrowIcon = null;
510 pArrowIcon = dynamic_cast<_ExpandableListArrowBitmap*>(pTableViewGroupItemData->GetControl(ARROW_ELEMENT_NAME));
512 if (pArrowIcon == null)
514 _ExpandableListArrowBitmap* pArrowIcon = new (std::nothrow) _ExpandableListArrowBitmap();
515 SysTryReturn(NID_UI_CTRL, pArrowIcon, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
517 r = pArrowIcon->Construct(Rectangle((GetCore().GetBounds().width - (size + _EXPANDABLE_ARROW_X_POSITION)), _EXPANDABLE_ARROW_Y_POSITION, size, size), GROUP_STYLE_NONE);
518 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
520 pArrowIcon->SetName(ARROW_ELEMENT_NAME);
522 Boolean* pIsExpanded = dynamic_cast<Boolean*>(const_cast<Object*>(__groupExpandStateList.GetAt(groupIndex)));
523 bool isCustomBitmap = false;
526 if (pIsExpanded && pIsExpanded->ToBool())
528 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
531 pArrowIcon->SetBitmap(*__pClosedImage);
535 pArrowIcon->SetBitmap(*__pClosedImage, __pEffectClosedImage);
540 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
544 pArrowIcon->SetBitmap(*__pOpenedImage);
548 pArrowIcon->SetBitmap(*__pOpenedImage, __pEffectOpenedImage);
555 if (pIsExpanded && pIsExpanded->ToBool())
557 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
560 pArrowIcon->SetBitmap(*__pClosedDisabledImage);
564 pArrowIcon->SetBitmap(*__pClosedDisabledImage, __pEffectClosedImage);
569 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
573 pArrowIcon->SetBitmap(*__pOpenedDisabledImage);
577 pArrowIcon->SetBitmap(*__pOpenedDisabledImage, __pEffectOpenedImage);
582 pArrowIcon->AddTouchEventListener(*this);
584 pTableViewGroupItemData->AddControl(*pArrowIcon);
585 pTableViewGroupItemData->SetIndividualSelectionEnabled(pArrowIcon, true);
592 _ExpandableListImpl::LoadArrowBitmap(void)
594 result r = E_SUCCESS;
595 Bitmap* pTempBitmap = null;
600 GET_COLOR_CONFIG(TABLEVIEW::EXPANDABLE_ARROW_NORMAL, normalColor);
601 GET_COLOR_CONFIG(TABLEVIEW::EXPANDABLE_ARROW_DISABLED, disabledColor);
602 GET_COLOR_CONFIG(TABLEVIEW::EXPANDABLE_ARROW_PRESSED, pressedColor);
604 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_COLLAPSE_GROUP, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
605 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow Bitmap");
606 __pOpenedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor);
607 __pOpenedDisabledImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), disabledColor);
608 __pOpenedPressedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedColor);
613 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_EXPAND_GROUP, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
614 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow Bitmap");
615 __pClosedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor);
616 __pClosedDisabledImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), disabledColor);
617 __pClosedPressedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedColor);
622 r = GET_BITMAP_CONFIG_N(TABLEVIEW::BUTTON_EXPAND_CLOSED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pEffectOpenedImage);
623 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow effect Bitmap");
625 r = GET_BITMAP_CONFIG_N(TABLEVIEW::BUTTON_EXPAND_OPENED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pEffectClosedImage);
626 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow effect Bitmap");
632 _ExpandableListImpl::AddExpandableItemEventListener(const IExpandableItemEventListener& listener)
634 _ListListener* pListenersList = new (std::nothrow) _ListListener();
636 SysTryReturn(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
638 pListenersList->pListener = const_cast<IExpandableItemEventListener*>(&listener);
639 __itemListenersList.Add(*pListenersList);
645 _ExpandableListImpl::RemoveExpandableItemEventListener(const IExpandableItemEventListener& listener)
647 _ListListener* pListenersList = null;
649 int count = __itemListenersList.GetCount();
651 for (int listenerCount = 0; listenerCount < count; listenerCount++)
653 pListenersList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
655 if ((pListenersList != null) && (pListenersList->pListener == &listener))
658 __itemListenersList.RemoveAt(listenerCount, true);
667 _ExpandableListImpl::AddItem(const CustomListItem& item, int itemId)
669 return InsertItemAt(GetGroupCount(), item, itemId);
673 _ExpandableListImpl::InsertItemAt(int mainIndex, const CustomListItem& item, int itemId)
675 result r = E_SUCCESS;
677 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
679 item.__pCustomListItemImpl->itemId = itemId;
681 Boolean* pIsExpanded = new Boolean(false);
682 SysTryReturn(NID_UI_CTRL, pIsExpanded, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
684 __groupExpandStateList.InsertAt(*pIsExpanded, mainIndex);
686 r = InsertIntoItemsList(item, mainIndex, -1);
687 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item.");
689 r = GetCore().RefreshTableView(mainIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
690 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
692 if (GetCore().GetFirstDrawnFlag() == false)
694 SetItemExpanded(mainIndex, false);
700 RemoveFromItemsList(mainIndex, -1);
701 __groupExpandStateList.RemoveAt(mainIndex, true);
707 _ExpandableListImpl::AddSubItem(int mainIndex, const CustomListItem& item, int itemId)
709 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
711 return InsertSubItemAt(mainIndex, GetSubItemCountAt(mainIndex), item, itemId);
715 _ExpandableListImpl::InsertSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId)
717 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex);
719 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex <= GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d.", subIndex);
721 item.__pCustomListItemImpl->itemId = itemId;
723 result r = E_SUCCESS;
725 r = InsertIntoItemsList(item, mainIndex, subIndex);
726 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to insert item");
728 r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
729 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
734 RemoveFromItemsList(mainIndex, subIndex);
739 _ExpandableListImpl::GetItemCount(void) const
741 return GetGroupCount();
745 _ExpandableListImpl::GetSubItemCount(int mainIndex) const
747 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d.", mainIndex);
749 return GetSubItemCountAt(mainIndex);
753 _ExpandableListImpl::SetItemAt(int mainIndex, const CustomListItem& item, int itemId)
755 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
757 SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item already exists.");
759 result r = E_SUCCESS;
760 item.__pCustomListItemImpl->itemId = itemId;
762 r = SetInItemsList(item, mainIndex, -1);
763 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
765 _TableViewItemUpdateParams updateParams;
766 updateParams.pItem = const_cast<CustomListItem*>(&item);
767 updateParams.isDividerEnabled = _isDividerEnabled;
768 updateParams.pCheckBitmaps = _pCheckBitmaps;
769 updateParams.annexStyle = _annexStyle;
771 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
772 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to refresh an item.");
778 _ExpandableListImpl::RemoveItemAt(int mainIndex)
780 result r = E_SUCCESS;
782 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex);
784 r = RemoveFromSubItemsList(mainIndex);
785 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
787 r = RemoveFromItemsList(mainIndex, -1);
788 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
790 __groupExpandStateList.RemoveAt(mainIndex, true);
792 __directDelete = true;
794 r = GetCore().RefreshTableView(mainIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
796 __directDelete = false;
798 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
804 _ExpandableListImpl::SetSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId)
806 result r = E_SUCCESS;
808 SysTryReturn(NID_UI_CTRL, ((mainIndex >= 0) && (mainIndex < GetGroupCount())), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
810 _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(mainIndex);
811 SysTryReturn(NID_UI_CTRL, pGroupItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get GroupItem at %d index.", mainIndex);
813 SysTryReturn(NID_UI_CTRL, ((subIndex >= 0) && (subIndex < GetSubItemCountAt(mainIndex))), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
815 item.__pCustomListItemImpl->itemId = itemId;
817 CustomListItem* pOldItem = GetCustomListItemAt(mainIndex, subIndex);
818 SysTryReturnResult(NID_UI_CTRL, pOldItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d), subIndex(%d).", mainIndex, subIndex);
819 SysTryReturnResult(NID_UI_CTRL, pOldItem->__pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d), subIndex(%d).", mainIndex, subIndex);
821 item.__pCustomListItemImpl->__pTableViewItemData = pOldItem->__pCustomListItemImpl->__pTableViewItemData;
823 r = SetInItemsList(item, mainIndex, subIndex);
824 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to update an item.");
826 _TableViewItemUpdateParams updateParams;
827 updateParams.pItem = const_cast<CustomListItem*>(&item);
828 updateParams.isDividerEnabled = _isDividerEnabled;
829 updateParams.pCheckBitmaps = _pCheckBitmaps;
830 updateParams.annexStyle = _annexStyle;
832 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
833 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
835 r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
836 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "Item not inserted successFully.");
842 _ExpandableListImpl::RemoveSubItemAt(int mainIndex, int subIndex)
844 result r = E_SUCCESS;
846 SysTryReturn(NID_UI_CTRL, ((mainIndex >= 0) && (mainIndex < GetGroupCount())), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
848 SysTryReturn(NID_UI_CTRL, ((subIndex >= 0) && (subIndex < GetSubItemCount(mainIndex))), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
850 r = RemoveFromItemsList(mainIndex, subIndex);
851 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove item.");
853 __directDelete = true;
855 r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
857 __directDelete = false;
859 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove item.");
861 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
863 int checkedCount = GetCheckedItemCount(mainIndex);
865 if (checkedCount == 0)
867 _CheckElementModel* pGroupCheckElement = GetCheckElementAt(mainIndex, -1);
868 SysTryReturnResult(NID_UI_CTRL, pGroupCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at %d index.", mainIndex);
870 pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
872 DrawItem(mainIndex, -1);
880 _ExpandableListImpl::RemoveAllSubItemsAt(int mainIndex)
882 result r = E_SUCCESS;
884 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex);
886 int count = GetSubItemCountAt(mainIndex);
887 for (int index = 0; index < count; index++)
889 r = RemoveSubItemAt(mainIndex, 0);
896 _ExpandableListImpl::RemoveAllItems(void)
898 result r = E_SUCCESS;
899 result finalResult = E_SUCCESS;
901 int count = GetGroupCount();
902 for (int index = count - 1; index >= 0; index--)
904 r = RemoveItemAt(index);
909 SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Item at %d index not removed successfully", index);
917 _ExpandableListImpl::IsItemChecked(int groupIndex, int subIndex) const
921 return IsItemChecked(groupIndex);
925 return IsSubItemChecked(groupIndex, subIndex);
930 _ExpandableListImpl::IsItemChecked(int mainIndex) const
932 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. list style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL.");
934 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()),
935 false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
937 const _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, -1);
938 SysTryReturn(NID_UI_CTRL, pCheckElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get checkElement at mainIndex(%d).", mainIndex);
940 return (bool)pCheckElement->GetCheckBoxStatus();
944 _ExpandableListImpl::GetFirstCheckedItemIndex(void) const
946 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, INVALID_INDEX, "[INVALID_INDEX] List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
948 int count = GetGroupCount();
949 for (int index = 0; index < count; index++)
951 if (IsItemChecked(index))
954 return INVALID_INDEX;
958 _ExpandableListImpl::GetItemIdAt(int mainIndex) const
960 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
962 const CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, -1);
963 SysTryReturn(NID_UI_CTRL, pCustomListItem, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d).", mainIndex);
965 return pCustomListItem->__pCustomListItemImpl->itemId;
969 _ExpandableListImpl::GetItemIndexFromItemId(int itemId) const
971 int count = GetGroupCount();
972 for (int index = 0; index < count; index++)
974 const CustomListItem* pCustomListItem = GetCustomListItemAt(index, -1);
975 SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", index);
977 if (itemId == pCustomListItem->__pCustomListItemImpl->itemId)
980 return INVALID_INDEX;
984 _ExpandableListImpl::GetSubItemIdAt(int mainIndex, int subIndex) const
986 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
988 SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
990 const CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, subIndex);
991 SysTryReturn(NID_UI_CTRL, pCustomListItem, INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d), subIndex(%d).", mainIndex, subIndex);
993 return pCustomListItem->__pCustomListItemImpl->itemId;
997 _ExpandableListImpl::SetItemExpanded(int mainIndex, bool expand)
999 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1001 Boolean* pIsExpanded = new Boolean(expand);
1002 SysTryReturn(NID_UI_CTRL, pIsExpanded, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1004 __groupExpandStateList.SetAt(*pIsExpanded, mainIndex, true);
1006 if (GetCore().GetFirstDrawnFlag() || (GetCore().IsGroupExpanded(mainIndex) == expand))
1011 result r = E_SUCCESS;
1013 _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(mainIndex);
1014 SysTryReturn(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item at %d mainIndex.", mainIndex);
1016 _ExpandableListArrowBitmap* pArrowIcon = dynamic_cast<_ExpandableListArrowBitmap*>(pTableViewGroupItemData->GetControl(ARROW_ELEMENT_NAME));
1017 SysTryReturn(NID_UI_CTRL, pArrowIcon, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get arrow icon.");
1019 bool isCustomBitmap = false;
1023 r = GetCore().ExpandGroup(mainIndex);
1025 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
1029 pArrowIcon->SetBitmap(*__pClosedImage);
1033 pArrowIcon->SetBitmap(*__pClosedImage, __pEffectClosedImage);
1038 r = GetCore().CollapseGroup(mainIndex);
1040 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
1044 pArrowIcon->SetBitmap(*__pOpenedImage);
1048 pArrowIcon->SetBitmap(*__pOpenedImage, __pEffectOpenedImage);
1052 pArrowIcon->Invalidate(true);
1058 _ExpandableListImpl::SetItemEnabled(int mainIndex, bool enable)
1060 result r = E_SUCCESS;
1062 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1064 _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, -1);
1065 SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d).", mainIndex);
1071 if (pCheckElement->GetCheckBoxStatus() == CHECK_BOX_DISABLED)
1073 pCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1078 if (pCheckElement->GetCheckBoxStatus() == CHECK_BOX_CHECKED)
1080 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
1082 pCheckElement->SetCheckBoxStatus(CHECK_BOX_DISABLED);
1088 r = GetCore().SetItemEnabled(mainIndex, -1, enable);
1089 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1095 _ExpandableListImpl::IsItemEnabled(int mainIndex) const
1097 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1099 return GetCore().IsItemEnabled(mainIndex, -1);
1103 _ExpandableListImpl::SetSubItemEnabled(int mainIndex, int subIndex, bool enable)
1105 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex(%d)", mainIndex);
1106 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex(%d)", subIndex);
1108 result r = E_SUCCESS;
1110 _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, subIndex);
1111 SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex);
1117 if (pCheckElement->GetCheckBoxStatus() == CHECK_BOX_DISABLED)
1119 pCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1124 if (pCheckElement->GetCheckBoxStatus() == CHECK_BOX_CHECKED)
1126 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK)
1128 pCheckElement->SetCheckBoxStatus(CHECK_BOX_DISABLED);
1134 r = GetCore().SetItemEnabled(mainIndex, subIndex, enable);
1135 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1141 _ExpandableListImpl::IsSubItemEnabled(int mainIndex, int subIndex) const
1143 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1145 SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
1147 return GetCore().IsItemEnabled(mainIndex, subIndex);
1151 _ExpandableListImpl::SetItemChecked(int groupIndex, int itemIndex, bool check)
1153 if (itemIndex == -1)
1155 return SetItemChecked(groupIndex, check);
1159 return SetSubItemChecked(groupIndex, itemIndex, check);
1164 _ExpandableListImpl::SetItemChecked(int mainIndex, bool check)
1166 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1168 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1170 SysTryReturnResult(NID_UI_CTRL, (IsItemEnabled(mainIndex)), E_SYSTEM, "A system error has occurred. The item is not enabled at mainIndex %d.", mainIndex);
1172 if (IsItemChecked(mainIndex) == check)
1177 _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, -1);
1178 SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d)", mainIndex);
1180 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1182 if (_currentRadioGroupIndex != -1)
1184 _CheckElementModel* pOldSubCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex);
1185 SysTryReturnResult(NID_UI_CTRL, pOldSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", _currentRadioGroupIndex, _currentRadioIndex);
1187 pOldSubCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1189 DrawItem(_currentRadioGroupIndex, _currentRadioIndex);
1192 _currentRadioGroupIndex = (check == true) ? mainIndex : -1;
1193 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1194 _currentRadioIndex = -1;
1199 int subCount = GetSubItemCountAt(mainIndex);
1203 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1207 for (int subItemCount = 0; subItemCount < subCount; subItemCount++)
1209 SetSubItemChecked(mainIndex, subItemCount, check);
1217 _ExpandableListImpl::SetSubItemCheckedRadio(int mainIndex, int subIndex, bool check)
1219 if (_currentRadioGroupIndex != -1)
1221 _CheckElementModel* pOldSubCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex);
1222 SysTryReturnResult(NID_UI_CTRL, pOldSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", _currentRadioGroupIndex, _currentRadioIndex);
1224 pOldSubCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1226 DrawItem(_currentRadioGroupIndex, _currentRadioIndex);
1231 _currentRadioGroupIndex = mainIndex;
1232 _currentRadioIndex = subIndex;
1236 _currentRadioGroupIndex = -1;
1237 _currentRadioIndex = -1;
1240 _CheckElementModel* pSubCheckElement = GetCheckElementAt(mainIndex, subIndex);
1241 SysTryReturnResult(NID_UI_CTRL, pSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex);
1243 pSubCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1245 DrawItem(mainIndex, subIndex);
1251 _ExpandableListImpl::SetSubItemCheckedMarkOnOff(int mainIndex, int subIndex, bool check)
1253 _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, subIndex);
1254 SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex);
1256 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1258 _CheckElementModel* pGroupCheckElement = GetCheckElementAt(mainIndex, -1);
1259 SysTryReturnResult(NID_UI_CTRL, pGroupCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d).", mainIndex);
1261 if ((check) || (GetCheckedItemCountAt(mainIndex) > 0))
1263 pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1267 pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1270 DrawItem(mainIndex, -1);
1271 DrawItem(mainIndex, subIndex);
1277 _ExpandableListImpl::SetSubItemChecked(int mainIndex, int subIndex, bool check)
1279 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1281 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex);
1283 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1285 if (IsSubItemChecked(mainIndex, subIndex) == check)
1290 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1292 return SetSubItemCheckedRadio(mainIndex, subIndex, check);
1296 return SetSubItemCheckedMarkOnOff(mainIndex, subIndex, check);
1301 _ExpandableListImpl::GetCheckedItemCountAt(int mainIndex) const
1303 int totalSubItemCount = GetSubItemCountAt(mainIndex);
1306 for (int index = 0; index < totalSubItemCount; index++)
1308 if (IsSubItemChecked(mainIndex, index) == true)
1318 _ExpandableListImpl::IsSubItemChecked(int mainIndex, int subIndex) const
1320 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. list style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL.");
1322 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1324 SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
1326 const _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, subIndex);
1327 SysTryReturn(NID_UI_CTRL, pCheckElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex);
1329 return (bool)pCheckElement->GetCheckBoxStatus();
1333 _ExpandableListImpl::SetAllSubItemsChecked(int mainIndex, bool check)
1335 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1337 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1338 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_RADIO");
1340 int totalSubItemCount = GetSubItemCountAt(mainIndex);
1341 result r = E_SUCCESS;
1343 for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++)
1345 r = SetSubItemChecked(mainIndex, subItemCount, check);
1346 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1353 _ExpandableListImpl::RemoveAllCheckedSubItemsAt(int mainIndex)
1355 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1357 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1359 SysTryReturnResult(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_RADIO), E_SYSTEM, "A system error has occurred. The List Style should not be TABLE_VIEW_ANNEX_STYLE_RADIO");
1361 result r = E_SUCCESS;
1362 int totalSubItemCount = GetSubItemCountAt(mainIndex);
1364 for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++)
1366 bool isChecked = IsSubItemChecked(mainIndex, subItemCount);
1370 r = RemoveSubItemAt(mainIndex, subItemCount);
1371 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to remove item");
1379 _ExpandableListImpl::GetFirstCheckedSubItemIndex(int mainIndex) const
1381 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1383 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1385 int totalSubItemCount = GetSubItemCountAt(mainIndex);
1387 for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++)
1389 if (IsSubItemChecked(mainIndex, subItemCount))
1391 return subItemCount;
1395 return INVALID_INDEX;
1399 _ExpandableListImpl::GetLastCheckedItemIndex(void) const
1401 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1403 int count = GetGroupCount();
1405 for (int index = count - 1; index >= 0; index--)
1407 if (IsItemChecked(index))
1413 return INVALID_INDEX;
1417 _ExpandableListImpl::GetLastCheckedSubItemIndex(int mainIndex) const
1419 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1421 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1423 int count = GetSubItemCountAt(mainIndex);
1425 for (int index = count - 1; index >= 0; index--)
1427 if (IsSubItemChecked(mainIndex, index))
1432 return INVALID_INDEX;
1436 _ExpandableListImpl::GetNextCheckedItemIndexAfter(int mainIndex) const
1438 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1440 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1442 for (int index = mainIndex+1; index < GetGroupCount(); index++)
1444 if (IsItemChecked(index))
1450 return INVALID_INDEX;
1454 _ExpandableListImpl::GetNextCheckedSubItemIndexAfter(int mainIndex, int subIndex) const
1456 SysTryReturn(NID_UI_CTRL, (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL), INVALID_INDEX, E_SYSTEM, "[E_SYSTEM] A system error has occurred. List style should not be TABLE_VIEW_ANNEX_STYLE_NORMAL");
1458 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1459 SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
1461 int count = GetSubItemCountAt(mainIndex);
1463 for (int index = subIndex + 1; index < count; index++)
1465 if (IsSubItemChecked(mainIndex, index))
1471 return INVALID_INDEX;
1475 _ExpandableListImpl::GetSubItemIndexFromItemId(int itemId, int& mainIndex, int& subIndex) const
1477 mainIndex = INVALID_INDEX;
1478 subIndex = INVALID_INDEX;
1480 for (int index = 0; index < GetGroupCount(); index++)
1482 for (int count = 0; count < GetSubItemCountAt(index); count++)
1484 const CustomListItem* pCustomListItem = GetCustomListItemAt(index, count);
1485 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", index, count);
1487 SysTryReturnResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, E_SYSTEM, "A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", index, count);
1489 if (itemId == pCustomListItem->__pCustomListItemImpl->itemId)
1498 return E_OBJ_NOT_FOUND;
1502 _ExpandableListImpl::ScrollToBottom(void)
1504 result r = E_SUCCESS;
1506 int lastGroupIndex = GetGroupCount() - 1;
1507 int lastItemIndex = GetSubItemCountAt(lastGroupIndex) - 1;
1509 r = GetCore().SetBottomDrawnItemIndex(lastGroupIndex, lastItemIndex);
1510 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1517 _ExpandableListImpl::ScrollToTop(void)
1519 result r = E_SUCCESS;
1521 r = GetCore().SetTopDrawnItemIndex(0, -1);
1522 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1523 SetLastResult(E_SUCCESS);
1531 _ExpandableListImpl::ScrollToTop(int mainIndex, int subIndex)
1533 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1534 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex);
1535 result r = E_SUCCESS;
1537 r = GetCore().SetTopDrawnItemIndex(mainIndex, subIndex);
1538 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1546 _ExpandableListImpl::ScrollToTop(int mainIndex)
1548 SysTryReturn(NID_UI_CTRL, ((mainIndex < GetGroupCount()) && (mainIndex >= 0)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d.", mainIndex);
1550 result r = E_SUCCESS;
1552 r = GetCore().SetTopDrawnItemIndex(mainIndex, -1);
1553 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1561 _ExpandableListImpl::SetBgColor(const Color& color)
1563 GetCore().SetBackgroundColor(color);
1568 _ExpandableListImpl::RefreshItem(int mainIndex)
1570 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex);
1572 int topGroupIndex = -1;
1573 int bottomGroupIndex = -1;
1576 GetCore().GetTopDrawnItemIndex(topGroupIndex, itemIndex);
1577 GetCore().GetBottomDrawnItemIndex(bottomGroupIndex, itemIndex);
1579 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= topGroupIndex && mainIndex <= bottomGroupIndex), E_INVALID_OPERATION, "Index should be within drawn item range %d.", mainIndex);
1581 result r = E_SUCCESS;
1583 int count = GetSubItemCountAt(mainIndex);
1584 for (int indexItem = 0; indexItem < count; indexItem++)
1586 r = RefreshSubItem(mainIndex, indexItem);
1589 SysLog(NID_UI_CTRL, "Not able to refresh item with index %d %d.", mainIndex, indexItem);
1597 _ExpandableListImpl::RefreshSubItem(int mainIndex, int subIndex)
1599 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1600 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex);
1602 int topItemIndex = -1;
1603 int bottomItemIndex = -1;
1604 int groupItemIndex = -1;
1606 GetCore().GetTopDrawnItemIndex(groupItemIndex, topItemIndex);
1607 GetCore().GetBottomDrawnItemIndex(groupItemIndex, bottomItemIndex);
1609 SysTryReturnResult(NID_UI_CTRL, (subIndex >= topItemIndex && subIndex <= bottomItemIndex), E_INVALID_OPERATION,
1610 "Index should be within drawn item range %d.", subIndex);
1612 result r = E_SUCCESS;
1614 CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, subIndex);
1615 SysTryReturn(NID_UI_CTRL, pCustomListItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", mainIndex, subIndex);
1617 _TableViewItemUpdateParams updateParams;
1618 updateParams.pItem = pCustomListItem;
1619 updateParams.isDividerEnabled = _isDividerEnabled;
1620 updateParams.pCheckBitmaps = _pCheckBitmaps;
1621 updateParams.annexStyle = _annexStyle;
1623 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
1624 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to refresh an item.");
1626 _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
1627 SysTryReturn(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", mainIndex, subIndex);
1629 pTableViewItemData->Invalidate(true);
1635 _ExpandableListImpl::GetCheckedItemCount(int mainIndex)
1637 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), 0, E_INVALID_ARG, "[E_INVALID_ARG] The groupIndex %d is invalid", mainIndex);
1639 _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(mainIndex);
1640 SysTryReturn(NID_UI_CTRL, pGroupItem, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get GroupItem at %d index.", mainIndex);
1642 int checkedCount = 0;
1643 int subItemCount = GetSubItemCountAt(mainIndex);
1645 for (int itemCount = 0; itemCount < subItemCount; itemCount++)
1647 if (IsSubItemChecked(mainIndex, itemCount) == true)
1653 return checkedCount;
1657 _ExpandableListImpl::IsItemExpanded(int mainIndex) const
1659 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1661 if (GetCore().GetFirstDrawnFlag())
1663 Boolean* pIsExpanded = dynamic_cast<Boolean*>(const_cast<Object*>(__groupExpandStateList.GetAt(mainIndex)));
1664 SysTryReturn(NID_UI_CTRL, pIsExpanded, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get expanded state at index(%d).", mainIndex);
1666 return pIsExpanded->ToBool();
1669 return (GetCore().IsGroupExpanded(mainIndex));
1673 _ExpandableListImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1679 _ExpandableListImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated)
1685 _ExpandableListImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo)
1691 _ExpandableListImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem, TableViewItemStatus status)
1693 CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1);
1694 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
1696 CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL;
1697 ItemStatus itemStatus = ITEM_HIGHLIGHTED;
1701 case TABLE_VIEW_ITEM_STATUS_SELECTED:
1702 itemStatus = ITEM_SELECTED;
1703 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED;
1705 case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED:
1706 itemStatus = ITEM_HIGHLIGHTED;
1707 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED;
1709 case TABLE_VIEW_ITEM_STATUS_CHECKED:
1710 itemStatus = ITEM_CHECKED;
1712 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
1713 itemStatus = ITEM_UNCHECKED;
1716 SetLastResult(E_SYSTEM);
1720 LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements;
1721 _ElementBaseModel* pElementBase = null;
1723 for (int i = 0; i < pElements->GetCount(); i++)
1725 pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i));
1726 SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get valid element at index %d.", i);
1728 if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX)
1730 pElementBase->HandleElementEvent(customListItemStatus);
1734 if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL))
1736 bool isChecked = false;
1737 isChecked = IsItemChecked(groupIndex);
1741 itemStatus = ITEM_UNCHECKED;
1745 itemStatus = ITEM_CHECKED;
1748 SetItemChecked(groupIndex, !isChecked);
1751 ProcessItemStateChange(groupIndex, -1, itemStatus);
1758 _ExpandableListImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1760 CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex);
1761 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d), itemIndex(%d).", groupIndex, itemIndex);
1763 CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL;
1764 ItemStatus itemStatus = ITEM_HIGHLIGHTED;
1765 result r = E_SUCCESS;
1769 case TABLE_VIEW_ITEM_STATUS_SELECTED:
1770 itemStatus = ITEM_SELECTED;
1771 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED;
1773 case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED:
1774 itemStatus = ITEM_HIGHLIGHTED;
1775 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED;
1777 case TABLE_VIEW_ITEM_STATUS_CHECKED:
1778 itemStatus = ITEM_CHECKED;
1780 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
1781 itemStatus = ITEM_UNCHECKED;
1784 SetLastResult(E_SYSTEM);
1788 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[E_SYSTEM] A system error has occurred. ListItemStatus is invalid");
1790 LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements;
1791 _ElementBaseModel* pElementBase = null;
1793 for (int i = 0; i < pElements->GetCount(); i++)
1795 pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i));
1796 SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "Invalid element.");
1798 if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX)
1800 pElementBase->HandleElementEvent(customListItemStatus);
1804 if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL))
1806 bool isChecked = false;
1807 isChecked = IsSubItemChecked(groupIndex, itemIndex);
1811 itemStatus = ITEM_UNCHECKED;
1815 itemStatus = ITEM_CHECKED;
1818 SetSubItemChecked(groupIndex, itemIndex, !isChecked);
1821 ProcessItemStateChange(groupIndex, itemIndex, itemStatus);
1827 _ExpandableListImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pContextItem, bool activated)
1833 _ExpandableListImpl::OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo)
1839 _ExpandableListImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1845 _ExpandableListImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pContextItem, bool activated)
1851 _ExpandableListImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction)
1857 _ExpandableListImpl::OnTouchPressed (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
1859 _ExpandableListArrowBitmap* pArrowIcon = dynamic_cast<_ExpandableListArrowBitmap*>(const_cast<Control*>(&source));
1861 if (pArrowIcon != null)
1863 _TableViewGroupItemData* pTableViewGroupItemData = dynamic_cast<_TableViewGroupItemData*>(pArrowIcon->GetParent());
1864 SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewGroupItemData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get arrow icon.");
1866 bool isCustomBitmap = false;
1868 if (GetCore().IsGroupExpanded(pTableViewGroupItemData->groupIndex))
1870 GetCore().CollapseGroup(pTableViewGroupItemData->groupIndex);
1872 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
1875 pArrowIcon->SetBitmap(*__pOpenedPressedImage);
1879 pArrowIcon->SetBitmap(*__pOpenedPressedImage, __pEffectOpenedImage);
1884 GetCore().ExpandGroup(pTableViewGroupItemData->groupIndex);
1886 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
1890 pArrowIcon->SetBitmap(*__pClosedPressedImage);
1894 pArrowIcon->SetBitmap(*__pClosedPressedImage, __pEffectClosedImage);
1898 pArrowIcon->Invalidate(true);
1902 _ListBaseImpl::OnTouchPressed(source, currentPosition, touchInfo);
1908 _ExpandableListImpl::OnTouchReleased (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
1910 _ExpandableListArrowBitmap* pArrowIcon = dynamic_cast<_ExpandableListArrowBitmap*>(const_cast<Control*>(&source));
1912 if (pArrowIcon != null)
1914 _TableViewGroupItemData* pTableViewGroupItemData = dynamic_cast<_TableViewGroupItemData*>(pArrowIcon->GetParent());
1915 SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewGroupItemData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get arrow icon.");
1917 bool isCustomBitmap = false;
1919 if (GetCore().IsGroupExpanded(pTableViewGroupItemData->groupIndex))
1921 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
1924 pArrowIcon->SetBitmap(*__pClosedImage);
1928 pArrowIcon->SetBitmap(*__pClosedImage, __pEffectClosedImage);
1933 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
1937 pArrowIcon->SetBitmap(*__pOpenedImage);
1941 pArrowIcon->SetBitmap(*__pOpenedImage, __pEffectOpenedImage);
1945 pArrowIcon->Invalidate(true);
1949 _ListBaseImpl::OnTouchReleased(source, currentPosition, touchInfo);
1955 _ExpandableListImpl::ProcessItemStateChange(int mainIndex, int subIndex, int elementId, ItemStatus itemStatus)
1960 itemId = GetItemIdAt(mainIndex);
1964 itemId = GetSubItemIdAt(mainIndex, subIndex);
1967 _ListListener* pListenerList = null;
1968 IExpandableItemEventListener* pEventListener = null;
1970 for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
1972 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1973 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get ListListener");
1975 pEventListener = dynamic_cast<IExpandableItemEventListener*>(pListenerList->pListener);
1976 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get EventListener");
1978 pEventListener->OnItemStateChanged(GetPublic(), mainIndex, subIndex, itemId, elementId, itemStatus);
1980 SetLastResult(E_SUCCESS);
1985 _ExpandableListImpl::ProcessItemStateChange(int mainIndex, int subIndex, ItemStatus itemStatus)
1988 if (subIndex == -1 )
1990 itemId = GetItemIdAt(mainIndex);
1994 itemId = GetSubItemIdAt(mainIndex, subIndex);
1997 _ListListener* pListenerList = null;
1998 IExpandableItemEventListener* pEventListener = null;
2000 for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
2002 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
2003 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get ListListener");
2005 pEventListener = dynamic_cast<IExpandableItemEventListener*>(pListenerList->pListener);
2006 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get EventListener");
2008 pEventListener->OnItemStateChanged(GetPublic(), mainIndex, subIndex, itemId, itemStatus);
2010 SetLastResult(E_SUCCESS);
2015 _ExpandableListImpl::OnDraw(void)
2017 if (GetCore().GetFirstDrawnFlag())
2019 _ListBaseImpl::OnDraw();
2021 int mainItemCount = GetGroupCount();
2023 for (int mainIndex = 0; mainIndex < mainItemCount; mainIndex++)
2025 Boolean* pIsExpanded = dynamic_cast<Boolean*>(__groupExpandStateList.GetAt(mainIndex));
2026 SysTryReturnVoidResult(NID_UI_CTRL, pIsExpanded, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get expanded state at index(%d).", mainIndex);
2028 if (!pIsExpanded->ToBool())
2030 SetItemExpanded(mainIndex, false);
2034 GetCore().UpdateTableView();
2038 _ListBaseImpl::OnDraw();
2045 _ExpandableListImpl::DeleteExpandStateFlag(Object* pObj)
2047 Boolean* pExpanded = null;
2048 pExpanded = dynamic_cast<Boolean*>(pObj);
2054 _ExpandableListImpl::OnBoundsChanged(void)
2056 int mainCount = GetGroupCount();
2057 result r = E_SUCCESS;
2059 for (int mainIndex = 0; mainIndex < mainCount; mainIndex++)
2061 _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(mainIndex);
2062 SysTryReturnVoidResult(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, "A system error has occurred. Failed to get GroupItemData at %d index.", mainIndex);
2064 _ExpandableListArrowBitmap* pArrowLabel = dynamic_cast<_ExpandableListArrowBitmap*>(pTableViewGroupItemData->GetControl(ARROW_ELEMENT_NAME));
2068 pTableViewGroupItemData->RemoveControl(*pArrowLabel);
2071 r = CreateArrowIcon(mainIndex);
2072 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to Create Arrow Icon at %d index.", mainIndex);
2075 _ListBaseImpl::OnBoundsChanged();
2078 class _ExpandableListMaker
2079 : public _UiBuilderControlMaker
2082 _ExpandableListMaker(_UiBuilder* uibuilder)
2083 : _UiBuilderControlMaker(uibuilder){};
2084 virtual ~_ExpandableListMaker(){};
2085 static _UiBuilderControlMaker*
2086 GetInstance(_UiBuilder* uibuilder)
2088 _ExpandableListMaker* pExpandableListMaker = new (std::nothrow) _ExpandableListMaker(uibuilder);
2090 return pExpandableListMaker;
2094 Make(_UiBuilderControl* pControl)
2096 result r = E_SYSTEM;
2097 _UiBuilderControlLayout* pControlProperty = null;
2098 ExpandableList* pExpandableList = null;
2102 CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL;
2103 Tizen::Base::String elementString;
2104 bool isItemDivider = true;
2107 GetProperty(pControl, &pControlProperty);
2108 if (pControlProperty == null)
2113 pExpandableList = new (std::nothrow) ExpandableList();
2114 if (pExpandableList == null)
2119 rect = pControlProperty->GetRect();
2120 Tizen::Base::String styleString;
2121 styleString = pControlProperty->GetStyle();
2123 if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false))
2125 style = CUSTOM_LIST_STYLE_NORMAL;
2127 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false))
2129 style = CUSTOM_LIST_STYLE_RADIO;
2131 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false))
2133 style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER;
2135 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false))
2137 style = CUSTOM_LIST_STYLE_MARK;
2139 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false))
2141 style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER;
2143 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false))
2145 style = CUSTOM_LIST_STYLE_ONOFF;
2147 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false))
2149 style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER;
2153 style = CUSTOM_LIST_STYLE_NORMAL;
2156 if (pControl->GetElement(L"itemDivider", elementString))
2158 if (elementString.Equals(L"true", false))
2160 isItemDivider = true;
2164 isItemDivider = false;
2168 r = pExpandableList->Construct(rect, style, isItemDivider);
2171 delete pExpandableList;
2175 if (pControl->GetElement(L"textOfEmptyList", elementString))
2177 pExpandableList->SetTextOfEmptyList(elementString);
2180 if (pControl->GetElement(L"colorOfEmptyListText", elementString))
2182 ConvertStringToColor(elementString, color);
2183 pExpandableList->SetTextColorOfEmptyList(color);
2185 GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin);
2186 rectMin = (pControl->GetAttribute(0))->GetRect();
2187 (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
2189 GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin);
2190 rectMin = (pControl->GetAttribute(1))->GetRect();
2191 (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
2193 return pExpandableList;
2199 _ExpandableListRegister::_ExpandableListRegister()
2201 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2203 if (pUiBuilderControlTableManager)
2205 pUiBuilderControlTableManager->RegisterControl(L"ExpandableList", _ExpandableListMaker::GetInstance);
2208 _ExpandableListRegister::~_ExpandableListRegister()
2210 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2212 if (pUiBuilderControlTableManager)
2214 pUiBuilderControlTableManager->UnregisterControl(L"ExpandableList");
2217 static _ExpandableListRegister ExpandableListRegisterToUiBuilder;
2218 }}} //Tizen::Ui::Controls