AddAccessibilityElement(pButton);
+ if (__highlightedItemIndex != -1 && itemIndex <= __highlightedItemIndex)
+ {
+ __highlightedItemIndex++;
+ }
+
return E_SUCCESS;
}
{
for (int i = 0; i < BUTTON_MAX; i++)
{
- _Button* pButtonItem = __pButtonItems[i];
-
- if (pButtonItem != null)
+ if (i == LEFT_BUTTON)
{
- if (i == LEFT_BUTTON)
- {
- if (__pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT] != null)
- {
- StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_LEFT);
- }
- }
- else if (i == RIGHT_BUTTON)
- {
- if (__pAnimation[TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT] != null)
- {
- StopWaitingAnimation(TOOLBAR_ANIMATION_POSITION_BUTTON_RIGHT);
- }
- }
-
- if (pButtonItem->GetChildCount() != 0)
- {
- _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pButtonItem->GetChild(0));
- SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
-
- pButtonItem->DetachChild(*pTempBadgeIcon);
-
- delete pTempBadgeIcon;
- pTempBadgeIcon = null;
- }
-
- DetachChild(*pButtonItem);
- delete pButtonItem;
- pButtonItem = null;
-
- __pButtonItems[i] = null;
+ RemoveButtonAt(LEFT_BUTTON);
+ }
+ else if (i == RIGHT_BUTTON)
+ {
+ RemoveButtonAt(RIGHT_BUTTON);
}
}
result
_Toolbar::RemoveAllItems(void)
{
- __itemCount = 0;
-
int itemCount = __pItems.size();
- _Button* pItem = null;
-
// frees item nodes from the memory
if (itemCount > 0)
{
for (int i = itemCount - 1; i >= 0; i--)
{
- pItem = __pItems.at(i);
-
- if (pItem != null)
- {
- if (pItem->GetChildCount() != 0)
- {
- _Label* pTempBadgeIcon = dynamic_cast<_Label*>(pItem->GetChild(0));
- SysTryReturnResult(NID_UI_CTRL, pTempBadgeIcon, E_INVALID_STATE, "[E_INVALID_STATE] Couldn't get a badge icon.");
-
- pItem->DetachChild(*pTempBadgeIcon);
-
- delete pTempBadgeIcon;
- pTempBadgeIcon = null;
- }
-
- DetachChild(*pItem);
- delete pItem;
-
- pItem = null;
- }
+ RemoveItemAt(i);
}
-
}
// clears vector
DetachChild(*__pButtonItems[position]);
delete __pButtonItems[position];
__pButtonItems[position] = null;
+
+ if (!__header || __style == TOOLBAR_TEXT)
+ {
+ if (position == LEFT_BUTTON)
+ {
+ if (__highlightedItemIndex == 0)
+ {
+ __highlightedItemIndex = -1;
+ __isEnterKeyPressed = false;
+ }
+ else if (__highlightedItemIndex > 0)
+ {
+ __highlightedItemIndex--;
+ }
+ }
+ else // right button
+ {
+ if (__pButtonItems[LEFT_BUTTON])
+ {
+ if (__highlightedItemIndex == __itemCount + 1)
+ {
+ __highlightedItemIndex = -1;
+ __isEnterKeyPressed = false;
+ }
+ }
+ else if (__highlightedItemIndex == __itemCount)
+ {
+ __highlightedItemIndex = -1;
+ __isEnterKeyPressed = false;
+ }
+ }
+ }
+ else
+ {
+ if (position == LEFT_BUTTON)
+ {
+ if (__highlightedItemIndex == __itemCount)
+ {
+ __highlightedItemIndex = -1;
+ __isEnterKeyPressed = false;
+ }
+ }
+ else
+ {
+ if (__pButtonItems[LEFT_BUTTON])
+ {
+ if (__highlightedItemIndex == __itemCount + 1)
+ {
+ __highlightedItemIndex = -1;
+ __isEnterKeyPressed = false;
+ }
+ }
+ else if (__highlightedItemIndex == __itemCount)
+ {
+ __highlightedItemIndex = -1;
+ __isEnterKeyPressed = false;
+ }
+ }
+ }
}
if (__itemCount == 0 && __pButtonItems[LEFT_BUTTON] == null && __pButtonItems[RIGHT_BUTTON] == null)
delete pItem;
pItem = null;
+ if (itemIndex == __highlightedItemIndex)
+ {
+ __highlightedItemIndex = -1;
+ __isEnterKeyPressed = false;
+ }
+ else if (itemIndex < __highlightedItemIndex)
+ {
+ __highlightedItemIndex--;
+ }
__itemCount--;
if (__itemCount == 0 && __pButtonItems[LEFT_BUTTON] == null && __pButtonItems[RIGHT_BUTTON] == null)
}
}
+void
+_Toolbar::SetHighlightedState(ToolbarButton position)
+{
+ if (__highlightedItemIndex == __itemCount)
+ {
+ if (__pButtonItems[LEFT_BUTTON])
+ {
+ if (position == LEFT_BUTTON)
+ {
+ __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED, false);
+ }
+ else
+ {
+ __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+ }
+ }
+ else // Right button case
+ {
+ __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED, false);
+ }
+ }
+ else if (__highlightedItemIndex == __itemCount + 1 )
+ {
+ if (position == RIGHT_BUTTON)
+ {
+ __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_HIGHLIGHTED, false);
+ }
+ else
+ {
+ __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+ }
+ }
+ else
+ {
+ __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+ }
+
+}
+
result
_Toolbar::SetButtonEnabled(ToolbarButton position, bool enabled)
{
if (enabled)
{
- __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+ if (_ControlManager::GetInstance() != null && _ControlManager::GetInstance()->GetFocusControl() != this)
+ {
+ __highlightedItemIndex = -1;
+ __isEnterKeyPressed = false;
+ }
+
+ if (__itemCount != 0)
+ {
+ if (__highlightedItemIndex >= __itemCount)
+ {
+ SetHighlightedState(position);
+ }
+ else
+ {
+ __pButtonItems[position]->SetButtonStatus(_BUTTON_STATUS_NORMAL);
+ }
+ }
+ else
+ {
+ SetHighlightedState(position);
+ }
SetFocusNavigateEnabled(true);
}
else // itemCount != 0
{
- if (__highlightedItemIndex != -1 && __pItems.at(__highlightedItemIndex))
+ if (__highlightedItemIndex != -1 && (__highlightedItemIndex < __itemCount) && __pItems.at(__highlightedItemIndex))
{
if (__pItems.at(__highlightedItemIndex)->GetButtonStatus() != _BUTTON_STATUS_DISABLED)
{