2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FUiCtrl_Tab.cpp
19 * @brief This is the implementation file for the _Tab class.
22 #include <FBaseErrorDefine.h>
23 #include <FBaseSysLog.h>
24 #include <FGrp_BitmapImpl.h>
25 #include "FUi_ResourceManager.h"
26 #include "FUi_UiTouchEvent.h"
27 #include "FUi_AccessibilityContainer.h"
28 #include "FUi_AccessibilityElement.h"
29 #include "FUi_TouchLongPressGestureDetector.h"
30 #include "FUiCtrl_Tab.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Base::Runtime;
36 namespace Tizen { namespace Ui { namespace Controls {
39 : __pTabPresenter(null)
40 , __style(_TAB_STYLE_TEXT)
41 , __tabStatus(_TAB_STATUS_NORMAL)
42 , __pActionEvent(null)
43 , __pGestureLongPress(null)
44 , __pFlickGesture(null)
45 , __pBackgroundBitmap(null)
46 , __pPressedItemBackgroundBitmap(null)
47 , __pSelectedItemBackgroundBitmap(null)
48 , __pHighlightedItemBackgroundBitmap(null)
53 __tabItems.Construct();
55 GET_COLOR_CONFIG(TAB::ITEM_BG_NORMAL, __itemBgColor[_TAB_STATUS_NORMAL]);
56 GET_COLOR_CONFIG(TAB::ITEM_BG_PRESSED, __itemBgColor[_TAB_STATUS_PRESSED]);
57 GET_COLOR_CONFIG(TAB::ITEM_BG_SELECTED, __itemBgColor[_TAB_STATUS_SELECTED]);
58 GET_COLOR_CONFIG(TAB::ITEM_BG_HIGHLIGHTED, __itemBgColor[_TAB_STATUS_HIGHLIGHTED]);
59 GET_COLOR_CONFIG(TAB::ITEM_BG_DISABLED, __itemBgColor[_TAB_STATUS_DISABLED]);
61 GET_COLOR_CONFIG(TAB::ITEM_TEXT_NORMAL, __itemTextColor[_TAB_STATUS_NORMAL]);
62 GET_COLOR_CONFIG(TAB::ITEM_TEXT_PRESSED, __itemTextColor[_TAB_STATUS_PRESSED]);
63 GET_COLOR_CONFIG(TAB::ITEM_TEXT_SELECTED, __itemTextColor[_TAB_STATUS_SELECTED]);
64 GET_COLOR_CONFIG(TAB::ITEM_TEXT_HIGHLIGHTED, __itemTextColor[_TAB_STATUS_HIGHLIGHTED]);
65 GET_COLOR_CONFIG(TAB::ITEM_TEXT_DISABLED, __itemTextColor[_TAB_STATUS_DISABLED]);
68 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to load bitmap.");
70 _Control::SetResizable(false);
71 _Control::SetMovable(false);
73 _TabPresenter* pPresenter = new (std::nothrow) _TabPresenter;
74 SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
76 r = SetPresenter(*pPresenter);
77 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance could not be set.");
79 r = pPresenter->Construct(*this);
80 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _TabPresenter instance construct failed.");
86 delete __pTabPresenter;
87 __pTabPresenter = null;
91 delete __pActionEvent;
92 __pActionEvent = null;
95 __tabItems.RemoveAll(true);
97 if (__pFlickGesture != null)
99 __pFlickGesture->RemoveGestureListener(*this);
100 RemoveGestureDetector(*__pFlickGesture);
102 delete __pFlickGesture;
103 __pFlickGesture = null;
106 if (__pGestureLongPress != null)
108 __pGestureLongPress->RemoveGestureListener(*this);
109 RemoveGestureDetector(*__pGestureLongPress);
111 delete __pGestureLongPress;
112 __pGestureLongPress = null;
115 if (__pBackgroundBitmap)
117 delete __pBackgroundBitmap;
118 __pBackgroundBitmap = null;
121 if (__pPressedItemBackgroundBitmap)
123 delete __pPressedItemBackgroundBitmap;
124 __pPressedItemBackgroundBitmap = null;
127 if (__pSelectedItemBackgroundBitmap)
129 delete __pSelectedItemBackgroundBitmap;
130 __pSelectedItemBackgroundBitmap = null;
133 if (__pHighlightedItemBackgroundBitmap)
135 delete __pHighlightedItemBackgroundBitmap;
136 __pHighlightedItemBackgroundBitmap = null;
139 RemoveAllAccessibilityElement();
143 _Tab::CreateTabN(void)
145 result r = E_SUCCESS;
147 _Tab* pTab = new (std::nothrow) _Tab;
148 SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
150 if (IsFailed(GetLastResult()))
155 pTab->AcquireHandle();
157 pTab->__pGestureLongPress = new (std::nothrow) _TouchLongPressGestureDetector;
158 SysTryCatch(NID_UI_CTRL, pTab->__pGestureLongPress, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
160 pTab->__pGestureLongPress->SetDuration(300);
161 pTab->AddGestureDetector(*(pTab->__pGestureLongPress));
162 r = pTab->__pGestureLongPress->AddGestureListener(*pTab);
163 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
165 pTab->__pFlickGesture = new (std::nothrow) _TouchFlickGestureDetector;
166 SysTryCatch(NID_UI_CTRL, pTab->__pFlickGesture, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
168 r = pTab->AddGestureDetector(*(pTab->__pFlickGesture));
169 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
171 r = pTab->__pFlickGesture->AddGestureListener(*pTab);
172 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r = E_SYSTEM, "[E_SYSTEM] A system error has occurred. The _ITouchGestureEventListener instance could not be set.");
177 if (pTab->__pGestureLongPress != null)
179 pTab->__pGestureLongPress->RemoveGestureListener(*pTab);
180 pTab->RemoveGestureDetector(*pTab->__pGestureLongPress);
182 delete pTab->__pGestureLongPress;
183 pTab->__pGestureLongPress = null;
185 if (pTab->__pFlickGesture != null)
187 pTab->__pFlickGesture->RemoveGestureListener(*pTab);
188 pTab->RemoveGestureDetector(*pTab->__pFlickGesture);
190 delete pTab->__pFlickGesture;
191 pTab->__pFlickGesture = null;
199 _Tab::SetPresenter(const _TabPresenter& tabPresenter)
202 __pTabPresenter = const_cast<_TabPresenter*>(&tabPresenter);
208 _Tab::AddItem(const Bitmap& icon, const String& text, int actionId)
210 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
212 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
213 return E_OUT_OF_RANGE;
216 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
221 __style = _TAB_STYLE_ICON_TEXT;
223 bool isDuplicate = CheckDuplicatedActionId(actionId);
224 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);
226 int itemCount = __tabItems.GetCount();
228 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
230 _TabItem *pItem = new (std::nothrow) _TabItem;
231 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
233 pItem->SetIcon(icon);
234 pItem->SetText(text);
235 pItem->SetActionId(actionId);
236 pItem->SetUpdateState(true);
240 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
244 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
247 __pTabPresenter->SetReCalculateItemBounds(true);
249 return __tabItems.Add(*pItem);
253 _Tab::AddItem(const Bitmap& icon, int actionId)
255 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
257 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
258 return E_OUT_OF_RANGE;
261 if (__style != _TAB_STYLE_ICON)
266 bool isDuplicate = CheckDuplicatedActionId(actionId);
267 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);
269 int itemCount = __tabItems.GetCount();
271 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
273 _TabItem *pItem = new (std::nothrow) _TabItem;
274 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
276 pItem->SetIcon(icon);
277 pItem->SetActionId(actionId);
278 pItem->SetUpdateState(true);
282 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
286 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
289 __pTabPresenter->SetReCalculateItemBounds(true);
291 return __tabItems.Add(*pItem);
295 _Tab::AddItem(const String& text, int actionId)
297 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
299 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
300 return E_OUT_OF_RANGE;
303 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
308 bool isDuplicate = CheckDuplicatedActionId(actionId);
309 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);
311 int itemCount = __tabItems.GetCount();
313 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
315 _TabItem *pItem = new (std::nothrow) _TabItem;
316 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
318 pItem->SetText(text);
319 pItem->SetActionId(actionId);
320 pItem->SetUpdateState(true);
324 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
328 pItem->SetStatus(_TABITEM_STATUS_SELECTED);
331 __pTabPresenter->SetReCalculateItemBounds(true);
334 return __tabItems.Add(*pItem);
338 _Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int actionId)
340 result r = E_SUCCESS;
341 bool selected = false;
343 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
345 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
346 return E_OUT_OF_RANGE;
349 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
354 __style = _TAB_STYLE_ICON_TEXT;
356 bool isDuplicate = CheckDuplicatedActionId(actionId);
357 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);
359 int itemCount = __tabItems.GetCount();
361 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
363 _TabItem *pItem = new (std::nothrow) _TabItem;
364 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
366 pItem->SetIcon(icon);
367 pItem->SetText(text);
368 pItem->SetActionId(actionId);
369 pItem->SetUpdateState(true);
371 int i = GetSelectedItemIndex();
375 _TabItem *pSelectedItem = null;
376 pSelectedItem = GetItemAt(i);
377 if (pSelectedItem != null)
380 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
385 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
388 __pTabPresenter->SetReCalculateItemBounds(true);
390 r = __tabItems.InsertAt(*pItem, index);
394 SetSelectedItemIndex(i);
401 _Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
403 result r = E_SUCCESS;
404 bool selected = false;
406 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
408 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
409 return E_OUT_OF_RANGE;
412 if (__style != _TAB_STYLE_ICON)
417 bool isDuplicate = CheckDuplicatedActionId(actionId);
418 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);
420 int itemCount = __tabItems.GetCount();
422 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
424 _TabItem *pItem = new (std::nothrow) _TabItem;
425 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
427 pItem->SetIcon(icon);
428 pItem->SetActionId(actionId);
429 pItem->SetUpdateState(true);
430 int i = GetSelectedItemIndex();
434 _TabItem *pSelectedItem = null;
435 pSelectedItem = GetItemAt(i);
436 if (pSelectedItem != null)
439 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
444 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
447 __pTabPresenter->SetReCalculateItemBounds(true);
449 r = __tabItems.InsertAt(*pItem, index);
453 SetSelectedItemIndex(i);
460 _Tab::InsertItemAt(int index, const String& text, int actionId)
462 result r = E_SUCCESS;
463 bool selected = false;
465 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
467 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
468 return E_OUT_OF_RANGE;
471 bool isDuplicate = CheckDuplicatedActionId(actionId);
472 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);
474 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
479 int itemCount = __tabItems.GetCount();
481 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
483 _TabItem *pItem = new (std::nothrow) _TabItem;
484 SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
486 pItem->SetText(text);
487 pItem->SetActionId(actionId);
488 pItem->SetUpdateState(true);
489 int i = GetSelectedItemIndex();
493 _TabItem *pSelectedItem = null;
494 pSelectedItem = GetItemAt(i);
495 if (pSelectedItem != null)
498 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
503 pItem->SetStatus(_TABITEM_STATUS_NORMAL);
506 __pTabPresenter->SetReCalculateItemBounds(true);
508 r = __tabItems.InsertAt(*pItem, index);
512 SetSelectedItemIndex(i);
519 _Tab::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId)
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 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
532 __style = _TAB_STYLE_ICON_TEXT;
534 int itemCount = __tabItems.GetCount();
536 if ((index < 0) || (index >= itemCount))
538 return E_OUT_OF_RANGE;
541 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
543 if (GetItemIndex(actionId) != index)
548 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
549 result r = GetLastResult();
550 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
552 pItem->SetIcon(icon);
553 pItem->SetText(text);
554 pItem->SetActionId(actionId);
555 pItem->SetUpdateState(true);
561 _Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
563 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
565 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
566 return E_OUT_OF_RANGE;
569 if (__style != _TAB_STYLE_ICON)
574 int itemCount = __tabItems.GetCount();
576 if ((index < 0) || (index >= itemCount))
578 return E_OUT_OF_RANGE;
581 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
583 if (GetItemIndex(actionId) != index)
588 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
589 result r = GetLastResult();
590 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
592 pItem->SetIcon(icon);
593 pItem->SetActionId(actionId);
594 pItem->SetUpdateState(true);
600 _Tab::SetItemAt(int index, const String& text, int actionId)
602 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
604 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
605 return E_OUT_OF_RANGE;
608 if (!((__style == _TAB_STYLE_TEXT) || (__style == _TAB_STYLE_ICON_TEXT)))
613 int itemCount = __tabItems.GetCount();
615 if ((index < 0) || (index >= itemCount))
617 return E_OUT_OF_RANGE;
620 SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
622 if (GetItemIndex(actionId) != index)
627 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
628 result r = GetLastResult();
629 SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
631 pItem->SetText(text);
632 pItem->SetActionId(actionId);
633 pItem->SetUpdateState(true);
639 _Tab::RemoveItemAt(int index)
641 result r = E_SUCCESS;
642 int i = GetSelectedItemIndex();
646 _TabItem *pSelectedItem = null;
647 pSelectedItem = GetItemAt(i);
648 if (pSelectedItem != null)
650 pSelectedItem->SetStatus(_TABITEM_STATUS_NORMAL);
653 __pTabPresenter->SetReCalculateItemBounds(true);
655 r = __tabItems.RemoveAt(index, true);
657 SetSelectedItemIndex(0);
663 _Tab::RemoveAllItems(void)
665 __pTabPresenter->SetReCalculateItemBounds(true);
666 SetSelectedItemIndex(0);
667 SetFirstDrawnItemIndex(-1);
669 __tabItems.RemoveAll(true);
675 _Tab::ChangeItemAt(const int srcIndex, const int destIndex)
677 _TabItem* pItem = null;
678 pItem = GetItemAt(srcIndex);
680 __tabItems.InsertAt(*pItem, destIndex);
682 if (srcIndex > destIndex)
684 __tabItems.RemoveAt((srcIndex + 1), false);
688 __tabItems.RemoveAt(srcIndex, false);
695 _Tab::GetItemIndex(int actionId)
697 int itemCount = __tabItems.GetCount();
699 _TabItem* pItem = null;
701 for (int i = 0; i < itemCount; i++)
703 pItem = GetItemAt(i);
705 if ((pItem != null) && (actionId == pItem->GetActionId()))
715 _Tab::CheckDuplicatedActionId(int actionId)
717 int itemIndex = GetItemIndex(actionId);
728 _Tab::LoadBitmap(void)
730 result r = E_SUCCESS;
732 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pPressedItemBackgroundBitmap);
733 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap.");
735 if (__pPressedItemBackgroundBitmap)
737 __pPressedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(__pPressedItemBackgroundBitmap), Color::GetColor(COLOR_ID_MAGENTA), GetPressedItemBackgroundColor());
738 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap.");
741 r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHighlightedItemBackgroundBitmap);
742 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap.");
744 if (__pHighlightedItemBackgroundBitmap)
746 __pHighlightedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(__pHighlightedItemBackgroundBitmap), Color::GetColor(COLOR_ID_MAGENTA), GetHighlightedItemBackgroundColor());
747 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap.");
753 _Tab::SetBadgeIcon(int actionId, const Bitmap* pBadgeIcon)
755 result r = E_SUCCESS;
757 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
759 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
760 return E_OUT_OF_RANGE;
763 int itemIndex = GetItemIndexFromActionId(actionId);
765 _TabItem *pItem = null;
769 SysLog(NID_UI_CTRL, "[E_INVALID_ARG] Invalid argument(s) is used. The specified actionId is not found.");
770 return E_INVALID_ARG;
773 pItem = dynamic_cast<_TabItem*>(__tabItems.GetAt(itemIndex));
777 pItem->SetBadgeIcon(*pBadgeIcon);
779 r = __tabItems.SetAt(*pItem, itemIndex, false);
786 _Tab::GetItemCount(void) const
788 return __tabItems.GetCount();
792 _Tab::GetItemIndexFromActionId(int actionId) const
794 if (actionId < _TAB_ACTION_ID_MIN || actionId > _TAB_ACTION_ID_MAX)
796 SysLog(NID_UI_CTRL, "[E_OUT_OF_RANGE] The actionId (%d) is out of range.", actionId);
801 int itemCount = __tabItems.GetCount();
803 for (index = 0; index < itemCount; index++)
805 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
809 if (pItem->GetActionId() == actionId)
820 _Tab::GetItemActionIdAt(int index) const
822 if (__tabItems.GetAt(index) == null )
827 const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
828 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);
830 return pItem->GetActionId();
834 _Tab::GetItemAt(int index)
836 if (__tabItems.GetAt(index) == null )
841 _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
842 result r = GetLastResult();
843 SysTryReturn(NID_UI_CTRL, pItem != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
849 _Tab::SetSelectedItemIndex(int index)
851 __pTabPresenter->SetSelectedItemIndex(index);
856 _Tab::GetSelectedItemIndex(void) const
858 return __pTabPresenter->GetSelectedItemIndex();
862 _Tab::SetFirstDrawnItemIndex(int index)
864 __pTabPresenter->SetFirstDrawnItemIndex(index);
869 _Tab::GetFirstDrawnItemIndex(void) const
871 return __pTabPresenter->GetFirstDrawnItemIndex();
875 _Tab::SetEditModeEnabled(bool enable)
877 return __pTabPresenter->SetEditModeEnabled(enable);
881 _Tab::IsEditModeEnabled(void) const
883 return __pTabPresenter->IsEditModeEnabled();
887 _Tab::SetBackgroundBitmap(const Bitmap& bitmap)
891 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
893 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
895 if (__pBackgroundBitmap)
897 delete __pBackgroundBitmap;
898 __pBackgroundBitmap = null;
901 __pBackgroundBitmap = pBitmap;
907 _Tab::GetBackgroundBitmap(void) const
909 return __pBackgroundBitmap;
914 _Tab::SetPressedItemBackgroundBitmap(const Bitmap& bitmap)
918 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
920 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
922 if (__pPressedItemBackgroundBitmap)
924 delete __pPressedItemBackgroundBitmap;
925 __pPressedItemBackgroundBitmap = null;
928 __pPressedItemBackgroundBitmap = pBitmap;
933 _Tab::GetPressedItemBackgroundBitmap(void) const
935 return __pPressedItemBackgroundBitmap;
939 _Tab::SetSelectedItemBackgroundBitmap(const Bitmap& bitmap)
943 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
945 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
947 if (__pSelectedItemBackgroundBitmap)
949 delete __pSelectedItemBackgroundBitmap;
950 __pSelectedItemBackgroundBitmap = null;
952 __pSelectedItemBackgroundBitmap = pBitmap;
953 __pTabPresenter->FreeHorizontalLineBitmap();
960 _Tab::GetSelectedItemBackgroundBitmap(void) const
962 return __pSelectedItemBackgroundBitmap;
966 _Tab::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap)
970 Tizen::Graphics::Bitmap* pBitmap = _BitmapImpl::CloneN(bitmap);
972 SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
974 if (__pHighlightedItemBackgroundBitmap)
976 delete __pHighlightedItemBackgroundBitmap;
977 __pHighlightedItemBackgroundBitmap = null;
980 __pHighlightedItemBackgroundBitmap = pBitmap;
986 _Tab::GetHighlightedItemBackgroundBitmap(void) const
988 return __pHighlightedItemBackgroundBitmap;
992 _Tab::SetItemBackgroundColor(Color color)
994 __itemBgColor[_TAB_STATUS_NORMAL] = color;
999 _Tab::GetItemBackgroundColor(void) const
1001 return __itemBgColor[_TAB_STATUS_NORMAL];
1005 _Tab::SetPressedItemBackgroundColor(Color color)
1007 __itemBgColor[_TAB_STATUS_PRESSED] = color;
1012 _Tab::GetPressedItemBackgroundColor(void) const
1014 return __itemBgColor[_TAB_STATUS_PRESSED];
1018 _Tab::SetSelectedItemBackgroundColor(Color color)
1020 __itemBgColor[_TAB_STATUS_SELECTED] = color;
1025 _Tab::GetSelectedItemBackgroundColor(void) const
1027 return __itemBgColor[_TAB_STATUS_SELECTED];
1031 _Tab::SetHighlightedItemBackgroundColor(Color color)
1033 __itemBgColor[_TAB_STATUS_HIGHLIGHTED] = color;
1038 _Tab::GetHighlightedItemBackgroundColor(void) const
1040 return __itemBgColor[_TAB_STATUS_HIGHLIGHTED];
1044 _Tab::SetTextColor(const Color& textColor)
1046 __itemTextColor[_TAB_STATUS_NORMAL] = textColor;
1051 _Tab::GetTextColor(void) const
1053 return __itemTextColor[_TAB_STATUS_NORMAL];
1057 _Tab::SetPressedTextColor(const Color& textColor)
1059 __itemTextColor[_TAB_STATUS_PRESSED] = textColor;
1064 _Tab::GetPressedTextColor(void) const
1066 return __itemTextColor[_TAB_STATUS_PRESSED];
1070 _Tab::SetSelectedTextColor(const Color& textColor)
1072 __itemTextColor[_TAB_STATUS_SELECTED] = textColor;
1077 _Tab::GetSelectedTextColor(void) const
1079 return __itemTextColor[_TAB_STATUS_SELECTED];
1083 _Tab::SetHighlightedTextColor(const Color& color)
1085 __itemTextColor[_TAB_STATUS_HIGHLIGHTED] = color;
1090 _Tab::GetHighlightedTextColor(void) const
1092 return __itemTextColor[_TAB_STATUS_HIGHLIGHTED];
1096 _Tab::SetStyle(int style)
1103 _Tab::GetStyle(void) const
1105 return _TabStyle(__style);
1109 _Tab::AddActionEventListener(const _IActionEventListener& listener)
1113 if (__pActionEvent == null)
1115 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
1117 if (__pActionEvent == null || IsFailed(GetLastResult()))
1119 SetLastResult(E_SYSTEM);
1120 delete __pActionEvent;
1124 __pActionEvent->AddListener(listener);
1129 _Tab::RemoveActionEventListener(const _IActionEventListener& listener)
1133 __pActionEvent->RemoveListener(listener);
1138 _Tab::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
1140 if (this != &source)
1145 return __pTabPresenter->OnTouchPressed(source, touchinfo);
1149 _Tab::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
1151 if (this != &source)
1156 __pTabPresenter->OnTouchReleased(source, touchinfo);
1158 int index = __pTabPresenter->GetItemIndexFromPosition(touchinfo.GetCurrentPosition());
1160 _TabItem* pItem = __pTabPresenter->GetItemAt(index);
1169 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(pItem->GetActionId());
1170 SysTryReturn(NID_UI_CTRL, pEventArg, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1172 __pActionEvent->Fire(*pEventArg);
1179 _Tab::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
1181 if (this != &source)
1186 return __pTabPresenter->OnTouchMoved(source, touchinfo);
1190 _Tab::OnLongPressGestureDetected(_TouchLongPressGestureDetector& gesture)
1192 return __pTabPresenter->OnLongPressGestureDetected();
1196 _Tab::OnLongPressGestureCanceled(_TouchLongPressGestureDetector& gesture)
1202 _Tab::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture)
1205 return __pTabPresenter->OnFlickGestureDetected(gesture);
1209 _Tab::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture)
1218 __pTabPresenter->Draw();
1224 _Tab::OnBoundsChanged(void)
1226 __pTabPresenter->OnBoundsChanged();
1230 _Tab::OnAttachedToMainTree(void)
1232 _AccessibilityContainer* pContainer = null;
1234 if (likely((_AccessibilityManager::IsActivated())))
1236 pContainer = GetAccessibilityContainer();
1240 pContainer->Activate(true);
1241 pContainer->AddListener(*this);
1249 _Tab::OnFontChanged(Font* pFont)
1251 __pTabPresenter->OnFontChanged(pFont);
1256 _Tab::OnFontInfoRequested(unsigned long& style, int& size)
1258 __pTabPresenter->OnFontInfoRequested(style, size);
1263 _Tab::AddAccessibilityElement(const Rectangle& itemBounds, const String& itemText, _TabItemStatus status)
1265 if (likely(!(_AccessibilityManager::IsActivated())))
1270 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1272 if (pContainer != null)
1274 _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
1275 SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
1277 pAccessibilityElement->SetTrait(ACCESSIBILITY_TRAITS_TAB);
1278 pAccessibilityElement->SetHint(L"Double tap to move to contents");
1279 pAccessibilityElement->SetBounds(itemBounds);
1281 if (GetStyle() != _TAB_STYLE_ICON)
1283 pAccessibilityElement->SetLabel(itemText);
1286 if (status == _TABITEM_STATUS_SELECTED)
1288 pAccessibilityElement->SetStatus("Selected");
1292 pAccessibilityElement->SetStatus("");
1295 pContainer->AddElement(*pAccessibilityElement);
1296 __accessibilityElements.Add(pAccessibilityElement);
1303 _Tab::RemoveAllAccessibilityElement(void)
1305 if (likely(!(_AccessibilityManager::IsActivated())))
1310 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
1312 if (pContainer == null)
1317 _AccessibilityElement* pAccessibilityElement = null;
1319 while (__accessibilityElements.GetCount() > 0)
1321 if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS)
1323 pContainer->RemoveElement(*pAccessibilityElement);
1324 __accessibilityElements.RemoveAt(0);
1328 __accessibilityElements.RemoveAt(0);
1336 _Tab::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1340 return __pTabPresenter->OnAccessibilityFocusMovedNext(control, element);
1344 _Tab::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1348 return __pTabPresenter->OnAccessibilityFocusMovedPrevious(control, element);
1352 _Tab::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1358 _Tab::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1364 _Tab::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1370 _Tab::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1376 _Tab::OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&)
1382 _Tab::OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&)
1387 }}} // Tizen::Ui::Controls