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;
97 delete __pActionEvent;
98 __pActionEvent = null;
101 __tabItems.RemoveAll(true);
103 if (__pFlickGesture != null)
105 __pFlickGesture->RemoveGestureListener(*this);
106 RemoveGestureDetector(*__pFlickGesture);
108 delete __pFlickGesture;
109 __pFlickGesture = null;
112 if (__pGestureLongPress != null)
114 __pGestureLongPress->RemoveGestureListener(*this);
115 RemoveGestureDetector(*__pGestureLongPress);
117 delete __pGestureLongPress;
118 __pGestureLongPress = null;
121 if (__pBackgroundBitmap)
123 delete __pBackgroundBitmap;
124 __pBackgroundBitmap = null;
127 if (__pDisabledBackgroundBitmap)
129 delete __pDisabledBackgroundBitmap;
130 __pDisabledBackgroundBitmap = null;
133 if (__pPressedItemBackgroundBitmap)
135 delete __pPressedItemBackgroundBitmap;
136 __pPressedItemBackgroundBitmap = null;
139 if (__pPressedItemBackgroundEffectBitmap)
141 delete __pPressedItemBackgroundEffectBitmap;
142 __pPressedItemBackgroundEffectBitmap = null;
145 if (__pSelectedItemBackgroundBitmap)
147 delete __pSelectedItemBackgroundBitmap;
148 __pSelectedItemBackgroundBitmap = null;
151 if (__pHighlightedItemBackgroundBitmap)
153 delete __pHighlightedItemBackgroundBitmap;
154 __pHighlightedItemBackgroundBitmap = null;
157 RemoveAllAccessibilityElement();
161 _Tab::CreateTabN(void)
163 result r = E_SUCCESS;
165 _Tab* pTab = new (std::nothrow) _Tab;
166 SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
168 if (IsFailed(GetLastResult()))
173 pTab->AcquireHandle();
175 pTab->__pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector;
176 SysTryCatch(NID_UI_CTRL, pTab->__pGestureLongPress, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
178 pTab->__pGestureLongPress->SetDuration(500);
179 pTab->AddGestureDetector(*(pTab->__pGestureLongPress));
180 r = pTab->__pGestureLongPress->AddGestureListener(*pTab);
181 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
183 pTab->__pFlickGesture = new (std::nothrow) _TouchFlickGestureDetector;
184 SysTryCatch(NID_UI_CTRL, pTab->__pFlickGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
186 r = pTab->AddGestureDetector(*(pTab->__pFlickGesture));
187 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
189 r = pTab->__pFlickGesture->AddGestureListener(*pTab);
190 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
195 if (pTab->__pGestureLongPress != null)
197 pTab->__pGestureLongPress->RemoveGestureListener(*pTab);
198 pTab->RemoveGestureDetector(*pTab->__pGestureLongPress);
200 delete pTab->__pGestureLongPress;
201 pTab->__pGestureLongPress = null;
203 if (pTab->__pFlickGesture != null)
205 pTab->__pFlickGesture->RemoveGestureListener(*pTab);
206 pTab->RemoveGestureDetector(*pTab->__pFlickGesture);
208 delete pTab->__pFlickGesture;
209 pTab->__pFlickGesture = null;
217 _Tab::SetPresenter(const _TabPresenter& tabPresenter)
220 __pTabPresenter = const_cast<_TabPresenter*>(&tabPresenter);
226 _Tab::AddItem(const Bitmap& icon, const String& text, int actionId)
228 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
230 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
231 return E_OUT_OF_RANGE;
234 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
239 __style = _TAB_STYLE_ICON_TEXT;
241 bool isDuplicate = CheckDuplicatedActionId(actionId);
242 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);
244 int itemCount = __tabItems.GetCount();
246 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
248 _TabItem *pItem = new (std::nothrow) _TabItem;
249 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
251 pItem->SetIcon(icon);
252 pItem->SetText(text);
253 pItem->SetActionId(actionId);
254 pItem->SetUpdateState(true);
258 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
262 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
265 __pTabPresenter->SetRecalculateItemBounds(true);
267 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
269 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
271 __currentHighlightedItemIndex = 0;
273 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
275 return __tabItems.Add(*pItem);
279 _Tab::AddItem(const Bitmap& icon, int actionId)
281 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
283 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
284 return E_OUT_OF_RANGE;
287 if (__style != _TAB_STYLE_ICON)
292 bool isDuplicate = CheckDuplicatedActionId(actionId);
293 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);
295 int itemCount = __tabItems.GetCount();
297 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
299 _TabItem *pItem = new (std::nothrow) _TabItem;
300 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
302 pItem->SetIcon(icon);
303 pItem->SetActionId(actionId);
304 pItem->SetUpdateState(true);
308 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
312 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
315 __pTabPresenter->SetRecalculateItemBounds(true);
317 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
319 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
321 __currentHighlightedItemIndex = 0;
323 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
325 return __tabItems.Add(*pItem);
329 _Tab::AddItem(const String& text, int actionId)
331 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
333 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
334 return E_OUT_OF_RANGE;
337 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
342 bool isDuplicate = CheckDuplicatedActionId(actionId);
343 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);
345 int itemCount = __tabItems.GetCount();
347 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
349 _TabItem *pItem = new (std::nothrow) _TabItem;
350 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
352 pItem->SetText(text);
353 pItem->SetActionId(actionId);
354 pItem->SetUpdateState(true);
358 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
362 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
365 __pTabPresenter->SetRecalculateItemBounds(true);
367 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
369 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
371 __currentHighlightedItemIndex = 0;
373 AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
375 return __tabItems.Add(*pItem);
379 _Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int actionId)
381 result r = E_SUCCESS;
382 bool isSelected = false;
384 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
386 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
387 return E_OUT_OF_RANGE;
390 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
395 __style = _TAB_STYLE_ICON_TEXT;
397 bool isDuplicate = CheckDuplicatedActionId(actionId);
398 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);
400 int itemCount = __tabItems.GetCount();
402 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
404 _TabItem *pItem = new (std::nothrow) _TabItem;
405 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
407 pItem->SetIcon(icon);
408 pItem->SetText(text);
409 pItem->SetActionId(actionId);
410 pItem->SetUpdateState(true);
412 int selectedIndex = GetSelectedItemIndex();
414 if (selectedIndex >= index)
416 _TabItem *pSelectedItem = null;
417 pSelectedItem = GetItemAt(selectedIndex);
418 if (pSelectedItem != null)
421 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
426 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
429 __pTabPresenter->SetRecalculateItemBounds(true);
431 r = __tabItems.InsertAt(*pItem, index);
435 SetSelectedItemIndex(selectedIndex);
438 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
440 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
442 __currentHighlightedItemIndex = 0;
444 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
450 _Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
452 result r = E_SUCCESS;
453 bool isSelected = false;
455 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
457 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
458 return E_OUT_OF_RANGE;
461 if (__style != _TAB_STYLE_ICON)
466 bool isDuplicate = CheckDuplicatedActionId(actionId);
467 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);
469 int itemCount = __tabItems.GetCount();
471 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
473 _TabItem *pItem = new (std::nothrow) _TabItem;
474 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
476 pItem->SetIcon(icon);
477 pItem->SetActionId(actionId);
478 pItem->SetUpdateState(true);
479 int selectedIndex = GetSelectedItemIndex();
481 if (selectedIndex >= index)
483 _TabItem *pSelectedItem = null;
484 pSelectedItem = GetItemAt(selectedIndex);
485 if (pSelectedItem != null)
488 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
493 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
496 __pTabPresenter->SetRecalculateItemBounds(true);
498 r = __tabItems.InsertAt(*pItem, index);
502 SetSelectedItemIndex(selectedIndex);
505 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
507 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
509 __currentHighlightedItemIndex = 0;
511 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
517 _Tab::InsertItemAt(int index, const String& text, int actionId)
519 result r = E_SUCCESS;
520 bool isSelected = false;
522 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
524 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
525 return E_OUT_OF_RANGE;
528 bool isDuplicate = CheckDuplicatedActionId(actionId);
529 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);
531 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
536 int itemCount = __tabItems.GetCount();
538 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
540 _TabItem *pItem = new (std::nothrow) _TabItem;
541 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
543 pItem->SetText(text);
544 pItem->SetActionId(actionId);
545 pItem->SetUpdateState(true);
546 int selectedIndex = GetSelectedItemIndex();
548 if (selectedIndex >= index)
550 _TabItem *pSelectedItem = null;
551 pSelectedItem = GetItemAt(selectedIndex);
552 if (pSelectedItem != null)
555 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
560 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
563 __pTabPresenter->SetRecalculateItemBounds(true);
565 r = __tabItems.InsertAt(*pItem, index);
569 SetSelectedItemIndex(selectedIndex);
572 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
574 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
576 __currentHighlightedItemIndex = 0;
578 InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
584 _Tab::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId)
586 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
588 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
589 return E_OUT_OF_RANGE;
592 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
597 __style = _TAB_STYLE_ICON_TEXT;
599 int itemCount = __tabItems.GetCount();
601 if ((index < 0) || (index >= itemCount))
603 return E_OUT_OF_RANGE;
606 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
608 if (GetItemIndex(actionId) != index)
613 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
614 result r = GetLastResult();
615 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
617 pItem->SetIcon(icon);
618 pItem->SetText(text);
619 pItem->SetActionId(actionId);
620 pItem->SetUpdateState(true);
622 UpdateAccessibilityLabel(index, text);
628 _Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
630 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
632 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
633 return E_OUT_OF_RANGE;
636 if (__style != _TAB_STYLE_ICON)
641 int itemCount = __tabItems.GetCount();
643 if ((index < 0) || (index >= itemCount))
645 return E_OUT_OF_RANGE;
648 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
650 if (GetItemIndex(actionId) != index)
655 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
656 result r = GetLastResult();
657 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
659 pItem->SetIcon(icon);
660 pItem->SetActionId(actionId);
661 pItem->SetUpdateState(true);
667 _Tab::SetItemAt(int index, const String& text, int actionId)
669 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
671 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
672 return E_OUT_OF_RANGE;
675 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
680 int itemCount = __tabItems.GetCount();
682 if ((index < 0) || (index >= itemCount))
684 return E_OUT_OF_RANGE;
687 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
689 if (GetItemIndex(actionId) != index)
694 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
695 result r = GetLastResult();
696 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
698 pItem->SetText(text);
699 pItem->SetActionId(actionId);
700 pItem->SetUpdateState(true);
702 UpdateAccessibilityLabel(index, text);
708 _Tab::RemoveItemAt(int index)
710 result r = E_SUCCESS;
711 int selectedIndex = GetSelectedItemIndex();
713 if (selectedIndex >= index)
715 _TabItem *pSelectedItem = null;
716 pSelectedItem = GetItemAt(selectedIndex);
717 if (pSelectedItem != null)
719 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
722 __pTabPresenter->SetRecalculateItemBounds(true);
724 r = __tabItems.RemoveAt(index, true);
726 SetSelectedItemIndex(0);
728 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
730 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
732 if (GetItemCount() > 0)
734 __currentHighlightedItemIndex = 0;
738 __currentHighlightedItemIndex = -1;
741 RemoveAccessibilityElementAt(index);
747 _Tab::RemoveAllItems(void)
749 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
751 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
753 __currentHighlightedItemIndex = -1;
755 __pTabPresenter->SetRecalculateItemBounds(true);
756 SetSelectedItemIndex(0);
757 SetFirstDrawnItemIndex(-1);
759 __tabItems.RemoveAll(true);
761 RemoveAllAccessibilityElement();
767 _Tab::ChangeItemAt(const int srcIndex, const int destIndex)
769 _TabItem* pItem = null;
770 pItem = GetItemAt(srcIndex);
772 __tabItems.InsertAt(*pItem, destIndex);
774 if (srcIndex > destIndex)
776 __tabItems.RemoveAt((srcIndex + 1), false);
780 __tabItems.RemoveAt(srcIndex, false);
787 _Tab::GetItemIndex(int actionId)
789 int itemCount = __tabItems.GetCount();
791 _TabItem* pItem = null;
793 for (int i = 0; i < itemCount; i++)
795 pItem = GetItemAt(i);
797 if ((pItem != null) && (actionId == pItem->GetActionId()))
807 _Tab::CheckDuplicatedActionId(int actionId)
809 int itemIndex = GetItemIndex(actionId);
820 _Tab::LoadBitmap(void)
822 result r = E_SUCCESS;
823 Bitmap* pPressedItemBackgroundBitmap = null;
824 Bitmap* pItemBackgroundBitmap = null;
825 Bitmap* pDisabledBackgroundBitmap = null;
826 Bitmap* pSelectedItemBackgroundBitmap = null;
827 Bitmap* pPressedItemBackgroundEffectBitmap = null;
828 Bitmap* pHighlightedItemBackgroundBitmap = null;
829 Color pressedEffectColor;
830 GET_COLOR_CONFIG(TAB::ITEM_BG_EFFECT_PRESSED, pressedEffectColor);
832 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisabledBackgroundBitmap);
833 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate disabled item background bitmap.");
835 if (pDisabledBackgroundBitmap)
837 __pDisabledBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDisabledBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetDisabledItemBackgroundColor());
838 SysTryLog(NID_UI_CTRL, (__pDisabledBackgroundBitmap != null), "Failed to locate disabled item background bitmap.");
840 delete pDisabledBackgroundBitmap;
843 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pItemBackgroundBitmap);
844 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate item background bitmap.");
846 if (pItemBackgroundBitmap)
848 __pBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetItemBackgroundColor());
849 SysTryLog(NID_UI_CTRL, (__pBackgroundBitmap != null), "Failed to locate item background bitmap.");
851 delete pItemBackgroundBitmap;
854 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundBitmap);
855 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap.");
857 if (pPressedItemBackgroundBitmap)
859 __pPressedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetPressedItemBackgroundColor());
860 SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundBitmap != null), "Failed to locate pressed item background bitmap.");
862 delete pPressedItemBackgroundBitmap;
865 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pSelectedItemBackgroundBitmap);
866 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
868 if (pSelectedItemBackgroundBitmap)
870 __pSelectedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSelectedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetSelectedItemBackgroundColor());
871 SysTryLog(NID_UI_CTRL, (__pSelectedItemBackgroundBitmap != null), "Failed to locate selected item background bitmap.");
873 delete pSelectedItemBackgroundBitmap;
876 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundEffectBitmap);
877 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
879 if (pPressedItemBackgroundEffectBitmap)
881 __pPressedItemBackgroundEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedEffectColor);
882 SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundEffectBitmap != null), "Failed to locate selected item background bitmap.");
884 delete pPressedItemBackgroundEffectBitmap;
887 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pHighlightedItemBackgroundBitmap);
888 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap.");
890 if (pHighlightedItemBackgroundBitmap)
892 __pHighlightedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pHighlightedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetHighlightedItemBackgroundColor());
893 SysTryLog(NID_UI_CTRL, (__pHighlightedItemBackgroundBitmap != null), "Failed to locate highlighted item background bitmap.");
895 delete pHighlightedItemBackgroundBitmap;
901 _Tab::SetBadgeIcon(int actionId, const Bitmap* pBadgeIcon)
903 result r = E_SUCCESS;
905 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
907 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
908 return E_OUT_OF_RANGE;
911 int itemIndex = GetItemIndexFromActionId(actionId);
913 _TabItem *pItem = null;
917 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument(s) is used. The specified actionId is not found.");
918 return E_INVALID_ARG;
921 pItem = dynamic_cast<_TabItem*>(__tabItems.GetAt(itemIndex));
925 pItem->SetBadgeIcon(*pBadgeIcon);
927 r = __tabItems.SetAt(*pItem, itemIndex, false);
934 _Tab::GetItemCount(void) const
936 return __tabItems.GetCount();
940 _Tab::GetItemIndexFromActionId(int actionId) const
942 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
944 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
949 int itemCount = __tabItems.GetCount();
951 for (index = 0; index < itemCount; index++)
953 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
957 if (pItem->GetActionId() == actionId)
968 _Tab::GetItemActionIdAt(int index) const
970 if (__tabItems.GetAt(index) == null )
975 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
976 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);
978 return pItem->GetActionId();
982 _Tab::GetItemAt(int index)
984 if (__tabItems.GetAt(index) == null )
989 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
990 result r = GetLastResult();
991 SysTryReturn(NID_UI_CTRL, pItem != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
997 _Tab::SetSelectedItemIndex(int index)
999 __pTabPresenter->SetSelectedItemIndex(index);
1004 _Tab::GetSelectedItemIndex(void) const
1006 return __pTabPresenter->GetSelectedItemIndex();
1010 _Tab::SetFirstDrawnItemIndex(int index)
1012 __pTabPresenter->SetFirstDrawnItemIndex(index);
1017 _Tab::GetFirstDrawnItemIndex(void) const
1019 return __pTabPresenter->GetFirstDrawnItemIndex();
1023 _Tab::SetEditModeEnabled(bool isEnabled)
1025 return __pTabPresenter->SetEditModeEnabled(isEnabled);
1029 _Tab::IsEditModeEnabled(void) const
1031 return __pTabPresenter->IsEditModeEnabled();
1035 _Tab::IsInFocusMode(void) const
1037 return __isInFocusMode;
1041 _Tab::SetBackgroundBitmap(const Bitmap& bitmap)
1045 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1047 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1049 if (__pBackgroundBitmap)
1051 delete __pBackgroundBitmap;
1052 __pBackgroundBitmap = null;
1055 __pBackgroundBitmap = pBitmap;
1057 if (__pDisabledBackgroundBitmap)
1059 delete __pDisabledBackgroundBitmap;
1060 __pDisabledBackgroundBitmap = null;
1067 _Tab::GetBackgroundBitmap(void) const
1069 return __pBackgroundBitmap;
1073 _Tab::GetDisabledBackgroundBitmap(void) const
1075 return __pDisabledBackgroundBitmap;
1079 _Tab::GetPressedItemBackgroundBitmap(void) const
1081 return __pPressedItemBackgroundBitmap;
1085 _Tab::GetPressedItemBackgroundEffectBitmap(void) const
1087 return __pPressedItemBackgroundEffectBitmap;
1091 _Tab::SetSelectedItemBackgroundBitmap(const Bitmap& bitmap)
1095 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1097 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1099 if (__pSelectedItemBackgroundBitmap)
1101 delete __pSelectedItemBackgroundBitmap;
1102 __pSelectedItemBackgroundBitmap = null;
1104 __pSelectedItemBackgroundBitmap = pBitmap;
1105 __pTabPresenter->FreeHorizontalLineBitmap();
1112 _Tab::GetSelectedItemBackgroundBitmap(void) const
1114 return __pSelectedItemBackgroundBitmap;
1118 _Tab::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap)
1122 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
1124 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1126 if (__pHighlightedItemBackgroundBitmap)
1128 delete __pHighlightedItemBackgroundBitmap;
1129 __pHighlightedItemBackgroundBitmap = null;
1132 __pHighlightedItemBackgroundBitmap = pBitmap;
1138 _Tab::GetHighlightedItemBackgroundBitmap(void) const
1140 return __pHighlightedItemBackgroundBitmap;
1144 _Tab::SetItemBackgroundColor(Color color)
1146 __itemBgColor[_TAB_STATUS_NORMAL] = color;
1151 _Tab::GetItemBackgroundColor(void) const
1153 return __itemBgColor[_TAB_STATUS_NORMAL];
1157 _Tab::GetPressedItemBackgroundColor(void) const
1159 return __itemBgColor[_TAB_STATUS_PRESSED];
1163 _Tab::SetSelectedItemBackgroundColor(Color color)
1165 __itemBgColor[_TAB_STATUS_SELECTED] = color;
1170 _Tab::GetSelectedItemBackgroundColor(void) const
1172 return __itemBgColor[_TAB_STATUS_SELECTED];
1176 _Tab::SetHighlightedItemBackgroundColor(Color color)
1178 __itemBgColor[_TAB_STATUS_HIGHLIGHTED] = color;
1183 _Tab::GetHighlightedItemBackgroundColor(void) const
1185 return __itemBgColor[_TAB_STATUS_HIGHLIGHTED];
1189 _Tab::GetDisabledItemBackgroundColor(void) const
1191 return __itemBgColor[_TAB_STATUS_DISABLED];
1195 _Tab::SetTextColor(const Color& textColor)
1197 __itemTextColor[_TAB_STATUS_NORMAL] = textColor;
1202 _Tab::GetTextColor(void) const
1204 return __itemTextColor[_TAB_STATUS_NORMAL];
1208 _Tab::GetDisabledTextColor(void) const
1210 return __itemTextColor[_TAB_STATUS_DISABLED];
1214 _Tab::SetPressedTextColor(const Color& textColor)
1216 __itemTextColor[_TAB_STATUS_PRESSED] = textColor;
1221 _Tab::GetPressedTextColor(void) const
1223 return __itemTextColor[_TAB_STATUS_PRESSED];
1227 _Tab::SetSelectedTextColor(const Color& textColor)
1229 __itemTextColor[_TAB_STATUS_SELECTED] = textColor;
1234 _Tab::GetSelectedTextColor(void) const
1236 return __itemTextColor[_TAB_STATUS_SELECTED];
1240 _Tab::SetHighlightedTextColor(const Color& color)
1242 __itemTextColor[_TAB_STATUS_HIGHLIGHTED] = color;
1247 _Tab::GetHighlightedTextColor(void) const
1249 return __itemTextColor[_TAB_STATUS_HIGHLIGHTED];
1253 _Tab::SetStyle(int style)
1260 _Tab::GetStyle(void) const
1262 return _TabStyle(__style);
1266 _Tab::GetCurrentHighlightedItemIndex(void) const
1268 return __currentHighlightedItemIndex;
1272 _Tab::AddActionEventListener(const _IActionEventListener& listener)
1276 if (__pActionEvent == null)
1278 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1280 if (__pActionEvent == null || IsFailed(GetLastResult()))
1282 SetLastResult(E_SYSTEM);
1283 delete __pActionEvent;
1287 __pActionEvent->AddListener(listener);
1292 _Tab::RemoveActionEventListener(const _IActionEventListener& listener)
1296 __pActionEvent->RemoveListener(listener);
1301 _Tab::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1303 if (this != &source)
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();
1430 if (itemCount == 0 || __isInFocusMode == false)
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::OnDrawFocus(void)
1499 if (__pTabPresenter->GetItemCount() > 0)
1501 __currentHighlightedItemIndex = 0;
1505 __currentHighlightedItemIndex = -1;
1507 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
1509 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
1511 __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_LEFT);
1512 __isInFocusMode = true;
1517 _Tab::OnFocusModeStateChanged(void)
1519 if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
1521 __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
1523 __currentHighlightedItemIndex = -1;
1524 __isInFocusMode = false;
1529 _Tab::AddAccessibilityElement(const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
1531 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1532 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1534 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1535 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1537 pAccessibilityElement->SetTrait(L"Tab");
1538 pAccessibilityElement->SetHint(L"Double tap to move to contents");
1540 if (GetStyle() != _TAB_STYLE_ICON)
1542 pAccessibilityElement->SetLabel(itemText);
1545 if (status == _TABITEM_STATUS_SELECTED)
1547 pAccessibilityElement->SetStatus("Selected");
1548 pAccessibilityElement->SetHintDisabled(true);
1552 pAccessibilityElement->SetStatus("");
1553 pAccessibilityElement->SetHintDisabled(false);
1556 pContainer->AddElement(*pAccessibilityElement);
1557 __accessibilityElements.Add(pAccessibilityElement);
1563 _Tab::InsertAccessibilityElementAt(int index, const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
1565 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1566 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1568 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1569 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1571 pAccessibilityElement->SetTrait(L"Tab");
1572 pAccessibilityElement->SetHint(L"Double tap to move to contents");
1574 if (GetStyle() != _TAB_STYLE_ICON)
1576 pAccessibilityElement->SetLabel(itemText);
1579 if (status == _TABITEM_STATUS_SELECTED)
1581 pAccessibilityElement->SetStatus("Selected");
1582 pAccessibilityElement->SetHintDisabled(true);
1586 pAccessibilityElement->SetStatus("");
1587 pAccessibilityElement->SetHintDisabled(false);
1590 pContainer->InsertElement(*pAccessibilityElement, index);
1591 __accessibilityElements.InsertAt(pAccessibilityElement, index);
1597 _Tab::RemoveAccessibilityElementAt(int index)
1599 _AccessibilityElement* pAccessibilityElement = null;
1600 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1601 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1603 if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
1605 __accessibilityElements.RemoveAt(index);
1606 pContainer->RemoveElement(*pAccessibilityElement);
1613 _Tab::RemoveAllAccessibilityElement(void)
1615 _AccessibilityElement* pAccessibilityElement = null;
1616 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1617 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1619 while (__accessibilityElements.GetCount() > 0)
1621 if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS)
1623 __accessibilityElements.RemoveAt(0);
1624 pContainer->RemoveElement(*pAccessibilityElement);
1632 _Tab::UpdateAccessibilityElement(void)
1634 _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
1635 _TabItem* pItem = null;
1636 _AccessibilityElement* pAccessibilityElement = null;
1637 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1638 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1640 int count = __accessibilityElements.GetCount();
1642 FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
1644 for (int i = 0; i < count; i++)
1646 if ((__accessibilityElements.GetAt(i, pAccessibilityElement)) == E_SUCCESS)
1648 pItem = GetItemAt(i);
1651 bounds = pItem->GetItemBounds();
1652 itemStatus = pItem->GetStatus();
1655 if (pAccessibilityElement)
1657 pAccessibilityElement->SetBounds(bounds);
1659 if (itemStatus == _TABITEM_STATUS_SELECTED)
1661 pAccessibilityElement->SetStatus("Selected");
1662 pAccessibilityElement->SetHintDisabled(true);
1666 pAccessibilityElement->SetStatus("");
1667 pAccessibilityElement->SetHintDisabled(false);
1677 _Tab::UpdateAccessibilityLabel(int index, const String& text)
1679 _AccessibilityElement* pAccessibilityElement = null;
1680 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1681 SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1683 if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
1685 if (pAccessibilityElement)
1687 pAccessibilityElement->SetLabel(text);
1695 _Tab::OnChangeLayout(_ControlOrientation orientation)
1697 __pTabPresenter->OnChangeLayout(orientation);
1703 _Tab::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1709 _Tab::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1715 _Tab::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1720 _Tab::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1726 _Tab::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1728 FloatRectangle bounds = element.GetBounds();
1732 if (bounds.x == -bounds.width)
1734 __pTabPresenter->MovePrevious();
1738 __pTabPresenter->MoveToFirst();
1741 else if (bounds.x + bounds.width > GetBounds().width)
1743 if (bounds.x == GetBounds().width)
1745 __pTabPresenter->MoveNext();
1749 __pTabPresenter->MoveToLast(bounds.x);
1757 _Tab::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1763 _Tab::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1769 _Tab::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1775 _Tab::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1780 }}} // Tizen::Ui::Controls