//------------------------------------------------------------------------// BOOL CBCGPGlobalUtils::IsWndCanFloatMulti (CWnd* pWnd) const { CBCGPControlBar* pBar = NULL; CBCGPMiniFrameWnd* pMiniFrame = DYNAMIC_DOWNCAST (CBCGPMiniFrameWnd, pWnd); if (pMiniFrame != NULL) { pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, pMiniFrame->GetControlBar ()); } else { pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, pWnd); } if (pBar == NULL) { return FALSE; } if (pBar->IsTabbed ()) { CWnd* pParentMiniFrame = pBar->GetParentMiniFrame (); // tabbed bar that is floating in multi miniframe if (pParentMiniFrame != NULL && pParentMiniFrame->IsKindOf (RUNTIME_CLASS (CBCGPMultiMiniFrameWnd))) { return TRUE; } } return ((pBar->GetBarStyle () & CBRS_FLOAT_MULTI) != 0); }
//--------------------------------------------------------------------------------------- void CBCGPAutoHideToolBar::SetActiveInGroup (BOOL bActive) { CBCGPControlBar::SetActiveInGroup (bActive); if (bActive) { CObList lst; m_pDockBarRow->GetGroupFromBar (this, lst); for (POSITION pos = lst.GetHeadPosition (); pos != NULL;) { CBCGPControlBar* pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, lst.GetNext (pos)); ASSERT_VALID (pBar); if (pBar != this) { pBar->SetActiveInGroup (FALSE); } } CRect rect; rect.SetRectEmpty (); m_pParentDockBar->RepositionBars (rect); } }
CSize CBCGPReBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); // the union of the band rectangles is the total bounding rect int nCount = (int) DefWindowProc(RB_GETBANDCOUNT, 0, 0); REBARBANDINFO rbBand; rbBand.cbSize = globalData.GetRebarBandInfoSize (); int nTemp; // sync up hidden state of the bands for (nTemp = nCount; nTemp--; ) { rbBand.fMask = RBBIM_CHILD|RBBIM_STYLE; VERIFY(DefWindowProc(RB_GETBANDINFO, nTemp, (LPARAM)&rbBand)); CBCGPControlBar* pBar = DYNAMIC_DOWNCAST(CBCGPControlBar, CWnd::FromHandlePermanent(rbBand.hwndChild)); BOOL bWindowVisible; if (pBar != NULL) bWindowVisible = pBar->IsVisible(); else bWindowVisible = (::GetWindowLong(rbBand.hwndChild, GWL_STYLE) & WS_VISIBLE) != 0; BOOL bBandVisible = (rbBand.fStyle & RBBS_HIDDEN) == 0; if (bWindowVisible != bBandVisible) VERIFY(DefWindowProc(RB_SHOWBAND, nTemp, bWindowVisible)); } // determine bounding rect of all visible bands CRect rectBound; rectBound.SetRectEmpty(); for (nTemp = nCount; nTemp--; ) { rbBand.fMask = RBBIM_STYLE; VERIFY(DefWindowProc(RB_GETBANDINFO, nTemp, (LPARAM)&rbBand)); if ((rbBand.fStyle & RBBS_HIDDEN) == 0) { CRect rect; VERIFY(DefWindowProc(RB_GETRECT, nTemp, (LPARAM)&rect)); rectBound |= rect; } } // add borders as part of bounding rect if (!rectBound.IsRectEmpty()) { CRect rect; rect.SetRectEmpty(); CalcInsideRect(rect, bHorz); rectBound.right -= rect.Width(); rectBound.bottom -= rect.Height(); } bStretch = 1; return CSize((bHorz && bStretch) ? 32767 : rectBound.Width(), (!bHorz && bStretch) ? 32767 : rectBound.Height()); }
BOOL CBCGPReBar::_AddBar(CWnd* pBar, REBARBANDINFO* pRBBI) { ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); ASSERT(pBar != NULL); ASSERT(::IsWindow(pBar->m_hWnd)); pRBBI->cbSize = globalData.GetRebarBandInfoSize (); pRBBI->fMask |= RBBIM_CHILD | RBBIM_CHILDSIZE; pRBBI->hwndChild = pBar->m_hWnd; CSize size; CBCGPControlBar* pTemp = DYNAMIC_DOWNCAST(CBCGPControlBar, pBar); if (pTemp != NULL) { size = pTemp->CalcFixedLayout(FALSE, m_dwStyle & CBRS_ORIENT_HORZ); pTemp->SetBCGStyle(pTemp->GetBCGStyle () & ~(CBRS_BCGP_AUTOHIDE | CBRS_BCGP_FLOAT)); pTemp->m_bIsRebarPane = TRUE; } else { CRect rect; pBar->GetWindowRect(&rect); size = rect.Size(); } //WINBUG: COMCTL32.DLL is off by 4 pixels in its sizing logic. Whatever // is specified as the minimum size, the system rebar will allow that band // to be 4 actual pixels smaller! That's why we add 4 to the size here. pRBBI->cxMinChild = size.cx; pRBBI->cyMinChild = size.cy; BOOL bResult = (BOOL)DefWindowProc(RB_INSERTBAND, (WPARAM)-1, (LPARAM)pRBBI); CFrameWnd* pFrameWnd = BCGPGetParentFrame(this); if (pFrameWnd != NULL) pFrameWnd->RecalcLayout(); return bResult; }
LRESULT CBCGPReBar::OnShowBand(WPARAM wParam, LPARAM) { LRESULT lResult = Default(); if (lResult) { // keep window visible state in sync with band visible state REBARBANDINFO rbBand; rbBand.cbSize = globalData.GetRebarBandInfoSize (); rbBand.fMask = RBBIM_CHILD|RBBIM_STYLE; VERIFY(DefWindowProc(RB_GETBANDINFO, wParam, (LPARAM)&rbBand)); CBCGPControlBar* pBar = DYNAMIC_DOWNCAST(CBCGPControlBar, CWnd::FromHandlePermanent(rbBand.hwndChild)); BOOL bWindowVisible; if (pBar != NULL) bWindowVisible = pBar->IsVisible(); else bWindowVisible = (::GetWindowLong(rbBand.hwndChild, GWL_STYLE) & WS_VISIBLE) != 0; BOOL bBandVisible = (rbBand.fStyle & RBBS_HIDDEN) == 0; if (bWindowVisible != bBandVisible) VERIFY(::ShowWindow(rbBand.hwndChild, bBandVisible ? SW_SHOW : SW_HIDE)); } return lResult; }
//--------------------------------------------------------------------------------------// void CBCGPDragFrameImpl::Init (CWnd* pDraggedWnd) { ASSERT_VALID (pDraggedWnd); m_pDraggedWnd = pDraggedWnd; CWnd* pDockSite = NULL; if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd))) { CBCGPMiniFrameWnd* pMiniFrame = DYNAMIC_DOWNCAST (CBCGPMiniFrameWnd, m_pDraggedWnd); pDockSite = pMiniFrame->GetParent (); } else if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPControlBar))) { CBCGPControlBar* pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, m_pDraggedWnd); ASSERT_VALID (pBar); CBCGPMiniFrameWnd* pParentMiniFrame = pBar->GetParentMiniFrame (); if (pParentMiniFrame != NULL) { pDockSite = pParentMiniFrame->GetParent (); } else { pDockSite = pBar->GetDockSite (); } } m_pDockManager = globalUtils.GetDockManager (pDockSite); if (globalUtils.m_bDialogApp) { return; } ASSERT(m_pDockManager != NULL); }
//******************************************************************************* BOOL CBCGPBaseTabbedBar::FloatTab (CWnd* pBar, int nTabID, BCGP_DOCK_METHOD dockMethod, BOOL bHide) { ASSERT_VALID (this); ASSERT_VALID (pBar); ASSERT_VALID (m_pTabWnd); CString strWndText; pBar->GetWindowText (strWndText); if (strWndText.IsEmpty ()) { if (m_pTabWnd->GetTabLabel (nTabID, strWndText)) { pBar->SetWindowText (strWndText); } } m_pTabWnd->RemoveTab (nTabID); if (dockMethod == BCGP_DM_MOUSE) { m_pTabWnd->SendMessage (WM_LBUTTONUP, 0, 0); } CBCGPDockingControlBar* pDockingBar = DYNAMIC_DOWNCAST (CBCGPDockingControlBar, pBar); if (pDockingBar != NULL) { pDockingBar->StoreRecentTabRelatedInfo (); } if (dockMethod == BCGP_DM_DBL_CLICK && pDockingBar != NULL) { CBCGPMultiMiniFrameWnd* pParentMiniFrame = DYNAMIC_DOWNCAST (CBCGPMultiMiniFrameWnd, GetParentMiniFrame ()); if (pParentMiniFrame != NULL) { pParentMiniFrame->DockRecentControlBarToMainFrame (pDockingBar); return TRUE; } else if (m_hDefaultSlider != NULL && IsWindow (m_hDefaultSlider)) { CBCGPMultiMiniFrameWnd* pRecentMiniFrame = DYNAMIC_DOWNCAST (CBCGPMultiMiniFrameWnd, CWnd::FromHandlePermanent (pDockingBar->m_recentDockInfo.m_hRecentMiniFrame)); if (pRecentMiniFrame != NULL && pRecentMiniFrame->AddRecentControlBar (pDockingBar)) { return TRUE; } } } if (pBar->IsKindOf (RUNTIME_CLASS (CBCGPControlBar))) { CBCGPControlBar* pControlBar = DYNAMIC_DOWNCAST (CBCGPControlBar, pBar); ASSERT_VALID (pControlBar); pControlBar->FloatControlBar (pControlBar->m_recentDockInfo.m_rectRecentFloatingRect, dockMethod, !bHide); return TRUE; } return FALSE; }
//*********************************************************************************** BOOL CBCGPBaseTabbedBar::AddTab (CWnd* pNewBar, BOOL bVisible, BOOL bSetActive, BOOL bDetachable) { ASSERT_VALID (this); ASSERT_VALID (m_pTabWnd); ASSERT_VALID (pNewBar); if (pNewBar->IsKindOf (RUNTIME_CLASS (CBCGPBaseTabbedBar))) { CBCGPBaseTabbedBar* pTabbedControlBar = DYNAMIC_DOWNCAST (CBCGPBaseTabbedBar, pNewBar); // it's false when the tabbed bar is added from miniframe to docksite BOOL bSetInfoForSlider = (GetParentMiniFrame () != NULL); ASSERT_VALID (pTabbedControlBar); CBCGPBaseTabWnd* pWndTab = pTabbedControlBar->GetUnderlinedWindow (); ASSERT_VALID (pWndTab); int nTabsNum = pWndTab->GetTabsNum (); ASSERT (nTabsNum > 0); for (int i = 0; i < nTabsNum; i++) { CBCGPBaseControlBar* pWnd = DYNAMIC_DOWNCAST (CBCGPBaseControlBar, pWndTab->GetTabWnd (i)); ASSERT_VALID (pWnd); BOOL bVisible = pWndTab->IsTabVisible (i); BOOL bDetachable = pWndTab->IsTabDetachable (i); pWnd->EnableGripper (FALSE); if (!AddTab (pWnd, bVisible, bVisible, bDetachable)) { ASSERT (FALSE); } CBCGPDockingControlBar* pDockingBar = DYNAMIC_DOWNCAST (CBCGPDockingControlBar, pWnd); if (pDockingBar != NULL) { pDockingBar->m_recentDockInfo.SetInfo (bSetInfoForSlider, pTabbedControlBar->m_recentDockInfo); } } pWndTab->RemoveAllTabs (); pNewBar->DestroyWindow (); // stop processing - this function will be called // from AttachToTabWnd return FALSE; } else { if (pNewBar->IsKindOf (RUNTIME_CLASS (CBCGPControlBar))) { CBCGPControlBar* pNewControlBar = DYNAMIC_DOWNCAST (CBCGPControlBar, pNewBar); ASSERT_VALID (pNewControlBar); CWnd* pOldParent = pNewControlBar->GetParent (); pNewControlBar->OnBeforeChangeParent (m_pTabWnd, TRUE); pNewControlBar->SetParent (m_pTabWnd); pNewControlBar->OnAfterChangeParent (pOldParent); if (pNewControlBar->IsKindOf (RUNTIME_CLASS (CBCGPDockingControlBar))) { ((CBCGPDockingControlBar*) pNewControlBar)->EnableGripper (FALSE); } } CString strText; pNewBar->GetWindowText (strText); m_pTabWnd->AddTab (pNewBar, strText, bSetActive, bDetachable); int iTab = m_pTabWnd->GetTabsNum () - 1; m_pTabWnd->SetTabHicon (iTab, pNewBar->GetIcon (FALSE)); m_pTabWnd->EnableTabDetach (iTab, bDetachable); if (bVisible) { if (bSetActive) { m_pTabWnd->SetActiveTab (iTab); } } else { ASSERT (!bSetActive); m_pTabWnd->ShowTab (iTab, FALSE); } } return TRUE; }
//------------------------------------------------------------------------// void CBCGPGlobalUtils::CalcExpectedDockedRect (CBCGPBarContainerManager& barContainerManager, CWnd* pWndToDock, CPoint ptMouse, CRect& rectResult, BOOL& bDrawTab, CBCGPDockingControlBar** ppTargetBar) { ASSERT (ppTargetBar != NULL); DWORD dwAlignment = CBRS_ALIGN_ANY; BOOL bTabArea = FALSE; BOOL bCaption = FALSE; bDrawTab = FALSE; *ppTargetBar = NULL; rectResult.SetRectEmpty (); if (GetKeyState (VK_CONTROL) < 0) { return; } if (!GetCBAndAlignFromPoint (barContainerManager, ptMouse, ppTargetBar, dwAlignment, bTabArea, bCaption) || *ppTargetBar == NULL) { return; } CBCGPControlBar* pBar = NULL; if (pWndToDock->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd))) { CBCGPMiniFrameWnd* pMiniFrame = DYNAMIC_DOWNCAST (CBCGPMiniFrameWnd, pWndToDock); ASSERT_VALID (pMiniFrame); pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, pMiniFrame->GetFirstVisibleBar ()); } else { pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, pWndToDock); } if (*ppTargetBar != NULL) { DWORD dwTargetEnabledAlign = (*ppTargetBar)->GetEnabledAlignment (); DWORD dwTargetCurrentAlign = (*ppTargetBar)->GetCurrentAlignment (); BOOL bTargetBarIsFloating = ((*ppTargetBar)->GetParentMiniFrame () != NULL); if (pBar != NULL) { if (pBar->GetEnabledAlignment () != dwTargetEnabledAlign && bTargetBarIsFloating || (pBar->GetEnabledAlignment () & dwTargetCurrentAlign) == 0 && !bTargetBarIsFloating) { return; } } } if (bTabArea || bCaption) { // can't make tab on miniframe bDrawTab = ((*ppTargetBar) != NULL); if (bDrawTab) { bDrawTab = (*ppTargetBar)->CanBeAttached () && CanBeAttached (pWndToDock) && pBar != NULL && ((*ppTargetBar)->GetEnabledAlignment () == pBar->GetEnabledAlignment ()); } if (!bDrawTab) { return; } } if ((*ppTargetBar) != NULL && (*ppTargetBar)->GetParentMiniFrame () != NULL && !IsWndCanFloatMulti (pWndToDock)) { bDrawTab = FALSE; return; } if ((*ppTargetBar) != NULL && pWndToDock->IsKindOf (RUNTIME_CLASS (CBCGPBaseControlBar)) && !(*ppTargetBar)->CanAcceptBar ((CBCGPBaseControlBar*) pWndToDock)) { bDrawTab = FALSE; return; } CRect rectOriginal; (*ppTargetBar)->GetWindowRect (rectOriginal); if ((*ppTargetBar) == pWndToDock || pWndToDock->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd)) && (*ppTargetBar)->GetParentMiniFrame () == pWndToDock) { bDrawTab = FALSE; return; } CRect rectInserted; CRect rectSlider; DWORD dwSliderStyle; CSize sizeMinOriginal (0, 0); CSize sizeMinInserted (0, 0); pWndToDock->GetWindowRect (rectInserted); if ((dwAlignment & pBar->GetEnabledAlignment ()) != 0 || CBCGPDockManager::m_bIgnoreEnabledAlignment) { barContainerManager.CalcRects (rectOriginal, rectInserted, rectSlider, dwSliderStyle, dwAlignment, sizeMinOriginal, sizeMinInserted); rectResult = rectInserted; } }
//--------------------------------------------------------------------------------------// void CBCGPDragFrameImpl::MoveDragFrame (BOOL bForceMove) { ASSERT_VALID (m_pDraggedWnd); m_pFinalTargetBar = NULL; if (m_pDraggedWnd == NULL || m_pDockManager == NULL) { return; } if (m_pWndDummy == NULL) { m_pWndDummy = new CBCGPDummyDockingControlBar; m_pWndDummy->CreateEx (0, _T (""), BCGCBProGetTopLevelFrame (m_pDraggedWnd), CRect (0, 0, 0, 0), FALSE, BCGP_DUMMY_WND_ID, WS_CHILD); } CSize szSencitivity = CBCGPDockingControlBar::GetDragSencitivity (); CPoint ptMouse; GetCursorPos (&ptMouse); CPoint ptOffset = ptMouse - m_ptHot; if (abs (ptOffset.x) < szSencitivity.cx && abs (ptOffset.y) < szSencitivity.cy && m_rectDrag.IsRectEmpty () && !bForceMove) { return; } m_bDragStarted = TRUE; m_pDockManager->LockUpdate (TRUE); CRect rectOld = m_rectExpectedDocked.IsRectEmpty () ? m_rectDrag : m_rectExpectedDocked; BOOL bFirstTime = FALSE; if (m_rectDrag.IsRectEmpty ()) { if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd))) { m_pDraggedWnd->GetWindowRect (m_rectDrag); } else if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPControlBar))) { CBCGPControlBar* pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, m_pDraggedWnd); ASSERT_VALID (pBar); m_pDraggedWnd->GetWindowRect (m_rectDrag); // if the bar is docked then the floating rect has to be set to recent floating rect if (pBar->GetParentMiniFrame () == NULL) { m_rectDrag.right = m_rectDrag.left + pBar->m_recentDockInfo.m_rectRecentFloatingRect.Width (); m_rectDrag.bottom = m_rectDrag.top + pBar->m_recentDockInfo.m_rectRecentFloatingRect.Height (); } if (!m_rectDrag.PtInRect (m_ptHot)) { int nOffset = m_rectDrag.left - m_ptHot.x; m_rectDrag.OffsetRect (-nOffset - 5, 0); // offset of mouse pointer // from the drag rect bound } } bFirstTime = TRUE; } BOOL bDrawTab = FALSE; CBCGPDockingControlBar* pOldTargetBar = m_pTargetBar; CRect rectExpected; rectExpected.SetRectEmpty (); CBCGPSmartDockingManager* pSDManager = NULL; BOOL bSDockingIsOn = FALSE; if (m_pDockManager != NULL && (pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL && pSDManager->IsStarted()) { bSDockingIsOn = TRUE; } m_pDockManager->CalcExpectedDockedRect (m_pDraggedWnd, ptMouse, rectExpected, bDrawTab, &m_pTargetBar); if (pOldTargetBar != NULL && m_nInsertedTabID != -1 && (pOldTargetBar != m_pTargetBar || !bDrawTab)) { RemoveTabPreDocking (pOldTargetBar); bFirstTime = TRUE; } BOOL bCanBeAttached = TRUE; if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd))) { } else if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPControlBar))) { CBCGPControlBar* pBar = DYNAMIC_DOWNCAST (CBCGPControlBar, m_pDraggedWnd); bCanBeAttached = pBar->CanBeAttached (); } if (m_pTargetBar != NULL && bCanBeAttached) { CBCGPBaseTabbedBar* pTabbedBar = DYNAMIC_DOWNCAST (CBCGPBaseTabbedBar, m_pTargetBar); if (pTabbedBar != NULL && bDrawTab && (pTabbedBar->GetVisibleTabsNum () > 1 && pTabbedBar->IsHideSingleTab () || pTabbedBar->GetVisibleTabsNum () > 0 && !pTabbedBar->IsHideSingleTab ())) { PlaceTabPreDocking (pTabbedBar, bFirstTime); return; } else if (bDrawTab) { if (m_nInsertedTabID != -1) { return; } if (!bFirstTime) { EndDrawDragFrame (FALSE); } DrawFrameTab (m_pTargetBar, FALSE); m_nInsertedTabID = 1; return; } } m_rectDrag.OffsetRect (ptOffset); m_ptHot = ptMouse; m_rectExpectedDocked = rectExpected; int nNewThickness = m_rectExpectedDocked.IsRectEmpty ()? globalData.m_nDragFrameThiknessFloat : globalData.m_nDragFrameThiknessDock; CRect rectDocked; if (m_rectExpectedDocked.IsRectEmpty ()) { if (!m_rectDrag.PtInRect (ptMouse)) { CPoint ptMiddleRect (m_rectDrag.TopLeft ().x + m_rectDrag.Width () / 2, m_rectDrag.top + 5); CPoint ptOffset = ptMouse - ptMiddleRect; m_rectDrag.OffsetRect (ptOffset); } rectDocked = m_rectDrag; } else { rectDocked = m_rectExpectedDocked; } if (!bSDockingIsOn || !m_rectExpectedDocked.IsRectEmpty ()) { DrawDragFrame (rectOld, rectDocked, bFirstTime, nNewThickness, m_nOldThikness); m_nOldThikness = nNewThickness; } }