Fixed Coding Idioms Violations
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_Tab.cpp
index 64fce2d..5997edf 100644 (file)
@@ -39,7 +39,9 @@ namespace Tizen { namespace Ui { namespace Controls {
 
 _Tab::_Tab(void)
        : __pTabPresenter(null)
+       , __isInFocusMode(false)
        , __style(_TAB_STYLE_TEXT)
+       , __currentHighlightedItemIndex(-1)
        , __tabStatus(_TAB_STATUS_NORMAL)
        , __pActionEvent(null)
        , __pGestureLongPress(null)
@@ -90,11 +92,8 @@ _Tab::~_Tab(void)
        delete __pTabPresenter;
        __pTabPresenter = null;
 
-       if (__pActionEvent)
-       {
-               delete __pActionEvent;
-               __pActionEvent = null;
-       }
+       delete __pActionEvent;
+       __pActionEvent = null;
 
        __tabItems.RemoveAll(true);
 
@@ -116,41 +115,23 @@ _Tab::~_Tab(void)
                __pGestureLongPress = null;
        }
 
-       if (__pBackgroundBitmap)
-       {
-               delete __pBackgroundBitmap;
-               __pBackgroundBitmap = null;
-       }
+       delete __pBackgroundBitmap;
+       __pBackgroundBitmap = null;
 
-       if (__pDisabledBackgroundBitmap)
-       {
-               delete __pDisabledBackgroundBitmap;
-               __pDisabledBackgroundBitmap = null;
-       }
+       delete __pDisabledBackgroundBitmap;
+       __pDisabledBackgroundBitmap = null;
 
-       if (__pPressedItemBackgroundBitmap)
-       {
-               delete __pPressedItemBackgroundBitmap;
-               __pPressedItemBackgroundBitmap = null;
-       }
+       delete __pPressedItemBackgroundBitmap;
+       __pPressedItemBackgroundBitmap = null;
 
-       if (__pPressedItemBackgroundEffectBitmap)
-       {
-               delete __pPressedItemBackgroundEffectBitmap;
-               __pPressedItemBackgroundEffectBitmap = null;
-       }
+       delete __pPressedItemBackgroundEffectBitmap;
+       __pPressedItemBackgroundEffectBitmap = null;
 
-       if (__pSelectedItemBackgroundBitmap)
-       {
-               delete __pSelectedItemBackgroundBitmap;
-               __pSelectedItemBackgroundBitmap = null;
-       }
+       delete __pSelectedItemBackgroundBitmap;
+       __pSelectedItemBackgroundBitmap = null;
 
-       if (__pHighlightedItemBackgroundBitmap)
-       {
-               delete __pHighlightedItemBackgroundBitmap;
-               __pHighlightedItemBackgroundBitmap = null;
-       }
+       delete __pHighlightedItemBackgroundBitmap;
+       __pHighlightedItemBackgroundBitmap = null;
 
        RemoveAllAccessibilityElement();
 }
@@ -243,7 +224,7 @@ _Tab::AddItem(const Bitmap& icon, const String& text, int actionId)
 
        SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
 
-       _TabItem *pItem = new (std::nothrow) _TabItem;
+       _TabItempItem = new (std::nothrow) _TabItem;
        SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
        pItem->SetIcon(icon);
@@ -262,6 +243,14 @@ _Tab::AddItem(const Bitmap& icon, const String& text, int actionId)
 
        __pTabPresenter->SetRecalculateItemBounds(true);
 
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       __currentHighlightedItemIndex = 0;
+
+       AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
+
        return __tabItems.Add(*pItem);
 }
 
@@ -286,7 +275,7 @@ _Tab::AddItem(const Bitmap& icon, int actionId)
 
        SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
 
-       _TabItem *pItem = new (std::nothrow) _TabItem;
+       _TabItempItem = new (std::nothrow) _TabItem;
        SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
        pItem->SetIcon(icon);
@@ -304,6 +293,14 @@ _Tab::AddItem(const Bitmap& icon, int actionId)
 
        __pTabPresenter->SetRecalculateItemBounds(true);
 
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       __currentHighlightedItemIndex = 0;
+
+       AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
+
        return __tabItems.Add(*pItem);
 }
 
@@ -328,7 +325,7 @@ _Tab::AddItem(const String& text, int actionId)
 
        SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
 
