Esempio n. 1
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();
}
Esempio n. 2
0
HRESULT UIButtonGroup::Draw(DK_IMAGE drawingImg)
{
    if (!m_bIsVisible)
        return S_OK;
    
    HRESULT hr(S_OK);
    DK_IMAGE imgSelf;
    int left = m_iLeft, top = m_iTop, right = m_iLeft + m_iWidth, bottom = m_iTop + m_iHeight;
    DK_RECT rcSelf={left, top, right, bottom};
    RTN_HR_IF_FAILED(CropImage(
        drawingImg,
        rcSelf,
        &imgSelf
        ));
    CTpGraphics grf(imgSelf);
    ValidChildBtnShown();
    int iSize = GetChildrenCount();
    for (int i = 0; i < iSize; i++)
    {
        UIWindow* pWin = GetChildByIndex(i);
        if (pWin && pWin->IsVisible())
        {
            DebugPrintf(DLC_GUI_VERBOSE,
                    "%s: Drawing Child %d / %d : %s, (%d, %d)-(%d, %d), %s ...",
                    GetClassName(), i, iSize, pWin->GetClassName(),
                    pWin->GetX(), pWin->GetY(),
                    pWin->GetWidth(), pWin->GetHeight(),
                    pWin->GetText());
            hr = pWin->Draw(imgSelf);
            if (!SUCCEEDED(hr))
            {
                DebugPrintf(DLC_GUI_VERBOSE, "Draw child failed");
            }
        }
        else
        {
            DebugPrintf(DLC_ERROR, "%s: FAILED to get child %d/%d !!!", GetClassName(), i, iSize);
        }
    }

    if (m_btnsDirection == BGD_Horizontal)
    {
        DrawTopLine(grf);
        DrawBottomLine(grf);
    }
    DrawSplitLine(grf);

    if (m_currentFocusedIndex >= 0 && (unsigned int)m_currentFocusedIndex < GetChildrenCount())
    {
        DrawFocusedSymbol(imgSelf);
    }

    return hr;
}