Beispiel #1
0
void CDockContext::EndDrag()
/**************************/
{
    DrawFocusRect( TRUE );
    if( m_dwOverDockStyle != 0L && !m_bForceFrame ) {
        CDockBar *pDockBar = GetDockBar( m_dwOverDockStyle );
        ASSERT( pDockBar != NULL );
        if( ((m_dwOverDockStyle & CBRS_ORIENT_HORZ) && !m_bFlip) ||
            ((m_dwOverDockStyle & CBRS_ORIENT_VERT) && m_bFlip) ) {
            pDockBar->DockControlBar( m_pBar, &m_rectDragHorz );
        } else {
            pDockBar->DockControlBar( m_pBar, &m_rectDragVert );
        }
        m_dwOverDockStyle = 0L;
        m_uMRUDockID = pDockBar->GetDlgCtrlID();
        m_pBar->GetWindowRect( &m_rectMRUDockPos );
    } else {
        ASSERT( m_pDockSite != NULL );
        if( ((m_dwStyle & CBRS_ORIENT_HORZ) && !m_bFlip) ||
            ((m_dwStyle & CBRS_ORIENT_VERT) && m_bFlip) ) {
            m_pDockSite->FloatControlBar( m_pBar, m_rectFrameDragHorz.TopLeft(),
                CBRS_ALIGN_TOP | (m_dwDockStyle & CBRS_FLOAT_MULTI) );
            m_ptMRUFloatPos = m_rectFrameDragHorz.TopLeft();
        } else {
            m_pDockSite->FloatControlBar( m_pBar, m_rectFrameDragVert.TopLeft(),
                CBRS_ALIGN_LEFT | (m_dwDockStyle & CBRS_FLOAT_MULTI) );
            m_ptMRUFloatPos = m_rectFrameDragVert.TopLeft();
        }
    }
    delete m_pDC;
    m_pDC = NULL;
    m_bDragging = FALSE;
}
DWORD CGuiDockContext::CanDock(CRect rect, DWORD dwDockStyle, CDockBar** ppDockBar)
{
	// dwDockStyle -- allowable styles of bar
	// don't allow to dock to floating unless multi is specified
	BOOL bTipoToolBar=m_pBar->IsKindOf(RUNTIME_CLASS( CGuiToolBarWnd)) ||
		              m_pBar->IsKindOf(RUNTIME_CLASS( CMenuBar));
	dwDockStyle &= CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI;
	if (ppDockBar != NULL)
		*ppDockBar = NULL;
	POSITION pos = m_pDockSite->m_listControlBars.GetHeadPosition();
	while (pos != NULL)
	{
		CDockBar* pDockBar = (CDockBar*)m_pDockSite->m_listControlBars.GetNext(pos);
		if (pDockBar->IsDockBar() && pDockBar->IsWindowVisible() &&
			(pDockBar->m_dwStyle & dwDockStyle & CBRS_ALIGN_ANY) &&
			(!pDockBar->m_bFloating ||
				(dwDockStyle & pDockBar->m_dwStyle & CBRS_FLOAT_MULTI)))
		{
		
				int nSize=pDockBar->m_arrBars.GetSize();
				for (int i=0;i <nSize;  i++)
				{
					UINT m_nDockBarID = pDockBar->GetDlgCtrlID();
					CControlBar* pBar;
					 pBar = (CControlBar*) pDockBar->m_arrBars[i];
					 if (HIWORD(pBar) == 0) continue; // placeholder
					 if (!pBar->IsVisible()) continue;
					 CRect rectBar;
					 pBar->GetWindowRect(&rectBar);
					 if (rectBar.Width() == 0)
						rectBar.right++;
					 if (rectBar.Height() == 0)
							rectBar.bottom++;
					 CRect rectBar1;
					 pDockBar->GetWindowRect(&rectBar1);
					 if (dwDockStyle==CBRS_ORIENT_VERT)
					 {
						 if (m_nDockBarID==AFX_IDW_DOCKBAR_LEFT)
					 		rectBar1.right=rectBar1.left+10;
						 if(m_nDockBarID==AFX_IDW_DOCKBAR_RIGHT)
							 rectBar1.left=rectBar1.right-10;
					 }
					 else
					 {

						if (m_nDockBarID==AFX_IDW_DOCKBAR_BOTTOM)
							rectBar1.top=rectBar1.bottom-10;
						if (m_nDockBarID==AFX_IDW_DOCKBAR_TOP)
							rectBar1.bottom=rectBar1.top+10;
						
					 }
					 if (rectBar1.IntersectRect(rectBar1, rect))
					 {
						if (ppDockBar != NULL)
							
							*ppDockBar = pDockBar;
						
						return pDockBar->m_dwStyle & dwDockStyle;
					 }
			

					//***********************************************
					if (rectBar.IntersectRect(rectBar, rect))
					{
							if (bTipoToolBar)
							{
								if (pBar->IsKindOf(RUNTIME_CLASS( CGuiControlBar)))
									return 0;
							}
							if (ppDockBar != NULL)
								*ppDockBar = pDockBar;
							return pDockBar->m_dwStyle & dwDockStyle;
							
						 
							
					}
					 
				}//fin del for
							
		
			CRect rectBar;
			pDockBar->GetWindowRect(&rectBar);
			if (rectBar.Width() == 0)
				rectBar.right++;
			if (rectBar.Height() == 0)
				rectBar.bottom++;
			if (rectBar.IntersectRect(rectBar, rect))
			{
				if (ppDockBar != NULL)
					*ppDockBar = pDockBar;
				return pDockBar->m_dwStyle & dwDockStyle;
			}
		}
	}
	return 0;
}