#include "Menu.h"

Menu::Menu(MenuManager*manager,DWORD id) : GUIElement(manager,id)
{
}

Menu::~Menu(void)
{
}

void Menu::AddTabEntry(GUIElement*el)
{
	m_TabList.AddSortedByID(el,el->GetTabIndex(),true);
}

void Menu::DelTabEntry(GUIElement*el)
{
	m_TabList.ReleaseElement(el->GetTabIndex());
}

void Menu::FocusNext(DWORD tabindex)
{
	if(m_TabList.GetElementCount())
	{
		ListElement<GUIElement> *curfocus = m_TabList.GetElement(tabindex);
		if(curfocus)
		{
			curfocus->GetInfo()->SetFocus(false);
			if(curfocus->GetNext())
				curfocus->GetNext()->GetInfo()->SetFocus(true);
			else //if(m_TabList.GetHead()) //dont need to check it
				m_TabList.GetHead()->GetInfo()->SetFocus(true);
		}
	}
}