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_ListBaseImpl.cpp
20 * @brief This file contains implementation of common classes used by 1.x Lists
23 #include <FGrpBitmap.h>
24 #include <FBaseSysLog.h>
25 #include <FGrp_TextTextSimple.h>
26 #include "FUiCtrl_ListBaseImpl.h"
27 #include "FUiCtrl_CustomListElements.h"
28 #include "FUiCtrl_CustomListItemImpl.h"
29 #include "FUiCtrl_Label.h"
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Base;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Graphics::_Text;
36 namespace Tizen { namespace Ui { namespace Controls
39 _ListBaseImpl::_ListBaseImpl(Control* pList, _TableView* pCore)
40 : _ControlImpl(pList, pCore)
41 , _annexStyle(TABLE_VIEW_ANNEX_STYLE_NORMAL)
42 , _currentRadioIndex(-1)
43 , _currentRadioGroupIndex(-1)
44 , _isDividerEnabled(false)
45 , _itemsList(_CustomListItemImpl::DeleteCustomListItem)
48 GET_SHAPE_CONFIG(LIST::LIST_DEFAULT_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, _defaultItemHeight);
49 GET_COLOR_CONFIG(LISTVIEW::EMPTY_LIST_TEXT_NORMAL, __emptyTextColor);
51 for (int i = 0; i < CHECK_BOX_MAX; i++)
53 _pCheckBitmaps[i] = null;
58 _ListBaseImpl::~_ListBaseImpl(void)
60 for (int i = 0; i < CHECK_BOX_MAX; i++)
62 delete _pCheckBitmaps[i];
65 _TableView* pCore = static_cast<_TableView*>(&GetCore());
66 SysTryReturnVoidResult(NID_UI_CTRL, (pCore != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get _TableView core object.");
68 pCore->DetachAllChildren();
72 _ListBaseImpl::LoadDefaultBitmap(void)
76 if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_RADIO)
78 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_RADIO_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_UNCHECKED]);
79 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
81 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_RADIO_SELECTED_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_CHECKED]);
82 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
84 else if (_annexStyle == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
86 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_OFF_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_UNCHECKED]);
87 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
89 r = GET_BITMAP_CONFIG_N(LIST::BUTTON_ON_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_CHECKED]);
90 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
94 r = GET_BITMAP_CONFIG_N(LIST::CHECK_BG_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_UNCHECKED]);
95 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
97 r = GET_BITMAP_CONFIG_N(LIST::CHECK_MARK_BG_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_CHECKED]);
98 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
100 r = GET_BITMAP_CONFIG_N(LIST::CHECK_DIM_BITMAP, BITMAP_PIXEL_FORMAT_ARGB8888, _pCheckBitmaps[CHECK_BOX_DISABLED]);
101 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
107 Tizen::Graphics::Bitmap**
108 _ListBaseImpl::GetCheckBitmaps(void)
110 return _pCheckBitmaps;
114 _ListBaseImpl::SetItemChecked(int groupIndex, int itemIndex, bool check)
120 _ListBaseImpl::IsItemChecked(int groupIndex, int itemIndex) const
126 _ListBaseImpl::OnTouchDoublePressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
132 _ListBaseImpl::OnTouchFocusIn(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
138 _ListBaseImpl::OnTouchFocusOut(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
140 OnTouchReleased(source, currentPosition, touchInfo);
145 _ListBaseImpl::OnTouchLongPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
151 _ListBaseImpl::OnTouchMoved(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
157 _ListBaseImpl::OnTouchPressed(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
159 CustomListItem* pCustomListItem = GetItemFromControl(source);
160 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item");
162 pCustomListItem->__pCustomListItemImpl->StartSliding();
164 UpdateElements(source, CUSTOM_LIST_ITEM_STATUS_FOCUSED);
169 _ListBaseImpl::OnTouchReleased(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo)
171 CustomListItem* pCustomListItem = GetItemFromControl(source);
172 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item");
174 pCustomListItem->__pCustomListItemImpl->StopSliding();
176 UpdateElements(source, CUSTOM_LIST_ITEM_STATUS_NORMAL);
181 _ListBaseImpl::GetItemFromControl(const Control &source)
183 _ITableViewBaseItemData* pBaseData = dynamic_cast<_ITableViewBaseItemData*>(const_cast<Control*>(&source));
184 SysTryReturn(NID_UI_CTRL, (pBaseData != null), null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item.");
189 pBaseData->GetIndex(groupIndex, itemIndex);
191 return GetCustomListItemAt(groupIndex, itemIndex- GetTopItemIndex(groupIndex));
195 _ListBaseImpl::UpdateElements(const Control &source, CustomListItemStatus itemStatus)
197 _ITableViewBaseItemData* pBaseData = dynamic_cast<_ITableViewBaseItemData*>(const_cast<Control*>(&source));
198 SysTryReturnVoidResult(NID_UI_CTRL, (pBaseData != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get item.");
203 pBaseData->GetIndex(groupIndex, itemIndex);
205 CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex - GetTopItemIndex(groupIndex));
206 SysTryReturnVoidResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item");
208 LinkedList* pElements = &pCustomListItem->__pCustomListItemImpl->elements;
210 int elementCount = pElements->GetCount();
211 for (int i = 0; i < elementCount; i++)
213 _ElementBaseModel* pElementBase = dynamic_cast<_ElementBaseModel*>(pElements->GetAt(i));
214 SysTryReturnVoidResult(NID_UI_CTRL, (pElementBase != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get element.");
216 if (pElementBase->_elementType != LIST_ITEM_ELEMENT_TYPE_CHECKBOX)
218 pElementBase->HandleElementEvent(itemStatus);
222 DrawItem(groupIndex, itemIndex);
226 _ListBaseImpl::GetTopItemIndex(int groupIndex) const
232 _ListBaseImpl::IsItemNew(const CustomListItem& item) const
234 for (int itemCount = 0; itemCount < _itemsList.GetCount(); itemCount++)
236 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(itemCount)));
237 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM,
238 "A system error has occurred. Failed to get CustomList item at index %d.", itemCount);
240 _CustomListItemImpl* pCustomListItemImpl = pCustomListItem->__pCustomListItemImpl;
241 SysTryReturnResult(NID_UI_CTRL, pCustomListItemImpl, E_SYSTEM, "A system error has occurred. Failed to get an item at index(%d)", itemCount);
243 if ((pCustomListItem == const_cast<CustomListItem*>(&item)) && (pCustomListItemImpl->itemId == item.__pCustomListItemImpl->itemId))
248 for (int subItemCount = 0; subItemCount < GetSubItemCountAt(itemCount); subItemCount++)
250 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(pCustomListItemImpl->__pSubItemsList->GetAt(subItemCount)));
251 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM,
252 "A system error has occurred. Failed to get CustomList item at index %d.", itemCount);
254 if ((pCustomListItem == const_cast<CustomListItem*>(&item)) && (pCustomListItem->__pCustomListItemImpl->itemId == item.__pCustomListItemImpl->itemId))
265 _ListBaseImpl::UpdateIndices(int groupIndex, int itemIndex, int updateBy)
267 if (groupIndex == -1)
269 for (int index = itemIndex; index < _itemsList.GetCount(); index++)
271 _TableViewItemData* pTableViewItemData = GetTableViewItemAt(-1, index);
273 if (pTableViewItemData)
275 pTableViewItemData->itemIndex += updateBy;
279 if (_currentRadioIndex >= itemIndex)
281 _currentRadioIndex += updateBy;
284 else if (itemIndex == -1)
286 for (int index = groupIndex; index < _itemsList.GetCount(); index++)
288 _TableViewGroupItemData* pGroupItem = GetTableViewGroupItemAt(index);
292 pGroupItem->groupIndex += updateBy;
296 if (_currentRadioGroupIndex >= groupIndex)
298 _currentRadioGroupIndex += updateBy;
303 int subItemCount = GetSubItemCountAt(groupIndex);
305 for (int index = itemIndex; index < subItemCount; index++)
307 _TableViewItemData* pTableViewItemData = GetTableViewItemAt(groupIndex, index);
309 if (pTableViewItemData)
311 pTableViewItemData->itemIndex += updateBy;
315 if (_currentRadioIndex >= itemIndex)
317 _currentRadioIndex += updateBy;
325 _ListBaseImpl::InsertIntoItemsList(const CustomListItem& item, int groupIndex, int itemIndex, bool updateIndexes)
327 result r = E_SUCCESS;
329 if (GetCore().GetFirstDrawnFlag() == true)
331 updateIndexes = false;
334 if (groupIndex == -1)
336 r = _itemsList.InsertAt(item, itemIndex);
337 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
339 else if (itemIndex == -1)
341 r = _itemsList.InsertAt(item, groupIndex);
342 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to insert an item.");
346 CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1);
347 SysTryReturnResult(NID_UI_CTRL, pCustomListItem, E_SYSTEM, "A system error has occurred. Failed to get item at %d index.", groupIndex);
349 if (pCustomListItem->__pCustomListItemImpl->__pSubItemsList == null)
351 pCustomListItem->__pCustomListItemImpl->__pSubItemsList = new (std::nothrow) ArrayList(_CustomListItemImpl::DeleteCustomListItem);
352 SysTryReturnResult(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl->__pSubItemsList, E_OUT_OF_MEMORY, "Memory allocation failed.");
354 pCustomListItem->__pCustomListItemImpl->__pSubItemsList->Construct(1);
357 pCustomListItem->__pCustomListItemImpl->__pSubItemsList->InsertAt(item, itemIndex);
362 return UpdateIndices(groupIndex, itemIndex, 1);
371 _ListBaseImpl::RemoveFromItemsList(int groupIndex, int itemIndex, bool updateIndexes)
373 result r = E_SUCCESS;
375 if (GetCore().GetFirstDrawnFlag() == true)
377 updateIndexes = false;
380 if (groupIndex == -1)
382 r = _itemsList.RemoveAt(itemIndex, true);
383 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "A system error has occurred. Failed to remove an item.");
385 else if (itemIndex == -1)
387 r = _itemsList.RemoveAt(groupIndex, true);
388 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to remove an item.");
392 CustomListItem* pCustomListGroupItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(groupIndex)));
393 SysTryReturnResult(NID_UI_CTRL, pCustomListGroupItem, E_SYSTEM, "A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex);
395 ArrayList* pList = pCustomListGroupItem->__pCustomListItemImpl->__pSubItemsList;
396 SysTryReturnResult(NID_UI_CTRL, pList, E_SYSTEM, "A system error has occurred. Failed to get subItem at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex);
398 r = pList->RemoveAt(itemIndex, true);
399 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "A system error has occurred. Failed to remove an item.");
404 return UpdateIndices(groupIndex, itemIndex, -1);
414 _ListBaseImpl::SetInItemsList(const CustomListItem& item, int groupIndex, int itemIndex)
416 result r = E_SUCCESS;
418 if (groupIndex == -1)
420 r = _itemsList.SetAt(item, itemIndex, true);
421 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "A system error has occurred. Failed to remove an item.");
423 else if (itemIndex == -1)
425 CustomListItem* pOldItem = GetCustomListItemAt(groupIndex, -1);
426 SysTryReturnResult(NID_UI_CTRL, pOldItem, E_SYSTEM, "A system error has occurred. Failed to get current item.");
428 item.__pCustomListItemImpl->__pTableViewGroupItemData = pOldItem->__pCustomListItemImpl->__pTableViewGroupItemData;
429 item.__pCustomListItemImpl->__pSubItemsList = pOldItem->__pCustomListItemImpl->__pSubItemsList;
431 r = _itemsList.SetAt(item, groupIndex, true);
432 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "A system error has occurred. Failed to remove an item.");
436 CustomListItem* pCustomListGroupItem = GetCustomListItemAt(groupIndex, -1);
437 SysTryReturnResult(NID_UI_CTRL, pCustomListGroupItem, E_SYSTEM, "A system error has occurred. Failed to get GroupItem at %d index.", groupIndex);
439 ArrayList* pList = pCustomListGroupItem->__pCustomListItemImpl->__pSubItemsList;
440 SysTryReturnResult(NID_UI_CTRL, pList, E_SYSTEM, "A system error has occurred. Failed to get subItem at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex);
442 pList->SetAt(item, itemIndex, true);
449 _ListBaseImpl::RemoveAllFromItemsList(void)
451 _itemsList.RemoveAll(true);
455 _ListBaseImpl::GetCustomListItemAt(int groupIndex, int itemIndex)
457 const CustomListItem* pItem = (static_cast<const _ListBaseImpl*>(this))->GetCustomListItemAt(groupIndex, itemIndex);
458 return const_cast<CustomListItem*>(pItem);
461 const CustomListItem*
462 _ListBaseImpl::GetCustomListItemAt(int groupIndex, int itemIndex) const
464 if (groupIndex == -1)
466 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(itemIndex)));
467 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. itemIndex = %d", itemIndex);
469 return pCustomListItem;
471 else if (itemIndex == -1)
473 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(groupIndex)));
474 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument used. groupIndex = %d", groupIndex);
476 return pCustomListItem;
480 CustomListItem* pCustomListGroupItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(_itemsList.GetAt(groupIndex)));
481 SysTryReturn(NID_UI_CTRL, pCustomListGroupItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex);
483 ArrayList* pList = pCustomListGroupItem->__pCustomListItemImpl->__pSubItemsList;
484 SysTryReturn(NID_UI_CTRL, pList, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get subItem at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex);
486 CustomListItem* pCustomListItem = dynamic_cast<CustomListItem*>(const_cast<Object*>(pList->GetAt(itemIndex)));
487 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex);
489 return pCustomListItem;
494 _ListBaseImpl::GetTableViewItemAt(int groupIndex, int itemIndex)
496 const _TableViewItemData* pTableViewItemData = (static_cast<const _ListBaseImpl*>(this))->GetTableViewItemAt(groupIndex, itemIndex);
497 return const_cast<_TableViewItemData*>(pTableViewItemData);
500 const _TableViewItemData*
501 _ListBaseImpl::GetTableViewItemAt(int groupIndex, int itemIndex) const
503 const CustomListItem* pCustomListGroupItem = (static_cast<const _ListBaseImpl*>(this))->GetCustomListItemAt(groupIndex, itemIndex);
504 SysTryReturn(NID_UI_CTRL, pCustomListGroupItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex);
506 SysTryReturn(NID_UI_CTRL, pCustomListGroupItem->__pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d) itemIndex(%d)", groupIndex, itemIndex);
508 return pCustomListGroupItem->__pCustomListItemImpl->__pTableViewItemData;
511 _TableViewGroupItemData*
512 _ListBaseImpl::GetTableViewGroupItemAt(int groupIndex)
514 const _TableViewGroupItemData* pTableViewGroupItemData = (static_cast<const _ListBaseImpl*>(this))->GetTableViewGroupItemAt(groupIndex);
515 return const_cast<_TableViewGroupItemData*>(pTableViewGroupItemData);
518 const _TableViewGroupItemData*
519 _ListBaseImpl::GetTableViewGroupItemAt(int groupIndex) const
521 const CustomListItem* pCustomListGroupItem = (static_cast<const _ListBaseImpl*>(this))->GetCustomListItemAt(groupIndex, -1);
522 SysTryReturn(NID_UI_CTRL, pCustomListGroupItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex);
524 SysTryReturn(NID_UI_CTRL, pCustomListGroupItem->__pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex);
526 return pCustomListGroupItem->__pCustomListItemImpl->__pTableViewGroupItemData;
530 _ListBaseImpl::GetCheckElementAt(int groupIndex, int itemIndex)
532 const _CheckElementModel* pCheckElementModel = (static_cast<const _ListBaseImpl*>(this))->GetCheckElementAt(groupIndex, itemIndex);
533 return const_cast<_CheckElementModel*>(pCheckElementModel);
536 const _CheckElementModel*
537 _ListBaseImpl::GetCheckElementAt(int groupIndex, int itemIndex) const
539 const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, itemIndex);
540 SysTryReturn(NID_UI_CTRL, pCustomListItem, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d), itemIndex(%d)", groupIndex, itemIndex);
542 SysTryReturn(NID_UI_CTRL, pCustomListItem->__pCustomListItemImpl, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d), itemIndex(%d)", groupIndex, itemIndex);
544 return pCustomListItem->__pCustomListItemImpl->GetCheckElement();
548 _ListBaseImpl::DrawItem(int groupIndex, int itemIndex)
552 _TableViewGroupItemData* pTableViewGroupItemData = GetTableViewGroupItemAt(groupIndex);
553 SysTryReturnVoidResult(NID_UI_CTRL, pTableViewGroupItemData, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get an item at groupIndex(%d)", groupIndex);
555 pTableViewGroupItemData->Invalidate(true);
559 _TableViewItemData* pTableViewItemData = GetTableViewItemAt(groupIndex, itemIndex);
560 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);
562 pTableViewItemData->Invalidate(true);
567 _ListBaseImpl::SetListStyle(CustomListStyle style)
569 result r = E_SUCCESS;
573 case CUSTOM_LIST_STYLE_NORMAL:
574 _annexStyle = TABLE_VIEW_ANNEX_STYLE_NORMAL;
577 case CUSTOM_LIST_STYLE_RADIO:
578 _annexStyle = TABLE_VIEW_ANNEX_STYLE_RADIO;
581 case CUSTOM_LIST_STYLE_RADIO_WITH_DIVIDER:
582 _annexStyle = TABLE_VIEW_ANNEX_STYLE_RADIO;
583 _isDividerEnabled = true;
586 case CUSTOM_LIST_STYLE_MARK:
587 _annexStyle = TABLE_VIEW_ANNEX_STYLE_MARK;
590 case CUSTOM_LIST_STYLE_MARK_WITH_DIVIDER:
591 _annexStyle = TABLE_VIEW_ANNEX_STYLE_MARK;
592 _isDividerEnabled = true;
595 case CUSTOM_LIST_STYLE_ONOFF:
596 _annexStyle = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
599 case CUSTOM_LIST_STYLE_ONOFF_WITH_DIVIDER:
600 _annexStyle = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
601 _isDividerEnabled = true;
605 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument used. style is invalid.");
614 _ListBaseImpl::GetCore(void)
616 return static_cast<_TableView&>(_ControlImpl::GetCore());
620 _ListBaseImpl::GetCore(void) const
622 return static_cast<const _TableView&>(_ControlImpl::GetCore());
626 _ListBaseImpl::SetTextOfEmptyList(const String& text)
630 if (__pEmptyText != null)
632 GetCore().DetachChild(*__pEmptyText);
640 if (__pEmptyText == null)
642 __pEmptyText = _Label::CreateLabelN();
643 SysTryReturnVoidResult(NID_UI_CTRL, (__pEmptyText != null), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
645 __pEmptyText->SetVisibleState(false);
646 __pEmptyText->SetMargin(0, 0);
648 GetCore().AttachChild(*__pEmptyText);
651 TextObject* pText = new (std::nothrow) TextObject;
652 SysTryReturnVoidResult(NID_UI_CTRL, (pText != null), E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
656 TextSimple* pSimpleText = new (std::nothrow) TextSimple(const_cast <wchar_t*>(text.GetPointer()), text.GetLength());
657 SysTryReturnVoidResult(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
659 pText->AppendElement(*pSimpleText);
662 GET_SHAPE_CONFIG(LIST::EMPTY_LIST_TEXT_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, textSize);
665 font.Construct(GetFont(), FONT_STYLE_PLAIN, textSize);
666 pText->SetFont(&font, 0, pText->GetTextLength());
668 Dimension listDimension = GetCore().GetSize();
670 pText->SetBounds(Rectangle(0, 0, listDimension.width, 1));
673 Dimension labelDimension = pText->GetTextExtent(0, pText->GetTextLength());
674 labelDimension.height = pText->GetTotalHeight();
676 if (labelDimension.width > listDimension.width)
678 pText->SetBounds(Rectangle(0, 0, listDimension.width, 1));
681 int labelHeight = pText->GetTotalHeight();
683 labelDimension.width = listDimension.width;
684 labelDimension.height = ((listDimension.height < labelHeight) ? listDimension.height : labelHeight);
689 Rectangle bounds = GetCore().GetBounds();
691 __pEmptyText->SetBounds(Rectangle((bounds.width - labelDimension.width)/2, (bounds.height - labelDimension.height)/2, labelDimension.width, labelDimension.height));
692 __pEmptyText->SetBackgroundColor(Color(0, 0, 0, 0));
693 __pEmptyText->SetTextColor(__emptyTextColor);
694 __pEmptyText->SetTextConfig(textSize, LABEL_TEXT_STYLE_NORMAL);
695 __pEmptyText->SetText(text);
702 _ListBaseImpl::SetTextColorOfEmptyList(const Color& color)
704 __emptyTextColor = color;
706 if (__pEmptyText != null)
708 __pEmptyText->SetTextColor(color);
715 _ListBaseImpl::GetTextColorOfEmptyList(void) const
717 return __emptyTextColor;
721 _ListBaseImpl::GetTopDrawnItemIndex(int& groupIndex, int& itemIndex) const
723 result r = GetCore().GetTopDrawnItemIndex(groupIndex, itemIndex);
724 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
730 _ListBaseImpl::GetBottomDrawnItemIndex(int& groupIndex, int& itemIndex) const
732 result r = GetCore().GetBottomDrawnItemIndex(groupIndex, itemIndex);
733 SysTryReturnResult(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
739 _ListBaseImpl::GetItemIndexFromPosition(const Point& position, int& groupIndex, int& itemIndex) const
741 return GetCore().GetItemIndexFromPosition(position, groupIndex, itemIndex);
745 _ListBaseImpl::GetItemCount(void) const
747 return _itemsList.GetCount();
751 _ListBaseImpl::GetGroupCount(void) const
753 return _itemsList.GetCount();
757 _ListBaseImpl::GetSubItemCountAt(int groupIndex) const
759 result r = E_SUCCESS;
761 const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1);
763 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
765 ArrayList* pList = pCustomListItem->__pCustomListItemImpl->__pSubItemsList;
766 SysTryReturn(NID_UI_CTRL, pList, 0, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get subItemsList at groupIndex(%d)", groupIndex);
768 return pList->GetCount();
772 _ListBaseImpl::RemoveFromSubItemsList(int groupIndex)
774 result r = E_SUCCESS;
776 const CustomListItem* pCustomListItem = GetCustomListItemAt(groupIndex, -1);
778 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
780 ArrayList* pList = pCustomListItem->__pCustomListItemImpl->__pSubItemsList;
786 pCustomListItem->__pCustomListItemImpl->__pSubItemsList = null;
793 _ListBaseImpl::OnDraw(void)
795 _ControlImpl::OnDraw();
797 bool isEmpty = (GetItemCount() <= 0);
799 if (__pEmptyText != null)
801 __pEmptyText->SetVisibleState(isEmpty);
805 }}} //Tizen::Ui::Controls