//--------------------------------------------------------------------------------------//
void CBCGPDragFrameImpl::EndDrawDragFrame (BOOL bClearInternalRects)
{
	if (m_pDockManager == NULL)
	{
		return;
	}

    BOOL bSDockingIsOn = FALSE;
    CBCGPSmartDockingManager* pSDManager = NULL;

    if ((pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
        && pSDManager->IsStarted())
    {
        bSDockingIsOn = TRUE;
        pSDManager->HidePlace ();
    }

	CRect rectEmpty; rectEmpty.SetRectEmpty ();
	CRect rectDocked = m_rectExpectedDocked.IsRectEmpty () ? m_rectDrag : 
															 m_rectExpectedDocked;

	// do not draw the final frame (meaning - clear) if it was not drawn because of tab
	if (m_nInsertedTabID == -1)
	{
        if (!bSDockingIsOn)
        {
		    DrawDragFrame (rectEmpty, rectDocked, 0, m_nOldThikness);
        }
	}
	else
	{
		m_bDockToTab = TRUE;
	}
	
	if (bClearInternalRects)
	{
        RemoveTabPreDocking ();

		m_rectExpectedDocked.SetRectEmpty ();
		m_rectDrag.SetRectEmpty ();

		m_pFinalTargetBar = m_pTargetBar;
		m_pTargetBar = NULL;
	}

	m_bDragStarted = FALSE;
	
	ASSERT (m_pDockManager != NULL);
	if (!bSDockingIsOn)
	{
		m_pDockManager->LockUpdate (FALSE);
	}
}
//--------------------------------------------------------------------------------------//
void CBCGPDragFrameImpl::DrawFrameTab (CBCGPDockingControlBar* pTargetBar, BOOL bErase)
{
	CRect rectWnd;
	pTargetBar->GetWindowRect (rectWnd);
	
    CBCGPSmartDockingManager* pSDManager = NULL;
    BOOL bSDockingIsOn = FALSE;

    if (m_pDockManager != NULL
        && (pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
        && pSDManager->IsStarted())
    {
        bSDockingIsOn = TRUE;
    }

	int nThikness = globalData.m_nDragFrameThiknessDock;
	CRect rectSmallTab = rectWnd;
	// to be changed to tab height
	
	if (CBCGPTabbedControlBar::m_bTabsAlwaysTop)
	{
		rectWnd.top += globalData.GetTextHeight ();  
		rectSmallTab.bottom = rectSmallTab.top + globalData.GetTextHeight (); 
		rectSmallTab.left += 10;
		rectSmallTab.right = rectSmallTab.left + 40;
	}
	else
	{
		rectWnd.bottom -= globalData.GetTextHeight ();  
		rectSmallTab.top = rectSmallTab.bottom - globalData.GetTextHeight (); 
		rectSmallTab.left += 10;
		rectSmallTab.right = rectSmallTab.left + 40;
	}

	if (rectSmallTab.right >= rectWnd.right)
	{
		rectSmallTab.right = rectWnd.right - nThikness - 4;
	}

	CRect rectEmpty; rectEmpty.SetRectEmpty ();
	

	CRect rectLine; 
	if (CBCGPTabbedControlBar::m_bTabsAlwaysTop)
	{
		rectLine.SetRect (rectSmallTab.left + nThikness, 
							rectSmallTab.bottom - nThikness,  
							rectSmallTab.right - nThikness, 
							rectSmallTab.bottom + nThikness);
	}
	else
	{
		rectLine.SetRect (rectSmallTab.left + nThikness, 
							rectSmallTab.top  - nThikness,  
							rectSmallTab.right - nThikness, 
							rectSmallTab.top + nThikness);
	}

	if (bErase)
	{
        if (bSDockingIsOn)
        {
            pSDManager->HidePlace ();
        } 
		else
        {
			DrawDragFrame (rectEmpty, rectSmallTab, FALSE, nThikness, nThikness);
			DrawDragFrame (rectEmpty, rectWnd, FALSE, nThikness, nThikness);
			DrawDragFrame (rectEmpty, rectLine, FALSE, nThikness, nThikness);
			m_bFrameTabDrawn = FALSE;
        }
	}
	else
	{
        if (bSDockingIsOn)
        {
            pSDManager->ShowTabbedPlaceAt (&rectWnd, 10, rectSmallTab.Width(), rectSmallTab.Height());
        } 
		else
        {
			
			DrawDragFrame (rectEmpty, rectSmallTab, TRUE, nThikness, nThikness);
			DrawDragFrame (rectEmpty, rectWnd, TRUE, nThikness, nThikness);
			DrawDragFrame (rectEmpty, rectLine, TRUE, nThikness, nThikness);
			m_bFrameTabDrawn = TRUE;
        }
	}
}