Esempio n. 1
0
void Menu::Move(bool down)
{
	Control *find = m_focus;
	if (find == NULL)
		return;
	do {
		if (down)
		{
			find = find->m_next;
			if (find == NULL)
				find = m_controls;
		}
		else
		{
			find = find->m_last;
			if (find == NULL)
			{
				find = m_controls;
				while (find->m_next != NULL)
					find = find->m_next;
			}
		}
		if (find == m_focus)
		{
			// Avoid an infinite loop, if we're on the input it must be the only one (or none)
			return;
		}
	} while((!find->CanFocus()) || (!find->Visible()));
	m_focus->SetFocus(false);
	m_focus = find;
	m_focus->SetFocus(true);
	Update();
}
Esempio n. 2
0
void Menu::Update(void)
{
	if (!IsOnScreen(m_focus))
	{
		int dir = FindInList(m_topView, m_focus);
		if (dir == 0)
		{
			// Item not in list? Suspicious
			return;
		}
		if (dir < 0)
		{
			// First, move up until view is visible
			do
			{
				do
				{
					m_topView = m_topView->m_last;
				}
				while ((m_topView != NULL) && (!m_topView->Visible()));
			}
			while (!IsOnScreen(m_focus));
			// Second, optionally find top label
			Control *label = m_topView->m_last;
			while ((label != NULL) && ((!label->Visible()) || label->CanFocus()))
				label = label->m_last;
			if (label != NULL)
			{
				Control *minTop = m_topView;
				m_topView = label;
				if (!IsOnScreen(m_focus))
					m_topView = minTop;
			}
		}
		else
		{
			// Simply move down until item visible
			do
			{
				do
				{
					m_topView = m_topView->m_next;
				}
				while (!m_topView->Visible());
			}
			while (!IsOnScreen(m_focus));
		}
	}
	OnPaint(m_destination);
}