-       _TabItem *pItem = new (std::nothrow) _TabItem;
+       _TabItempItem = new (std::nothrow) _TabItem;
        SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
        pItem->SetText(text);
@@ -346,6 +343,13 @@ _Tab::AddItem(const String& text, int actionId)
 
        __pTabPresenter->SetRecalculateItemBounds(true);
 
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       __currentHighlightedItemIndex = 0;
+
+       AddAccessibilityElement(pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
 
        return __tabItems.Add(*pItem);
 }
@@ -376,7 +380,7 @@ _Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int action
 
        SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
 
-       _TabItem *pItem = new (std::nothrow) _TabItem;
+       _TabItempItem = new (std::nothrow) _TabItem;
        SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
        pItem->SetIcon(icon);
@@ -388,7 +392,7 @@ _Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int action
 
        if (selectedIndex >= index)
        {
-               _TabItem *pSelectedItem = null;
+               _TabItempSelectedItem = null;
                pSelectedItem = GetItemAt(selectedIndex);
                if (pSelectedItem != null)
                {
@@ -410,6 +414,14 @@ _Tab::InsertItemAt(int index, const Bitmap& icon, const String& text, int action
                SetSelectedItemIndex(selectedIndex);
        }
 
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       __currentHighlightedItemIndex = 0;
+
+       InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
+
        return r;
 }
 
@@ -437,7 +449,7 @@ _Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
 
        SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
 
-       _TabItem *pItem = new (std::nothrow) _TabItem;
+       _TabItempItem = new (std::nothrow) _TabItem;
        SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
        pItem->SetIcon(icon);
@@ -447,7 +459,7 @@ _Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
 
        if (selectedIndex >= index)
        {
-               _TabItem *pSelectedItem = null;
+               _TabItempSelectedItem = null;
                pSelectedItem = GetItemAt(selectedIndex);
                if (pSelectedItem != null)
                {
@@ -469,6 +481,14 @@ _Tab::InsertItemAt(int index, const Bitmap& icon, int actionId)
                SetSelectedItemIndex(selectedIndex);
        }
 
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       __currentHighlightedItemIndex = 0;
+
+       InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
+
        return r;
 }
 
@@ -496,7 +516,7 @@ _Tab::InsertItemAt(int index, const String& text, int actionId)
 
        SysTryReturnResult(NID_UI_CTRL, itemCount < _TAB_ITEM_MAXCOUNT, E_SYSTEM, "A system error has occurred. The tab has maximum number of items.");
 
-       _TabItem *pItem = new (std::nothrow) _TabItem;
+       _TabItempItem = new (std::nothrow) _TabItem;
        SysTryReturnResult(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
 
        pItem->SetText(text);
@@ -506,7 +526,7 @@ _Tab::InsertItemAt(int index, const String& text, int actionId)
 
        if (selectedIndex >= index)
        {
-               _TabItem *pSelectedItem = null;
+               _TabItempSelectedItem = null;
                pSelectedItem = GetItemAt(selectedIndex);
                if (pSelectedItem != null)
                {
@@ -528,6 +548,14 @@ _Tab::InsertItemAt(int index, const String& text, int actionId)
                SetSelectedItemIndex(selectedIndex);
        }
 
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       __currentHighlightedItemIndex = 0;
+
+       InsertAccessibilityElementAt(index, pItem->GetItemBounds(), pItem->GetText(), pItem->GetStatus());
+
        return r;
 }
 
@@ -561,7 +589,7 @@ _Tab::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId)
                return E_SYSTEM;
        }
 
-       _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
+       _TabItempItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
        result r = GetLastResult();
        SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -570,6 +598,8 @@ _Tab::SetItemAt(int index, const Bitmap& icon, const String& text, int actionId)
        pItem->SetActionId(actionId);
        pItem->SetUpdateState(true);
 
+       UpdateAccessibilityLabel(index, text);
+
        return E_SUCCESS;
 }
 
@@ -601,7 +631,7 @@ _Tab::SetItemAt(int index, const Bitmap& icon, int actionId)
                return E_SYSTEM;
        }
 
-       _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
+       _TabItempItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
        result r = GetLastResult();
        SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -640,7 +670,7 @@ _Tab::SetItemAt(int index, const String& text, int actionId)
                return E_SYSTEM;
        }
 
