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; }
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 ); }
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 ); } }
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; }
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; }