Print Page | Close Window

Is this implementation correct?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=22193
Printed Date: 16 April 2024 at 4:29am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Is this implementation correct?
Posted By: Michl
Subject: Is this implementation correct?
Date Posted: 05 February 2014 at 9:09am
Hello guys

I'm implements a own header style for a tabbed container.

If the control paints itself, the overrideable method is calling:

CRect CXTPTabPaintManagerTheme::FillTabControl(CXTPTabManager* /*pTabManager*/, CDC* /*pDC*/, CRect /*rcControl*/)


There I apply the code from various existing themes:

    CRect rcHeader = GetHeaderRect(rcControl, pTabManager);
    GetColorSet()->FillHeader(pDC, rcHeader, pTabManager);


I wondering why my line at bottom is never displayed. The reason is, that the result height of GetHeaderRect is 22 pixels, but bevor painting/drawing codejock selects a clip box of 21 pixels.

In my opinion the header area should be fully visible if rcHeader indicates this.



Further information of debbuging results:

I found that the clip box will be calculated from top until the beginning of the client area of the pane. The top position of client area will be calculated in:


CRect CXTPTabPaintManagerTheme::GetClientRect(CRect rcControl, CXTPTabManager* pTabManager)
{
    if (!m_pPaintManager->m_bShowTabs)
        return rcControl;

    CRect rcClient(rcControl);
    CRect rcHeader = GetHeaderRect(rcControl, pTabManager);

    switch (pTabManager->GetPosition())
    {
        case xtpTabPositionTop: rcClient.top = rcHeader.bottom - 1; break;
        case xtpTabPositionLeft: rcClient.left = rcHeader.right - 1; break;
        case xtpTabPositionBottom: rcClient.bottom = rcHeader.top + 1; break;
        case xtpTabPositionRight: rcClient.right = rcHeader.left + 1; break;
    }
    return rcClient;
}


Here i'm disagree your logic. Why does the client area starts at rcHeader.bottom - 1???
So client and header is overlapped.
It should be

    switch (pTabManager->GetPosition())
    {
        case xtpTabPositionTop: rcClient.top = rcHeader.bottom + 1; break;
        case xtpTabPositionLeft: rcClient.left = rcHeader.right + 1; break;
        case xtpTabPositionBottom: rcClient.bottom = rcHeader.top - 1; break;
        case xtpTabPositionRight: rcClient.right = rcHeader.left - 1; break;
    }


I correct this overlapp by adding 2 margin pixels at top which will be added in:

void CXTPTabPaintManagerTheme::AdjustClientRect(CXTPTabManager* pTabManager, CRect& rcClient)
{
    DeflateRectEx(rcClient, m_pPaintManager->m_rcControlMargin, pTabManager->GetPosition());
    rcClient = GetClientRect(rcClient, pTabManager);

    DeflateRectEx(rcClient, GetClientMargin(), pTabManager->GetPosition());

    if (m_pPaintManager->m_clientFrame == xtpTabFrameBorder)
    {
        DeflateRectEx(rcClient, CRect(2, 2, 2, 2), pTabManager->GetPosition());
    }
    if (m_pPaintManager->m_clientFrame == xtpTabFrameSingleLine)
    {
        DeflateRectEx(rcClient, CRect(0, 2, 0, 0), pTabManager->GetPosition());
    }
}


Is this a bug or "by design"?

Thanks



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net