Ejemplo n.º 1
0
bool Dialog::OnKeyPressed(Key key)
{
	switch( key )
	{
	case Key::Up:
		if( GetManager().GetFocusWnd() && this != GetManager().GetFocusWnd() )
		{
			// try to pass focus to previous siblings
			UIWindow *r = GetManager().GetFocusWnd()->GetPrevSibling();
			for( ; r; r = r->GetPrevSibling() )
			{
				if( r->GetVisibleCombined() && r->GetEnabledCombined() && GetManager().SetFocusWnd(r) ) break;
			}
		}
		break;
	case Key::Down:
		if( GetManager().GetFocusWnd() && this != GetManager().GetFocusWnd() )
		{
			// try to pass focus to next siblings
			UIWindow *r = GetManager().GetFocusWnd()->GetNextSibling();
			for( ; r; r = r->GetNextSibling() )
			{
				if( r->GetVisibleCombined() && r->GetEnabledCombined() && GetManager().SetFocusWnd(r) ) break;
			}
		}
		break;
	case Key::Tab:
		if( GetManager().GetFocusWnd() && this != GetManager().GetFocusWnd() )
		{
			// try to pass focus to next siblings ...
			UIWindow *r = GetManager().GetFocusWnd()->GetNextSibling();
			for( ; r; r = r->GetNextSibling() )
			{
				if( r->GetVisibleCombined() && r->GetEnabledCombined() && GetManager().SetFocusWnd(r) ) break;
			}
			if( r ) break;

			// ... and then start from first one
			r = GetFirstChild();
			for( ; r; r = r->GetNextSibling() )
			{
				if( r->GetVisibleCombined() && r->GetEnabledCombined() && GetManager().SetFocusWnd(r) ) break;
			}
		}
		break;
	case Key::Enter:
	case Key::NumEnter:
		Close(_resultOK);
		break;
	case Key::Escape:
		Close(_resultCancel);
		break;
	default:
		return false;
	}
	return true;
}
Ejemplo n.º 2
0
static void DrawWindowRecursive(const UIWindow &wnd, DrawingContext &dc, bool topMostPass, bool insideTopMost)
{
    insideTopMost |= wnd.GetTopMost();

    if (!wnd.GetVisible() || (insideTopMost && !topMostPass))
        return; // skip window and all its children
    
	dc.PushTransform(Vector2(wnd.GetX(), wnd.GetY()));

    if (insideTopMost == topMostPass)
        wnd.Draw(dc);
    
    // topmost windows escape parents' clip
    bool clipChildren = wnd.GetClipChildren() && (!topMostPass || insideTopMost);

	if (clipChildren)
	{
		math::RectInt clip;
		clip.left = 0;
		clip.top = 0;
		clip.right = (int)wnd.GetWidth();
		clip.bottom = (int)wnd.GetHeight();
		dc.PushClippingRect(clip);
	}

	for (UIWindow *w = wnd.GetFirstChild(); w; w = w->GetNextSibling())
        DrawWindowRecursive(*w, dc, topMostPass, wnd.GetTopMost() || insideTopMost);

	if (clipChildren)
		dc.PopClippingRect();

	dc.PopTransform();
}