-       _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
+       _TabItempItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
        result r = GetLastResult();
        SysTryReturnResult(NID_UI_CTRL, pItem != null, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -648,6 +678,8 @@ _Tab::SetItemAt(int index, const String& text, int actionId)
        pItem->SetActionId(actionId);
        pItem->SetUpdateState(true);
 
+       UpdateAccessibilityLabel(index, text);
+
        return E_SUCCESS;
 }
 
@@ -659,7 +691,7 @@ _Tab::RemoveItemAt(int index)
 
        if (selectedIndex >= index)
        {
-               _TabItem *pSelectedItem = null;
+               _TabItempSelectedItem = null;
                pSelectedItem = GetItemAt(selectedIndex);
                if (pSelectedItem != null)
                {
@@ -672,18 +704,41 @@ _Tab::RemoveItemAt(int index)
 
        SetSelectedItemIndex(0);
 
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       if (GetItemCount() > 0)
+       {
+               __currentHighlightedItemIndex = 0;
+       }
+       else
+       {
+               __currentHighlightedItemIndex = -1;
+       }
+
+       RemoveAccessibilityElementAt(index);
+
        return r;
 }
 
 result
 _Tab::RemoveAllItems(void)
 {
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       __currentHighlightedItemIndex = -1;
+
        __pTabPresenter->SetRecalculateItemBounds(true);
        SetSelectedItemIndex(0);
        SetFirstDrawnItemIndex(-1);
 
        __tabItems.RemoveAll(true);
 
+       RemoveAllAccessibilityElement();
+
        return E_SUCCESS;
 }
 
@@ -744,80 +799,29 @@ result
 _Tab::LoadBitmap(void)
 {
        result r = E_SUCCESS;
-       Bitmap* pPressedItemBackgroundBitmap = null;
-       Bitmap* pItemBackgroundBitmap = null;
-       Bitmap* pDisabledBackgroundBitmap = null;
-       Bitmap* pSelectedItemBackgroundBitmap = null;
-       Bitmap* pPressedItemBackgroundEffectBitmap = null;
-       Bitmap* pHighlightedItemBackgroundBitmap = null;
        Color pressedEffectColor;
        GET_COLOR_CONFIG(TAB::ITEM_BG_EFFECT_PRESSED, pressedEffectColor);
 
-       r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pDisabledBackgroundBitmap);
+       r = GET_REPLACED_BITMAP_CONFIG_N(TAB::ITEM_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, GetDisabledItemBackgroundColor(), __pDisabledBackgroundBitmap);
        SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate disabled item background bitmap.");
 
-       if (pDisabledBackgroundBitmap)
-       {
-               __pDisabledBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pDisabledBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetDisabledItemBackgroundColor());
-               SysTryLog(NID_UI_CTRL, (__pDisabledBackgroundBitmap != null), "Failed to locate disabled item background bitmap.");
-
-               delete pDisabledBackgroundBitmap;
-       }
 
-       r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pItemBackgroundBitmap);
+       r = GET_REPLACED_BITMAP_CONFIG_N(TAB::ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, GetItemBackgroundColor(), __pBackgroundBitmap);
        SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate item background bitmap.");
 
-       if (pItemBackgroundBitmap)
-       {
-               __pBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetItemBackgroundColor());
-               SysTryLog(NID_UI_CTRL, (__pBackgroundBitmap != null), "Failed to locate item background bitmap.");
 
-               delete pItemBackgroundBitmap;
-       }
-
-       r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundBitmap);
+       r = GET_REPLACED_BITMAP_CONFIG_N(TAB::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, GetPressedItemBackgroundColor(), __pPressedItemBackgroundBitmap);
        SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate pressed item background bitmap.");
 
-       if (pPressedItemBackgroundBitmap)
-       {
-               __pPressedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetPressedItemBackgroundColor());
-               SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundBitmap != null), "Failed to locate pressed item background bitmap.");
-
-               delete pPressedItemBackgroundBitmap;
-       }
-
-       r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, pSelectedItemBackgroundBitmap);
+       r = GET_REPLACED_BITMAP_CONFIG_N(TAB::ITEM_BG_SELECTED, BITMAP_PIXEL_FORMAT_ARGB8888, GetSelectedItemBackgroundColor(), __pSelectedItemBackgroundBitmap);
        SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
 
