예제 #1
0
//-----------------------------------------------------------------------------
// Purpose: Highlight a menu item
//			Menu item buttons highlight if disabled, but won't activate.
//-----------------------------------------------------------------------------
void MenuItem::ArmItem()
{
	// close all other menus 
	GetParentMenu()->CloseOtherMenus(this);
	// arm the menuItem.
	Button::SetArmed(true);	

	// When you have a submenu with no scroll bar the menu
	// border will not be drawn correctly. This fixes it.
	Menu *parent = GetParentMenu();
	if ( parent )
	{
		parent->ForceCalculateWidth();
	}

	Repaint();
}
예제 #2
0
//-----------------------------------------------------------------------------
// Purpose: Unhighlight a menu item
//-----------------------------------------------------------------------------
void MenuItem::DisarmItem()
{
	// normal behaviour is that the button becomes unarmed
	// do not unarm if there is a cascading menu. CloseCascadeMenu handles this.
	// and the menu handles it since we close at different times depending
	// on whether menu is handling mouse or key events.
	if (!m_pCascadeMenu)
	{
		Button::OnCursorExited();
	}

	// When you have a submenu with no scroll bar the menu
	// border will not be drawn correctly. This fixes it.
	Menu *parent = GetParentMenu();
	if ( parent )
	{
		parent->ForceCalculateWidth();
	}
	Repaint();
}
예제 #3
0
//-----------------------------------------------------------------------------
// Purpose: Apply the resource scheme to the menu.
//-----------------------------------------------------------------------------
void MenuItem::ApplySchemeSettings(IScheme *pScheme)
{
	// chain back first
	Button::ApplySchemeSettings(pScheme);

	// get color settings
	SetDefaultColor(GetSchemeColor("Menu.TextColor", GetFgColor(), pScheme), GetSchemeColor("Menu.BgColor", GetBgColor(), pScheme));
	SetArmedColor(GetSchemeColor("Menu.ArmedTextColor", GetFgColor(), pScheme), GetSchemeColor("Menu.ArmedBgColor", GetBgColor(), pScheme));
	SetDepressedColor(GetSchemeColor("Menu.ArmedTextColor", GetFgColor(), pScheme), GetSchemeColor("Menu.ArmedBgColor", GetBgColor(), pScheme));

	SetTextInset(atoi(pScheme->GetResourceString("Menu.TextInset")), 0);
	
	// reload images since applyschemesettings in label wipes them out.
	if ( m_pCascadeArrow )
	{
		m_pCascadeArrow->SetFont(pScheme->GetFont("Marlett", IsProportional() ));
		m_pCascadeArrow->ResizeImageToContent();
		AddImage(m_pCascadeArrow, 0);
	}	
	else if (m_bCheckable)
	{
		( static_cast<MenuItemCheckImage *>(m_pCheck) )->SetFont( pScheme->GetFont("Marlett", IsProportional()));
		SetImageAtIndex(0, m_pCheck, CHECK_INSET);
		( static_cast<MenuItemCheckImage *>(m_pCheck) )->ResizeImageToContent();
	}

	if ( m_pCurrentKeyBinding )
	{
		m_pCurrentKeyBinding->SetFont(pScheme->GetFont("Default", IsProportional() ));
		m_pCurrentKeyBinding->ResizeImageToContent();
	}

	// Have the menu redo the layout
	// Get the parent to resize
	Menu * parent = GetParentMenu();
	if ( parent )
	{
		parent->ForceCalculateWidth();
	}
}