const BOOL CSizingControlBar::IsSideTracking() const { // don't call this when not tracking ASSERT(m_bTracking && !IsFloating()); return (m_htEdge == HTLEFT || m_htEdge == HTRIGHT) ? IsHorzDocked() : IsVertDocked(); }
void CSizingControlBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) { UNUSED_ALWAYS(bCalcValidRects); #ifndef _SCB_REPLACE_MINIFRAME // Enable diagonal resizing for floating miniframe if (IsFloating()) { CFrameWnd* pFrame = GetParentFrame(); if (pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd))) { DWORD dwStyle = ::GetWindowLong(pFrame->m_hWnd, GWL_STYLE); if ((dwStyle & MFS_4THICKFRAME) != 0) { pFrame->ModifyStyle(MFS_4THICKFRAME, 0); // clear GetParent()->ModifyStyle(0, WS_CLIPCHILDREN); } } } #endif _SCB_REPLACE_MINIFRAME // compute the the client area m_dwSCBStyle &= ~SCBS_EDGEALL; if (!IsFloating() && m_pDockBar != NULL) { CSCBArray arrSCBars; GetRowSizingBars(arrSCBars); for (int i = 0; i < arrSCBars.GetSize(); i++) if (arrSCBars[i] == this) { if (i > 0) m_dwSCBStyle |= IsHorzDocked() ? SCBS_EDGELEFT : SCBS_EDGETOP; if (i < arrSCBars.GetSize() - 1) m_dwSCBStyle |= IsHorzDocked() ? SCBS_EDGERIGHT : SCBS_EDGEBOTTOM; } } NcCalcClient(&lpncsp->rgrc[0], m_nDockBarID); }
void CSizingControlBar::OnTrackUpdateSize(CPoint& point) { ASSERT(!IsFloating()); CPoint pt = point; ClientToScreen(&pt); CSize szDelta = pt - m_ptOld; CSize sizeNew = m_szOld; switch (m_htEdge) { case HTLEFT: sizeNew -= CSize(szDelta.cx, 0); break; case HTTOP: sizeNew -= CSize(0, szDelta.cy); break; case HTRIGHT: sizeNew += CSize(szDelta.cx, 0); break; case HTBOTTOM: sizeNew += CSize(0, szDelta.cy); break; } // enforce the limits sizeNew.cx = max(m_szMinT.cx, min(m_szMaxT.cx, sizeNew.cx)); sizeNew.cy = max(m_szMinT.cy, min(m_szMaxT.cy, sizeNew.cy)); BOOL bHorz = IsHorzDocked(); szDelta = sizeNew - (bHorz ? m_szHorz : m_szVert); if (szDelta == CSize(0, 0)) return; // no size change OnTrackInvertTracker(); // erase tracker (bHorz ? m_szHorz : m_szVert) = sizeNew; // save the new size CSCBArray arrSCBars; GetRowSizingBars(arrSCBars); for (int i = 0; i < arrSCBars.GetSize(); i++) if (!IsSideTracking()) { // track simultaneously CSizingControlBar* pBar = arrSCBars[i]; (bHorz ? pBar->m_szHorz.cy : pBar->m_szVert.cx) = bHorz ? sizeNew.cy : sizeNew.cx; } else { // adjust the neighbour's size too if (arrSCBars[i] != this) continue; CSizingControlBar* pBar = arrSCBars[i + ((m_htEdge == HTTOP || m_htEdge == HTLEFT) ? -1 : 1)]; (bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy) -= bHorz ? szDelta.cx : szDelta.cy; } OnTrackInvertTracker(); // redraw tracker at new pos if (m_bDragShowContent) m_pDockSite->DelayRecalcLayout(); }
void CSizingControlBar::StartTracking(UINT nHitTest) { SetCapture(); // make sure no updates are pending if (!m_bDragShowContent) RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); BOOL bHorz = IsHorzDocked(); m_szOld = bHorz ? m_szHorz : m_szVert; CRect rc; GetWindowRect(&rc); CRect rcEdge; VERIFY(GetEdgeRect(rc, nHitTest, rcEdge)); m_ptOld = rcEdge.CenterPoint(); m_htEdge = nHitTest; m_bTracking = TRUE; CSCBArray arrSCBars; GetRowSizingBars(arrSCBars); // compute the minsize as the max minsize of the sizing bars on row m_szMinT = bHorz ? m_szMinHorz : m_szMinVert; for (int i = 0; i < arrSCBars.GetSize(); i++) if (bHorz) m_szMinT.cy = max(m_szMinT.cy, arrSCBars[i]->m_szMinHorz.cy); else m_szMinT.cx = max(m_szMinT.cx, arrSCBars[i]->m_szMinVert.cx); m_szMaxT = m_szOld; if (!IsSideTracking()) { // the control bar cannot grow with more than the size of // remaining client area of the mainframe m_pDockSite->RepositionBars(0, 0xFFFF, AFX_IDW_PANE_FIRST, reposQuery, &rc, NULL, TRUE); m_szMaxT += rc.Size() - CSize(4, 4); } else { // side tracking: max size is the actual size plus the amount // the neighbour bar can be decreased to reach its minsize for (int i = 0; i < arrSCBars.GetSize(); i++) if (arrSCBars[i] == this) break; CSizingControlBar* pBar = arrSCBars[i + ((m_htEdge == HTTOP || m_htEdge == HTLEFT) ? -1 : 1)]; m_szMaxT += (bHorz ? pBar->m_szHorz : pBar->m_szVert) - CSize(pBar->m_szMinHorz.cx, pBar->m_szMinVert.cy); } OnTrackInvertTracker(); // draw tracker }
BOOL CCJControlBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if ((nHitTest != HTSIZE) || m_bTracking) return CControlBar::OnSetCursor(pWnd, nHitTest, message); #if defined(MFCXLIB_STATIC) HINSTANCE hInst = AfxFindResourceHandle( MAKEINTRESOURCE(AFX_IDC_VSPLITBAR), RT_GROUP_CURSOR); if (IsHorzDocked()) ::SetCursor(::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_VSPLITBAR))); else ::SetCursor(::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_HSPLITBAR))); #else if (IsHorzDocked()) ::SetCursor(::LoadCursor(NULL, IDC_SIZENS)); else ::SetCursor(::LoadCursor(NULL, IDC_SIZEWE)); #endif return TRUE; }
void CCJControlBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) { CControlBar::OnWindowPosChanged(lpwndpos); // Find on which side are we docked m_nDockBarID = GetParent()->GetDlgCtrlID(); if (m_bInRecalcNC == FALSE) { m_bInRecalcNC = TRUE; // Force recalc the non-client area SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED); m_bInRecalcNC = FALSE; } if (m_bButtons) { ASSERT(m_ImageList); if (IsFloating()) { m_btnClose.ShowWindow(SW_HIDE); m_btnMinim.ShowWindow(SW_HIDE); return; } else { m_btnClose.ShowWindow(SW_SHOW); m_btnMinim.ShowWindow(SW_SHOW); } CRect rcClose(GetButtonRect()); CRect rcMinim(GetButtonRect()); if (IsHorzDocked()) { rcMinim.OffsetRect(0,14); m_btnMinim.SetIcon(m_ImageList->ExtractIcon(2),CSize(13,13)); } else { rcClose.OffsetRect(14,0); m_btnMinim.SetIcon(m_ImageList->ExtractIcon(1),CSize(13,13)); } m_btnClose.MoveWindow(rcClose); m_btnMinim.MoveWindow(rcMinim); } Invalidate(); }
void CCJControlBar::StartTracking() { SetCapture(); // make sure no updates are pending RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); m_pDockSite->LockWindowUpdate(); m_ptOld = m_rectBorder.CenterPoint(); m_bTracking = TRUE; m_rectTracker = m_rectBorder; if (!IsHorzDocked()) m_rectTracker.bottom -= 4; OnInvertTracker(m_rectTracker); }
void CSizingControlBar::AlignControlBars() { int nFirst, nLast, nThis; GetRowInfo(nFirst, nLast, nThis); BOOL bHorz = IsHorzDocked(); BOOL bNeedRecalc = FALSE; int nPos, nAlign = bHorz ? -2 : 0; CRect rc, rcDock; m_pDockBar->GetWindowRect(&rcDock); for (int i = nFirst; i <= nLast; i++) { CControlBar* pBar = (CControlBar*)m_pDockBar->m_arrBars[i]; if (HIWORD(pBar) == 0) continue; // placeholder if (!pBar->IsVisible()) continue; pBar->GetWindowRect(&rc); rc.OffsetRect(-rcDock.TopLeft()); if ((nPos = FindSizingBar(pBar)) >= 0) rc = CRect(rc.TopLeft(), bHorz ? m_arrBars[nPos]->m_szHorz : m_arrBars[nPos]->m_szVert); if ((bHorz ? rc.left : rc.top) != nAlign) { if (!bHorz) rc.OffsetRect(0, nAlign - rc.top - 2); else if (m_nDockBarID == AFX_IDW_DOCKBAR_TOP) rc.OffsetRect(nAlign - rc.left, -2); else rc.OffsetRect(nAlign - rc.left, 0); pBar->MoveWindow(rc); bNeedRecalc = TRUE; } nAlign += (bHorz ? rc.Width() : rc.Height()) - 2; } if (bNeedRecalc) { m_pDockSite->DelayRecalcLayout(); TRACE(_T("ccc\n")); } }
void CSizingControlBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) { UNUSED_ALWAYS(bCalcValidRects); #ifndef _SCB_REPLACE_MINIFRAME // Enable diagonal resizing for floating miniframe if (IsFloating()) { CFrameWnd* pFrame = GetParentFrame(); if (pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd))) { //mpc-hc custom code start LONG_PTR dwStyle = ::GetWindowLongPtr(pFrame->m_hWnd, GWL_STYLE); //mpc-hc custom code end if ((dwStyle & MFS_4THICKFRAME) != 0) { pFrame->ModifyStyle(MFS_4THICKFRAME, 0); // clear GetParent()->ModifyStyle(0, WS_CLIPCHILDREN); } } } #endif _SCB_REPLACE_MINIFRAME // compute the the client area m_dwSCBStyle &= ~SCBS_EDGEALL; // add resizing edges between bars on the same row if (!IsFloating() && m_pDockBar != NULL) { CSCBArray arrSCBars; int nThis; GetRowSizingBars(arrSCBars, nThis); BOOL bHorz = IsHorzDocked(); if (nThis > 0) m_dwSCBStyle |= bHorz ? SCBS_EDGELEFT : SCBS_EDGETOP; if (nThis < arrSCBars.GetUpperBound()) m_dwSCBStyle |= bHorz ? SCBS_EDGERIGHT : SCBS_EDGEBOTTOM; } NcCalcClient(&lpncsp->rgrc[0], m_nDockBarID); }
CRect CCJControlBar::GetButtonRect() { CRect pRect; GetClientRect(pRect); pRect.OffsetRect(-pRect.left,-pRect.top); if(IsHorzDocked()) { pRect.top += 3; pRect.bottom = pRect.top+12; pRect.left += 2; pRect.right = pRect.left+12; } else { pRect.right -= 19; pRect.left = pRect.right-12; pRect.top += 3; pRect.bottom = pRect.top+12; } return pRect; }
void CSizingControlBarG::NcPaintGripper(CDC* pDC, CRect rcClient) { if (!HasGripper()) return; // paints a simple "two raised lines" gripper // override this if you want a more sophisticated gripper CRect gripper = rcClient; CRect rcbtn = m_bUseMaxButton ? m_btnMax.GetRect() : m_biHide.GetRect(); BOOL bHorz = IsHorzDocked(); gripper.DeflateRect(1, 1); if (bHorz) { // gripper at left gripper.left -= m_cyGripper; gripper.right = gripper.left + 3; gripper.top = rcbtn.bottom + 3; } else { // gripper at top gripper.top -= m_cyGripper; gripper.bottom = gripper.top + 3; gripper.right = rcbtn.left - 3; } pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW)); gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3); pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW)); m_biHide.Paint(pDC); // MDM // Draw the max button as needed. if ( m_bUseMaxButton && !IsFloating() ) m_btnMax.Paint(pDC); }
void CSizingControlBar::OnTrackInvertTracker() { ASSERT(m_bTracking); if (m_bDragShowContent) return; // don't show tracker if DragFullWindows is on BOOL bHorz = IsHorzDocked(); CRect rc, rcBar, rcDock, rcFrame; GetWindowRect(rcBar); m_pDockBar->GetWindowRect(rcDock); m_pDockSite->GetWindowRect(rcFrame); VERIFY(GetEdgeRect(rcBar, m_htEdge, rc)); if (!IsSideTracking()) rc = bHorz ? CRect(rcDock.left + 1, rc.top, rcDock.right - 1, rc.bottom) : CRect(rc.left, rcDock.top + 1, rc.right, rcDock.bottom - 1); rc.OffsetRect(-rcFrame.TopLeft()); CSize sizeNew = bHorz ? m_szHorz : m_szVert; CSize sizeDelta = sizeNew - m_szOld; if (m_nDockBarID == AFX_IDW_DOCKBAR_LEFT && m_htEdge == HTTOP || m_nDockBarID == AFX_IDW_DOCKBAR_RIGHT && m_htEdge != HTBOTTOM || m_nDockBarID == AFX_IDW_DOCKBAR_TOP && m_htEdge == HTLEFT || m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM && m_htEdge != HTRIGHT) sizeDelta = -sizeDelta; rc.OffsetRect(sizeDelta); CDC *pDC = m_pDockSite->GetDCEx(NULL, DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE); CBrush* pBrush = CDC::GetHalftoneBrush(); CBrush* pBrushOld = pDC->SelectObject(pBrush); pDC->PatBlt(rc.left, rc.top, rc.Width(), rc.Height(), PATINVERT); pDC->SelectObject(pBrushOld); m_pDockSite->ReleaseDC(pDC); }
CRect CCJControlBar::GetGripperRect() { CRect pRect; GetClientRect(pRect); pRect.OffsetRect(-pRect.left,-pRect.top); if(IsHorzDocked()) { pRect.DeflateRect(3,3); pRect.left += 1; pRect.right = pRect.left+3; pRect.bottom -= 1; pRect.top += m_bButtons?30:1; } else { pRect.DeflateRect(4,4); pRect.top += 2; pRect.bottom = pRect.top+3; pRect.right -= m_bButtons?30:2; } return pRect; }
void CCJControlBar::DrawGripper(CDC* pDC) { if (IsFloating()) return; if (m_bGripper) { // draw the gripper. CRect pRect(GetGripperRect()); pDC->Draw3dRect( pRect, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW) ); if(IsHorzDocked()) pRect.OffsetRect(4,0); else pRect.OffsetRect(0,4); pDC->Draw3dRect( pRect, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW) ); } m_pDockSite->RecalcLayout(); }
BOOL CSizingControlBar::NegociateSpace(int nLengthAvail, BOOL bHorz) { ASSERT(bHorz == IsHorzDocked()); int nFirst, nLast, nThis; GetRowInfo(nFirst, nLast, nThis); // step 1: subtract the visible fixed bars' lengths for (int i = nFirst; i <= nLast; i++) { CControlBar* pFBar = (CControlBar*)m_pDockBar->m_arrBars[i]; if (HIWORD(pFBar) == 0) continue; // placeholder if (!pFBar->IsVisible() || (FindSizingBar(pFBar) >= 0)) continue; CRect rcBar; pFBar->GetWindowRect(&rcBar); nLengthAvail -= (bHorz ? rcBar.Width() - 2 : rcBar.Height() - 2); } CSCBArray arrSCBars; GetRowSizingBars(arrSCBars); CSizingControlBar* pBar; // step 2: compute actual and min lengths; also the common width int nActualLength = 0; int nMinLength = 2; int nWidth = 0; for (i = 0; i < arrSCBars.GetSize(); i++) { pBar = arrSCBars[i]; nActualLength += bHorz ? pBar->m_szHorz.cx - 2 : pBar->m_szVert.cy - 2; nMinLength += bHorz ? pBar->m_szMin.cx - 2: pBar->m_szMin.cy - 2; nWidth = max(nWidth, bHorz ? pBar->m_szHorz.cy : pBar->m_szVert.cx); } // step 3: pop the bar out of the row if not enough room if (nMinLength > nLengthAvail) { if (nFirst < nThis || nThis < nLast) { // not enough room - create a new row m_pDockBar->m_arrBars.InsertAt(nLast + 1, this); m_pDockBar->m_arrBars.InsertAt(nLast + 1, (CControlBar*) NULL); m_pDockBar->m_arrBars.RemoveAt(nThis); } return FALSE; } // step 4: make the bars same width for (i = 0; i < arrSCBars.GetSize(); i++) if (bHorz) arrSCBars[i]->m_szHorz.cy = nWidth; else arrSCBars[i]->m_szVert.cx = nWidth; if (nActualLength == nLengthAvail) return TRUE; // no change // step 5: distribute the difference between the bars, but // don't shrink them below minsize int nDelta = nLengthAvail - nActualLength; while (nDelta != 0) { int nDeltaOld = nDelta; for (i = 0; i < arrSCBars.GetSize(); i++) { pBar = arrSCBars[i]; int nLMin = bHorz ? pBar->m_szMin.cx : pBar->m_szMin.cy; int nL = bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy; if ((nL == nLMin) && (nDelta < 0) || // already at min length pBar->m_bKeepSize) // or wants to keep its size continue; // sign of nDelta int nDelta2 = (nDelta == 0) ? 0 : ((nDelta < 0) ? -1 : 1); (bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy) += nDelta2; nDelta -= nDelta2; if (nDelta == 0) break; } // clear m_bKeepSize flags if ((nDeltaOld == nDelta) || (nDelta == 0)) for (i = 0; i < arrSCBars.GetSize(); i++) arrSCBars[i]->m_bKeepSize = FALSE; } return TRUE; }
void CSizingControlBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) { // compute the the client area CRect rcClient = lpncsp->rgrc[0]; rcClient.DeflateRect(5, 5); m_dwSCBStyle &= ~SCBS_EDGEALL; switch(m_nDockBarID) { case AFX_IDW_DOCKBAR_TOP: m_dwSCBStyle |= SCBS_EDGEBOTTOM; rcClient.DeflateRect(m_cyGripper, 0, 0, 0); break; case AFX_IDW_DOCKBAR_BOTTOM: m_dwSCBStyle |= SCBS_EDGETOP; rcClient.DeflateRect(m_cyGripper, 0, 0, 0); break; case AFX_IDW_DOCKBAR_LEFT: m_dwSCBStyle |= SCBS_EDGERIGHT; rcClient.DeflateRect(0, m_cyGripper, 0, 0); break; case AFX_IDW_DOCKBAR_RIGHT: m_dwSCBStyle |= SCBS_EDGELEFT; rcClient.DeflateRect(0, m_cyGripper, 0, 0); break; default: break; } if (!IsFloating() && m_pDockBar != NULL) { CSCBArray arrSCBars; GetRowSizingBars(arrSCBars); for (int i = 0; i < arrSCBars.GetSize(); i++) if (arrSCBars[i] == this) { if (i > 0) m_dwSCBStyle |= IsHorzDocked() ? SCBS_EDGELEFT : SCBS_EDGETOP; if (i < arrSCBars.GetSize() - 1) m_dwSCBStyle |= IsHorzDocked() ? SCBS_EDGERIGHT : SCBS_EDGEBOTTOM; } } // make room for edges only if they will be painted if (m_dwSCBStyle & SCBS_SHOWEDGES) rcClient.DeflateRect( (m_dwSCBStyle & SCBS_EDGELEFT) ? m_cxEdge : 0, (m_dwSCBStyle & SCBS_EDGETOP) ? m_cxEdge : 0, (m_dwSCBStyle & SCBS_EDGERIGHT) ? m_cxEdge : 0, (m_dwSCBStyle & SCBS_EDGEBOTTOM) ? m_cxEdge : 0); // "hide" button positioning CPoint ptOrgBtn; if (IsHorzDocked()) ptOrgBtn = CPoint(rcClient.left - m_cyGripper - 1, rcClient.top - 1); else ptOrgBtn = CPoint(rcClient.right - 11, rcClient.top - m_cyGripper - 1); m_biHide.Move(ptOrgBtn - CRect(lpncsp->rgrc[0]).TopLeft()); lpncsp->rgrc[0] = rcClient; }
const BOOL CSizingControlBar::IsFloating() const { return !IsHorzDocked() && !IsVertDocked(); }
BOOL CSizingControlBar::NegotiateSpace(int nLengthTotal, BOOL bHorz) { ASSERT(bHorz == IsHorzDocked()); int nFirst, nLast, nThis; GetRowInfo(nFirst, nLast, nThis); int nLengthAvail = nLengthTotal; int nLengthActual = 0; int nLengthMin = 2; int nWidthMax = 0; CSizingControlBar* pBar; for (int i = nFirst; i <= nLast; i++) { pBar = (CSizingControlBar*) m_pDockBar->m_arrBars[i]; if (HIWORD(pBar) == 0) continue; // placeholder if (!pBar->IsVisible()) continue; BOOL bIsSizingBar = pBar->IsKindOf(RUNTIME_CLASS(CSizingControlBar)); int nLengthBar; // minimum length of the bar if (bIsSizingBar) nLengthBar = bHorz ? pBar->m_szMinHorz.cx - 2 : pBar->m_szMinVert.cy - 2; else { CRect rcBar; pBar->GetWindowRect(&rcBar); nLengthBar = bHorz ? rcBar.Width() - 2 : rcBar.Height() - 2; } nLengthMin += nLengthBar; if (nLengthMin > nLengthTotal) { // split the row after fixed bar if (i < nThis) { m_pDockBar->m_arrBars.InsertAt(i + 1, (CControlBar*) NULL); return FALSE; } // only this sizebar remains on the row, adjust it to minsize if (i == nThis) { if (bHorz) m_szHorz.cx = m_szMinHorz.cx; else m_szVert.cy = m_szMinVert.cy; return TRUE; // the dockbar will split the row for us } // we have enough bars - go negotiate with them m_pDockBar->m_arrBars.InsertAt(i, (CControlBar*) NULL); nLast = i - 1; break; } if (bIsSizingBar) { nLengthActual += bHorz ? pBar->m_szHorz.cx - 2 : pBar->m_szVert.cy - 2; nWidthMax = max(nWidthMax, bHorz ? pBar->m_szHorz.cy : pBar->m_szVert.cx); } else nLengthAvail -= nLengthBar; } CSCBArray arrSCBars; GetRowSizingBars(arrSCBars); int nNumBars = (int)arrSCBars.GetSize(); int nDelta = nLengthAvail - nLengthActual; // return faster when there is only one sizing bar per row (this one) if (nNumBars == 1) { ASSERT(arrSCBars[0] == this); if (nDelta == 0) return TRUE; m_bKeepSize = FALSE; (bHorz ? m_szHorz.cx : m_szVert.cy) += nDelta; return TRUE; } // make all the bars the same width for (i = 0; i < nNumBars; i++) if (bHorz) arrSCBars[i]->m_szHorz.cy = nWidthMax; else arrSCBars[i]->m_szVert.cx = nWidthMax; // distribute the difference between the bars, // but don't shrink them below their minsizes while (nDelta != 0) { int nDeltaOld = nDelta; for (i = 0; i < nNumBars; i++) { pBar = arrSCBars[i]; int nLMin = bHorz ? pBar->m_szMinHorz.cx : pBar->m_szMinVert.cy; int nL = bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy; if ((nL == nLMin) && (nDelta < 0) || // already at min length pBar->m_bKeepSize) // or wants to keep its size continue; // sign of nDelta int nDelta2 = (nDelta == 0) ? 0 : ((nDelta < 0) ? -1 : 1); (bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy) += nDelta2; nDelta -= nDelta2; if (nDelta == 0) break; } // clear m_bKeepSize flags if ((nDeltaOld == nDelta) || (nDelta == 0)) for (i = 0; i < nNumBars; i++) arrSCBars[i]->m_bKeepSize = FALSE; } return TRUE; }
void CSizingControlBar::OnTrackUpdateSize(CPoint& point) { ASSERT(!IsFloating()); BOOL bHorzTrack = m_htEdge == HTLEFT || m_htEdge == HTRIGHT; int nTrackPos = bHorzTrack ? point.x : point.y; nTrackPos = max(m_nTrackPosMin, min(m_nTrackPosMax, nTrackPos)); int nDelta = nTrackPos - m_nTrackPosOld; if (nDelta == 0) return; // no pos change OnTrackInvertTracker(); // erase tracker m_nTrackPosOld = nTrackPos; BOOL bHorz = IsHorzDocked(); CSize sizeNew = bHorz ? m_szHorz : m_szVert; switch (m_htEdge) { case HTLEFT: sizeNew -= CSize(nDelta, 0); break; case HTTOP: sizeNew -= CSize(0, nDelta); break; case HTRIGHT: sizeNew += CSize(nDelta, 0); break; case HTBOTTOM: sizeNew += CSize(0, nDelta); break; } CSCBArray arrSCBars; int nThis; GetRowSizingBars(arrSCBars, nThis); if (!IsSideTracking()) for (int i = 0; i < arrSCBars.GetSize(); i++) { CSizingControlBar* pBar = arrSCBars[i]; // make same width (or height) (bHorz ? pBar->m_szHorz.cy : pBar->m_szVert.cx) = bHorz ? sizeNew.cy : sizeNew.cx; } else { int nGrowingBar = nThis; BOOL bBefore = m_htEdge == HTTOP || m_htEdge == HTLEFT; if (bBefore && nDelta > 0) nGrowingBar--; if (!bBefore && nDelta < 0) nGrowingBar++; if (nGrowingBar != nThis) bBefore = !bBefore; // nGrowing is growing nDelta = abs(nDelta); CSizingControlBar* pBar = arrSCBars[nGrowingBar]; (bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy) += nDelta; // the others are shrinking int nFirst = bBefore ? nGrowingBar - 1 : nGrowingBar + 1; int nLimit = bBefore ? -1 : (int)arrSCBars.GetSize(); for (int i = nFirst; nDelta != 0 && i != nLimit; i += (bBefore ? -1 : 1)) { CSizingControlBar* pBar = arrSCBars[i]; int nDeltaT = min(nDelta, (bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy) - (bHorz ? pBar->m_szMinHorz.cx : pBar->m_szMinVert.cy)); (bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy) -= nDeltaT; nDelta -= nDeltaT; } } OnTrackInvertTracker(); // redraw tracker at new pos if (m_bDragShowContent) m_pDockSite->DelayRecalcLayout(); }
void CSizingControlBar::StartTracking(UINT nHitTest, CPoint point) { SetCapture(); // make sure no updates are pending if (!m_bDragShowContent) RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); m_htEdge = nHitTest; m_bTracking = TRUE; BOOL bHorz = IsHorzDocked(); BOOL bHorzTracking = m_htEdge == HTLEFT || m_htEdge == HTRIGHT; m_nTrackPosOld = bHorzTracking ? point.x : point.y; CRect rcBar, rcEdge; GetWindowRect(rcBar); GetEdgeRect(rcBar, m_htEdge, rcEdge); m_nTrackEdgeOfs = m_nTrackPosOld - (bHorzTracking ? rcEdge.CenterPoint().x : rcEdge.CenterPoint().y); CSCBArray arrSCBars; int nThis; GetRowSizingBars(arrSCBars, nThis); m_nTrackPosMin = m_nTrackPosMax = m_nTrackPosOld; if (!IsSideTracking()) { // calc minwidth as the max minwidth of the sizing bars on row int nMinWidth = bHorz ? m_szMinHorz.cy : m_szMinVert.cx; for (int i = 0; i < arrSCBars.GetSize(); i++) nMinWidth = max(nMinWidth, bHorz ? arrSCBars[i]->m_szMinHorz.cy : arrSCBars[i]->m_szMinVert.cx); int nExcessWidth = (bHorz ? m_szHorz.cy : m_szVert.cx) - nMinWidth; // the control bar cannot grow with more than the width of // remaining client area of the mainframe CRect rcT; m_pDockSite->RepositionBars(0, 0xFFFF, AFX_IDW_PANE_FIRST, reposQuery, &rcT, NULL, TRUE); int nMaxWidth = bHorz ? rcT.Height() - 2 : rcT.Width() - 2; BOOL bTopOrLeft = m_htEdge == HTTOP || m_htEdge == HTLEFT; m_nTrackPosMin -= bTopOrLeft ? nMaxWidth : nExcessWidth; m_nTrackPosMax += bTopOrLeft ? nExcessWidth : nMaxWidth; } else { // side tracking: // max size is the actual size plus the amount the other // sizing bars can be decreased until they reach their minsize if (m_htEdge == HTBOTTOM || m_htEdge == HTRIGHT) nThis++; for (int i = 0; i < arrSCBars.GetSize(); i++) { CSizingControlBar* pBar = arrSCBars[i]; int nExcessWidth = bHorz ? pBar->m_szHorz.cx - pBar->m_szMinHorz.cx : pBar->m_szVert.cy - pBar->m_szMinVert.cy; if (i < nThis) m_nTrackPosMin -= nExcessWidth; else m_nTrackPosMax += nExcessWidth; } } OnTrackInvertTracker(); // draw tracker }
BOOL CCJControlBar::IsFloating() { return (!IsHorzDocked() && !IsVertDocked()); }
void CCoolBar::NcPaintGripper(CDC* pDC, CRect rcClient) { if (!HasGripper()) return; #ifndef _SCB_STYLE_FLAT CRect gripper = rcClient; CRect rcbtn = m_biHide.GetRect(); BOOL bHorz = IsHorzDocked(); gripper.DeflateRect(1, 1); if (bHorz) { // gripper at left gripper.left -= m_cyGripper; gripper.right = gripper.left + 3; gripper.top = rcbtn.bottom + 3; } else { // gripper at top gripper.top -= m_cyGripper; gripper.bottom = gripper.top + 3; gripper.right = rcbtn.left - 3; } pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW)); gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3); pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT), ::GetSysColor(COLOR_BTNSHADOW)); m_biHide.Paint(pDC); #else // compute the caption rectangle BOOL bHorz = IsHorzDocked(); CRect rcGrip = rcClient; CRect rcBtn = m_biHide.GetRect(); if (bHorz) { // right side gripper rcGrip.left -= m_cyGripper + 1; rcGrip.right = rcGrip.left + 11; rcGrip.top = rcBtn.bottom + 3; } else { // gripper at top rcGrip.top -= m_cyGripper + 1; rcGrip.bottom = rcGrip.top + 11; rcGrip.right = rcBtn.left - 3; } rcGrip.InflateRect(bHorz ? 1 : 0, bHorz ? 0 : 1); // draw the caption background //CBrush br; COLORREF clrCptn = m_bActive ? ::GetSysColor(COLOR_ACTIVECAPTION) : ::GetSysColor(COLOR_INACTIVECAPTION); // query gradient info (usually TRUE for Win98/Win2k) BOOL bGradient = FALSE; ::SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradient, 0); if (!bGradient) pDC->FillSolidRect(&rcGrip, clrCptn); // solid color else { // gradient from left to right or from bottom to top // get second gradient color (the right end) COLORREF clrCptnRight = m_bActive ? ::GetSysColor(COLOR_GRADIENTACTIVECAPTION) : ::GetSysColor(COLOR_GRADIENTINACTIVECAPTION); // this will make 2^6 = 64 fountain steps int nShift = 6; int nSteps = 1 << nShift; for (int i = 0; i < nSteps; i++) { // do a little alpha blending int nR = (GetRValue(clrCptn) * (nSteps - i) + GetRValue(clrCptnRight) * i) >> nShift; int nG = (GetGValue(clrCptn) * (nSteps - i) + GetGValue(clrCptnRight) * i) >> nShift; int nB = (GetBValue(clrCptn) * (nSteps - i) + GetBValue(clrCptnRight) * i) >> nShift; COLORREF cr = RGB(nR, nG, nB); // then paint with the resulting color CRect r2 = rcGrip; if (bHorz) { r2.bottom = rcGrip.bottom - ((i * rcGrip.Height()) >> nShift); r2.top = rcGrip.bottom - (((i + 1) * rcGrip.Height()) >> nShift); if (r2.Height() > 0) pDC->FillSolidRect(r2, cr); } else { r2.left = rcGrip.left + ((i * rcGrip.Width()) >> nShift); r2.right = rcGrip.left + (((i + 1) * rcGrip.Width()) >> nShift); if (r2.Width() > 0) pDC->FillSolidRect(r2, cr); } } }
void CSizingControlBarCF::NcPaintGripper(CDC* pDC, CRect rcClient) { if (!HasGripper()) return; // compute the caption rectangle BOOL bHorz = IsHorzDocked(); CRect rcGrip = rcClient; CRect rcBtn = m_biHide.GetRect(); if (bHorz) { // right side gripper rcGrip.left -= m_cyGripper + 1; rcGrip.right = rcGrip.left + 11; rcGrip.top = rcBtn.bottom + 3; } else { // gripper at top rcGrip.top -= m_cyGripper + 1; rcGrip.bottom = rcGrip.top + 11; rcGrip.right = rcBtn.left - 3; } rcGrip.InflateRect(bHorz ? 1 : 0, bHorz ? 0 : 1); // draw the caption background //CBrush br; /* COLORREF clrCptn = m_bActive ? ::GetSysColor(COLOR_ACTIVECAPTION) : ::GetSysColor(COLOR_INACTIVECAPTION); // query gradient info (usually TRUE for Win98/Win2k) BOOL bGradient = FALSE; ::SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &bGradient, 0); if (!bGradient) pDC->FillSolidRect(&rcGrip, clrCptn); // solid color else { // gradient from left to right or from bottom to top // get second gradient color (the right end) COLORREF clrCptnRight = m_bActive ? ::GetSysColor(COLOR_GRADIENTACTIVECAPTION) : ::GetSysColor(COLOR_GRADIENTINACTIVECAPTION); // this will make 2^6 = 64 fountain steps int nShift = 6; int nSteps = 1 << nShift; for (int i = 0; i < nSteps; i++) { // do a little alpha blending int nR = (GetRValue(clrCptn) * (nSteps - i) + GetRValue(clrCptnRight) * i) >> nShift; int nG = (GetGValue(clrCptn) * (nSteps - i) + GetGValue(clrCptnRight) * i) >> nShift; int nB = (GetBValue(clrCptn) * (nSteps - i) + GetBValue(clrCptnRight) * i) >> nShift; COLORREF cr = RGB(nR, nG, nB); // then paint with the resulting color CRect r2 = rcGrip; if (bHorz) { r2.bottom = rcGrip.bottom - ((i * rcGrip.Height()) >> nShift); r2.top = rcGrip.bottom - (((i + 1) * rcGrip.Height()) >> nShift); if (r2.Height() > 0) pDC->FillSolidRect(r2, cr); } else { r2.left = rcGrip.left + ((i * rcGrip.Width()) >> nShift); r2.right = rcGrip.left + (((i + 1) * rcGrip.Width()) >> nShift); if (r2.Width() > 0) pDC->FillSolidRect(r2, cr); } } }*/ // draw the caption text - first select a font CFont font; int ppi = pDC->GetDeviceCaps(LOGPIXELSX); #ifdef CHINESE_VER int pointsize = MulDiv(90, 96, ppi); // 9.0 points at 96 ppi #else int pointsize = MulDiv(85, 96, ppi); // 8.5 points at 96 ppi for english #endif LOGFONT lf; BOOL bFont = font.CreatePointFont(pointsize, m_sFontFace); if (bFont) { // get the text color /* COLORREF clrCptnText = m_bActive ? ::GetSysColor(COLOR_CAPTIONTEXT) : ::GetSysColor(COLOR_INACTIVECAPTIONTEXT);*/ COLORREF clrCptnText = ::GetSysColor(COLOR_BTNTEXT); int nOldBkMode = pDC->SetBkMode(TRANSPARENT); COLORREF clrOldText = pDC->SetTextColor(clrCptnText); if (bHorz) { // rotate text 90 degrees CCW if horizontally docked font.GetLogFont(&lf); font.DeleteObject(); lf.lfEscapement = 900; font.CreateFontIndirect(&lf); } CFont* pOldFont = pDC->SelectObject(&font); CString sTitle; GetWindowText(sTitle); CPoint ptOrg = bHorz ? CPoint(rcGrip.left - 1, rcGrip.bottom - 3) : CPoint(rcGrip.left + 3, rcGrip.top ); pDC->ExtTextOut(ptOrg.x, ptOrg.y, ETO_CLIPPED, rcGrip, sTitle, NULL); pDC->SelectObject(pOldFont); pDC->SetBkMode(nOldBkMode); pDC->SetTextColor(clrOldText); } // draw the button m_biHide.Paint(pDC); }