-       if (pSelectedItemBackgroundBitmap)
-       {
-               __pSelectedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pSelectedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetSelectedItemBackgroundColor());
-               SysTryLog(NID_UI_CTRL, (__pSelectedItemBackgroundBitmap != null), "Failed to locate selected item background bitmap.");
-
-               delete pSelectedItemBackgroundBitmap;
-       }
-
-       r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pPressedItemBackgroundEffectBitmap);
+       r = GET_REPLACED_BITMAP_CONFIG_N(TAB::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pressedEffectColor, __pPressedItemBackgroundEffectBitmap);
        SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate selected item background bitmap.");
 
-       if (pPressedItemBackgroundEffectBitmap)
-       {
-               __pPressedItemBackgroundEffectBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pPressedItemBackgroundEffectBitmap, Color::GetColor(COLOR_ID_MAGENTA), pressedEffectColor);
-               SysTryLog(NID_UI_CTRL, (__pPressedItemBackgroundEffectBitmap != null), "Failed to locate selected item background bitmap.");
-
-               delete pPressedItemBackgroundEffectBitmap;
-       }
-
-       r = GET_BITMAP_CONFIG_N(TAB::ITEM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pHighlightedItemBackgroundBitmap);
+       r = GET_REPLACED_BITMAP_CONFIG_N(TAB::ITEM_BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, GetHighlightedItemBackgroundColor(), __pHighlightedItemBackgroundBitmap);
        SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "Failed to locate highlighted item background bitmap.");
 
-       if (pHighlightedItemBackgroundBitmap)
-       {
-               __pHighlightedItemBackgroundBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pHighlightedItemBackgroundBitmap, Color::GetColor(COLOR_ID_MAGENTA), GetHighlightedItemBackgroundColor());
-               SysTryLog(NID_UI_CTRL, (__pHighlightedItemBackgroundBitmap != null), "Failed to locate highlighted item background bitmap.");
-
-               delete pHighlightedItemBackgroundBitmap;
-       }
        return r;
 }
 
@@ -834,7 +838,7 @@ _Tab::SetBadgeIcon(int actionId, const Bitmap* pBadgeIcon)
 
        int itemIndex = GetItemIndexFromActionId(actionId);
 
