2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiCtrl_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"
34 #include "FUi_CoordinateSystemUtils.h"
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Runtime;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Base::Collection;
41 namespace Tizen { namespace Ui { namespace Controls
44 extern const int INVALID_INDEX;
46 static const char* ARROW_ELEMENT_NAME = "Arrow";
48 _ExpandableListItemDataProvider::_ExpandableListItemDataProvider(_ExpandableListImpl* pList)
53 _ExpandableListItemDataProvider::~_ExpandableListItemDataProvider(void)
59 _ExpandableListItemDataProvider::GetGroupCount(void)
61 SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
62 return __pListImpl->GetGroupCount();
66 _ExpandableListItemDataProvider::GetItemCount(int groupIndex)
68 SysTryReturn(NID_UI_CTRL, __pListImpl, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
70 return __pListImpl->GetSubItemCountAt(groupIndex);
74 _ExpandableListItemDataProvider::CreateGroupItem(int groupIndex, int itemWidth)
76 SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Item provider not constructed properly.");
78 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1);
79 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
81 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);
83 _TableViewItemParams tableViewItemParams;
84 tableViewItemParams.pItem = pCustomListItem;
85 tableViewItemParams.width = itemWidth;
86 tableViewItemParams.itemId = pCustomListItem->__pCustomListItemImpl->itemId;
87 tableViewItemParams.groupIndex = groupIndex;
88 tableViewItemParams.itemIndex = -1;
89 tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
90 tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
91 tableViewItemParams.annexStyle = __pListImpl->_annexStyle;
93 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
94 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
96 pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData->AddTouchEventListener(*__pListImpl);
98 if (__pListImpl->GetSubItemCountAt(groupIndex) > 0)
100 r = __pListImpl->CreateArrowIcon(groupIndex);
101 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
104 return pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData;
108 _ExpandableListItemDataProvider::CreateItem(int groupIndex, int itemIndex, int itemWidth)
110 SysTryReturn(NID_UI_CTRL, __pListImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Invalid data structure.");
112 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex);
113 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
115 _TableViewItemParams tableViewItemParams;
116 tableViewItemParams.pItem = pCustomListItem;
117 tableViewItemParams.width = itemWidth;
118 tableViewItemParams.itemId = pCustomListItem->__pCustomListItemImpl->itemId;
119 tableViewItemParams.groupIndex = groupIndex;
120 tableViewItemParams.itemIndex = itemIndex;
121 tableViewItemParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
122 tableViewItemParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
123 tableViewItemParams.annexStyle = __pListImpl->_annexStyle;
125 result r = _CustomListItemImpl::CreateTableViewItem(tableViewItemParams);
126 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
128 pCustomListItem->__pCustomListItemImpl->__pTableViewItemData->AddTouchEventListener(*__pListImpl);
130 if (__pListImpl->GetSubItemCountAt(groupIndex) == 1)
132 r = __pListImpl->CreateArrowIcon(groupIndex);
133 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
136 return pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
140 _ExpandableListItemDataProvider::GetDefaultGroupItemHeight(void)
142 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(0, -1);
143 SysTryReturn(NID_UI_CTRL, pCustomListItem, __pListImpl->_defaultItemHeight, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get first item");
145 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, __pListImpl->_defaultItemHeight, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get first item");
147 return pCustomListItem->__pCustomListItemImpl->height;
151 _ExpandableListItemDataProvider::GetDefaultItemHeight(void)
153 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(0, 0);
155 if (!pCustomListItem)
157 return __pListImpl->_defaultItemHeight;
161 return pCustomListItem->__pCustomListItemImpl->height;
166 _ExpandableListItemDataProvider::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
170 if (__pListImpl->__directDelete == false)
172 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex);
173 pCustomListItem->__pCustomListItemImpl->__pTableViewItemData = null;
180 _ExpandableListItemDataProvider::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
184 if (__pListImpl->__directDelete == false)
186 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1);
187 pCustomListItem->__pCustomListItemImpl->__pTableViewGroupItemData = null;
194 _ExpandableListItemDataProvider::IsReorderable(int groupIndexFrom, int groupIndexTo)
200 _ExpandableListItemDataProvider::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem)
202 CustomListItem* pGroupCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, -1);
203 SysTryReturnVoidResult(NID_UI_CTRL, pGroupCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
205 _TableViewItemUpdateParams updateParams;
206 updateParams.pItem = pGroupCustomListItem;
207 updateParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
208 updateParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
209 updateParams.annexStyle = __pListImpl->_annexStyle;
211 result r = E_SUCCESS;
213 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
214 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
216 SysTryReturnVoidResult(NID_UI_CTRL, pGroupCustomListItem->__pCustomListItemImpl, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
218 _TableViewItemData* pTableViewItemData = pGroupCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
219 SysTryReturnVoidResult(NID_UI_CTRL, pTableViewItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex);
221 pTableViewItemData->SetEnabled(true);
226 _ExpandableListItemDataProvider::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem)
228 CustomListItem* pCustomListItem = __pListImpl->GetCustomListItemAt(groupIndex, itemIndex);
229 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);
231 _TableViewItemUpdateParams updateParams;
232 updateParams.pItem = pCustomListItem;
233 updateParams.isDividerEnabled = __pListImpl->_isDividerEnabled;
234 updateParams.pCheckBitmaps = __pListImpl->_pCheckBitmaps;
235 updateParams.annexStyle = __pListImpl->_annexStyle;
237 result r = E_SUCCESS;
239 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
240 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
242 _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
243 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);
245 pTableViewItemData->SetEnabled(true);
250 _ExpandableListArrowBitmap::_ExpandableListArrowBitmap(void)
251 : __pNormalBitmap(null)
252 , __pEffectBitmap(null)
256 _ExpandableListArrowBitmap::~_ExpandableListArrowBitmap(void)
261 _ExpandableListArrowBitmap::SetBitmap(const Bitmap &pNormalBitmap, const Bitmap *pEffectBitmap)
263 __pNormalBitmap = &pNormalBitmap;
264 __pEffectBitmap = pEffectBitmap;
270 _ExpandableListArrowBitmap::OnDraw(void)
272 SysTryReturn(NID_UI_CTRL, (__pNormalBitmap), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Normal Arrow bitmap is null.");
274 result r = E_SUCCESS;
276 Canvas* pCanvas = null;
277 pCanvas = GetCanvasN();
280 SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
282 const FloatRectangle bounds = GetBoundsF();
284 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pNormalBitmap))
286 r = pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *__pNormalBitmap);
290 r = pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *__pNormalBitmap);
293 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
295 if (__pEffectBitmap != null)
297 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*__pEffectBitmap))
299 r = pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *__pEffectBitmap);
304 r = pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height), *__pEffectBitmap);
307 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
319 _ExpandableListImpl::GetInstance(ExpandableList& expandableList)
321 return static_cast<_ExpandableListImpl*>(expandableList._pControlImpl);
324 const _ExpandableListImpl*
325 _ExpandableListImpl::GetInstance(const ExpandableList& expandableList)
327 return static_cast<const _ExpandableListImpl*>(expandableList._pControlImpl);
330 _ExpandableListImpl::_ExpandableListImpl(Control* pList, _TableView* pCore)
331 : _ListBaseImpl(pList, pCore)
332 , __pOpenedImage(null)
333 , __pClosedImage(null)
334 , __pEffectClosedImage(null)
335 , __pEffectOpenedImage(null)
336 , __pItemProvider(null)
337 , __directDelete(false)
338 , __groupExpandStateList(DeleteExpandStateFlag)
342 _ExpandableListImpl::~_ExpandableListImpl(void)
344 GetCore().SetItemProvider(null);
346 int count = GetItemCount();
348 for (int index = 0; index < count; index++)
350 RemoveFromSubItemsList(index);
353 RemoveAllFromItemsList();
355 __groupExpandStateList.RemoveAll(true);
357 __itemListenersList.RemoveAll(true);
359 delete __pOpenedImage;
360 __pOpenedImage = null;
362 delete __pClosedImage;
363 __pClosedImage = null;
365 delete __pItemProvider;
366 __pItemProvider = null;
368 delete __pEffectOpenedImage;
369 __pEffectOpenedImage = null;
371 delete __pEffectClosedImage;
372 __pEffectClosedImage = null;
374 delete __pOpenedDisabledImage;
375 __pOpenedDisabledImage = null;
377 delete __pOpenedPressedImage;
378 __pOpenedPressedImage = null;
380 delete __pClosedDisabledImage;
381 __pClosedDisabledImage = null;
383 delete __pClosedPressedImage;
384 __pClosedPressedImage = null;
389 _ExpandableListImpl::GetPublicClassName(void) const
391 return "ExpandableList";
394 const ExpandableList&
395 _ExpandableListImpl::GetPublic(void) const
397 return static_cast<const ExpandableList&>(_ControlImpl::GetPublic());
401 _ExpandableListImpl::GetPublic(void)
403 return static_cast<ExpandableList&>(_ControlImpl::GetPublic());
407 _ExpandableListImpl::GetCore(void) const
409 return static_cast<const _TableView&>(_ControlImpl::GetCore());
413 _ExpandableListImpl::GetCore(void)
415 return static_cast<_TableView&>(_ControlImpl::GetCore());
419 _ExpandableListImpl::CreateExpandableListImplN(ExpandableList* pControl, const Rectangle& bounds, bool itemDivider)
421 result r = E_SUCCESS;
423 r = GET_SIZE_INFO(ExpandableList).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
424 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
426 _TableView* pCore = _TableView::CreateTableViewN(TABLE_VIEW_STYLE_GROUPED, true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
429 SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r));
431 _ExpandableListImpl* pImpl = new (std::nothrow) _ExpandableListImpl(pControl, pCore);
432 SysTryCatch(NID_UI_CTRL, pImpl, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
434 pCore->SetItemDividerEnabled(itemDivider);
436 r = pCore->SetScrollStyle(TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
437 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
449 _ExpandableListImpl::UpdateBounds(const Rectangle& rect)
451 result r = E_SUCCESS;
453 r = InitializeBoundsPropertiesF(GET_SIZE_INFO(CustomList), _CoordinateSystemUtils::ConvertToFloat(rect), GetCore().GetOrientation());
454 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
460 _ExpandableListImpl::Initialize(void)
462 result r = E_SUCCESS;
464 __pItemProvider = new (std::nothrow) _ExpandableListItemDataProvider(this);
465 SysTryReturnResult(NID_UI_CTRL, (__pItemProvider != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
467 TableViewStyle style = GetCore().GetTableViewStyle();
468 SysTryReturnResult(NID_UI_CTRL, style == TABLE_VIEW_STYLE_GROUPED, E_INVALID_OPERATION, "The style of TableView is not TABLE_VIEW_STYLE_GROUPED");
470 _TableViewItemProvider* pItemProvider = _TableViewItemProvider::CreateTableViewItemProviderN(style);
471 SysTryReturnResult(NID_UI_CTRL, pItemProvider != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
473 r = pItemProvider->SetGroupedStyleItemProvider(__pItemProvider);
477 delete pItemProvider;
478 SysTryReturn(NID_UI_CTRL, false, r, r, "[%s] Propagating.", GetErrorMessage(r));
481 r = GetCore().SetItemProvider(pItemProvider);
482 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
484 r = GetCore().AddGroupedTableViewItemEventListener(*this);
485 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
487 r = LoadArrowBitmap();
488 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
490 GET_COLOR_CONFIG(LIST::EXPANDABLELIST_SUB_ITEM_BG_COLOR, __subItemBgColor);
496 _ExpandableListImpl::CreateArrowIcon(int groupIndex)
498 int size = __pOpenedImage->GetWidth();
499 result r = E_SUCCESS;
500 bool isEnabled = true;
502 isEnabled = IsItemEnabled(groupIndex);
504 _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(groupIndex);
505 SysTryReturnResult(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, "A system error has occurred. Failed to get GroupItemData at %d index.", groupIndex);
507 _ExpandableListArrowBitmap* pArrowIcon = null;
508 pArrowIcon = dynamic_cast<_ExpandableListArrowBitmap*>(pTableViewGroupItemData->GetControl(ARROW_ELEMENT_NAME));
510 if (pArrowIcon == null)
512 _ExpandableListArrowBitmap* pArrowIcon = new (std::nothrow) _ExpandableListArrowBitmap();
513 SysTryReturn(NID_UI_CTRL, pArrowIcon, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
515 float xPosition = 0.0f;
516 float yPosition = 0.0f;
518 GET_SHAPE_CONFIG(LIST::EXPANDABLE_ARROW_X_POSITION, GetCore().GetOrientation(), xPosition);
519 yPosition = (pTableViewGroupItemData->GetHeight() - __pClosedImage->GetHeight())/2.0f;
521 r = pArrowIcon->Construct(FloatRectangle((GetCore().GetBoundsF().width - (size + xPosition)), yPosition, size, size), GROUP_STYLE_NONE);
522 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
524 pArrowIcon->SetName(ARROW_ELEMENT_NAME);
526 Boolean* pIsExpanded = dynamic_cast<Boolean*>(const_cast<Object*>(__groupExpandStateList.GetAt(groupIndex)));
527 bool isCustomBitmap = false;
530 if (pIsExpanded && pIsExpanded->ToBool())
532 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
535 pArrowIcon->SetBitmap(*__pClosedImage);
539 pArrowIcon->SetBitmap(*__pClosedImage, __pEffectClosedImage);
544 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
548 pArrowIcon->SetBitmap(*__pOpenedImage);
552 pArrowIcon->SetBitmap(*__pOpenedImage, __pEffectOpenedImage);
559 if (pIsExpanded && pIsExpanded->ToBool())
561 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
564 pArrowIcon->SetBitmap(*__pClosedDisabledImage);
568 pArrowIcon->SetBitmap(*__pClosedDisabledImage, __pEffectClosedImage);
573 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
577 pArrowIcon->SetBitmap(*__pOpenedDisabledImage);
581 pArrowIcon->SetBitmap(*__pOpenedDisabledImage, __pEffectOpenedImage);
586 pArrowIcon->AddTouchEventListener(*this);
588 pTableViewGroupItemData->AddControl(*pArrowIcon);
589 pTableViewGroupItemData->SetIndividualSelectionEnabled(pArrowIcon, true);
596 _ExpandableListImpl::LoadArrowBitmap(void)
598 result r = E_SUCCESS;
599 Bitmap* pTempBitmap = null;
604 GET_COLOR_CONFIG(LIST::EXPANDABLE_ARROW_NORMAL, normalColor);
605 GET_COLOR_CONFIG(LIST::EXPANDABLE_ARROW_DISABLED, disabledColor);
606 GET_COLOR_CONFIG(LIST::EXPANDABLE_ARROW_PRESSED, pressedColor);
608 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_COLLAPSE_GROUP, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
609 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow Bitmap");
610 __pOpenedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor);
611 __pOpenedDisabledImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), disabledColor);
612 __pOpenedPressedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedColor);
617 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_EXPAND_GROUP, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
618 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow Bitmap");
619 __pClosedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), normalColor);
620 __pClosedDisabledImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), disabledColor);
621 __pClosedPressedImage = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedColor);
626 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_EXPAND_CLOSED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pEffectOpenedImage);
627 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow effect Bitmap");
629 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_EXPAND_OPENED_EFFECT, BITMAP_PIXEL_FORMAT_ARGB8888, __pEffectClosedImage);
630 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), r, "Failed to fetch Arrow effect Bitmap");
636 _ExpandableListImpl::AddExpandableItemEventListener(const IExpandableItemEventListener& listener)
638 _ListListener* pListenersList = new (std::nothrow) _ListListener();
640 SysTryReturn(NID_UI_CTRL, pListenersList, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
642 pListenersList->pListener = const_cast<IExpandableItemEventListener*>(&listener);
643 __itemListenersList.Add(*pListenersList);
649 _ExpandableListImpl::RemoveExpandableItemEventListener(const IExpandableItemEventListener& listener)
651 _ListListener* pListenersList = null;
653 int count = __itemListenersList.GetCount();
655 for (int listenerCount = 0; listenerCount < count; listenerCount++)
657 pListenersList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
659 if ((pListenersList != null) && (pListenersList->pListener == &listener))
662 __itemListenersList.RemoveAt(listenerCount, true);
671 _ExpandableListImpl::AddItem(const CustomListItem& item, int itemId)
673 return InsertItemAt(GetGroupCount(), item, itemId);
677 _ExpandableListImpl::InsertItemAt(int mainIndex, const CustomListItem& item, int itemId)
679 result r = E_SUCCESS;
681 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
683 item.__pCustomListItemImpl->itemId = itemId;
685 Boolean* pIsExpanded = new Boolean(false);
686 SysTryReturn(NID_UI_CTRL, pIsExpanded, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
688 __groupExpandStateList.InsertAt(*pIsExpanded, mainIndex);
690 r = InsertIntoItemsList(item, mainIndex, -1);
691 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to insert an item.");
693 r = GetCore().RefreshTableView(mainIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
694 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
696 if (GetCore().GetFirstDrawnFlag() == false)
698 SetItemExpanded(mainIndex, false);
704 RemoveFromItemsList(mainIndex, -1);
705 __groupExpandStateList.RemoveAt(mainIndex, true);
711 _ExpandableListImpl::AddSubItem(int mainIndex, const CustomListItem& item, int itemId)
713 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
715 return InsertSubItemAt(mainIndex, GetSubItemCountAt(mainIndex), item, itemId);
719 _ExpandableListImpl::InsertSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId)
721 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex <= GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex);
723 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex <= GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d.", subIndex);
725 item.__pCustomListItemImpl->itemId = itemId;
727 result r = E_SUCCESS;
729 r = InsertIntoItemsList(item, mainIndex, subIndex);
730 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to insert item");
732 r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_ADD);
733 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
738 RemoveFromItemsList(mainIndex, subIndex);
743 _ExpandableListImpl::GetItemCount(void) const
745 return GetGroupCount();
749 _ExpandableListImpl::GetSubItemCount(int mainIndex) const
751 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d.", mainIndex);
753 return GetSubItemCountAt(mainIndex);
757 _ExpandableListImpl::SetItemAt(int mainIndex, const CustomListItem& item, int itemId)
759 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
761 SysTryReturnResult(NID_UI_CTRL, (IsItemNew(item) == true), E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item already exists.");
763 result r = E_SUCCESS;
764 item.__pCustomListItemImpl->itemId = itemId;
766 r = SetInItemsList(item, mainIndex, -1);
767 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
769 _TableViewItemUpdateParams updateParams;
770 updateParams.pItem = const_cast<CustomListItem*>(&item);
771 updateParams.isDividerEnabled = _isDividerEnabled;
772 updateParams.pCheckBitmaps = _pCheckBitmaps;
773 updateParams.annexStyle = _annexStyle;
775 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
776 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to refresh an item.");
782 _ExpandableListImpl::RemoveItemAt(int mainIndex)
784 result r = E_SUCCESS;
786 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex);
788 r = RemoveFromSubItemsList(mainIndex);
789 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
791 r = RemoveFromItemsList(mainIndex, -1);
792 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
794 __groupExpandStateList.RemoveAt(mainIndex, true);
796 __directDelete = true;
798 r = GetCore().RefreshTableView(mainIndex, -1, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
800 __directDelete = false;
802 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
808 _ExpandableListImpl::SetSubItemAt(int mainIndex, int subIndex, const CustomListItem& item, int itemId)
810 result r = E_SUCCESS;
812 SysTryReturn(NID_UI_CTRL, ((mainIndex >= 0) && (mainIndex < GetGroupCount())), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
814 _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(mainIndex);
815 SysTryReturn(NID_UI_CTRL, pGroupItem, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get GroupItem at %d index.", mainIndex);
817 SysTryReturn(NID_UI_CTRL, ((subIndex >= 0) && (subIndex < GetSubItemCountAt(mainIndex))), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
819 item.__pCustomListItemImpl->itemId = itemId;
821 CustomListItem* pOldItem = GetCustomListItemAt(mainIndex, subIndex);
822 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);
823 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);
825 item.__pCustomListItemImpl->__pTableViewItemData = pOldItem->__pCustomListItemImpl->__pTableViewItemData;
827 r = SetInItemsList(item, mainIndex, subIndex);
828 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to update an item.");
830 _TableViewItemUpdateParams updateParams;
831 updateParams.pItem = const_cast<CustomListItem*>(&item);
832 updateParams.isDividerEnabled = _isDividerEnabled;
833 updateParams.pCheckBitmaps = _pCheckBitmaps;
834 updateParams.annexStyle = _annexStyle;
836 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
837 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to refresh an item.");
839 r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
840 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "Item not inserted successFully.");
846 _ExpandableListImpl::RemoveSubItemAt(int mainIndex, int subIndex)
848 result r = E_SUCCESS;
850 SysTryReturn(NID_UI_CTRL, ((mainIndex >= 0) && (mainIndex < GetGroupCount())), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
852 SysTryReturn(NID_UI_CTRL, ((subIndex >= 0) && (subIndex < GetSubItemCount(mainIndex))), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
854 r = RemoveFromItemsList(mainIndex, subIndex);
855 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove item.");
857 __directDelete = true;
859 r = GetCore().RefreshTableView(mainIndex, subIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_REMOVE);
861 __directDelete = false;
863 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to remove item.");
865 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_MARK || _annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
867 int checkedCount = GetCheckedItemCount(mainIndex);
869 if (checkedCount == 0)
871 _CheckElementModel* pGroupCheckElement = GetCheckElementAt(mainIndex, -1);
872 SysTryReturnResult(NID_UI_CTRL, pGroupCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at %d index.", mainIndex);
874 pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
876 DrawItem(mainIndex, -1);
884 _ExpandableListImpl::RemoveAllSubItemsAt(int mainIndex)
886 result r = E_SUCCESS;
888 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex);
890 int count = GetSubItemCountAt(mainIndex);
891 for (int index = 0; index < count; index++)
893 r = RemoveSubItemAt(mainIndex, 0);
900 _ExpandableListImpl::RemoveAllItems(void)
902 result r = E_SUCCESS;
903 result finalResult = E_SUCCESS;
905 int count = GetGroupCount();
906 for (int index = count - 1; index >= 0; index--)
908 r = RemoveItemAt(index);
913 SysLog(NID_UI_CTRL, "[E_SYSTEM] A system error has occurred. Item at %d index not removed successfully", index);
921 _ExpandableListImpl::IsItemChecked(int groupIndex, int subIndex) const
925 return IsItemChecked(groupIndex);
929 return IsSubItemChecked(groupIndex, subIndex);
934 _ExpandableListImpl::IsItemChecked(int mainIndex) const
936 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.");
938 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()),
939 false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
941 const _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, -1);
942 SysTryReturn(NID_UI_CTRL, pCheckElement, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get checkElement at mainIndex(%d).", mainIndex);
944 return (bool)pCheckElement->GetCheckBoxStatus();
948 _ExpandableListImpl::GetFirstCheckedItemIndex(void) const
950 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");
952 int count = GetGroupCount();
953 for (int index = 0; index < count; index++)
955 if (IsItemChecked(index))
958 return INVALID_INDEX;
962 _ExpandableListImpl::GetItemIdAt(int mainIndex) const
964 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
966 const CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, -1);
967 SysTryReturn(NID_UI_CTRL, pCustomListItem, -1, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at mainIndex(%d).", mainIndex);
969 return pCustomListItem->__pCustomListItemImpl->itemId;
973 _ExpandableListImpl::GetItemIndexFromItemId(int itemId) const
975 int count = GetGroupCount();
976 for (int index = 0; index < count; index++)
978 const CustomListItem* pCustomListItem = GetCustomListItemAt(index, -1);
979 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);
981 if (itemId == pCustomListItem->__pCustomListItemImpl->itemId)
984 return INVALID_INDEX;
988 _ExpandableListImpl::GetSubItemIdAt(int mainIndex, int subIndex) const
990 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
992 SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
994 const CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, subIndex);
995 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);
997 return pCustomListItem->__pCustomListItemImpl->itemId;
1001 _ExpandableListImpl::SetItemExpanded(int mainIndex, bool expand)
1003 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1005 Boolean* pIsExpanded = new Boolean(expand);
1006 SysTryReturn(NID_UI_CTRL, pIsExpanded, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1008 __groupExpandStateList.SetAt(*pIsExpanded, mainIndex, true);
1010 if (GetCore().GetFirstDrawnFlag() || (GetCore().IsGroupExpanded(mainIndex) == expand))
1015 result r = E_SUCCESS;
1017 _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(mainIndex);
1018 SysTryReturn(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item at %d mainIndex.", mainIndex);
1020 _ExpandableListArrowBitmap* pArrowIcon = dynamic_cast<_ExpandableListArrowBitmap*>(pTableViewGroupItemData->GetControl(ARROW_ELEMENT_NAME));
1021 SysTryReturn(NID_UI_CTRL, pArrowIcon, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get arrow icon.");
1023 bool isCustomBitmap = false;
1027 r = GetCore().ExpandGroup(mainIndex);
1029 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
1033 pArrowIcon->SetBitmap(*__pClosedImage);
1037 pArrowIcon->SetBitmap(*__pClosedImage, __pEffectClosedImage);
1042 r = GetCore().CollapseGroup(mainIndex);
1044 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
1048 pArrowIcon->SetBitmap(*__pOpenedImage);
1052 pArrowIcon->SetBitmap(*__pOpenedImage, __pEffectOpenedImage);
1056 pArrowIcon->Invalidate(true);
1062 _ExpandableListImpl::SetItemEnabled(int mainIndex, bool enable)
1064 result r = E_SUCCESS;
1066 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1068 r = GetCore().SetItemEnabled(mainIndex, -1, enable);
1069 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1071 DrawItem(mainIndex, -1);
1076 _ExpandableListImpl::IsItemEnabled(int mainIndex) const
1078 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1080 return GetCore().IsItemEnabled(mainIndex, -1);
1084 _ExpandableListImpl::SetSubItemEnabled(int mainIndex, int subIndex, bool enable)
1086 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex(%d)", mainIndex);
1087 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex(%d)", subIndex);
1089 result r = E_SUCCESS;
1091 r = GetCore().SetItemEnabled(mainIndex, subIndex, enable);
1092 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1094 DrawItem(mainIndex, subIndex);
1099 _ExpandableListImpl::IsSubItemEnabled(int mainIndex, int subIndex) const
1101 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1103 SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
1105 return GetCore().IsItemEnabled(mainIndex, subIndex);
1109 _ExpandableListImpl::SetItemChecked(int groupIndex, int itemIndex, bool check)
1111 if (itemIndex == -1)
1113 return SetItemChecked(groupIndex, check);
1117 return SetSubItemChecked(groupIndex, itemIndex, check);
1122 _ExpandableListImpl::SetItemChecked(int mainIndex, bool check)
1124 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1126 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");
1128 SysTryReturnResult(NID_UI_CTRL, (IsItemEnabled(mainIndex)), E_SYSTEM, "A system error has occurred. The item is not enabled at mainIndex %d.", mainIndex);
1130 if (IsItemChecked(mainIndex) == check)
1135 _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, -1);
1136 SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d)", mainIndex);
1138 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1140 if (_currentRadioGroupIndex != -1)
1142 _CheckElementModel* pOldSubCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex);
1143 SysTryReturnResult(NID_UI_CTRL, pOldSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", _currentRadioGroupIndex, _currentRadioIndex);
1145 pOldSubCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1147 DrawItem(_currentRadioGroupIndex, _currentRadioIndex);
1150 _currentRadioGroupIndex = (check == true) ? mainIndex : -1;
1151 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1152 _currentRadioIndex = -1;
1157 int subCount = GetSubItemCountAt(mainIndex);
1161 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1165 for (int subItemCount = 0; subItemCount < subCount; subItemCount++)
1167 SetSubItemChecked(mainIndex, subItemCount, check);
1175 _ExpandableListImpl::SetSubItemCheckedRadio(int mainIndex, int subIndex, bool check)
1177 if (_currentRadioGroupIndex != -1)
1179 _CheckElementModel* pOldSubCheckElement = GetCheckElementAt(_currentRadioGroupIndex, _currentRadioIndex);
1180 SysTryReturnResult(NID_UI_CTRL, pOldSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", _currentRadioGroupIndex, _currentRadioIndex);
1182 pOldSubCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1184 DrawItem(_currentRadioGroupIndex, _currentRadioIndex);
1189 _currentRadioGroupIndex = mainIndex;
1190 _currentRadioIndex = subIndex;
1194 _currentRadioGroupIndex = -1;
1195 _currentRadioIndex = -1;
1198 _CheckElementModel* pSubCheckElement = GetCheckElementAt(mainIndex, subIndex);
1199 SysTryReturnResult(NID_UI_CTRL, pSubCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex);
1201 pSubCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1203 DrawItem(mainIndex, subIndex);
1209 _ExpandableListImpl::SetSubItemCheckedMarkOnOff(int mainIndex, int subIndex, bool check)
1211 _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, subIndex);
1212 SysTryReturnResult(NID_UI_CTRL, pCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d) subIndex(%d).", mainIndex, subIndex);
1214 pCheckElement->SetCheckBoxStatus((_CheckBoxBitmapType)check);
1216 _CheckElementModel* pGroupCheckElement = GetCheckElementAt(mainIndex, -1);
1217 SysTryReturnResult(NID_UI_CTRL, pGroupCheckElement, E_SYSTEM, "A system error has occurred. Failed to get checkElement at mainIndex(%d).", mainIndex);
1219 if ((check) || (GetCheckedItemCountAt(mainIndex) > 0))
1221 pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_CHECKED);
1225 pGroupCheckElement->SetCheckBoxStatus(CHECK_BOX_UNCHECKED);
1228 DrawItem(mainIndex, -1);
1229 DrawItem(mainIndex, subIndex);
1235 _ExpandableListImpl::SetSubItemChecked(int mainIndex, int subIndex, bool check)
1237 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1239 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex);
1241 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");
1243 if (IsSubItemChecked(mainIndex, subIndex) == check)
1248 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
1250 return SetSubItemCheckedRadio(mainIndex, subIndex, check);
1254 return SetSubItemCheckedMarkOnOff(mainIndex, subIndex, check);
1259 _ExpandableListImpl::GetCheckedItemCountAt(int mainIndex) const
1261 int totalSubItemCount = GetSubItemCountAt(mainIndex);
1264 for (int index = 0; index < totalSubItemCount; index++)
1266 if (IsSubItemChecked(mainIndex, index) == true)
1276 _ExpandableListImpl::IsSubItemChecked(int mainIndex, int subIndex) const
1278 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.");
1280 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1282 SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
1284 const _CheckElementModel* pCheckElement = GetCheckElementAt(mainIndex, subIndex);
1285 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);
1287 return (bool)pCheckElement->GetCheckBoxStatus();
1291 _ExpandableListImpl::SetAllSubItemsChecked(int mainIndex, bool check)
1293 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1295 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");
1296 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");
1298 int totalSubItemCount = GetSubItemCountAt(mainIndex);
1299 result r = E_SUCCESS;
1301 for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++)
1303 r = SetSubItemChecked(mainIndex, subItemCount, check);
1304 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
1311 _ExpandableListImpl::RemoveAllCheckedSubItemsAt(int mainIndex)
1313 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1315 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");
1317 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");
1319 result r = E_SUCCESS;
1320 int totalSubItemCount = GetSubItemCountAt(mainIndex);
1322 for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++)
1324 bool isChecked = IsSubItemChecked(mainIndex, subItemCount);
1328 r = RemoveSubItemAt(mainIndex, subItemCount);
1329 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to remove item");
1337 _ExpandableListImpl::GetFirstCheckedSubItemIndex(int mainIndex) const
1339 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");
1341 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1343 int totalSubItemCount = GetSubItemCountAt(mainIndex);
1345 for (int subItemCount = 0; subItemCount < totalSubItemCount; subItemCount++)
1347 if (IsSubItemChecked(mainIndex, subItemCount))
1349 return subItemCount;
1353 return INVALID_INDEX;
1357 _ExpandableListImpl::GetLastCheckedItemIndex(void) const
1359 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");
1361 int count = GetGroupCount();
1363 for (int index = count - 1; index >= 0; index--)
1365 if (IsItemChecked(index))
1371 return INVALID_INDEX;
1375 _ExpandableListImpl::GetLastCheckedSubItemIndex(int mainIndex) const
1377 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");
1379 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1381 int count = GetSubItemCountAt(mainIndex);
1383 for (int index = count - 1; index >= 0; index--)
1385 if (IsSubItemChecked(mainIndex, index))
1390 return INVALID_INDEX;
1394 _ExpandableListImpl::GetNextCheckedItemIndexAfter(int mainIndex) const
1396 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");
1398 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1400 for (int index = mainIndex+1; index < GetGroupCount(); index++)
1402 if (IsItemChecked(index))
1408 return INVALID_INDEX;
1412 _ExpandableListImpl::GetNextCheckedSubItemIndexAfter(int mainIndex, int subIndex) const
1414 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");
1416 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1417 SysTryReturn(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), INVALID_INDEX, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. subIndex = %d", subIndex);
1419 int count = GetSubItemCountAt(mainIndex);
1421 for (int index = subIndex + 1; index < count; index++)
1423 if (IsSubItemChecked(mainIndex, index))
1429 return INVALID_INDEX;
1433 _ExpandableListImpl::GetSubItemIndexFromItemId(int itemId, int& mainIndex, int& subIndex) const
1435 mainIndex = INVALID_INDEX;
1436 subIndex = INVALID_INDEX;
1438 for (int index = 0; index < GetGroupCount(); index++)
1440 for (int count = 0; count < GetSubItemCountAt(index); count++)
1442 const CustomListItem* pCustomListItem = GetCustomListItemAt(index, count);
1443 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "A system error has occurred. Failed to get an item at mainIndex(%d) subIndex(%d).", index, count);
1445 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);
1447 if (itemId == pCustomListItem->__pCustomListItemImpl->itemId)
1456 return E_OBJ_NOT_FOUND;
1460 _ExpandableListImpl::ScrollToBottom(void)
1462 result r = E_SUCCESS;
1464 int lastGroupIndex = GetGroupCount() - 1;
1465 int lastItemIndex = GetSubItemCountAt(lastGroupIndex) - 1;
1467 r = GetCore().SetBottomDrawnItemIndex(lastGroupIndex, lastItemIndex);
1468 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1475 _ExpandableListImpl::ScrollToTop(void)
1477 result r = E_SUCCESS;
1479 r = GetCore().SetTopDrawnItemIndex(0, -1);
1480 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
1481 SetLastResult(E_SUCCESS);
1489 _ExpandableListImpl::ScrollToTop(int mainIndex, int subIndex)
1491 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1492 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex);
1493 result r = E_SUCCESS;
1495 r = GetCore().SetTopDrawnItemIndex(mainIndex, subIndex);
1496 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1504 _ExpandableListImpl::ScrollToTop(int mainIndex)
1506 SysTryReturn(NID_UI_CTRL, ((mainIndex < GetGroupCount()) && (mainIndex >= 0)), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d.", mainIndex);
1508 result r = E_SUCCESS;
1510 r = GetCore().SetTopDrawnItemIndex(mainIndex, -1);
1511 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1519 _ExpandableListImpl::SetBgColor(const Color& color)
1521 GetCore().SetBackgroundColor(color);
1526 _ExpandableListImpl::RefreshItem(int mainIndex)
1528 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d.", mainIndex);
1530 int topGroupIndex = -1;
1531 int bottomGroupIndex = -1;
1534 GetCore().GetTopDrawnItemIndex(topGroupIndex, itemIndex);
1535 GetCore().GetBottomDrawnItemIndex(bottomGroupIndex, itemIndex);
1537 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= topGroupIndex && mainIndex <= bottomGroupIndex), E_INVALID_OPERATION, "Index should be within drawn item range %d.", mainIndex);
1539 result r = E_SUCCESS;
1541 int count = GetSubItemCountAt(mainIndex);
1542 for (int indexItem = 0; indexItem < count; indexItem++)
1544 r = RefreshSubItem(mainIndex, indexItem);
1547 SysLog(NID_UI_CTRL, "Not able to refresh item with index %d %d.", mainIndex, indexItem);
1555 _ExpandableListImpl::RefreshSubItem(int mainIndex, int subIndex)
1557 SysTryReturnResult(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), E_INVALID_ARG, "Invalid argument used. mainIndex = %d", mainIndex);
1558 SysTryReturnResult(NID_UI_CTRL, (subIndex >= 0 && subIndex < GetSubItemCount(mainIndex)), E_INVALID_ARG, "Invalid argument used. subIndex = %d", subIndex);
1560 int topItemIndex = -1;
1561 int bottomItemIndex = -1;
1562 int groupItemIndex = -1;
1564 GetCore().GetTopDrawnItemIndex(groupItemIndex, topItemIndex);
1565 GetCore().GetBottomDrawnItemIndex(groupItemIndex, bottomItemIndex);
1567 SysTryReturnResult(NID_UI_CTRL, (subIndex >= topItemIndex && subIndex <= bottomItemIndex), E_INVALID_OPERATION,
1568 "Index should be within drawn item range %d.", subIndex);
1570 result r = E_SUCCESS;
1572 CustomListItem* pCustomListItem = GetCustomListItemAt(mainIndex, subIndex);
1573 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);
1575 _TableViewItemUpdateParams updateParams;
1576 updateParams.pItem = pCustomListItem;
1577 updateParams.isDividerEnabled = _isDividerEnabled;
1578 updateParams.pCheckBitmaps = _pCheckBitmaps;
1579 updateParams.annexStyle = _annexStyle;
1581 r = _CustomListItemImpl::UpdateTableViewItem(updateParams);
1582 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "A system error has occurred. Failed to refresh an item.");
1584 _TableViewItemData* pTableViewItemData = pCustomListItem->__pCustomListItemImpl->__pTableViewItemData;
1585 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);
1587 pTableViewItemData->Invalidate(true);
1593 _ExpandableListImpl::GetCheckedItemCount(int mainIndex)
1595 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), 0, E_INVALID_ARG, "[E_INVALID_ARG] The groupIndex %d is invalid", mainIndex);
1597 _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(mainIndex);
1598 SysTryReturn(NID_UI_CTRL, pGroupItem, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get GroupItem at %d index.", mainIndex);
1600 int checkedCount = 0;
1601 int subItemCount = GetSubItemCountAt(mainIndex);
1603 for (int itemCount = 0; itemCount < subItemCount; itemCount++)
1605 if (IsSubItemChecked(mainIndex, itemCount) == true)
1611 return checkedCount;
1615 _ExpandableListImpl::IsItemExpanded(int mainIndex) const
1617 SysTryReturn(NID_UI_CTRL, (mainIndex >= 0 && mainIndex < GetGroupCount()), false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. mainIndex = %d", mainIndex);
1619 if (GetCore().GetFirstDrawnFlag())
1621 Boolean* pIsExpanded = dynamic_cast<Boolean*>(const_cast<Object*>(__groupExpandStateList.GetAt(mainIndex)));
1622 SysTryReturn(NID_UI_CTRL, pIsExpanded, false, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get expanded state at index(%d).", mainIndex);
1624 return pIsExpanded->ToBool();
1627 return (GetCore().IsGroupExpanded(mainIndex));
1631 _ExpandableListImpl::OnTableViewItemStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1637 _ExpandableListImpl::OnTableViewContextItemActivationStateChanged(_TableView& tableView, int itemIndex, _TableViewItem* pContextItem, bool activated)
1643 _ExpandableListImpl::OnTableViewItemReordered(_TableView& tableView, int itemIndexFrom, int itemIndexTo)
1649 _ExpandableListImpl::OnGroupedTableViewGroupItemStateChanged(_TableView& tableView, int groupIndex, _TableViewItem* pItem, TableViewItemStatus status)
1651 CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1);
1652 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at index(%d).", groupIndex);
1654 CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL;
1655 ItemStatus itemStatus = ITEM_HIGHLIGHTED;
1659 case TABLE_VIEW_ITEM_STATUS_SELECTED:
1660 itemStatus = ITEM_SELECTED;
1661 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED;
1663 case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED:
1664 itemStatus = ITEM_HIGHLIGHTED;
1665 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED;
1667 case TABLE_VIEW_ITEM_STATUS_CHECKED:
1668 itemStatus = ITEM_CHECKED;
1670 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
1671 itemStatus = ITEM_UNCHECKED;
1674 SetLastResult(E_SYSTEM);
1678 LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements;
1679 _ElementBaseModel* pElementBase = null;
1681 for (int i = 0; i < pElements->GetCount(); i++)
1683 pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i));
1684 SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get valid element at index %d.", i);
1686 if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX)
1688 pElementBase->HandleElementEvent(customListItemStatus);
1692 if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL))
1694 bool isChecked = false;
1695 isChecked = IsItemChecked(groupIndex);
1699 itemStatus = ITEM_UNCHECKED;
1703 itemStatus = ITEM_CHECKED;
1706 SetItemChecked(groupIndex, !isChecked);
1709 ProcessItemStateChange(groupIndex, -1, itemStatus);
1716 _ExpandableListImpl::OnGroupedTableViewItemStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1718 CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex);
1719 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);
1721 CustomListItemStatus customListItemStatus = CUSTOM_LIST_ITEM_STATUS_NORMAL;
1722 ItemStatus itemStatus = ITEM_HIGHLIGHTED;
1723 result r = E_SUCCESS;
1727 case TABLE_VIEW_ITEM_STATUS_SELECTED:
1728 itemStatus = ITEM_SELECTED;
1729 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_SELECTED;
1731 case TABLE_VIEW_ITEM_STATUS_HIGHLIGHTED:
1732 itemStatus = ITEM_HIGHLIGHTED;
1733 customListItemStatus = CUSTOM_LIST_ITEM_STATUS_FOCUSED;
1735 case TABLE_VIEW_ITEM_STATUS_CHECKED:
1736 itemStatus = ITEM_CHECKED;
1738 case TABLE_VIEW_ITEM_STATUS_UNCHECKED:
1739 itemStatus = ITEM_UNCHECKED;
1742 SetLastResult(E_SYSTEM);
1746 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[E_SYSTEM] A system error has occurred. ListItemStatus is invalid");
1748 LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements;
1749 _ElementBaseModel* pElementBase = null;
1751 for (int i = 0; i < pElements->GetCount(); i++)
1753 pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i));
1754 SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "Invalid element.");
1756 if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX)
1758 pElementBase->HandleElementEvent(customListItemStatus);
1762 if ((!_isDividerEnabled) && (_annexStyle != TABLE_VIEW_ANNEX_STYLE_NORMAL))
1764 bool isChecked = false;
1765 isChecked = IsSubItemChecked(groupIndex, itemIndex);
1769 itemStatus = ITEM_UNCHECKED;
1773 itemStatus = ITEM_CHECKED;
1776 SetSubItemChecked(groupIndex, itemIndex, !isChecked);
1779 ProcessItemStateChange(groupIndex, itemIndex, itemStatus);
1785 _ExpandableListImpl::OnGroupedTableViewContextItemActivationStateChanged(_TableView& tableView, int groupIndex, int itemIndex, _TableViewItem* pContextItem, bool activated)
1791 _ExpandableListImpl::OnGroupedTableViewItemReordered(_TableView& tableView, int groupIndexFrom, int itemIndexFrom, int groupIndexTo, int itemIndexTo)
1797 _ExpandableListImpl::OnSectionTableViewItemStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pItem, TableViewItemStatus status)
1803 _ExpandableListImpl::OnSectionTableViewContextItemActivationStateChanged(_TableView& tableView, int sectionIndex, int itemIndex, _TableViewItem* pContextItem, bool activated)
1809 _ExpandableListImpl::OnTableViewItemSwept(_TableView& tableView, int groupIndex, int itemIndex, TableViewSweepDirection direction)
1815 _ExpandableListImpl::OnTouchPressed (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
1817 _ExpandableListArrowBitmap* pArrowIcon = dynamic_cast<_ExpandableListArrowBitmap*>(const_cast<Control*>(&source));
1819 if (pArrowIcon != null)
1821 _TableViewGroupItemData* pTableViewGroupItemData = dynamic_cast<_TableViewGroupItemData*>(pArrowIcon->GetParent());
1822 SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewGroupItemData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get arrow icon.");
1824 bool isCustomBitmap = false;
1826 if (GetCore().IsGroupExpanded(pTableViewGroupItemData->groupIndex))
1828 GetCore().CollapseGroup(pTableViewGroupItemData->groupIndex);
1830 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
1833 pArrowIcon->SetBitmap(*__pOpenedPressedImage);
1837 pArrowIcon->SetBitmap(*__pOpenedPressedImage, __pEffectOpenedImage);
1842 GetCore().ExpandGroup(pTableViewGroupItemData->groupIndex);
1844 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
1848 pArrowIcon->SetBitmap(*__pClosedPressedImage);
1852 pArrowIcon->SetBitmap(*__pClosedPressedImage, __pEffectClosedImage);
1856 pArrowIcon->Invalidate(true);
1860 _ListBaseImpl::OnTouchPressed(source, currentPosition, touchInfo);
1866 _ExpandableListImpl::OnTouchReleased (const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
1868 _ExpandableListArrowBitmap* pArrowIcon = dynamic_cast<_ExpandableListArrowBitmap*>(const_cast<Control*>(&source));
1870 if (pArrowIcon != null)
1872 _TableViewGroupItemData* pTableViewGroupItemData = dynamic_cast<_TableViewGroupItemData*>(pArrowIcon->GetParent());
1873 SysTryReturnVoidResult(NID_UI_CTRL, (pTableViewGroupItemData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get arrow icon.");
1875 bool isCustomBitmap = false;
1877 if (GetCore().IsGroupExpanded(pTableViewGroupItemData->groupIndex))
1879 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_COLLAPSE_GROUP);
1882 pArrowIcon->SetBitmap(*__pClosedImage);
1886 pArrowIcon->SetBitmap(*__pClosedImage, __pEffectClosedImage);
1891 isCustomBitmap = IS_CUSTOM_BITMAP(LIST::BUTTON_EXPAND_GROUP);
1895 pArrowIcon->SetBitmap(*__pOpenedImage);
1899 pArrowIcon->SetBitmap(*__pOpenedImage, __pEffectOpenedImage);
1903 pArrowIcon->Invalidate(true);
1907 _ListBaseImpl::OnTouchReleased(source, currentPosition, touchInfo);
1913 _ExpandableListImpl::ProcessItemStateChange(int mainIndex, int subIndex, int elementId, ItemStatus itemStatus)
1918 itemId = GetItemIdAt(mainIndex);
1922 itemId = GetSubItemIdAt(mainIndex, subIndex);
1925 _ListListener* pListenerList = null;
1926 IExpandableItemEventListener* pEventListener = null;
1928 for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
1930 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1931 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get ListListener");
1933 pEventListener = dynamic_cast<IExpandableItemEventListener*>(pListenerList->pListener);
1934 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get EventListener");
1936 pEventListener->OnItemStateChanged(GetPublic(), mainIndex, subIndex, itemId, elementId, itemStatus);
1938 SetLastResult(E_SUCCESS);
1943 _ExpandableListImpl::ProcessItemStateChange(int mainIndex, int subIndex, ItemStatus itemStatus)
1946 if (subIndex == -1 )
1948 itemId = GetItemIdAt(mainIndex);
1952 itemId = GetSubItemIdAt(mainIndex, subIndex);
1955 _ListListener* pListenerList = null;
1956 IExpandableItemEventListener* pEventListener = null;
1958 for (int listenerCount = 0; listenerCount < __itemListenersList.GetCount(); listenerCount++)
1960 pListenerList = dynamic_cast<_ListListener*>(__itemListenersList.GetAt(listenerCount));
1961 SysTryReturnVoidResult(NID_UI_CTRL, (pListenerList != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get ListListener");
1963 pEventListener = dynamic_cast<IExpandableItemEventListener*>(pListenerList->pListener);
1964 SysTryReturnVoidResult(NID_UI_CTRL, (pEventListener != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get EventListener");
1966 pEventListener->OnItemStateChanged(GetPublic(), mainIndex, subIndex, itemId, itemStatus);
1968 SetLastResult(E_SUCCESS);
1973 _ExpandableListImpl::OnDraw(void)
1975 if (GetCore().GetFirstDrawnFlag())
1977 _ListBaseImpl::OnDraw();
1979 int mainItemCount = GetGroupCount();
1981 for (int mainIndex = 0; mainIndex < mainItemCount; mainIndex++)
1983 Boolean* pIsExpanded = dynamic_cast<Boolean*>(__groupExpandStateList.GetAt(mainIndex));
1984 SysTryReturnVoidResult(NID_UI_CTRL, pIsExpanded, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get expanded state at index(%d).", mainIndex);
1986 if (!pIsExpanded->ToBool())
1988 SetItemExpanded(mainIndex, false);
1992 GetCore().UpdateTableView();
1996 _ListBaseImpl::OnDraw();
2003 _ExpandableListImpl::DeleteExpandStateFlag(Object* pObj)
2005 Boolean* pExpanded = null;
2006 pExpanded = dynamic_cast<Boolean*>(pObj);
2012 _ExpandableListImpl::OnBoundsChanged(void)
2014 int mainCount = GetGroupCount();
2015 result r = E_SUCCESS;
2017 for (int mainIndex = 0; mainIndex < mainCount; mainIndex++)
2019 _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(mainIndex);
2020 SysTryReturnVoidResult(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, "A system error has occurred. Failed to get GroupItemData at %d index.", mainIndex);
2022 _ExpandableListArrowBitmap* pArrowLabel = dynamic_cast<_ExpandableListArrowBitmap*>(pTableViewGroupItemData->GetControl(ARROW_ELEMENT_NAME));
2026 pTableViewGroupItemData->RemoveControl(*pArrowLabel);
2029 r = CreateArrowIcon(mainIndex);
2030 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to Create Arrow Icon at %d index.", mainIndex);
2033 _ListBaseImpl::OnBoundsChanged();
2036 class _ExpandableListMaker
2037 : public _UiBuilderControlMaker
2040 _ExpandableListMaker(_UiBuilder* uibuilder)
2041 : _UiBuilderControlMaker(uibuilder){};
2042 virtual ~_ExpandableListMaker(){};
2043 static _UiBuilderControlMaker*
2044 GetInstance(_UiBuilder* uibuilder)
2046 _ExpandableListMaker* pExpandableListMaker = new (std::nothrow) _ExpandableListMaker(uibuilder);
2048 return pExpandableListMaker;
2052 Make(_UiBuilderControl* pControl)
2054 result r = E_SYSTEM;
2055 _UiBuilderControlLayout* pControlProperty = null;
2056 ExpandableList* pExpandableList = null;
2060 CustomListStyle style = CUSTOM_LIST_STYLE_NORMAL;
2061 Tizen::Base::String elementString;
2062 bool isItemDivider = true;
2065 GetProperty(pControl, &pControlProperty);
2066 if (pControlProperty == null)
2071 pExpandableList = new (std::nothrow) ExpandableList();
2072 if (pExpandableList == null)
2077 rect = pControlProperty->GetRect();
2078 Tizen::Base::String styleString;
2079 styleString = pControlProperty->GetStyle();
2081 if (styleString.Equals(L"CUSTOM_LIST_STYLE_NORMAL", false))
2083 style = CUSTOM_LIST_STYLE_NORMAL;
2085 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO", false))
2087 style = CUSTOM_LIST_STYLE_RADIO;
2089 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER", false))
2091 style = CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER;
2093 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK", false))
2095 style = CUSTOM_LIST_STYLE_MARK;
2097 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER", false))
2099 style = CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER;
2101 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF", false))
2103 style = CUSTOM_LIST_STYLE_ONOFF;
2105 else if (styleString.Equals(L"CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER", false))
2107 style = CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER;
2111 style = CUSTOM_LIST_STYLE_NORMAL;
2114 if (pControl->GetElement(L"itemDivider", elementString))
2116 if (elementString.Equals(L"true", false))
2118 isItemDivider = true;
2122 isItemDivider = false;
2126 r = pExpandableList->Construct(rect, style, isItemDivider);
2129 delete pExpandableList;
2133 if (pControl->GetElement(L"textOfEmptyList", elementString))
2135 pExpandableList->SetTextOfEmptyList(elementString);
2138 if (pControl->GetElement(L"colorOfEmptyListText", elementString))
2140 ConvertStringToColor(elementString, color);
2141 pExpandableList->SetTextColorOfEmptyList(color);
2143 GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_PORTRAIT, dimMin);
2144 rectMin = (pControl->GetAttribute(0))->GetRect();
2145 (pControl->GetAttribute(0))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
2147 GET_DIMENSION_CONFIG(LIST::LIST_MIN_SIZE, _CONTROL_ORIENTATION_LANDSCAPE, dimMin);
2148 rectMin = (pControl->GetAttribute(1))->GetRect();
2149 (pControl->GetAttribute(1))->SetRect(rectMin.x, rectMin.y, dimMin.width, dimMin.height);
2151 return pExpandableList;
2157 _ExpandableListRegister::_ExpandableListRegister()
2159 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2161 if (pUiBuilderControlTableManager)
2163 pUiBuilderControlTableManager->RegisterControl(L"ExpandableList", _ExpandableListMaker::GetInstance);
2166 _ExpandableListRegister::~_ExpandableListRegister()
2168 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2170 if (pUiBuilderControlTableManager)
2172 pUiBuilderControlTableManager->UnregisterControl(L"ExpandableList");
2175 static _ExpandableListRegister ExpandableListRegisterToUiBuilder;
2176 }}} //Tizen::Ui::Controls