BOOL CXTPDockingPaneSplitterWnd::GetAvailableRect(CRect& rcAvail, CRect& rcUnion) { CXTPDockingPaneManager* pManager = GetDockingPaneManager(); if (!pManager) return FALSE; int nSplitterSize = pManager->GetPaintManager()->m_nSplitterSize; BOOL bHoriz = m_pContainer->m_bHoriz; ASSERT(m_pFirst && m_pSecond); if (!m_pFirst || !m_pSecond) return FALSE; CRect rcFirst = m_pFirst->GetPaneWindowRect(); CRect rcSecond = m_pSecond->GetPaneWindowRect(); MINMAXINFO mmiFirst, mmiSecond; m_pFirst->GetMinMaxInfo(&mmiFirst); m_pSecond->GetMinMaxInfo(&mmiSecond); rcAvail.UnionRect(rcFirst, rcSecond); rcUnion = rcAvail; int nGap = pManager->m_nSplitterGap; if (bHoriz) { rcAvail.DeflateRect(max(mmiFirst.ptMinTrackSize.x, nGap), 0, max(mmiSecond.ptMinTrackSize.x + nSplitterSize, nGap), 0); if (rcUnion.Width() > mmiFirst.ptMaxTrackSize.x) rcAvail.right = min(rcAvail.right, rcUnion.left + mmiFirst.ptMaxTrackSize.x); if (rcUnion.Width() > mmiSecond.ptMaxTrackSize.x) rcAvail.left = max(rcAvail.left, rcUnion.right - mmiSecond.ptMaxTrackSize.x - nSplitterSize); if (rcAvail.left >= rcAvail.right) return FALSE; } else { rcAvail.DeflateRect(0, max(mmiFirst.ptMinTrackSize.y, nGap), 0, max(mmiSecond.ptMinTrackSize.y + nSplitterSize, nGap)); if (rcUnion.Height() > mmiFirst.ptMaxTrackSize.y) rcAvail.bottom = min(rcAvail.bottom, rcUnion.top + mmiFirst.ptMaxTrackSize.y); if (rcUnion.Height() > mmiSecond.ptMaxTrackSize.y) rcAvail.top = max(rcAvail.top, rcUnion.bottom - mmiSecond.ptMaxTrackSize.y - nSplitterSize); if (rcAvail.top >= rcAvail.bottom) return FALSE; } return TRUE; }
CRect CXTPDockingPaneSplitterContainer::_CalculateResultDockingRect(BOOL bHoriz, CXTPDockingPaneBaseList& lst, CRect rect, CXTPDockingPaneBase* pPaneI) { CXTPDockingPaneManager* pManager = pPaneI->GetDockingPaneManager(); int nSplitterSize = pManager->GetPaintManager()->m_nSplitterSize; int nTotalLength = 0; int nLengthAvail = 0; _AdjustPanesLength(pManager, lst, rect, bHoriz, FALSE, nTotalLength, nLengthAvail); POSITION pos = lst.GetHeadPosition(); CRect rcPane(rect); while (pos) { CXTPDockingPaneBase* pPane = lst.GetNext(pos); int nLength = -pPane->m_nLength; if (pPane->m_nLength > 0) { nLength = nTotalLength == 0 ? 0 : int((nLengthAvail * pPane->m_nLength) / nTotalLength); nTotalLength -= pPane->m_nLength; nLengthAvail = max(nLengthAvail - nLength, 0); } if (bHoriz) { rcPane.right = pos == NULL ? rect.right : rcPane.left + nLength; if (pPaneI == pPane) break; rcPane.left = rcPane.right + nSplitterSize; } else { rcPane.bottom = pos == NULL ? rect.bottom : rcPane.top + nLength; if (pPaneI == pPane) break; rcPane.top = rcPane.bottom + nSplitterSize; } } return rcPane; }
void CXTPDockingPaneSplitterContainer::OnSizeParent(CWnd* pParent, CRect rect, LPVOID lParam) { CXTPDockingPaneManager* pManager = GetDockingPaneManager(); CXTPDockingPanePaintManager* pPaintManager = pManager->GetPaintManager(); int nSplitterSize = pPaintManager->m_nSplitterSize; int nSplitterIndent = pPaintManager->m_bShowCaption ? pPaintManager->m_nSplitterIndent : 0; CXTPDockingPaneBase* pClient = pManager->GetClientPane(); AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam; m_pDockingSite = pParent; m_rcWindow = rect; BOOL bClientPane = !pManager->m_bHideClient; // getting list of nonempty panes CXTPDockingPaneBaseList lst; POSITION pos = GetHeadPosition(); while (pos) { CXTPDockingPaneBase* pPane = GetNext(pos); if (!pPane->IsEmpty()) lst.AddTail(pPane); if (!bClientPane && pPane->ContainPane(pClient)) bClientPane = TRUE; } if (!lst.IsEmpty() && bClientPane && pManager->m_bHideClient) { pClient->OnSizeParent(pParent, CXTPEmptyRect(), lParam); } if (lst.GetCount() == 0) return; if (lst.GetCount() == 1) { lst.GetHead()->OnSizeParent(pParent, rect, lParam); return; } if (m_bRecalcLayout) return; m_bRecalcLayout = TRUE; //ASSERT(m_lstSpliters.GetCount() == lst.GetCount() - 1); int nTotalLength = 0; int nLengthAvail = 0; _AdjustPanesLength(pManager, lst, rect, m_bHoriz, TRUE, nTotalLength, nLengthAvail); pos = lst.GetHeadPosition(); POSITION posSplitter = m_lstSpliters.GetHeadPosition(); CRect rcPane(rect); while (pos) { CXTPDockingPaneBase* pPane = lst.GetNext(pos); int nLength = -pPane->m_nLength; if (pPane->m_nLength > 0) { nLength = nTotalLength == 0 ? 0 : int((nLengthAvail * pPane->m_nLength) / nTotalLength); nTotalLength -= pPane->m_nLength; nLengthAvail = max(nLengthAvail - nLength, 0); } CRect rcSplitter; if (m_bHoriz) { rcPane.right = pos == NULL ? rect.right : rcPane.left + nLength; rcSplitter.SetRect(rcPane.right - nSplitterIndent, rect.top, rcPane.right + nSplitterSize + nSplitterIndent, rect.bottom); } else { rcPane.bottom = pos == NULL ? rect.bottom : rcPane.top + nLength; rcSplitter.SetRect(rect.left, rcPane.bottom - nSplitterIndent, rect.right, rcPane.bottom + nSplitterSize + nSplitterIndent); } if (lpLayout->hDWP != NULL && posSplitter) { CXTPDockingPaneSplitterWnd* pSplitter = m_lstSpliters.GetNext(posSplitter); if (pSplitter) { rcSplitter.IntersectRect(rcSplitter, rect); pSplitter->SetWindowPos(&CWnd::wndBottom, rcSplitter.left, rcSplitter.top, rcSplitter.Width(), rcSplitter.Height(), 0); pSplitter->Invalidate(FALSE); } } pPane->OnSizeParent(pParent, rcPane, lParam); if (m_bHoriz) { rcPane.left = rcPane.right + nSplitterSize; } else { rcPane.top = rcPane.bottom + nSplitterSize; } } m_bRecalcLayout = FALSE; }