-       _TabItem *pItem = null;
+       _TabItempItem = null;
 
        if (itemIndex < 0)
        {
@@ -874,7 +878,7 @@ _Tab::GetItemIndexFromActionId(int actionId) const
 
        for (index = 0; index < itemCount; index++)
        {
-               const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
+               const _TabItempItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
 
                if (pItem != null)
                {
@@ -891,12 +895,12 @@ _Tab::GetItemIndexFromActionId(int actionId) const
 int
 _Tab::GetItemActionIdAt(int index) const
 {
-       if (__tabItems.GetAt(index) == null )
+       if (__tabItems.GetAt(index) == null)
        {
                return -1;
        }
 
-       const _TabItem *pItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
+       const _TabItempItem = dynamic_cast<const _TabItem*>(__tabItems.GetAt(index));
        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);
 
        return pItem->GetActionId();
@@ -905,12 +909,12 @@ _Tab::GetItemActionIdAt(int index) const
 _TabItem*
 _Tab::GetItemAt(int index)
 {
-       if (__tabItems.GetAt(index) == null )
+       if (__tabItems.GetAt(index) == null)
        {
                return null;
        }
 
-       _TabItem *pItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
+       _TabItempItem = static_cast<_TabItem*>(__tabItems.GetAt(index));
        result r = GetLastResult();
        SysTryReturn(NID_UI_CTRL, pItem != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
 
@@ -955,6 +959,12 @@ _Tab::IsEditModeEnabled(void) const
        return __pTabPresenter->IsEditModeEnabled();
 }
 
+bool
+_Tab::IsInFocusMode(void) const
+{
+       return __isInFocusMode;
+}
+
 result
 _Tab::SetBackgroundBitmap(const Bitmap& bitmap)
 {
@@ -964,7 +974,7 @@ _Tab::SetBackgroundBitmap(const Bitmap& bitmap)
 
        SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-       if (__pBackgroundBitmap)
+       if (__pBackgroundBitmap != null)
        {
                delete __pBackgroundBitmap;
                __pBackgroundBitmap = null;
@@ -972,7 +982,7 @@ _Tab::SetBackgroundBitmap(const Bitmap& bitmap)
 
        __pBackgroundBitmap = pBitmap;
 
-       if (__pDisabledBackgroundBitmap)
+       if (__pDisabledBackgroundBitmap != null)
        {
                delete __pDisabledBackgroundBitmap;
                __pDisabledBackgroundBitmap = null;
@@ -1014,7 +1024,7 @@ _Tab::SetSelectedItemBackgroundBitmap(const Bitmap& bitmap)
 
        SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-       if (__pSelectedItemBackgroundBitmap)
+       if (__pSelectedItemBackgroundBitmap != null)
        {
                delete __pSelectedItemBackgroundBitmap;
                __pSelectedItemBackgroundBitmap = null;
@@ -1041,7 +1051,7 @@ _Tab::SetHighlightedItemBackgroundBitmap(const Bitmap& bitmap)
 
        SysTryReturn(NID_UI_CTRL, (pBitmap), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-       if (__pHighlightedItemBackgroundBitmap)
+       if (__pHighlightedItemBackgroundBitmap != null)
        {
                delete __pHighlightedItemBackgroundBitmap;
                __pHighlightedItemBackgroundBitmap = null;
@@ -1180,6 +1190,12 @@ _Tab::GetStyle(void) const
        return _TabStyle(__style);
 }
 
+int
+_Tab::GetCurrentHighlightedItemIndex(void) const
+{
+       return __currentHighlightedItemIndex;
+}
+
 void
 _Tab::AddActionEventListener(const _IActionEventListener& listener)
 {
@@ -1216,7 +1232,6 @@ _Tab::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
        {
                return true;
        }
-
        return __pTabPresenter->OnTouchPressed(source, touchinfo);
 }
 
@@ -1239,7 +1254,7 @@ _Tab::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
                return true;
        }
 
-       if (__pActionEvent)
+       if (__pActionEvent != null)
        {
                IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(pItem->GetActionId());
                SysTryReturn(NID_UI_CTRL, pEventArg, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
@@ -1308,7 +1323,7 @@ _Tab::OnAttachedToMainTree(void)
 
        pContainer = GetAccessibilityContainer();
 
-       if (pContainer)
+       if (pContainer != null)
        {
                pContainer->Activate(true);
                pContainer->AddListener(*this);
@@ -1331,65 +1346,273 @@ _Tab::OnFontInfoRequested(unsigned long& style, float& size)
     return;
 }
 
-void
-_Tab::AddAccessibilityElement(const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
+bool
+_Tab::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
 {
-       _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+       if (this != &source)
+       {
+               return false;
+       }
+       _KeyCode keyCode = keyInfo.GetKeyCode();
+       int itemCount = __pTabPresenter->GetItemCount();
+       if (itemCount == 0 || !__isInFocusMode)
+       {
+               return false;
+       }
 
-       if (pContainer != null)
+       if (keyCode == _KEY_RIGHT)
        {
-               _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
-               SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+               if (__currentHighlightedItemIndex < (itemCount - 1))
+               {
+                       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
+                       {
+                               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+                       }
 
-               pAccessibilityElement->SetTrait(L"Tab");
-               pAccessibilityElement->SetHint(L"Double tap to move to contents");
-               pAccessibilityElement->SetBounds(itemBounds);
+                       __currentHighlightedItemIndex++;
 
-               if (GetStyle() != _TAB_STYLE_ICON)
-               {
-                       pAccessibilityElement->SetLabel(itemText);
+                       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
+                       {
+                               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
+                       }
+                       __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_RIGHT);
                }
+               return true;
+       }
 
-               if (status == _TABITEM_STATUS_SELECTED)
-               {
-                       pAccessibilityElement->SetStatus("Selected");
-                       pAccessibilityElement->SetHintDisabled(true);
-               }
-               else
+       if (keyCode == _KEY_LEFT)
+       {
+               if (__currentHighlightedItemIndex >= -1)
                {
-                       pAccessibilityElement->SetStatus("");
-                       pAccessibilityElement->SetHintDisabled(false);
+                       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
+                       {
+                               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+                       }
+                       if (__currentHighlightedItemIndex == -1)
+                       {
+                               __currentHighlightedItemIndex = 0;
+                       }
+                       if (__currentHighlightedItemIndex > 0)
+                       {
+                               __currentHighlightedItemIndex--;
+                       }
+                       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
+                       {
+                               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
+                       }
+                       __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_LEFT);
                }
+               return true;
+       }
 
-               pContainer->AddElement(*pAccessibilityElement);
-               __accessibilityElements.Add(pAccessibilityElement);
+       if (keyCode == _KEY_ENTER && __currentHighlightedItemIndex != -1)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_SELECTED);
+               __pTabPresenter->SetSelectedItemIndex(__currentHighlightedItemIndex);
+               Invalidate();
+               return true;
        }
+       return false;
+}
 
+bool
+_Tab::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+{
+       return false;
+}
+
+void
+_Tab::OnDrawFocus(void)
+{
+       if (__pTabPresenter->GetItemCount() > 0)
+       {
+               __currentHighlightedItemIndex = 0;
+       }
+       else
+       {
+               __currentHighlightedItemIndex = -1;
+       }
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) != _TABITEM_STATUS_SELECTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_HIGHLIGHTED);
+       }
+       __pTabPresenter->ShiftToFocusedItem(__currentHighlightedItemIndex, _FOCUS_DIRECTION_MOVE_LEFT);
+       __isInFocusMode = true;
        return;
 }
 
 void
-_Tab::RemoveAllAccessibilityElement(void)
+_Tab::OnFocusModeStateChanged(void)
+{
+       if (__pTabPresenter->GetItemStatus(__currentHighlightedItemIndex) == _TABITEM_STATUS_HIGHLIGHTED)
+       {
+               __pTabPresenter->SetItemStatus(__currentHighlightedItemIndex, _TABITEM_STATUS_NORMAL);
+       }
+       __currentHighlightedItemIndex = -1;
+       __isInFocusMode = false;
+       Invalidate();
+}
+
+void
+_Tab::AddAccessibilityElement(const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
+{
+       _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+       SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
+       SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_TAB_T_TTS");
+       pAccessibilityElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_MOVE_TO_CONTENT_T_TTS");
+
+       if (GetStyle() != _TAB_STYLE_ICON)
+       {
+               pAccessibilityElement->SetLabel(itemText);
+       }
+
+       if (status == _TABITEM_STATUS_SELECTED)
+       {
+               pAccessibilityElement->SetStatusWithStringId("IDS_TPLATFORM_BODY_SELECTED_T_TTS");
+               pAccessibilityElement->SetHintDisabled(true);
+       }
+       else
+       {
+               pAccessibilityElement->SetStatus("");
+               pAccessibilityElement->SetHintDisabled(false);
+       }
+
+       pContainer->AddElement(*pAccessibilityElement);
+       __accessibilityElements.Add(pAccessibilityElement);
+
+       return;
+}
+
+void
+_Tab::InsertAccessibilityElementAt(int index, const FloatRectangle& itemBounds, const String& itemText, _TabItemStatus status)
+{
+       _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+       SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       _AccessibilityElement* pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
+       SysTryReturnVoidResult(NID_UI_CTRL, pAccessibilityElement != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+       pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_TAB_T_TTS");
+       pAccessibilityElement->SetHintWithStringId("IDS_TPLATFORM_BODY_DOUBLE_TAP_TO_MOVE_TO_CONTENT_T_TTS");
+
+       if (GetStyle() != _TAB_STYLE_ICON)
+       {
+               pAccessibilityElement->SetLabel(itemText);
+       }
+
+       if (status == _TABITEM_STATUS_SELECTED)
+       {
+               pAccessibilityElement->SetStatusWithStringId("IDS_TPLATFORM_BODY_SELECTED_T_TTS");
+               pAccessibilityElement->SetHintDisabled(true);
+       }
+       else
+       {
+               pAccessibilityElement->SetStatus("");
+               pAccessibilityElement->SetHintDisabled(false);
+       }
+
+       pContainer->InsertElement(*pAccessibilityElement, index);
+       __accessibilityElements.InsertAt(pAccessibilityElement, index);
+
+       return;
+}
+
+void
+_Tab::RemoveAccessibilityElementAt(int index)
 {
+       _AccessibilityElement* pAccessibilityElement = null;
        _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+       SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
-       if (pContainer == null)
+       if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
        {
-               return;
+               __accessibilityElements.RemoveAt(index);
+               pContainer->RemoveElement(*pAccessibilityElement);
        }
 
+       return;
+}
+
+void
+_Tab::RemoveAllAccessibilityElement(void)
+{
        _AccessibilityElement* pAccessibilityElement = null;
+       _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+       SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
        while (__accessibilityElements.GetCount() > 0)
        {
                if ((__accessibilityElements.GetAt(0, pAccessibilityElement)) == E_SUCCESS)
                {
-                       pContainer->RemoveElement(*pAccessibilityElement);
                        __accessibilityElements.RemoveAt(0);
+                       pContainer->RemoveElement(*pAccessibilityElement);
                }
-               else
+       }
+
+       return;
+}
+
+void
+_Tab::UpdateAccessibilityElement(void)
+{
+       _TabItemStatus itemStatus = _TABITEM_STATUS_NORMAL;
+       _TabItem* pItem = null;
+       _AccessibilityElement* pAccessibilityElement = null;
+       _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+       SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       int count = __accessibilityElements.GetCount();
+
+       FloatRectangle bounds(0.0f, 0.0f, 0.0f, 0.0f);
+
+       for (int i = 0; i < count; i++)
+       {
+               if ((__accessibilityElements.GetAt(i, pAccessibilityElement)) == E_SUCCESS)
                {
-                       __accessibilityElements.RemoveAt(0);
+                       pItem = GetItemAt(i);
+                       if (pItem != null)
+                       {
+                               bounds = pItem->GetItemBounds();
+                               itemStatus = pItem->GetStatus();
+                       }
+
+                       if (pAccessibilityElement != null)
+                       {
+                               pAccessibilityElement->SetBounds(bounds);
+
+                               if (itemStatus == _TABITEM_STATUS_SELECTED)
+                               {
+                                       pAccessibilityElement->SetStatusWithStringId("IDS_TPLATFORM_BODY_SELECTED_T_TTS");
+                                       pAccessibilityElement->SetHintDisabled(true);
+                               }
+                               else
+                               {
+                                       pAccessibilityElement->SetStatus("");
+                                       pAccessibilityElement->SetHintDisabled(false);
+                               }
+                       }
+               }
+       }
+
+       return;
+}
+
+void
+_Tab::UpdateAccessibilityLabel(int index, const String& text)
+{
+       _AccessibilityElement* pAccessibilityElement = null;
+       _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+       SysTryReturnVoidResult(NID_UI_CTRL, (pContainer != null), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+       if ((__accessibilityElements.GetAt(index, pAccessibilityElement)) == E_SUCCESS)
+       {
+               if (pAccessibilityElement != null)
+               {
+                       pAccessibilityElement->SetLabel(text);
                }
        }
 
@@ -1407,17 +1630,13 @@ _Tab::OnChangeLayout(_ControlOrientation orientation)
 bool
 _Tab::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
 {
-       ClearLastResult();
-
-       return __pTabPresenter->OnAccessibilityFocusMovedNext(control, element);
+       return false;
 }
 
 bool
 _Tab::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
 {
-       ClearLastResult();
-
-       return __pTabPresenter->OnAccessibilityFocusMovedPrevious(control, element);
+       return false;
 }
 
 bool
@@ -1434,7 +1653,32 @@ _Tab::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _
 bool
 _Tab::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
 {
-       return false;
+       FloatRectangle bounds = element.GetBounds();
+
+       if (bounds.x < 0)
+       {
+               if (bounds.x == -bounds.width)
+               {
+                       __pTabPresenter->MovePrevious();
+               }
+               else
+               {
+                       __pTabPresenter->MoveToFirst();
+               }
+       }
+       else if (bounds.x + bounds.width > GetBounds().width)
+       {
+               if (bounds.x  == GetBounds().width)
+               {
+                       __pTabPresenter->MoveNext();
+               }
+               else
+               {
+                       __pTabPresenter->MoveToLast(bounds.x);
+               }
+       }
+
+       return true;
 }
 
 bool
@@ -1450,13 +1694,13 @@ _Tab::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, con
 }
 
 bool
-_Tab::OnAccessibilityValueIncreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&)
+_Tab::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
 {
        return false;
 }
 
 bool
-_Tab::OnAccessibilityValueDecreased(const Tizen::Ui::_AccessibilityContainer&, const Tizen::Ui::_AccessibilityElement&)
+_Tab::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
 {
        return false;
 }