Ejemplo n.º 1
0
void MenuItem::MouseReleasedOutside(const MouseEvent& lEvent)
{
	FocusManager::GetInstance()->SetFocusOwner(0);

	Menu* lpParentMenu = (Menu* )GetParent();
	lpParentMenu->CloseMenu();
}
Ejemplo n.º 2
0
void MenuItem::FocusLost(const FocusEvent& lEvent)
{
	if(!IsParentMenuOpen())
	{
		return;
	}

	Menu* lpParentMenu = (Menu* )GetParent();
	lpParentMenu->CloseMenu();
}
Ejemplo n.º 3
0
void MenuBar::CloseAllMenus()
{
	ComponentList::const_iterator iterator;

	for(iterator = m_vpComponentList.begin(); iterator != m_vpComponentList.end(); ++iterator)
	{
		if((*iterator)->GetComponentType() == EComponentType_Menu)
		{
			Menu* lpMenu = (Menu *)(*iterator);

			lpMenu->CloseMenu();
		}
	}
}
Ejemplo n.º 4
0
void MenuItem::MouseReleased(const MouseEvent& lEvent)
{
	if(!IsParentMenuOpen())
	{
		return;
	}

	Menu* lpParentMenu = (Menu* )GetParent();
	
	// Make sure that we are inside the bounds of the parent menu
	if(lpParentMenu->GetPullDownMenuParent() != NULL)
	{
		int lTextHeight = m_pRenderer->GetFreeTypeTextHeight(lpParentMenu->GetPullDownMenuParent()->GetGUIFont(), "%s", lpParentMenu->GetMenuTitle().c_str());
		int lMenuHeight = lTextHeight + (lpParentMenu->GetMenuItemSpacer() * 2);
		int lFullMenuDisplayHeight = lpParentMenu->GetPullDownMenuParent()->GetMaxNumItemsDisplayed() * lMenuHeight;

		Point location = lpParentMenu->GetPullDownMenuParent()->GetLocation();
		for(Component* parent = lpParentMenu->GetPullDownMenuParent()->GetParent(); parent != 0;)
		{
			Point parentLocation = parent->GetLocation();

			location.m_x += parentLocation.m_x;
			location.m_y += parentLocation.m_y;

			parent = parent->GetParent();
		}
		int lMenuX = location.m_x;
		int lMenuY = location.m_y - lFullMenuDisplayHeight;
		int lMenuWidth = lpParentMenu->GetBiggestWidth()+ (lpParentMenu->GetMenuItemSpacer() * 2);

		if(lEvent.GetX() > lMenuX && lEvent.GetX() <= lMenuX+lMenuWidth && lEvent.GetY() > lMenuY && lEvent.GetY() <= lMenuY+lFullMenuDisplayHeight)
		{
			// Close the menu, since we have clicked this menu item
			lpParentMenu->CloseMenu();

			SetHover(false);
			SetSelected(false);

			// Signal that we have pressed this menu item
			MenuItemPressed();
		}
	}


	FocusManager::GetInstance()->SetFocusOwner(0);

	OnMouseReleased();
}