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 , __isInFocusMode(false)
43 , __style(_TAB_STYLE_TEXT)
44 , __currentHighlightedItemIndex(-1)
45 , __tabStatus(_TAB_STATUS_NORMAL)
46 , __pActionEvent(null)
47 , __pGestureLongPress(null)
48 , __pFlickGesture(null)
49 , __pBackgroundBitmap(null)
50 , __pDisabledBackgroundBitmap(null)
51 , __pPressedItemBackgroundBitmap(null)
52 , __pPressedItemBackgroundEffectBitmap(null)
53 , __pSelectedItemBackgroundBitmap(null)
54 , __pHighlightedItemBackgroundBitmap(null)
59 __tabItems.Construct();
61 GET_COLOR_CONFIG(TAB::ITEM_BG_NORMAL, __itemBgColor[_TAB_STATUS_NORMAL]);
62 GET_COLOR_CONFIG(TAB::ITEM_BG_PRESSED, __itemBgColor[_TAB_STATUS_PRESSED]);
63 GET_COLOR_CONFIG(TAB::ITEM_BG_SELECTED, __itemBgColor[_TAB_STATUS_SELECTED]);
64 GET_COLOR_CONFIG(TAB::ITEM_BG_HIGHLIGHTED, __itemBgColor[_TAB_STATUS_HIGHLIGHTED]);
65 GET_COLOR_CONFIG(TAB::ITEM_BG_DISABLED, __itemBgColor[_TAB_STATUS_DISABLED]);
67 GET_COLOR_CONFIG(TAB::ITEM_TEXT_NORMAL, __itemTextColor[_TAB_STATUS_NORMAL]);
68 GET_COLOR_CONFIG(TAB::ITEM_TEXT_PRESSED, __itemTextColor[_TAB_STATUS_PRESSED]);
69 GET_COLOR_CONFIG(TAB::ITEM_TEXT_SELECTED, __itemTextColor[_TAB_STATUS_SELECTED]);
70 GET_COLOR_CONFIG(TAB::ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_TAB_STATUS_HIGHLIGHTED]);
71 GET_COLOR_CONFIG(TAB::ITEM_TEXT_DISABLED, __itemTextColor[_TAB_STATUS_DISABLED]);
74 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to load bitmap.");
76 _Control::SetResizable(false);
77 _Control::SetMovable(false);
79 _TabPresenter* pPresenter = new (std::nothrow) _TabPresenter;
80 SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
82 r = SetPresenter(*pPresenter);
83 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance could not be set.");
85 r = pPresenter->Construct(*this);
86 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance construct failed.");
92 delete __pTabPresenter;
93 __pTabPresenter = null;
95 delete __pActionEvent;
96 __pActionEvent = null;
98 __tabItems.RemoveAll(true);
100 if (__pFlickGesture != null)
102 __pFlickGesture->RemoveGestureListener(*this);
103 RemoveGestureDetector(*__pFlickGesture);
105 delete __pFlickGesture;
106 __pFlickGesture = null;
109 if (__pGestureLongPress != null)
111 __pGestureLongPress->RemoveGestureListener(*this);
112 RemoveGestureDetector(*__pGestureLongPress);
114 delete __pGestureLongPress;
115 __pGestureLongPress = null;
118 delete __pBackgroundBitmap;
119 __pBackgroundBitmap = null;
121 delete __pDisabledBackgroundBitmap;
122 __pDisabledBackgroundBitmap = null;
124 delete __pPressedItemBackgroundBitmap;
125 __pPressedItemBackgroundBitmap = null;
127 delete __pPressedItemBackgroundEffectBitmap;
128 __pPressedItemBackgroundEffectBitmap = null;
130 delete __pSelectedItemBackgroundBitmap;
131 __pSelectedItemBackgroundBitmap = null;
133 delete __pHighlightedItemBackgroundBitmap;
134 __pHighlightedItemBackgroundBitmap = null;
136 RemoveAllAccessibilityElement();
140 _Tab::CreateTabN(void)
142 result r = E_SUCCESS;
144 _Tab* pTab = new (std::nothrow) _Tab;
145 SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
147 if (IsFailed(GetLastResult()))
152 pTab->AcquireHandle();
154 pTab->__pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector;
155 SysTryCatch(NID_UI_CTRL, pTab->__pGestureLongPress, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
157 pTab->__pGestureLongPress->SetDuration(500);
158 pTab->AddGestureDetector(*(pTab->__pGestureLongPress));
159 r = pTab->__pGestureLongPress->AddGestureListener(*pTab);
160 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
162 pTab->__pFlickGesture = new (std::nothrow) _TouchFlickGestureDetector;
163 SysTryCatch(NID_UI_CTRL, pTab->__pFlickGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
165 r = pTab->AddGestureDetector(*(pTab->__pFlickGesture));
166 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
168 r = pTab->__pFlickGesture->AddGestureListener(*pTab);
169 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
174 if (pTab->__pGestureLongPress != null)
176 pTab->__pGestureLongPress->RemoveGestureListener(*pTab);
177 pTab->RemoveGestureDetector(*pTab->__pGestureLongPress);
179 delete pTab->__pGestureLongPress;
180 pTab->__pGestureLongPress = null;
182 if (pTab->__pFlickGesture != null)
184 pTab->__pFlickGesture->RemoveGestureListener(*pTab);
185 pTab->RemoveGestureDetector(*pTab->__pFlickGesture);
187 delete pTab->__pFlickGesture;
188 pTab->__pFlickGesture = null;
196 _Tab::SetPresenter(const _TabPresenter& tabPresenter)
199 __pTabPresenter = const_cast<_TabPresenter*>(&tabPresenter);
205 _Tab::AddItem(const Bitmap& icon, const String& text, int actionId)
207 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
209 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
210 return E_OUT_OF_RANGE;
213 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
218 __style = _TAB_STYLE_ICON_TEXT;
220 bool isDuplicate = CheckDuplicatedActionId(actionId);
221 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);
223 int itemCount = __tabItems.GetCount();
225 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
227 _TabItem *pItem = new (std::nothrow) _TabItem;
228 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
230 pItem->SetIcon(icon);
231 pItem->SetText(text);
232 pItem->SetActionId(actionId);
233 pItem->SetUpdateState(true);
237 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
241 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
244 __pTabPresenter->SetRecalculateItemBounds(true);
246 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
248 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
250 __currentHighlightedItemIndex = 0;
252 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
254 return __tabItems.Add(*pItem);
258 _Tab::AddItem(const Bitmap& icon, int actionId)
260 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
262 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
263 return E_OUT_OF_RANGE;
266 if (__style != _TAB_STYLE_ICON)
271 bool isDuplicate = CheckDuplicatedActionId(actionId);
272 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);
274 int itemCount = __tabItems.GetCount();
276 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
278 _TabItem *pItem = new (std::nothrow) _TabItem;
279 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
281 pItem->SetIcon(icon);
282 pItem->SetActionId(actionId);
283 pItem->SetUpdateState(true);
287 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
291 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
294 __pTabPresenter->SetRecalculateItemBounds(true);
296 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
298 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
300 __currentHighlightedItemIndex = 0;
302 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
304 return __tabItems.Add(*pItem);
308 _Tab::AddItem(const String& text, int actionId)
310 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
312 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
313 return E_OUT_OF_RANGE;
316 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
321 bool isDuplicate = CheckDuplicatedActionId(actionId);
322 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);
324 int itemCount = __tabItems.GetCount();
326 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
328 _TabItem *pItem = new (std::nothrow) _TabItem;
329 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
331 pItem->SetText(text);
332 pItem->SetActionId(actionId);
333 pItem->SetUpdateState(true);
337 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
341 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
344 __pTabPresenter->SetRecalculateItemBounds(true);
346 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
348 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
350 __currentHighlightedItemIndex = 0;
352 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
354 return __tabItems.Add(*pItem);
358 _Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int actionId)
360 result r = E_SUCCESS;
361 bool isSelected = false;
363 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
365 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
366 return E_OUT_OF_RANGE;
369 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
374 __style = _TAB_STYLE_ICON_TEXT;
376 bool isDuplicate = CheckDuplicatedActionId(actionId);
377 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);
379 int itemCount = __tabItems.GetCount();
381 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
383 _TabItem *pItem = new (std::nothrow) _TabItem;
384 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
386 pItem->SetIcon(icon);
387 pItem->SetText(text);
388 pItem->SetActionId(actionId);
389 pItem->SetUpdateState(true);
391 int selectedIndex = GetSelectedItemIndex();
393 if (selectedIndex >= index)
395 _TabItem *pSelectedItem = null;
396 pSelectedItem = GetItemAt(selectedIndex);
397 if (pSelectedItem != null)
400 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
405 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
408 __pTabPresenter->SetRecalculateItemBounds(true);
410 r = __tabItems.InsertAt(*pItem, index);
414 SetSelectedItemIndex(selectedIndex);
417 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
419 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
421 __currentHighlightedItemIndex = 0;
423 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
429 _Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
431 result r = E_SUCCESS;
432 bool isSelected = false;
434 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
436 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
437 return E_OUT_OF_RANGE;
440 if (__style != _TAB_STYLE_ICON)
445 bool isDuplicate = CheckDuplicatedActionId(actionId);
446 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);
448 int itemCount = __tabItems.GetCount();
450 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
452 _TabItem *pItem = new (std::nothrow) _TabItem;
453 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
455 pItem->SetIcon(icon);
456 pItem->SetActionId(actionId);
457 pItem->SetUpdateState(true);
458 int selectedIndex = GetSelectedItemIndex();
460 if (selectedIndex >= index)
462 _TabItem *pSelectedItem = null;
463 pSelectedItem = GetItemAt(selectedIndex);
464 if (pSelectedItem != null)
467 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
472 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
475 __pTabPresenter->SetRecalculateItemBounds(true);
477 r = __tabItems.InsertAt(*pItem, index);
481 SetSelectedItemIndex(selectedIndex);
484 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
486 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
488 __currentHighlightedItemIndex = 0;
490 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
496 _Tab::InsertItemAt(int index, const String& text, int actionId)
498 result r = E_SUCCESS;
499 bool isSelected = false;
501 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
503 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
504 return E_OUT_OF_RANGE;
507 bool isDuplicate = CheckDuplicatedActionId(actionId);
508 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);
510 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
515 int itemCount = __tabItems.GetCount();
517 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
519 _TabItem *pItem = new (std::nothrow) _TabItem;
520 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
522 pItem->SetText(text);
523 pItem->SetActionId(actionId);
524 pItem->SetUpdateState(true);
525 int selectedIndex = GetSelectedItemIndex();
527 if (selectedIndex >= index)
529 _TabItem *pSelectedItem = null;
530 pSelectedItem = GetItemAt(selectedIndex);
531 if (pSelectedItem != null)
534 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
539 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
542 __pTabPresenter->SetRecalculateItemBounds(true);
544 r = __tabItems.InsertAt(*pItem, index);
548 SetSelectedItemIndex(selectedIndex);
551 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
553 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
555 __currentHighlightedItemIndex = 0;
557 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
563 _Tab::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId)
565 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
567 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
568 return E_OUT_OF_RANGE;
571 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
576 __style = _TAB_STYLE_ICON_TEXT;
578 int itemCount = __tabItems.GetCount();
580 if ((index < 0) || (index >= itemCount))
582 return E_OUT_OF_RANGE;
585 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
587 if (GetItemIndex(actionId) != index)
592 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
593 result r = GetLastResult();
594 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
596 pItem->SetIcon(icon);
597 pItem->SetText(text);
598 pItem->SetActionId(actionId);
599 pItem->SetUpdateState(true);
601 UpdateAccessibilityLabel(index, text);
607 _Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
609 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
611 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
612 return E_OUT_OF_RANGE;
615 if (__style != _TAB_STYLE_ICON)
620 int itemCount = __tabItems.GetCount();
622 if ((index < 0) || (index >= itemCount))
624 return E_OUT_OF_RANGE;
627 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
629 if (GetItemIndex(actionId) != index)
634 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
635 result r = GetLastResult();
636 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
638 pItem->SetIcon(icon);
639 pItem->SetActionId(actionId);
640 pItem->SetUpdateState(true);
646 _Tab::SetItemAt(int index, const String& text, int actionId)
648 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
650 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
651 return E_OUT_OF_RANGE;
654 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
659 int itemCount = __tabItems.GetCount();
661 if ((index < 0) || (index >= itemCount))
663 return E_OUT_OF_RANGE;
666 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
668 if (GetItemIndex(actionId) != index)
673 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
674 result r = GetLastResult();
675 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
677 pItem->SetText(text);
678 pItem->SetActionId(actionId);
679 pItem->SetUpdateState(true);
681 UpdateAccessibilityLabel(index, text);
687 _Tab::RemoveItemAt(int index)
689 result r = E_SUCCESS;
690 int selectedIndex = GetSelectedItemIndex();
692 if (selectedIndex >= index)
694 _TabItem *pSelectedItem = null;
695 pSelectedItem = GetItemAt(selectedIndex);
696 if (pSelectedItem != null)
698 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
701 __pTabPresenter->SetRecalculateItemBounds(true);
703 r = __tabItems.RemoveAt(index, true);
705 SetSelectedItemIndex(0);
707 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
709 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
711 if (GetItemCount() > 0)
713 __currentHighlightedItemIndex = 0;
717 __currentHighlightedItemIndex = -1;
720 RemoveAccessibilityElementAt(index);
726 _Tab::RemoveAllItems(void)
728 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
730 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
732 __currentHighlightedItemIndex = -1;
734 __pTabPresenter->SetRecalculateItemBounds(true);
735 SetSelectedItemIndex(0);
736 SetFirstDrawnItemIndex(-1);
738 __tabItems.RemoveAll(true);
740 RemoveAllAccessibilityElement();
746 _Tab::ChangeItemAt(const int srcIndex, const int destIndex)
748 _TabItem* pItem = null;
749 pItem = GetItemAt(srcIndex);
751 __tabItems.InsertAt(*pItem, destIndex);
753 if (srcIndex > destIndex)
755 __tabItems.RemoveAt((srcIndex + 1), false);
759 __tabItems.RemoveAt(srcIndex, false);
766 _Tab::GetItemIndex(int actionId)
768 int itemCount = __tabItems.GetCount();
770 _TabItem* pItem = null;
772 for (int i = 0; i < itemCount; i++)
774 pItem = GetItemAt(i);
776 if ((pItem != null) && (actionId == pItem->GetActionId()))
786 _Tab::CheckDuplicatedActionId(int actionId)
788 int itemIndex = GetItemIndex(actionId);
799 _Tab::LoadBitmap(void)
801 result r = E_SUCCESS;
802 Bitmap* pPressedItemBackgroundBitmap = null;
803 Bitmap* pItemBackgroundBitmap = null;
804 Bitmap* pDisabledBackgroundBitmap = null;
805 Bitmap* pSelectedItemBackgroundBitmap = null;
806 Bitmap* pPressedItemBackgroundEffectBitmap = null;
807 Bitmap* pHighlightedItemBackgroundBitmap = null;
808 Color pressedEffectColor;
809 GET_COLOR_CONFIG(TAB::ITEM_BG_EFFECT_PRESSED, pressedEffectColor);
811 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisabledBackgroundBitmap);
812 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate disabled item background bitmap.");
814 if (pDisabledBackgroundBitmap != null)
816 __pDisabledBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDisabledBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetDisabledItemBackgroundColor());
817 SysTryLog(NID_UI_CTRL, (__pDisabledBackgroundBitmap != null), "Failed to locate disabled item background bitmap.");
819 delete pDisabledBackgroundBitmap;
822 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pItemBackgroundBitmap);
823 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate item background bitmap.");
825 if (pItemBackgroundBitmap != null)
827 __pBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetItemBackgroundColor());
828 SysTryLog(NID_UI_CTRL, (__pBackgroundBitmap != null), "Failed to locate item background bitmap.");
830 delete pItemBackgroundBitmap;
833 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundBitmap);
834 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap.");
836 if (pPressedItemBackgroundBitmap != null)
838 __pPressedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetPressedItemBackgroundColor());
839 SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundBitmap != null), "Failed to locate pressed item background bitmap.");
841 delete pPressedItemBackgroundBitmap;
844 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pSelectedItemBackgroundBitmap);
845 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
847 if (pSelectedItemBackgroundBitmap != null)
849 __pSelectedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSelectedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetSelectedItemBackgroundColor());
850 SysTryLog(NID_UI_CTRL, (__pSelectedItemBackgroundBitmap != null), "Failed to locate selected item background bitmap.");
852 delete pSelectedItemBackgroundBitmap;
855 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundEffectBitmap);
856 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
858 if (pPressedItemBackgroundEffectBitmap != null)
860 __pPressedItemBackgroundEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedEffectColor);
861 SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundEffectBitmap != null), "Failed to locate selected item background bitmap.");
863 delete pPressedItemBackgroundEffectBitmap;
866 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pHighlightedItemBackgroundBitmap);
867 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap.");
869 if (pHighlightedItemBackgroundBitmap != null)
871 __pHighlightedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pHighlightedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetHighlightedItemBackgroundColor());
872 SysTryLog(NID_UI_CTRL, (__pHighlightedItemBackgroundBitmap != null), "Failed to locate highlighted item background bitmap.");
874 delete pHighlightedItemBackgroundBitmap;
880 _Tab::SetBadgeIcon(int actionId, const Bitmap* pBadgeIcon)
882 result r = E_SUCCESS;
884 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
886 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
887 return E_OUT_OF_RANGE;
890 int itemIndex = GetItemIndexFromActionId(actionId);
892 _TabItem *pItem = null;
896 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument(s) is used. The specified actionId is not found.");
897 return E_INVALID_ARG;
900 pItem = dynamic_cast<_TabItem*>(__tabItems.GetAt(itemIndex));
904 pItem->SetBadgeIcon(*pBadgeIcon);
906 r = __tabItems.SetAt(*pItem, itemIndex, false);
913 _Tab::GetItemCount(void) const
915 return __tabItems.GetCount();
919 _Tab::GetItemIndexFromActionId(int actionId) const
921 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
923 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
928 int itemCount = __tabItems.GetCount();
930 for (index = 0; index < itemCount; index++)
932 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
936 if (pItem->GetActionId() == actionId)
947 _Tab::GetItemActionIdAt(int index) const
949 if (__tabItems.GetAt(index) == null )
954 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
955 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);
957 return pItem->GetActionId();
961 _Tab::GetItemAt(int index)
963 if (__tabItems.GetAt(index) == null )
968 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
969 result r = GetLastResult();
970 SysTryReturn(NID_UI_CTRL, pItem != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
976 _Tab::SetSelectedItemIndex(int index)
978 __pTabPresenter->SetSelectedItemIndex(index);
983 _Tab::GetSelectedItemIndex(void) const
985 return __pTabPresenter->GetSelectedItemIndex();
989 _Tab::SetFirstDrawnItemIndex(int index)
991 __pTabPresenter->SetFirstDrawnItemIndex(index);
996 _Tab::GetFirstDrawnItemIndex(void) const
998 return __pTabPresenter->GetFirstDrawnItemIndex();
1002 _Tab::SetEditModeEnabled(bool isEnabled)
1004 return __pTabPresenter->SetEditModeEnabled(isEnabled);
1008 _Tab::IsEditModeEnabled(void) const
1010 return __pTabPresenter->IsEditModeEnabled();
1014 _Tab::IsInFocusMode(void) const
1016 return __isInFocusMode;
1020 _Tab::SetBackgroundBitmap(const Bitmap& bitmap)
1024 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1026 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1028 if (__pBackgroundBitmap != null)
1030 delete __pBackgroundBitmap;
1031 __pBackgroundBitmap = null;
1034 __pBackgroundBitmap = pBitmap;
1036 if (__pDisabledBackgroundBitmap != null)
1038 delete __pDisabledBackgroundBitmap;
1039 __pDisabledBackgroundBitmap = null;
1046 _Tab::GetBackgroundBitmap(void) const
1048 return __pBackgroundBitmap;
1052 _Tab::GetDisabledBackgroundBitmap(void) const
1054 return __pDisabledBackgroundBitmap;
1058 _Tab::GetPressedItemBackgroundBitmap(void) const
1060 return __pPressedItemBackgroundBitmap;
1064 _Tab::GetPressedItemBackgroundEffectBitmap(void) const
1066 return __pPressedItemBackgroundEffectBitmap;
1070 _Tab::SetSelectedItemBackgroundBitmap(const Bitmap& bitmap)
1074 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1076 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1078 if (__pSelectedItemBackgroundBitmap != null)
1080 delete __pSelectedItemBackgroundBitmap;
1081 __pSelectedItemBackgroundBitmap = null;
1083 __pSelectedItemBackgroundBitmap = pBitmap;
1084 __pTabPresenter->FreeHorizontalLineBitmap();
1091 _Tab::GetSelectedItemBackgroundBitmap(void) const
1093 return __pSelectedItemBackgroundBitmap;
1097 _Tab::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap)
1101 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1103 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1105 if (__pHighlightedItemBackgroundBitmap != null)
1107 delete __pHighlightedItemBackgroundBitmap;
1108 __pHighlightedItemBackgroundBitmap = null;
1111 __pHighlightedItemBackgroundBitmap = pBitmap;
1117 _Tab::GetHighlightedItemBackgroundBitmap(void) const
1119 return __pHighlightedItemBackgroundBitmap;
1123 _Tab::SetItemBackgroundColor(Color color)
1125 __itemBgColor[_TAB_STATUS_NORMAL] = color;
1130 _Tab::GetItemBackgroundColor(void) const
1132 return __itemBgColor[_TAB_STATUS_NORMAL];
1136 _Tab::GetPressedItemBackgroundColor(void) const
1138 return __itemBgColor[_TAB_STATUS_PRESSED];
1142 _Tab::SetSelectedItemBackgroundColor(Color color)
1144 __itemBgColor[_TAB_STATUS_SELECTED] = color;
1149 _Tab::GetSelectedItemBackgroundColor(void) const
1151 return __itemBgColor[_TAB_STATUS_SELECTED];
1155 _Tab::SetHighlightedItemBackgroundColor(Color color)
1157 __itemBgColor[_TAB_STATUS_HIGHLIGHTED] = color;
1162 _Tab::GetHighlightedItemBackgroundColor(void) const
1164 return __itemBgColor[_TAB_STATUS_HIGHLIGHTED];
1168 _Tab::GetDisabledItemBackgroundColor(void) const
1170 return __itemBgColor[_TAB_STATUS_DISABLED];
1174 _Tab::SetTextColor(const Color& textColor)
1176 __itemTextColor[_TAB_STATUS_NORMAL] = textColor;
1181 _Tab::GetTextColor(void) const
1183 return __itemTextColor[_TAB_STATUS_NORMAL];
1187 _Tab::GetDisabledTextColor(void) const
1189 return __itemTextColor[_TAB_STATUS_DISABLED];
1193 _Tab::SetPressedTextColor(const Color& textColor)
1195 __itemTextColor[_TAB_STATUS_PRESSED] = textColor;
1200 _Tab::GetPressedTextColor(void) const
1202 return __itemTextColor[_TAB_STATUS_PRESSED];
1206 _Tab::SetSelectedTextColor(const Color& textColor)
1208 __itemTextColor[_TAB_STATUS_SELECTED] = textColor;
1213 _Tab::GetSelectedTextColor(void) const
1215 return __itemTextColor[_TAB_STATUS_SELECTED];
1219 _Tab::SetHighlightedTextColor(const Color& color)
1221 __itemTextColor[_TAB_STATUS_HIGHLIGHTED] = color;
1226 _Tab::GetHighlightedTextColor(void) const
1228 return __itemTextColor[_TAB_STATUS_HIGHLIGHTED];
1232 _Tab::SetStyle(int style)
1239 _Tab::GetStyle(void) const
1241 return _TabStyle(__style);
1245 _Tab::GetCurrentHighlightedItemIndex(void) const
1247 return __currentHighlightedItemIndex;
1251 _Tab::AddActionEventListener(const _IActionEventListener& listener)
1255 if (__pActionEvent == null)
1257 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1259 if (__pActionEvent == null || IsFailed(GetLastResult()))
1261 SetLastResult(E_SYSTEM);
1262 delete __pActionEvent;
1266 __pActionEvent->AddListener(listener);
1271 _Tab::RemoveActionEventListener(const _IActionEventListener& listener)
1275 __pActionEvent->RemoveListener(listener);
1280 _Tab::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1282 if (this != &source)
1286 return __pTabPresenter->OnTouchPressed(source, touchinfo);
1290 _Tab::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1292 if (this != &source)
1297 __pTabPresenter->OnTouchReleased(source, touchinfo);
1299 int index = __pTabPresenter->GetItemIndexFromPosition(touchinfo.GetCurrentPosition());
1301 _TabItem* pItem = __pTabPresenter->GetItemAt(index);
1308 if (__pActionEvent != null)
1310 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(pItem->GetActionId());
1311 SysTryReturn(NID_UI_CTRL, pEventArg, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1313 __pActionEvent->Fire(*pEventArg);
1320 _Tab::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1322 if (this != &source)
1327 return __pTabPresenter->OnTouchMoved(source, touchinfo);
1331 _Tab::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
1333 return __pTabPresenter->OnLongPressGestureDetected();
1337 _Tab::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
1343 _Tab::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1346 return __pTabPresenter->OnFlickGestureDetected(gesture);
1350 _Tab::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
1359 __pTabPresenter->Draw();
1365 _Tab::OnBoundsChanged(void)
1367 __pTabPresenter->OnBoundsChanged();
1371 _Tab::OnAttachedToMainTree(void)
1373 _AccessibilityContainer* pContainer = null;
1375 pContainer = GetAccessibilityContainer();
1377 if (pContainer != null)
1379 pContainer->Activate(true);
1380 pContainer->AddListener(*this);
1387 _Tab::OnFontChanged(Font* pFont)
1389 __pTabPresenter->OnFontChanged(pFont);
1394 _Tab::OnFontInfoRequested(unsigned long& style, float& size)
1396 __pTabPresenter->OnFontInfoRequested(style, size);
1401 _Tab::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
1403 if (this != &source)
1407 _KeyCode keyCode = keyInfo.GetKeyCode();
1408 int itemCount = __pTabPresenter->GetItemCount();
1409 if (itemCount == 0 || !__isInFocusMode)
1414 if (keyCode == _KEY_RIGHT)
1416 if (__currentHighlightedItemIndex < (itemCount - 1))
1418 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1420 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
1423 __currentHighlightedItemIndex++;
1425 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1427 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
1429 __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_RIGHT);
1434 if (keyCode == _KEY_LEFT)
1436 if (__currentHighlightedItemIndex >= -1)
1438 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1440 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
1442 if (__currentHighlightedItemIndex == -1)
1444 __currentHighlightedItemIndex = 0;
1446 if (__currentHighlightedItemIndex > 0)
1448 __currentHighlightedItemIndex--;
1450 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1452 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
1454 __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_LEFT);
1459 if (keyCode == _KEY_ENTER && __currentHighlightedItemIndex != -1)
1461 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_SELECTED);
1462 __pTabPresenter->SetSelectedItemIndex(__currentHighlightedItemIndex);
1470 _Tab::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
1476 _Tab::OnDrawFocus(void)
1478 if (__pTabPresenter->GetItemCount() > 0)
1480 __currentHighlightedItemIndex = 0;
1484 __currentHighlightedItemIndex = -1;
1486 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1488 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
1490 __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_LEFT);
1491 __isInFocusMode = true;
1496 _Tab::OnFocusModeStateChanged(void)
1498 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
1500 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
1502 __currentHighlightedItemIndex = -1;
1503 __isInFocusMode = false;
1508 _Tab::AddAccessibilityElement(const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
1510 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1511 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1513 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1514 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1516 pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_TAB_T_TTS");
1517 pAccessibilityElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_MOVE_TO_CONTENT_T_TTS");
1519 if (GetStyle() != _TAB_STYLE_ICON)
1521 pAccessibilityElement->SetLabel(itemText);
1524 if (status == _TABITEM_STATUS_SELECTED)
1526 pAccessibilityElement->SetStatusWithStringId("IDS_TPLATFORM_BODY_SELECTED_T_TTS");
1527 pAccessibilityElement->SetHintDisabled(true);
1531 pAccessibilityElement->SetStatus("");
1532 pAccessibilityElement->SetHintDisabled(false);
1535 pContainer->AddElement(*pAccessibilityElement);
1536 __accessibilityElements.Add(pAccessibilityElement);
1542 _Tab::InsertAccessibilityElementAt(int index, const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
1544 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1545 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1547 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1548 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1550 pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_TAB_T_TTS");
1551 pAccessibilityElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_MOVE_TO_CONTENT_T_TTS");
1553 if (GetStyle() != _TAB_STYLE_ICON)
1555 pAccessibilityElement->SetLabel(itemText);
1558 if (status == _TABITEM_STATUS_SELECTED)
1560 pAccessibilityElement->SetStatusWithStringId("IDS_TPLATFORM_BODY_SELECTED_T_TTS");
1561 pAccessibilityElement->SetHintDisabled(true);
1565 pAccessibilityElement->SetStatus("");
1566 pAccessibilityElement->SetHintDisabled(false);
1569 pContainer->InsertElement(*pAccessibilityElement, index);
1570 __accessibilityElements.InsertAt(pAccessibilityElement, index);
1576 _Tab::RemoveAccessibilityElementAt(int index)
1578 _AccessibilityElement* pAccessibilityElement = null;
1579 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1580 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1582 if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
1584 __accessibilityElements.RemoveAt(index);
1585 pContainer->RemoveElement(*pAccessibilityElement);
1592 _Tab::RemoveAllAccessibilityElement(void)
1594 _AccessibilityElement* pAccessibilityElement = null;
1595 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1596 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1598 while (__accessibilityElements.GetCount() > 0)
1600 if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS)
1602 __accessibilityElements.RemoveAt(0);
1603 pContainer->RemoveElement(*pAccessibilityElement);
1611 _Tab::UpdateAccessibilityElement(void)
1613 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1614 _TabItem* pItem = null;
1615 _AccessibilityElement* pAccessibilityElement = null;
1616 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1617 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1619 int count = __accessibilityElements.GetCount();
1621 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1623 for (int i = 0; i < count; i++)
1625 if ((__accessibilityElements.GetAt(i, pAccessibilityElement)) == E_SUCCESS)
1627 pItem = GetItemAt(i);
1630 bounds = pItem->GetItemBounds();
1631 itemStatus = pItem->GetStatus();
1634 if (pAccessibilityElement != null)
1636 pAccessibilityElement->SetBounds(bounds);
1638 if (itemStatus == _TABITEM_STATUS_SELECTED)
1640 pAccessibilityElement->SetStatusWithStringId("IDS_TPLATFORM_BODY_SELECTED_T_TTS");
1641 pAccessibilityElement->SetHintDisabled(true);
1645 pAccessibilityElement->SetStatus("");
1646 pAccessibilityElement->SetHintDisabled(false);
1656 _Tab::UpdateAccessibilityLabel(int index, const String& text)
1658 _AccessibilityElement* pAccessibilityElement = null;
1659 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1660 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1662 if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
1664 if (pAccessibilityElement != null)
1666 pAccessibilityElement->SetLabel(text);
1674 _Tab::OnChangeLayout(_ControlOrientation orientation)
1676 __pTabPresenter->OnChangeLayout(orientation);
1682 _Tab::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1688 _Tab::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1694 _Tab::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1699 _Tab::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1705 _Tab::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1707 FloatRectangle bounds = element.GetBounds();
1711 if (bounds.x == -bounds.width)
1713 __pTabPresenter->MovePrevious();
1717 __pTabPresenter->MoveToFirst();
1720 else if (bounds.x + bounds.width > GetBounds().width)
1722 if (bounds.x == GetBounds().width)
1724 __pTabPresenter->MoveNext();
1728 __pTabPresenter->MoveToLast(bounds.x);
1736 _Tab::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1742 _Tab::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1748 _Tab::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1754 _Tab::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1759 }}} // Tizen::Ui::Controls