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_Tab.cpp
20 * @brief This is the implementation file for the _Tab class.
23 #include <FBaseErrorDefine.h>
24 #include <FBaseSysLog.h>
25 #include <FGrp_BitmapImpl.h>
26 #include "FUi_ResourceManager.h"
27 #include "FUi_UiTouchEvent.h"
28 #include "FUi_AccessibilityContainer.h"
29 #include "FUi_AccessibilityElement.h"
30 #include "FUi_TouchLongPressGestureDetector.h"
31 #include "FUiCtrl_Tab.h"
32 #include "FUi_CoordinateSystemUtils.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Base::Runtime;
38 namespace Tizen { namespace Ui { namespace Controls {
41 : __pTabPresenter(null)
42 , __style(_TAB_STYLE_TEXT)
43 , __currentHighlightedItemIndex(-1)
44 , __tabStatus(_TAB_STATUS_NORMAL)
45 , __pActionEvent(null)
46 , __pGestureLongPress(null)
47 , __pFlickGesture(null)
48 , __pBackgroundBitmap(null)
49 , __pDisabledBackgroundBitmap(null)
50 , __pPressedItemBackgroundBitmap(null)
51 , __pPressedItemBackgroundEffectBitmap(null)
52 , __pSelectedItemBackgroundBitmap(null)
53 , __pHighlightedItemBackgroundBitmap(null)
58 __tabItems.Construct();
60 GET_COLOR_CONFIG(TAB::ITEM_BG_NORMAL, __itemBgColor[_TAB_STATUS_NORMAL]);
61 GET_COLOR_CONFIG(TAB::ITEM_BG_PRESSED, __itemBgColor[_TAB_STATUS_PRESSED]);
62 GET_COLOR_CONFIG(TAB::ITEM_BG_SELECTED, __itemBgColor[_TAB_STATUS_SELECTED]);
63 GET_COLOR_CONFIG(TAB::ITEM_BG_HIGHLIGHTED, __itemBgColor[_TAB_STATUS_HIGHLIGHTED]);
64 GET_COLOR_CONFIG(TAB::ITEM_BG_DISABLED, __itemBgColor[_TAB_STATUS_DISABLED]);
66 GET_COLOR_CONFIG(TAB::ITEM_TEXT_NORMAL, __itemTextColor[_TAB_STATUS_NORMAL]);
67 GET_COLOR_CONFIG(TAB::ITEM_TEXT_PRESSED, __itemTextColor[_TAB_STATUS_PRESSED]);
68 GET_COLOR_CONFIG(TAB::ITEM_TEXT_SELECTED, __itemTextColor[_TAB_STATUS_SELECTED]);
69 GET_COLOR_CONFIG(TAB::ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_TAB_STATUS_HIGHLIGHTED]);
70 GET_COLOR_CONFIG(TAB::ITEM_TEXT_DISABLED, __itemTextColor[_TAB_STATUS_DISABLED]);
73 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to load bitmap.");
75 _Control::SetResizable(false);
76 _Control::SetMovable(false);
78 _TabPresenter* pPresenter = new (std::nothrow) _TabPresenter;
79 SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
81 r = SetPresenter(*pPresenter);
82 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance could not be set.");
84 r = pPresenter->Construct(*this);
85 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance construct failed.");
91 delete __pTabPresenter;
92 __pTabPresenter = null;
96 delete __pActionEvent;
97 __pActionEvent = null;
100 __tabItems.RemoveAll(true);
102 if (__pFlickGesture != null)
104 __pFlickGesture->RemoveGestureListener(*this);
105 RemoveGestureDetector(*__pFlickGesture);
107 delete __pFlickGesture;
108 __pFlickGesture = null;
111 if (__pGestureLongPress != null)
113 __pGestureLongPress->RemoveGestureListener(*this);
114 RemoveGestureDetector(*__pGestureLongPress);
116 delete __pGestureLongPress;
117 __pGestureLongPress = null;
120 if (__pBackgroundBitmap)
122 delete __pBackgroundBitmap;
123 __pBackgroundBitmap = null;
126 if (__pDisabledBackgroundBitmap)
128 delete __pDisabledBackgroundBitmap;
129 __pDisabledBackgroundBitmap = null;
132 if (__pPressedItemBackgroundBitmap)
134 delete __pPressedItemBackgroundBitmap;
135 __pPressedItemBackgroundBitmap = null;
138 if (__pPressedItemBackgroundEffectBitmap)
140 delete __pPressedItemBackgroundEffectBitmap;
141 __pPressedItemBackgroundEffectBitmap = null;
144 if (__pSelectedItemBackgroundBitmap)
146 delete __pSelectedItemBackgroundBitmap;
147 __pSelectedItemBackgroundBitmap = null;
150 if (__pHighlightedItemBackgroundBitmap)
152 delete __pHighlightedItemBackgroundBitmap;
153 __pHighlightedItemBackgroundBitmap = null;
156 RemoveAllAccessibilityElement();
160 _Tab::CreateTabN(void)
162 result r = E_SUCCESS;
164 _Tab* pTab = new (std::nothrow) _Tab;
165 SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
167 if (IsFailed(GetLastResult()))
172 pTab->AcquireHandle();
174 pTab->__pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector;
175 SysTryCatch(NID_UI_CTRL, pTab->__pGestureLongPress, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
177 pTab->__pGestureLongPress->SetDuration(500);
178 pTab->AddGestureDetector(*(pTab->__pGestureLongPress));
179 r = pTab->__pGestureLongPress->AddGestureListener(*pTab);
180 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
182 pTab->__pFlickGesture = new (std::nothrow) _TouchFlickGestureDetector;
183 SysTryCatch(NID_UI_CTRL, pTab->__pFlickGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
185 r = pTab->AddGestureDetector(*(pTab->__pFlickGesture));
186 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
188 r = pTab->__pFlickGesture->AddGestureListener(*pTab);
189 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
194 if (pTab->__pGestureLongPress != null)
196 pTab->__pGestureLongPress->RemoveGestureListener(*pTab);
197 pTab->RemoveGestureDetector(*pTab->__pGestureLongPress);
199 delete pTab->__pGestureLongPress;
200 pTab->__pGestureLongPress = null;
202 if (pTab->__pFlickGesture != null)
204 pTab->__pFlickGesture->RemoveGestureListener(*pTab);
205 pTab->RemoveGestureDetector(*pTab->__pFlickGesture);
207 delete pTab->__pFlickGesture;
208 pTab->__pFlickGesture = null;
216 _Tab::SetPresenter(const _TabPresenter& tabPresenter)
219 __pTabPresenter = const_cast<_TabPresenter*>(&tabPresenter);
225 _Tab::AddItem(const Bitmap& icon, const String& text, int actionId)
227 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
229 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
230 return E_OUT_OF_RANGE;
233 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
238 __style = _TAB_STYLE_ICON_TEXT;
240 bool isDuplicate = CheckDuplicatedActionId(actionId);
241 SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId);
243 int itemCount = __tabItems.GetCount();
245 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
247 _TabItem *pItem = new (std::nothrow) _TabItem;
248 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
250 pItem->SetIcon(icon);
251 pItem->SetText(text);
252 pItem->SetActionId(actionId);
253 pItem->SetUpdateState(true);
257 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
261 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
264 __pTabPresenter->SetRecalculateItemBounds(true);
266 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
268 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
270 __currentHighlightedItemIndex = 0;
272 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
274 return __tabItems.Add(*pItem);
278 _Tab::AddItem(const Bitmap& icon, int actionId)
280 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
282 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
283 return E_OUT_OF_RANGE;
286 if (__style != _TAB_STYLE_ICON)
291 bool isDuplicate = CheckDuplicatedActionId(actionId);
292 SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId);
294 int itemCount = __tabItems.GetCount();
296 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
298 _TabItem *pItem = new (std::nothrow) _TabItem;
299 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
301 pItem->SetIcon(icon);
302 pItem->SetActionId(actionId);
303 pItem->SetUpdateState(true);
307 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
311 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
314 __pTabPresenter->SetRecalculateItemBounds(true);
316 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
318 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
320 __currentHighlightedItemIndex = 0;
322 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
324 return __tabItems.Add(*pItem);
328 _Tab::AddItem(const String& text, int actionId)
330 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
332 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
333 return E_OUT_OF_RANGE;
336 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
341 bool isDuplicate = CheckDuplicatedActionId(actionId);
342 SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred. The tab already has an item with same action id (%d).", actionId);
344 int itemCount = __tabItems.GetCount();
346 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
348 _TabItem *pItem = new (std::nothrow) _TabItem;
349 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
351 pItem->SetText(text);
352 pItem->SetActionId(actionId);
353 pItem->SetUpdateState(true);
357 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
361 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
364 __pTabPresenter->SetRecalculateItemBounds(true);
366 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
368 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
370 __currentHighlightedItemIndex = 0;
372 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
374 return __tabItems.Add(*pItem);
378 _Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int actionId)
380 result r = E_SUCCESS;
381 bool isSelected = false;
383 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
385 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
386 return E_OUT_OF_RANGE;
389 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
394 __style = _TAB_STYLE_ICON_TEXT;
396 bool isDuplicate = CheckDuplicatedActionId(actionId);
397 SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId);
399 int itemCount = __tabItems.GetCount();
401 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
403 _TabItem *pItem = new (std::nothrow) _TabItem;
404 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
406 pItem->SetIcon(icon);
407 pItem->SetText(text);
408 pItem->SetActionId(actionId);
409 pItem->SetUpdateState(true);
411 int selectedIndex = GetSelectedItemIndex();
413 if (selectedIndex >= index)
415 _TabItem *pSelectedItem = null;
416 pSelectedItem = GetItemAt(selectedIndex);
417 if (pSelectedItem != null)
420 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
425 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
428 __pTabPresenter->SetRecalculateItemBounds(true);
430 r = __tabItems.InsertAt(*pItem, index);
434 SetSelectedItemIndex(selectedIndex);
437 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
439 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
441 __currentHighlightedItemIndex = 0;
443 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
449 _Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
451 result r = E_SUCCESS;
452 bool isSelected = false;
454 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
456 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
457 return E_OUT_OF_RANGE;
460 if (__style != _TAB_STYLE_ICON)
465 bool isDuplicate = CheckDuplicatedActionId(actionId);
466 SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId);
468 int itemCount = __tabItems.GetCount();
470 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
472 _TabItem *pItem = new (std::nothrow) _TabItem;
473 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
475 pItem->SetIcon(icon);
476 pItem->SetActionId(actionId);
477 pItem->SetUpdateState(true);
478 int selectedIndex = GetSelectedItemIndex();
480 if (selectedIndex >= index)
482 _TabItem *pSelectedItem = null;
483 pSelectedItem = GetItemAt(selectedIndex);
484 if (pSelectedItem != null)
487 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
492 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
495 __pTabPresenter->SetRecalculateItemBounds(true);
497 r = __tabItems.InsertAt(*pItem, index);
501 SetSelectedItemIndex(selectedIndex);
504 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
506 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
508 __currentHighlightedItemIndex = 0;
510 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
516 _Tab::InsertItemAt(int index, const String& text, int actionId)
518 result r = E_SUCCESS;
519 bool isSelected = false;
521 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
523 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
524 return E_OUT_OF_RANGE;
527 bool isDuplicate = CheckDuplicatedActionId(actionId);
528 SysTryReturnResult(NID_UI_CTRL, isDuplicate == false, E_SYSTEM, "A system error has occurred.The tab already has an item with same action id (%d).", actionId);
530 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
535 int itemCount = __tabItems.GetCount();
537 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
539 _TabItem *pItem = new (std::nothrow) _TabItem;
540 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
542 pItem->SetText(text);
543 pItem->SetActionId(actionId);
544 pItem->SetUpdateState(true);
545 int selectedIndex = GetSelectedItemIndex();
547 if (selectedIndex >= index)
549 _TabItem *pSelectedItem = null;
550 pSelectedItem = GetItemAt(selectedIndex);
551 if (pSelectedItem != null)
554 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
559 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
562 __pTabPresenter->SetRecalculateItemBounds(true);
564 r = __tabItems.InsertAt(*pItem, index);
568 SetSelectedItemIndex(selectedIndex);
571 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
573 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
575 __currentHighlightedItemIndex = 0;
577 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
583 _Tab::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId)
585 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
587 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
588 return E_OUT_OF_RANGE;
591 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
596 __style = _TAB_STYLE_ICON_TEXT;
598 int itemCount = __tabItems.GetCount();
600 if ((index < 0) || (index >= itemCount))
602 return E_OUT_OF_RANGE;
605 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
607 if (GetItemIndex(actionId) != index)
612 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
613 result r = GetLastResult();
614 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
616 pItem->SetIcon(icon);
617 pItem->SetText(text);
618 pItem->SetActionId(actionId);
619 pItem->SetUpdateState(true);
621 UpdateAccessibilityLabel(index, text);
627 _Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
629 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
631 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
632 return E_OUT_OF_RANGE;
635 if (__style != _TAB_STYLE_ICON)
640 int itemCount = __tabItems.GetCount();
642 if ((index < 0) || (index >= itemCount))
644 return E_OUT_OF_RANGE;
647 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
649 if (GetItemIndex(actionId) != index)
654 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
655 result r = GetLastResult();
656 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
658 pItem->SetIcon(icon);
659 pItem->SetActionId(actionId);
660 pItem->SetUpdateState(true);
666 _Tab::SetItemAt(int index, const String& text, int actionId)
668 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
670 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
671 return E_OUT_OF_RANGE;
674 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
679 int itemCount = __tabItems.GetCount();
681 if ((index < 0) || (index >= itemCount))
683 return E_OUT_OF_RANGE;
686 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
688 if (GetItemIndex(actionId) != index)
693 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
694 result r = GetLastResult();
695 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
697 pItem->SetText(text);
698 pItem->SetActionId(actionId);
699 pItem->SetUpdateState(true);
701 UpdateAccessibilityLabel(index, text);
707 _Tab::RemoveItemAt(int index)
709 result r = E_SUCCESS;
710 int selectedIndex = GetSelectedItemIndex();
712 if (selectedIndex >= index)
714 _TabItem *pSelectedItem = null;
715 pSelectedItem = GetItemAt(selectedIndex);
716 if (pSelectedItem != null)
718 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
721 __pTabPresenter->SetRecalculateItemBounds(true);
723 r = __tabItems.RemoveAt(index, true);
725 SetSelectedItemIndex(0);
727 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
729 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
731 if(GetItemCount() > 0)
733 __currentHighlightedItemIndex = 0;
737 __currentHighlightedItemIndex = -1;
740 RemoveAccessibilityElementAt(index);
746 _Tab::RemoveAllItems(void)
748 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
750 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
752 __currentHighlightedItemIndex = -1;
754 __pTabPresenter->SetRecalculateItemBounds(true);
755 SetSelectedItemIndex(0);
756 SetFirstDrawnItemIndex(-1);
758 __tabItems.RemoveAll(true);
760 RemoveAllAccessibilityElement();
766 _Tab::ChangeItemAt(const int srcIndex, const int destIndex)
768 _TabItem* pItem = null;
769 pItem = GetItemAt(srcIndex);
771 __tabItems.InsertAt(*pItem, destIndex);
773 if (srcIndex > destIndex)
775 __tabItems.RemoveAt((srcIndex + 1), false);
779 __tabItems.RemoveAt(srcIndex, false);
786 _Tab::GetItemIndex(int actionId)
788 int itemCount = __tabItems.GetCount();
790 _TabItem* pItem = null;
792 for (int i = 0; i < itemCount; i++)
794 pItem = GetItemAt(i);
796 if ((pItem != null) && (actionId == pItem->GetActionId()))
806 _Tab::CheckDuplicatedActionId(int actionId)
808 int itemIndex = GetItemIndex(actionId);
819 _Tab::LoadBitmap(void)
821 result r = E_SUCCESS;
822 Bitmap* pPressedItemBackgroundBitmap = null;
823 Bitmap* pItemBackgroundBitmap = null;
824 Bitmap* pDisabledBackgroundBitmap = null;
825 Bitmap* pSelectedItemBackgroundBitmap = null;
826 Bitmap* pPressedItemBackgroundEffectBitmap = null;
827 Bitmap* pHighlightedItemBackgroundBitmap = null;
828 Color pressedEffectColor;
829 GET_COLOR_CONFIG(TAB::ITEM_BG_EFFECT_PRESSED, pressedEffectColor);
831 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisabledBackgroundBitmap);
832 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate disabled item background bitmap.");
834 if (pDisabledBackgroundBitmap)
836 __pDisabledBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDisabledBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetDisabledItemBackgroundColor());
837 SysTryLog(NID_UI_CTRL, (__pDisabledBackgroundBitmap != null), "Failed to locate disabled item background bitmap.");
839 delete pDisabledBackgroundBitmap;
842 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pItemBackgroundBitmap);
843 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate item background bitmap.");
845 if (pItemBackgroundBitmap)
847 __pBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetItemBackgroundColor());
848 SysTryLog(NID_UI_CTRL, (__pBackgroundBitmap != null), "Failed to locate item background bitmap.");
850 delete pItemBackgroundBitmap;
853 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundBitmap);
854 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap.");
856 if (pPressedItemBackgroundBitmap)
858 __pPressedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetPressedItemBackgroundColor());
859 SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundBitmap != null), "Failed to locate pressed item background bitmap.");
861 delete pPressedItemBackgroundBitmap;
864 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pSelectedItemBackgroundBitmap);
865 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
867 if (pSelectedItemBackgroundBitmap)
869 __pSelectedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSelectedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetSelectedItemBackgroundColor());
870 SysTryLog(NID_UI_CTRL, (__pSelectedItemBackgroundBitmap != null), "Failed to locate selected item background bitmap.");
872 delete pSelectedItemBackgroundBitmap;
875 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundEffectBitmap);
876 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
878 if (pPressedItemBackgroundEffectBitmap)
880 __pPressedItemBackgroundEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedEffectColor);
881 SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundEffectBitmap != null), "Failed to locate selected item background bitmap.");
883 delete pPressedItemBackgroundEffectBitmap;
886 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pHighlightedItemBackgroundBitmap);
887 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap.");
889 if (pHighlightedItemBackgroundBitmap)
891 __pHighlightedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pHighlightedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetHighlightedItemBackgroundColor());
892 SysTryLog(NID_UI_CTRL, (__pHighlightedItemBackgroundBitmap != null), "Failed to locate highlighted item background bitmap.");
894 delete pHighlightedItemBackgroundBitmap;
900 _Tab::SetBadgeIcon(int actionId, const Bitmap* pBadgeIcon)
902 result r = E_SUCCESS;
904 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
906 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
907 return E_OUT_OF_RANGE;
910 int itemIndex = GetItemIndexFromActionId(actionId);
912 _TabItem *pItem = null;
916 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument(s) is used. The specified actionId is not found.");
917 return E_INVALID_ARG;
920 pItem = dynamic_cast<_TabItem*>(__tabItems.GetAt(itemIndex));
924 pItem->SetBadgeIcon(*pBadgeIcon);
926 r = __tabItems.SetAt(*pItem, itemIndex, false);
933 _Tab::GetItemCount(void) const
935 return __tabItems.GetCount();
939 _Tab::GetItemIndexFromActionId(int actionId) const
941 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
943 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
948 int itemCount = __tabItems.GetCount();
950 for (index = 0; index < itemCount; index++)
952 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
956 if (pItem->GetActionId() == actionId)
967 _Tab::GetItemActionIdAt(int index) const
969 if (__tabItems.GetAt(index) == null )
974 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
975 SysTryReturn(NID_UI_CTRL, pItem != null, E_SYSTEM, E_SYSTEM,"[E_SYSTEM] A system error has occurred. Failed to get an item at index (%d).", index);
977 return pItem->GetActionId();
981 _Tab::GetItemAt(int index)
983 if (__tabItems.GetAt(index) == null )
988 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
989 result r = GetLastResult();
990 SysTryReturn(NID_UI_CTRL, pItem != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
996 _Tab::SetSelectedItemIndex(int index)
998 __pTabPresenter->SetSelectedItemIndex(index);
1003 _Tab::GetSelectedItemIndex(void) const
1005 return __pTabPresenter->GetSelectedItemIndex();
1009 _Tab::SetFirstDrawnItemIndex(int index)
1011 __pTabPresenter->SetFirstDrawnItemIndex(index);
1016 _Tab::GetFirstDrawnItemIndex(void) const
1018 return __pTabPresenter->GetFirstDrawnItemIndex();
1022 _Tab::SetEditModeEnabled(bool isEnabled)
1024 return __pTabPresenter->SetEditModeEnabled(isEnabled);
1028 _Tab::IsEditModeEnabled(void) const
1030 return __pTabPresenter->IsEditModeEnabled();
1034 _Tab::SetBackgroundBitmap(const Bitmap& bitmap)
1038 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1040 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1042 if (__pBackgroundBitmap)
1044 delete __pBackgroundBitmap;
1045 __pBackgroundBitmap = null;
1048 __pBackgroundBitmap = pBitmap;
1050 if (__pDisabledBackgroundBitmap)
1052 delete __pDisabledBackgroundBitmap;
1053 __pDisabledBackgroundBitmap = null;
1060 _Tab::GetBackgroundBitmap(void) const
1062 return __pBackgroundBitmap;
1066 _Tab::GetDisabledBackgroundBitmap(void) const
1068 return __pDisabledBackgroundBitmap;
1072 _Tab::GetPressedItemBackgroundBitmap(void) const
1074 return __pPressedItemBackgroundBitmap;
1078 _Tab::GetPressedItemBackgroundEffectBitmap(void) const
1080 return __pPressedItemBackgroundEffectBitmap;
1084 _Tab::SetSelectedItemBackgroundBitmap(const Bitmap& bitmap)
1088 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1090 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1092 if (__pSelectedItemBackgroundBitmap)
1094 delete __pSelectedItemBackgroundBitmap;
1095 __pSelectedItemBackgroundBitmap = null;
1097 __pSelectedItemBackgroundBitmap = pBitmap;
1098 __pTabPresenter->FreeHorizontalLineBitmap();
1105 _Tab::GetSelectedItemBackgroundBitmap(void) const
1107 return __pSelectedItemBackgroundBitmap;
1111 _Tab::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap)
1115 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1117 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1119 if (__pHighlightedItemBackgroundBitmap)
1121 delete __pHighlightedItemBackgroundBitmap;
1122 __pHighlightedItemBackgroundBitmap = null;
1125 __pHighlightedItemBackgroundBitmap = pBitmap;
1131 _Tab::GetHighlightedItemBackgroundBitmap(void) const
1133 return __pHighlightedItemBackgroundBitmap;
1137 _Tab::SetItemBackgroundColor(Color color)
1139 __itemBgColor[_TAB_STATUS_NORMAL] = color;
1144 _Tab::GetItemBackgroundColor(void) const
1146 return __itemBgColor[_TAB_STATUS_NORMAL];
1150 _Tab::GetPressedItemBackgroundColor(void) const
1152 return __itemBgColor[_TAB_STATUS_PRESSED];
1156 _Tab::SetSelectedItemBackgroundColor(Color color)
1158 __itemBgColor[_TAB_STATUS_SELECTED] = color;
1163 _Tab::GetSelectedItemBackgroundColor(void) const
1165 return __itemBgColor[_TAB_STATUS_SELECTED];
1169 _Tab::SetHighlightedItemBackgroundColor(Color color)
1171 __itemBgColor[_TAB_STATUS_HIGHLIGHTED] = color;
1176 _Tab::GetHighlightedItemBackgroundColor(void) const
1178 return __itemBgColor[_TAB_STATUS_HIGHLIGHTED];
1182 _Tab::GetDisabledItemBackgroundColor(void) const
1184 return __itemBgColor[_TAB_STATUS_DISABLED];
1188 _Tab::SetTextColor(const Color& textColor)
1190 __itemTextColor[_TAB_STATUS_NORMAL] = textColor;
1195 _Tab::GetTextColor(void) const
1197 return __itemTextColor[_TAB_STATUS_NORMAL];
1201 _Tab::GetDisabledTextColor(void) const
1203 return __itemTextColor[_TAB_STATUS_DISABLED];
1207 _Tab::SetPressedTextColor(const Color& textColor)
1209 __itemTextColor[_TAB_STATUS_PRESSED] = textColor;
1214 _Tab::GetPressedTextColor(void) const
1216 return __itemTextColor[_TAB_STATUS_PRESSED];
1220 _Tab::SetSelectedTextColor(const Color& textColor)
1222 __itemTextColor[_TAB_STATUS_SELECTED] = textColor;
1227 _Tab::GetSelectedTextColor(void) const
1229 return __itemTextColor[_TAB_STATUS_SELECTED];
1233 _Tab::SetHighlightedTextColor(const Color& color)
1235 __itemTextColor[_TAB_STATUS_HIGHLIGHTED] = color;
1240 _Tab::GetHighlightedTextColor(void) const
1242 return __itemTextColor[_TAB_STATUS_HIGHLIGHTED];
1246 _Tab::SetStyle(int style)
1253 _Tab::GetStyle(void) const
1255 return _TabStyle(__style);
1259 _Tab::GetCurrentHighlightedItemIndex(void) const
1261 return __currentHighlightedItemIndex;
1265 _Tab::AddActionEventListener(const _IActionEventListener& listener)
1269 if (__pActionEvent == null)
1271 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1273 if (__pActionEvent == null || IsFailed(GetLastResult()))
1275 SetLastResult(E_SYSTEM);
1276 delete __pActionEvent;
1280 __pActionEvent->AddListener(listener);
1285 _Tab::RemoveActionEventListener(const _IActionEventListener& listener)
1289 __pActionEvent->RemoveListener(listener);
1294 _Tab::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1296 if (this != &source)
1301 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
1303 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
1305 __currentHighlightedItemIndex = -1;
1307 return __pTabPresenter->OnTouchPressed(source, touchinfo);
1311 _Tab::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1313 if (this != &source)
1318 __pTabPresenter->OnTouchReleased(source, touchinfo);
1320 int index = __pTabPresenter->GetItemIndexFromPosition(touchinfo.GetCurrentPosition());
1322 _TabItem* pItem = __pTabPresenter->GetItemAt(index);
1331 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(pItem->GetActionId());
1332 SysTryReturn(NID_UI_CTRL, pEventArg, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1334 __pActionEvent->Fire(*pEventArg);
1341 _Tab::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1343 if (this != &source)
1348 return __pTabPresenter->OnTouchMoved(source, touchinfo);
1352 _Tab::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
1354 return __pTabPresenter->OnLongPressGestureDetected();
1358 _Tab::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
1364 _Tab::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1367 return __pTabPresenter->OnFlickGestureDetected(gesture);
1371 _Tab::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
1380 __pTabPresenter->Draw();
1386 _Tab::OnBoundsChanged(void)
1388 __pTabPresenter->OnBoundsChanged();
1392 _Tab::OnAttachedToMainTree(void)
1394 _AccessibilityContainer* pContainer = null;
1396 pContainer = GetAccessibilityContainer();
1400 pContainer->Activate(true);
1401 pContainer->AddListener(*this);
1408 _Tab::OnFontChanged(Font* pFont)
1410 __pTabPresenter->OnFontChanged(pFont);
1415 _Tab::OnFontInfoRequested(unsigned long& style, float& size)
1417 __pTabPresenter->OnFontInfoRequested(style, size);
1422 _Tab::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1424 if (this != &source)
1428 _KeyCode keyCode = keyInfo.GetKeyCode();
1429 int itemCount = __pTabPresenter->GetItemCount();
1435 if (keyCode == _KEY_RIGHT)
1437 if (__currentHighlightedItemIndex < (itemCount - 1))
1439 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1441 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
1444 __currentHighlightedItemIndex++;
1446 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1448 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
1450 __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_RIGHT);
1455 if (keyCode == _KEY_LEFT)
1457 if (__currentHighlightedItemIndex >= -1)
1459 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1461 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
1463 if (__currentHighlightedItemIndex == -1)
1465 __currentHighlightedItemIndex = 0;
1467 if (__currentHighlightedItemIndex > 0)
1469 __currentHighlightedItemIndex--;
1471 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1473 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
1475 __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_LEFT);
1480 if (keyCode == _KEY_ENTER && __currentHighlightedItemIndex != -1)
1482 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_SELECTED);
1483 __pTabPresenter->SetSelectedItemIndex(__currentHighlightedItemIndex);
1491 _Tab::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1497 _Tab::OnFocusGained(const _Control & source)
1499 if (this != &source)
1504 if(__pTabPresenter->GetItemCount() > 0)
1506 __currentHighlightedItemIndex = 0;
1510 __currentHighlightedItemIndex = -1;
1516 _Tab::OnFocusLost(const _Control & source)
1518 if (this != &source)
1523 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
1525 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
1527 __currentHighlightedItemIndex = -1;
1535 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1537 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
1539 __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_LEFT);
1544 _Tab::AddAccessibilityElement(const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
1546 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1547 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1549 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1550 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1552 pAccessibilityElement->SetTrait(L"Tab");
1553 pAccessibilityElement->SetHint(L"Double tap to move to contents");
1555 if (GetStyle() != _TAB_STYLE_ICON)
1557 pAccessibilityElement->SetLabel(itemText);
1560 if (status == _TABITEM_STATUS_SELECTED)
1562 pAccessibilityElement->SetStatus("Selected");
1563 pAccessibilityElement->SetHintDisabled(true);
1567 pAccessibilityElement->SetStatus("");
1568 pAccessibilityElement->SetHintDisabled(false);
1571 pContainer->AddElement(*pAccessibilityElement);
1572 __accessibilityElements.Add(pAccessibilityElement);
1578 _Tab::InsertAccessibilityElementAt(int index, const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
1580 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1581 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1583 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1584 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1586 pAccessibilityElement->SetTrait(L"Tab");
1587 pAccessibilityElement->SetHint(L"Double tap to move to contents");
1589 if (GetStyle() != _TAB_STYLE_ICON)
1591 pAccessibilityElement->SetLabel(itemText);
1594 if (status == _TABITEM_STATUS_SELECTED)
1596 pAccessibilityElement->SetStatus("Selected");
1597 pAccessibilityElement->SetHintDisabled(true);
1601 pAccessibilityElement->SetStatus("");
1602 pAccessibilityElement->SetHintDisabled(false);
1605 pContainer->InsertElement(*pAccessibilityElement, index);
1606 __accessibilityElements.InsertAt(pAccessibilityElement, index);
1612 _Tab::RemoveAccessibilityElementAt(int index)
1614 _AccessibilityElement* pAccessibilityElement = null;
1615 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1616 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1618 if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
1620 __accessibilityElements.RemoveAt(index);
1621 pContainer->RemoveElement(*pAccessibilityElement);
1628 _Tab::RemoveAllAccessibilityElement(void)
1630 _AccessibilityElement* pAccessibilityElement = null;
1631 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1632 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1634 while (__accessibilityElements.GetCount() > 0)
1636 if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS)
1638 __accessibilityElements.RemoveAt(0);
1639 pContainer->RemoveElement(*pAccessibilityElement);
1647 _Tab::UpdateAccessibilityElement(void)
1649 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1650 _TabItem* pItem = null;
1651 _AccessibilityElement* pAccessibilityElement = null;
1652 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1653 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1655 int count = __accessibilityElements.GetCount();
1657 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1659 for (int i = 0; i < count; i++)
1661 if ((__accessibilityElements.GetAt(i, pAccessibilityElement)) == E_SUCCESS)
1663 pItem = GetItemAt(i);
1666 bounds = pItem->GetItemBounds();
1667 itemStatus = pItem->GetStatus();
1670 if (pAccessibilityElement)
1672 pAccessibilityElement->SetBounds(bounds);
1674 if (itemStatus == _TABITEM_STATUS_SELECTED)
1676 pAccessibilityElement->SetStatus("Selected");
1677 pAccessibilityElement->SetHintDisabled(true);
1681 pAccessibilityElement->SetStatus("");
1682 pAccessibilityElement->SetHintDisabled(false);
1692 _Tab::UpdateAccessibilityLabel(int index, const String& text)
1694 _AccessibilityElement* pAccessibilityElement = null;
1695 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1696 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1698 if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
1700 if (pAccessibilityElement)
1702 pAccessibilityElement->SetLabel(text);
1710 _Tab::OnChangeLayout(_ControlOrientation orientation)
1712 __pTabPresenter->OnChangeLayout(orientation);
1718 _Tab::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1724 _Tab::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1730 _Tab::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1735 _Tab::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1741 _Tab::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1743 FloatRectangle bounds = element.GetBounds();
1747 if (bounds.x == -bounds.width)
1749 __pTabPresenter->MovePrevious();
1753 __pTabPresenter->MoveToFirst();
1756 else if (bounds.x + bounds.width > GetBounds().width)
1758 if (bounds.x == GetBounds().width)
1760 __pTabPresenter->MoveNext();
1764 __pTabPresenter->MoveToLast(bounds.x);
1772 _Tab::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1778 _Tab::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1784 _Tab::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1790 _Tab::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1795 }}} // Tizen::Ui::Controls