DWORD CFrameWnd::CanDock( CRect rect, DWORD dwDockStyle, CDockBar **ppDockBar )
/*****************************************************************************/
{
    POSITION position = m_listControlBars.GetHeadPosition();
    while( position != NULL ) {
        CControlBar *pControlBar = (CControlBar *)m_listControlBars.GetNext( position );
        ASSERT( pControlBar != NULL );
        if( pControlBar->IsDockBar() && (pControlBar->GetBarStyle() & dwDockStyle) ) {
            CDockBar *pDockBar = (CDockBar *)pControlBar;
            ASSERT( pDockBar->IsKindOf( RUNTIME_CLASS( CDockBar ) ) );

            if( !pDockBar->m_bFloating ||
                (pDockBar->GetBarStyle() & CBRS_FLOAT_MULTI) ) {
                CRect rectBar;
                pDockBar->GetWindowRect( &rectBar );
                
                RECT rectJunk;
                if( rectBar.left == rectBar.right ) {
                    rectBar.right++;
                }
                if( rectBar.top == rectBar.bottom ) {
                    rectBar.bottom++;
                }
                if( ::IntersectRect( &rectJunk, &rect, &rectBar ) ) {
                    if( ppDockBar != NULL ) {
                        *ppDockBar = pDockBar;
                    }
                    return( pDockBar->GetBarStyle() & dwDockStyle );
                }
            }
        }
    }
    return( 0L );
}
Exemple #2
0
void CDockContext::ToggleDocking()
{
	if (m_pBar->IsFloating())
	{
		// Dock it only if is allowed to be docked
		if (m_pBar->m_dwDockStyle & CBRS_ALIGN_ANY)
		{
			ASSERT((m_uMRUDockID >= AFX_IDW_DOCKBAR_TOP &&
				m_uMRUDockID <= AFX_IDW_DOCKBAR_BOTTOM) ||
				m_uMRUDockID == 0);

			CRect rect = m_rectMRUDockPos;
			CDockBar* pDockBar = NULL;
			if (m_uMRUDockID != 0)
			{
				pDockBar = (CDockBar*)m_pDockSite->GetControlBar(m_uMRUDockID);
				pDockBar->ClientToScreen(&rect);
			}

			// dock it at the specified position, RecalcLayout will snap
			m_pDockSite->ReDockControlBar(m_pBar, pDockBar, &rect);
			m_pDockSite->RecalcLayout();
		}
	}
	else
	{
		CPoint ptFloat = m_ptMRUFloatPos;
		if (ptFloat.x < 0 || ptFloat.y < 0)
		{
			ptFloat = m_rectMRUDockPos.TopLeft();
			m_pBar->GetParent()->ClientToScreen(&ptFloat);
		}
		m_pDockSite->FloatControlBar(m_pBar, ptFloat, m_dwMRUFloatStyle);
	}
}
void CFrameWnd::ShowControlBar( CControlBar *pBar, BOOL bShow, BOOL bDelay )
/**************************************************************************/
{
    UNUSED_ALWAYS( bDelay );
    
    ASSERT( pBar != NULL );
    if( bShow ) {
        pBar->ShowWindow( SW_SHOW );
    } else {
        pBar->ShowWindow( SW_HIDE );
    }
    if( pBar->IsFloating() ) {
        CDockBar *pDockBar = pBar->m_pDockBar;
        ASSERT( pDockBar != NULL );
        CFrameWnd *pFrame = pDockBar->GetParentFrame();
        ASSERT( pFrame != NULL );
        if( !bShow && pDockBar->GetDockedVisibleCount() == 0 ) {
            pFrame->ShowWindow( SW_HIDE );
        } else if( bShow && pDockBar->GetDockedVisibleCount() == 1 ) {
            pFrame->ShowWindow( SW_SHOW );
            pFrame->UpdateWindow();
        }
    }
    RecalcLayout();
}
Exemple #4
0
// dock bars will be created in the order specified by dwMRCDockBarMap
// this also controls which gets priority during layout
// this order can be changed by calling EnableDocking repetitively
// with the exact order of priority
//------------------------------------------------------------------------------
void CMRCFrameWndSizeDock::EnableDocking(DWORD dwDockStyle, CRuntimeClass *pFloatingClass)
// This is over-ridden primarily because we need to insert our own CDockBar class
// to handle the recalc layout, and this is the place they are created.
//------------------------------------------------------------------------------
{
	// must be CBRS_ALIGN_XXX or CBRS_FLOAT_MULTI only
    ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);

    m_pFloatingFrameClass = pFloatingClass; // protected member
    for (int i = 0; i < 4; i++)
    {
    	if (dwMRCDockBarMap[i][1] & dwDockStyle & CBRS_ALIGN_ANY)          // protected
        {
        	CDockBar* pDock = (CDockBar*)GetControlBar(dwMRCDockBarMap[i][0]);
            if (pDock == NULL)
            	{
                	pDock = new CSizeDockBar;
                    if (!pDock->Create(this,
						               WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE |
                                              dwMRCDockBarMap[i][1], dwMRCDockBarMap[i][0]))
                    {
                    	AfxThrowResourceException();
                    }
                }
        }
    }
}
Exemple #5
0
void CGuiDocBarExten::BarsDocking(CFrameWnd * pFrame, DWORD dwDockStyle) 
{
	ASSERT_VALID(pFrame);

	// must be CBRS_ALIGN_XXX or CBRS_FLOAT_MULTI only
	ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);

	pFrame->EnableDocking(dwDockStyle);

	for (int i = 0; i < 4; i++) {
		if (dwDockBarMap[i][1] & dwDockStyle & CBRS_ALIGN_ANY) {
			CDockBar* pDock = (CDockBar*)pFrame->GetControlBar(dwDockBarMap[i][0]);
			if( pDock == 0 || ! pDock->IsKindOf(RUNTIME_CLASS(CGuiDocBarExten)) ) {
				BOOL bNeedDelete = ! pDock->m_bAutoDelete;
				pDock->m_pDockSite->RemoveControlBar(pDock);
				pDock->m_pDockSite = 0;	
				pDock->DestroyWindow();
				if( bNeedDelete )
					delete pDock;
				pDock = 0;
			}

			if( pDock == 0 ) {
				pDock = new CGuiDocBarExten;
				ASSERT_VALID(pDock);
				if ((!pDock) || (!pDock->Create(pFrame,
					WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE |
						dwDockBarMap[i][1], dwDockBarMap[i][0]))) {
					AfxThrowResourceException();
				}
			}
		}
	}
}
Exemple #6
0
DWORD CFrameWnd::CanDock(CRect rect, DWORD dwDockStyle, CDockBar** ppDockBar)
{
	// dwDockStyle -- allowable styles of bar
	// don't allow to dock to floating unless multi is specified
	dwDockStyle &= CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI;

	if (ppDockBar != NULL)
		*ppDockBar = NULL;
	POSITION pos = m_listControlBars.GetHeadPosition();
	while (pos != NULL)
	{
		CDockBar* pDockBar = (CDockBar*)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)))
		{
			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;
}
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;
}
Exemple #8
0
void CLogo::SetPosition()
{
	if(!::IsWindow(m_hWnd))
		return;

	CDockBar* pTopDockBar = GetParentDockBar();
	if(!pTopDockBar)
		return;

	CRect TopDockBarRect;
	pTopDockBar->GetClientRect(TopDockBarRect);

	CRect LogoRect;
	GetWindowRect(LogoRect);
	pTopDockBar->ScreenToClient(LogoRect);	

	int nLeft = TopDockBarRect.right-LogoRect.Width()-::GetSystemMetrics(SM_CXEDGE);
	int nTop = TopDockBarRect.top;

	if(nLeft != LogoRect.left ||
	   nTop != LogoRect.top)
		SetWindowPos(NULL, 
					 nLeft,
					 nTop,
					 0,
					 0,
					 SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE);

	CRect UnionToolbarRect;

	for(int nI=0;nI<pTopDockBar->m_arrBars.GetSize();nI++)
	{
		CWnd* pWnd = static_cast<CWnd*>(pTopDockBar->m_arrBars[nI]);
		if(!pWnd ||
		   !AfxIsValidAddress(pWnd,sizeof(CWnd)) || 
		   !::IsWindow(*pWnd))
				continue;

		CRect ToolBarRect;
		pWnd->GetWindowRect(&ToolBarRect);
		UnionToolbarRect.UnionRect(UnionToolbarRect,ToolBarRect);
	}

	GetWindowRect(LogoRect);

	UnionToolbarRect.IntersectRect(UnionToolbarRect,LogoRect);
	if(UnionToolbarRect.IsRectEmpty())
	{
		if(!IsWindowVisible())
			ShowWindow(SW_SHOW);
	}
	else
	{
		if(IsWindowVisible())
			ShowWindow(SW_HIDE);
	}
}
Exemple #9
0
void ForceLayoutAdjust(CControlBar * pBar)
// if control bar supplied, then set just resize it
{
	CDockBar * pDockBar;
	ASSERT(pBar != NULL);
	pDockBar = pBar->m_pDockBar;
	if (pDockBar!= NULL && pDockBar->IsKindOf(RUNTIME_CLASS(CSizeDockBar)))
		((CSizeDockBar *)pDockBar)->m_CountBars = 0;			
}
Exemple #10
0
void CFrameWnd::ReDockControlBar(CControlBar* pBar, CDockBar* pDockBar, LPCRECT lpRect)
{
	ASSERT(pBar != NULL);
	// make sure CControlBar::EnableDocking has been called
	ASSERT(pBar->m_pDockContext != NULL);

	if (pDockBar == NULL)
	{
		// Search for the place holder.

		// In case we don't find a place holder, find a bar with the correct alignment
		// and keep it in pPossibleBar.
		CDockBar* pPossibleBar = NULL;
		for (int i = 0; i < 4; i++)
		{
			CDockBar* pTempBar = (CDockBar*)GetControlBar(dwDockBarMap[i][0]);
			if (pTempBar != NULL)
			{
				// Is this the same bar we docked with before?
				if (pTempBar->FindBar((CControlBar*)_AfxGetDlgCtrlID(pBar->m_hWnd)) > 0)
				{
					pDockBar = pTempBar;
					break;
				}
			}

			if ((dwDockBarMap[i][1] & CBRS_ALIGN_ANY) ==
				(pBar->m_dwStyle & CBRS_ALIGN_ANY))
			{
				pPossibleBar = (CDockBar*)GetControlBar(dwDockBarMap[i][0]);
				ASSERT(pPossibleBar != NULL);
				// assert fails when initial CBRS_ of bar does not
				// match available docking sites, as set by EnableDocking()
			}
		}

		// Did we find the place holder?
		if (pDockBar == NULL)
			pDockBar = pPossibleBar;
	}
	ASSERT(pDockBar != NULL);
	ASSERT(m_listControlBars.Find(pBar) != NULL);
	ASSERT(pBar->m_pDockSite == this);
	// if this assertion occurred it is because the parent of pBar was not initially
	// this CFrameWnd when pBar's OnCreate was called
	// i.e. this control bar should have been created with a different parent initially

	pDockBar->ReDockControlBar(pBar, lpRect);
}
void CFrameWnd::EnableDocking( DWORD dwDockStyle )
/************************************************/
{
    for( int i = 0; i < NUM_DOCKBARS; i++ ) {
        DWORD dwBarDockStyle = _DockBarInfo[i][1];
        if( dwDockStyle & dwBarDockStyle ) {
            CDockBar *pDockBar = (CDockBar *)GetControlBar( _DockBarInfo[i][1] );
            if( pDockBar == NULL ) {
                pDockBar = new CDockBar;
                pDockBar->Create( this, WS_CHILD | WS_VISIBLE | _DockBarInfo[i][1],
                                  _DockBarInfo[i][0] );
            }
        }
    }
}
void CFrameWnd::DockControlBar( CControlBar *pBar, UINT nDockBarID, LPCRECT lpRect )
/**********************************************************************************/
{
    CDockBar *pDockBar = NULL;
    if( nDockBarID != 0 ) {
         pDockBar = (CDockBar *)GetControlBar( nDockBarID );
         if( pDockBar == NULL ) {
             // We're trying to dock to a dock bar that doesn't exist, so just don't do
             // anything.
             return;
         }
         if( !(pBar->m_dwDockStyle & (pDockBar->m_dwStyle & CBRS_ALIGN_ANY)) ) {
             // We don't support docking to a bar of this style, so just don't do
             // anything.
             return;
         }
         ASSERT( pDockBar->IsKindOf( RUNTIME_CLASS( CDockBar ) ) );
         if( lpRect != NULL ) {
            RECT    rectJunk;
            CRect   rectBar;
            pDockBar->GetWindowRect( &rectBar );
            if( rectBar.left == rectBar.right ) {
                rectBar.left--;
                rectBar.right++;
            }
            if( rectBar.top == rectBar.bottom ) {
                rectBar.top--;
                rectBar.bottom++;
            }
            if( !::IntersectRect( &rectJunk, &rectBar, lpRect ) ) {
                // The rectangle and the dock bar identifier don't coincide, so just
                // don't do anything.
                return;
            }
        }
    } else if( lpRect != NULL ){
        CanDock( *lpRect, pBar->m_dwDockStyle, &pDockBar );
    } else {
        CanDock( CRect( 0, 0, 32767, 32767 ), pBar->m_dwDockStyle, &pDockBar );
    }
    if( pDockBar != NULL ) {
        ASSERT( pDockBar->IsKindOf( RUNTIME_CLASS( CDockBar ) ) );
        pDockBar->DockControlBar( pBar, lpRect );
    }
}
Exemple #13
0
//--------------------------------------------------------------------------------------------
void CMRCMDIFrameWndSizeDock::UnFloatInMDIChild(CControlBar* pBar, CPoint point, DWORD dwStyle)
// removes the control bar from an MDI floating window, and then floats the bar
//--------------------------------------------------------------------------------------------
{
	ASSERT(pBar != NULL);
	ASSERT(pBar->IsFloating());
	CMRCMDIFloatWnd * pFloatFrame = (CMRCMDIFloatWnd *)pBar->GetParentFrame();
	ASSERT(pFloatFrame->IsKindOf(RUNTIME_CLASS(CMRCMDIFloatWnd)));

	// point at which to float is ignored at present - use the co-ordinates of the current frame
	CRect rcMDIFloat;
	pFloatFrame->GetWindowRect(&rcMDIFloat);
	point = rcMDIFloat.TopLeft();
	
	// This is basically the code from MFC's CFrameWnd::FloatControlBar(), with the
	// test to avoid destroying/creating the floating frame window removed. 
	// Tried explicitly removing the control bar, but this doesn't work as it destroys the
	// CMDIFloatWnd, which in turn kills the child control bar. So need to create the floating
	// frame first, and then dock into this.  

	ASSERT(m_pFloatingFrameClass != NULL);

	CMiniDockFrameWnd* pDockFrame = CreateFloatingFrame(dwStyle);
	ASSERT(pDockFrame != NULL);
	pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
		SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
	if (pDockFrame->m_hWndOwner == NULL)
		pDockFrame->m_hWndOwner = pBar->m_hWnd;

	CDockBar* pDockBar = (CDockBar*)pDockFrame->GetDlgItem(AFX_IDW_DOCKBAR_FLOAT);
	ASSERT(pDockBar != NULL);
	ASSERT(pDockBar->IsKindOf(RUNTIME_CLASS(CDockBar)));

	ASSERT(pBar->m_pDockSite == this);
	// if this assertion occurred it is because the parent of pBar was not
	//  initially this CFrameWnd when pBar's OnCreate was called
	// (this control bar should have been created with a different
	//  parent initially)

	pDockBar->DockControlBar(pBar);
	pDockFrame->RecalcLayout();
	pDockFrame->ShowWindow(SW_SHOWNA);
	pDockFrame->UpdateWindow();
}
void CGuiDockContext::EndDrag()
{
	CancelLoop();

	if (m_dwOverDockStyle != 0)
	{
		CDockBar* pDockBar = GetDockBar(m_dwOverDockStyle);
		ASSERT(pDockBar != NULL);

		CRect rect = (m_dwOverDockStyle & CBRS_ORIENT_VERT) ?
			m_rectDragVert : m_rectDragHorz;

		UINT uID = _AfxGetDlgCtrlID(pDockBar->m_hWnd);
		if (uID >= AFX_IDW_DOCKBAR_TOP &&
			uID <= AFX_IDW_DOCKBAR_BOTTOM)
		{
					
			m_uMRUDockID = uID;
			m_rectMRUDockPos = rect;
			pDockBar->ScreenToClient(&m_rectMRUDockPos);
		}
	
		// dock it at the specified position, RecalcLayout will snap
		m_pDockSite->DockControlBar(m_pBar, pDockBar, &rect);
		m_pDockSite->RecalcLayout();
	}
	else if ((m_dwStyle & CBRS_SIZE_DYNAMIC) || (HORZF(m_dwStyle) && !m_bFlip) ||
			(VERTF(m_dwStyle) && m_bFlip))
	{
		m_dwMRUFloatStyle = CBRS_ALIGN_TOP | (m_dwDockStyle & CBRS_FLOAT_MULTI);
		m_ptMRUFloatPos = m_rectFrameDragHorz.TopLeft();
		m_pDockSite->FloatControlBar(m_pBar, m_ptMRUFloatPos, m_dwMRUFloatStyle);
	}
	else // vertical float
	{
		m_dwMRUFloatStyle = CBRS_ALIGN_LEFT | (m_dwDockStyle & CBRS_FLOAT_MULTI);
		m_ptMRUFloatPos = m_rectFrameDragVert.TopLeft();
		m_pDockSite->FloatControlBar(m_pBar, m_ptMRUFloatPos, m_dwMRUFloatStyle);
	}
}
Exemple #15
0
void CGuiControlBar::OnActiveWindow()
{
	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_bFloating ))
			{
				int nNumBars=(int)pDockBar->m_arrBars.GetSize();
				for(int i=0; i< nNumBars;i++)
				{
					CGuiControlBar* pBar = (CGuiControlBar*) pDockBar->m_arrBars[i];
					if (HIWORD(pBar) == NULL) continue;
					if (!pBar->IsVisible()) continue;
					if (!pBar->IsKindOf(RUNTIME_CLASS(CGuiControlBar))) continue;
					if (pBar != this)
					{
						pBar->m_bOldActive=FALSE;
						pBar->m_bActive=FALSE;
						pBar->m_bForcepaint=TRUE;
						pBar->SendMessage(WM_NCPAINT);
						pBar->m_bForcepaint=FALSE;
					}
					else
					{
						m_bOldActive=m_bActive;
						m_bActive=TRUE;
						m_bForcepaint=TRUE;
						SendMessage(WM_NCPAINT);
						m_bForcepaint=FALSE;
						

					}
				}
			}
	}
}
Exemple #16
0
// dock bars will be created in the order specified by dwDockBarMap
// this also controls which gets priority during layout
// this order can be changed by calling EnableDocking repetitively
// with the exact order of priority
void CFrameWnd::EnableDocking(DWORD dwDockStyle)
{
	// must be CBRS_ALIGN_XXX or CBRS_FLOAT_MULTI only
	ASSERT((dwDockStyle & ~(CBRS_ALIGN_ANY|CBRS_FLOAT_MULTI)) == 0);

	m_pFloatingFrameClass = RUNTIME_CLASS(CMiniDockFrameWnd);
	for (int i = 0; i < 4; i++)
	{
		if (dwDockBarMap[i][1] & dwDockStyle & CBRS_ALIGN_ANY)
		{
			CDockBar* pDock = (CDockBar*)GetControlBar(dwDockBarMap[i][0]);
			if (pDock == NULL)
			{
				pDock = new CDockBar;
				if (!pDock->Create(this,
					WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE |
						dwDockBarMap[i][1], dwDockBarMap[i][0]))
				{
					AfxThrowResourceException();
				}
			}
		}
	}
}
void CFrameWnd::FloatControlBar( CControlBar *pBar, CPoint pt, DWORD dwStyle )
/****************************************************************************/
{
    ASSERT( pBar != NULL );
    if( pBar->IsFloating() && !(pBar->m_pDockBar->GetBarStyle() & CBRS_FLOAT_MULTI) ) {
        CFrameWnd *pFrame = pBar->GetParentFrame();
        pFrame->SetWindowPos( NULL, pt.x, pt.y, 0, 0,
                              SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER );
    } else {
        CMiniDockFrameWnd *pFrame = CreateFloatingFrame( dwStyle );
        ASSERT( pFrame != NULL );
        CDockBar *pDockBar = (CDockBar *)pFrame->GetDlgItem( AFX_IDW_DOCKBAR_FLOAT );
        ASSERT( pDockBar != NULL );
        ASSERT( pDockBar->IsKindOf( RUNTIME_CLASS( CDockBar ) ) );
        pDockBar->DockControlBar( pBar );
        if( pt.x != CW_USEDEFAULT && pt.y != CW_USEDEFAULT ) {
            pFrame->SetWindowPos( NULL, pt.x, pt.y, 0, 0,
                                  SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER );
        }
        pFrame->ShowWindow( SW_SHOW );
        pFrame->UpdateWindow();
        RecalcLayout();
    }
}
Exemple #18
0
void COXDragDockContext::EndDrag()
{
    CancelDrag();
	if (m_ptStart == m_ptLast)
		return;
	
	m_dwOverDockStyle = m_bForceFrame ? 0 : CanDock();
	if (m_dwOverDockStyle != 0)
	{
		// dockbar we're going to dock at.
		CDockBar* pDockBar = GetDockBar();
        ASSERT(pDockBar != NULL);
    
        // check the original dockbar - if a valid CSizeDockBar...
		// work out the row number.
		CDockBar* pOrigDockBar = m_pBar->m_pDockBar;
		int nOrigCheckSum = -1;
		if (pOrigDockBar != NULL && 
			pOrigDockBar->IsKindOf(RUNTIME_CLASS(COXSizeDockBar)))
			nOrigCheckSum = ((COXSizeDockBar*)pOrigDockBar)->CheckSumBars();

		// Now we're going to actually dock the window.
		
		// Update the appropriate size in the control bar.
		if (HORZF(m_dwOverDockStyle)) 
		{
			((COXSizeControlBar*)m_pBar)->m_HorzDockSize = m_rectDragDock.Size();
		}
		else
		{
			((COXSizeControlBar*)m_pBar)->m_VertDockSize = m_rectDragDock.Size();
		}
		
        m_pDockSite->DockControlBar(m_pBar, pDockBar, m_rectDragDock);
        
		// if into a sizeable dockbar (always we be !), then adjust other bars in the same row
		// to attempt to maintain size
		if (pDockBar->IsKindOf(RUNTIME_CLASS(COXSizeDockBar)))
		{
			if (pOrigDockBar != pDockBar || 
				((COXSizeDockBar*)pDockBar)->CheckSumBars() != nOrigCheckSum)
			{
				((COXSizeDockBar*)pDockBar)->AdjustForNewBar(m_pBar);
			}
			// force RecalcLayout below to adjust sizes always for the bar into 
			// which we have docked  - this is needed as if the bar doesn't 
			// actually changed position in the array, but has changed size 
			// (because the docking algorithm above guess the size wrong, then 
			// we need to set it back again.
			((COXSizeDockBar*)pDockBar)->m_CountBars = 0;			
		}
		// This RecalcLayout is what will adjust the size.
		m_pDockSite->RecalcLayout();
	}
    else
	{
    	m_ptMRUFloatPos = m_rectFrameDragHorz.TopLeft();
		m_pDockSite->FloatControlBar(m_pBar, m_rectFrameDragHorz.TopLeft(),
			CBRS_ALIGN_TOP | (m_dwDockStyle & CBRS_FLOAT_MULTI));
		m_pBar->SendMessage(WM_OX_APP_AFTERFLOAT_MSG);
		
		// set flag to indicate user has moved the bar - done as a style flag on the window.
		CWnd* pFrameWnd = m_pBar->GetParentFrame();
		ASSERT(pFrameWnd->IsKindOf(RUNTIME_CLASS(CMiniDockFrameWnd)));
		pFrameWnd->ModifyStyle(0, CBRS_MOVED_BY_USER);		
	}
}
Exemple #19
0
//-----------------------------------------------------------------------------------------------------
void CMRCMDIFrameWndSizeDock::FloatControlBarInMDIChild(CControlBar* pBar, CPoint point, DWORD dwStyle)
// float a control bar in an MDI Child window
// pBar = bar to float
// point = position in screen co-ordinates
//-----------------------------------------------------------------------------------------------------
{
	ASSERT(pBar != NULL);

	// point is in screen co-ords - map to client
	::ScreenToClient(m_hWndMDIClient, &point);

	// clip to client MDI client rectangle - ensures it's going to be visible
	CRect rcMDIClient;
	::GetClientRect(m_hWndMDIClient, &rcMDIClient);
	point.x = min (point.x, rcMDIClient.right - 32);
	point.x = max (point.x, rcMDIClient.left);		
	point.y = min (point.y, rcMDIClient.bottom - 20);
	point.y = max (point.y, rcMDIClient.top);		
	
	// If the bar is already floating in an MDI child, then just move it
	// MFC has a similar optimization for CMiniDockFrameWnd 
	if (pBar->m_pDockSite != NULL && pBar->m_pDockBar != NULL)
	{
		CDockBar* pDockBar = pBar->m_pDockBar;
		ASSERT(pDockBar->IsKindOf(RUNTIME_CLASS(CDockBar)));
		CFrameWnd* pDockFrame = (CFrameWnd*)pDockBar->GetParent();
		ASSERT(pDockFrame != NULL);
		ASSERT(pDockFrame->IsKindOf(RUNTIME_CLASS(CFrameWnd)));
		if (pDockFrame->IsKindOf(RUNTIME_CLASS(CMRCMDIFloatWnd)))
		{
		 	// already a floating as an MDI child, so just move it.
			if (pDockBar->m_bFloating && pDockBar->GetDockedCount() == 1 &&
				(dwStyle & pDockBar->m_dwStyle & CBRS_ALIGN_ANY) != 0)
		 	{
				pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
							SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
				return;
			}
		}
	}

	// Create a CMRCMDIFloatWnd, and dock the bar into it.
	CMRCMDIFloatWnd * pDockFrame = (CMRCMDIFloatWnd *)(RUNTIME_CLASS(CMRCMDIFloatWnd))->CreateObject();
	ASSERT(pDockFrame != NULL);
	if (!pDockFrame->Create(this, dwStyle))
		AfxThrowResourceException();
	
	pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
		SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
	
	if (pDockFrame->m_hWndOwner == NULL)
		pDockFrame->m_hWndOwner = pBar->m_hWnd;

	// Gets the dockbar created by the CMRCMDIFloatWnd
	CDockBar* pDockBar = (CDockBar*)pDockFrame->GetDlgItem(AFX_IDW_DOCKBAR_FLOAT);
	ASSERT(pDockBar != NULL);
	ASSERT(pDockBar->IsKindOf(RUNTIME_CLASS(CDockBar)));

	ASSERT(pBar->m_pDockSite == this);
	// if this assertion occurred it is because the parent of pBar was not
	//  initially this CFrameWnd when pBar's OnCreate was called
	// (this control bar should have been created with a different
	//  parent initially)

	pDockBar->DockControlBar(pBar);
	pDockFrame->RecalcLayout();
	pDockFrame->ShowWindow(SW_SHOWNA);
	pDockFrame->UpdateWindow(); 
}	
Exemple #20
0
void CFrameWnd::FloatControlBar(CControlBar* pBar, CPoint point, DWORD dwStyle)
{
	ASSERT(pBar != NULL);

	// if the bar is already floating and the dock bar only contains this
	// bar and same orientation then move the window rather than recreating
	// the frame
	if (pBar->m_pDockSite != NULL && pBar->m_pDockBar != NULL)
	{
		CDockBar* pDockBar = pBar->m_pDockBar;
		ASSERT_KINDOF(CDockBar, pDockBar);
		if (pDockBar->m_bFloating && pDockBar->GetDockedCount() == 1 &&
			(dwStyle & pDockBar->m_dwStyle & CBRS_ALIGN_ANY) != 0)
		{
			CMiniDockFrameWnd* pDockFrame =
				(CMiniDockFrameWnd*)pDockBar->GetParent();
			ASSERT(pDockFrame != NULL);
			ASSERT_KINDOF(CMiniDockFrameWnd, pDockFrame);
			pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
				SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
			pDockFrame->RecalcLayout(TRUE);
			pDockFrame->UpdateWindow();
			return;
		}
	}

	if (pBar->m_dwStyle & CBRS_SIZE_DYNAMIC)
	{
		dwStyle |= CBRS_SIZE_DYNAMIC;
		if (dwStyle & CBRS_ORIENT_VERT)
		{
			dwStyle &= ~CBRS_ALIGN_ANY;
			dwStyle |= CBRS_ALIGN_TOP;
		}
	}

	CMiniDockFrameWnd* pDockFrame = CreateFloatingFrame(dwStyle);
	ASSERT(pDockFrame != NULL);
	pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
		SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
	if (pDockFrame->m_hWndOwner == NULL)
		pDockFrame->m_hWndOwner = pBar->m_hWnd;

	CDockBar* pDockBar = (CDockBar*)pDockFrame->GetDlgItem(AFX_IDW_DOCKBAR_FLOAT);
	ASSERT(pDockBar != NULL);
	ASSERT_KINDOF(CDockBar, pDockBar);

	ASSERT(pBar->m_pDockSite == this);
	// if this assertion occurred it is because the parent of pBar was not
	//  initially this CFrameWnd when pBar's OnCreate was called
	// (this control bar should have been created with a different
	//  parent initially)

	pDockBar->DockControlBar(pBar);
	pDockFrame->RecalcLayout(TRUE);
	if (GetWindowLong(pBar->m_hWnd, GWL_STYLE) & WS_VISIBLE)
	{
		pDockFrame->ShowWindow(SW_SHOWNA);
		pDockFrame->UpdateWindow();
	}
}
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;
}
Exemple #22
0
CSize CCoolDialogBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
{
	if(IsFloating())
		return m_sizeFloat;

	CDockBar *pDockBar = (CDockBar*)GetParent();
	ASSERT_KINDOF(CDockBar , pDockBar);

	CRect dockrc;
	pDockBar->GetWindowRect(dockrc);
	//m_pDockSite->GetControlBar(m_nDockBarID)->GetWindowRect(dockrc);

	CSize sz = (bHorz ? m_sizeHorz : m_sizeVert);

	int width = (bHorz ? sz.cx : sz.cy);
	int height = (bHorz ? sz.cy : sz.cx);
		
	if (bStretch) {
		width = 32767;
	} else {
		int own;
		vector <CCoolDialogBar *> row = AllVisibleNeighbours(&own);
		for (int i = 0; i < row.size(); i++) {
			CSize sz2 = (bHorz ? row[i]->m_sizeHorz : row[i]->m_sizeVert);
			height = max(height, (bHorz ? sz2.cy : sz2.cx));
		}
		if (row.size() == 1) {
			width = (bHorz ? dockrc.Width() : dockrc.Height());
		} else if (own + 1 < row.size()) {
			CRect myrc, rc;
			GetWindowRect(myrc);
			row[own + 1]->GetWindowRect(rc);
			if (bHorz)
				width = rc.left - myrc.left + 2;
			else
				width = rc.top - myrc.top + 1;
		} else {
			CRect myrc;
			GetWindowRect(myrc);
			if (bHorz)
				width = dockrc.right - myrc.left - 1;
			else
				width = dockrc.bottom - myrc.top + 1;
		}
	}
		
	if (bHorz)
		sz = CSize(width, height);
	else
		sz = CSize(height, width);

	sz.cx = max(sz.cx, m_sizeMin.cx);
	sz.cy = max(sz.cy, m_sizeMin.cy);

	if (bHorz)
		m_sizeHorz = sz;
	else
		m_sizeVert = sz;

	return sz;
}
//*******************************************************************************************
BOOL CBCGOleDocIPFrameWnd::PreTranslateMessage(MSG* pMsg) 
{
	switch (pMsg->message)
	{
	case WM_KEYDOWN:
		if (!CBCGFrameImpl::IsHelpKey (pMsg) && 
			m_Impl.ProcessKeyboard ((int) pMsg->wParam))
		{
			return TRUE;
		}
		break;

	case WM_LBUTTONDOWN:
	case WM_LBUTTONDBLCLK:
	case WM_RBUTTONDOWN:
	case WM_RBUTTONUP:
	case WM_RBUTTONDBLCLK:
	case WM_MBUTTONDOWN:
	case WM_MBUTTONUP:
	case WM_MBUTTONDBLCLK:
		{
			CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam));
			CWnd* pWnd = CWnd::FromHandle(pMsg->hwnd);

			if (!::IsWindow (pMsg->hwnd))
			{
				return TRUE;
			}

			if (pWnd != NULL)
			{
				pWnd->ClientToScreen (&pt);
			}

			if (m_Impl.ProcessMouseClick (pMsg->message, pt, pMsg->hwnd))
			{
				return TRUE;
			}

			if (!::IsWindow (pMsg->hwnd))
			{
				return TRUE;
			}

			if (pMsg->message == WM_RBUTTONUP &&
				!CBCGToolBar::IsCustomizeMode ())
			{
				//---------------------------------------
				// Activate the control bar context menu:
				//---------------------------------------
				CDockBar* pBar = DYNAMIC_DOWNCAST(CDockBar, pWnd);
				if (pBar != NULL)
				{
					CPoint pt;

					pt.x = BCG_GET_X_LPARAM(pMsg->lParam);
					pt.y = BCG_GET_Y_LPARAM(pMsg->lParam);
					pBar->ClientToScreen(&pt);

					SendMessage (BCGM_TOOLBARMENU,
								(WPARAM) GetSafeHwnd (),
								MAKELPARAM (pt.x, pt.y));
				}
			}
		}
		break;

	case WM_NCLBUTTONDOWN:
	case WM_NCLBUTTONUP:
	case WM_NCRBUTTONDOWN:
	case WM_NCRBUTTONUP:
	case WM_NCMBUTTONDOWN:
	case WM_NCMBUTTONUP:
		if (m_Impl.ProcessMouseClick (pMsg->message,
			CPoint (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)),
			pMsg->hwnd))
		{
			return TRUE;
		}
		break;

	case WM_MOUSEMOVE:
		{
			CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam));
			CWnd* pWnd = CWnd::FromHandle(pMsg->hwnd);

			if (pWnd != NULL)
			{
				pWnd->ClientToScreen (&pt);
			}

			if (m_Impl.ProcessMouseMove (pt))
			{
				return TRUE;
			}
		}
	}

	return CFrameWnd::PreTranslateMessage(pMsg);
}