CSize CGuiToolBarWnd::CalcDynamicLayout(int nLength, DWORD dwMode) { if ((nLength == -1) && !(dwMode & LM_MRUWIDTH) && !(dwMode & LM_COMMIT) && ((dwMode & LM_HORZDOCK) || (dwMode & LM_VERTDOCK))) { return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZDOCK); } return CalcLayout(dwMode, nLength); }
CSize CMainFrameControls::GetDockZonesMinSize(unsigned uSaneFallback) { EnumPanelZones(); const long saneX = m_pMainFrame->m_dpi.ScaleX(uSaneFallback); const long saneY = m_pMainFrame->m_dpi.ScaleY(uSaneFallback); auto calcDock = [&](DockZone zone) { bool bHorz = (zone == DOCK_TOP || zone == DOCK_BOTTOM); const auto& panels = m_panelZones.find(zone)->second; auto pDock = m_panelDocks.find(zone)->second; unsigned stackSize = 0; unsigned maxRowSize = 0, rowSize = 0; bool bNewRow = true; for (int i = 0; i < pDock->m_arrBars.GetCount(); i++) { auto pBar = static_cast<CPlayerBar*>(pDock->m_arrBars[i]); if (!pBar && !bNewRow) { bNewRow = true; maxRowSize = max(maxRowSize, rowSize); rowSize = 0; } if (pBar) { for (const auto panel : panels) { if (m_panels[panel] == pBar) { rowSize += (rowSize ? 8 : 6); rowSize += (bHorz ? std::max(saneX, pBar->m_szMinHorz.cx) : std::max(saneY, pBar->m_szMinVert.cy)); rowSize += pBar->m_cxEdge; if (bNewRow) { CSize size = pBar->CalcFixedLayout(TRUE, bHorz); stackSize += (bHorz ? size.cy - 2 : (stackSize ? size.cx - 2 : size.cx - 4)); bNewRow = false; } break; } } } } return bHorz ? CSize(maxRowSize, stackSize) : CSize(stackSize, maxRowSize); }; const CSize sizeTop(m_panelZones.find(DOCK_TOP) != std::end(m_panelZones) ? calcDock(DOCK_TOP) : 0); const CSize sizeLeft(m_panelZones.find(DOCK_LEFT) != std::end(m_panelZones) ? calcDock(DOCK_LEFT) : 0); const CSize sizeRight(m_panelZones.find(DOCK_RIGHT) != std::end(m_panelZones) ? calcDock(DOCK_RIGHT) : 0); const CSize sizeBottom(m_panelZones.find(DOCK_BOTTOM) != std::end(m_panelZones) ? calcDock(DOCK_BOTTOM) : 0); CSize ret; ret.cx = max(sizeLeft.cx + sizeRight.cx, max(sizeTop.cx, sizeBottom.cx)); ret.cy = sizeTop.cy + sizeBottom.cy + max(sizeLeft.cy, sizeRight.cy); const unsigned uToolbars = GetToolbarsHeight(); if (uToolbars) { ret.cx = std::max(ret.cx, saneX); } ret.cy += uToolbars; return ret; }
CSize CDialBar::CalcDynamicLayout(int length, DWORD mode) { // TRACE2("length = %d \tmode = %x\n", length, (int)mode); if ((length == -1) && !(mode & LM_MRUWIDTH) && !(mode & LM_COMMIT) && ((mode & LM_HORZDOCK) || (mode & LM_VERTDOCK))) { return CalcFixedLayout(mode & LM_STRETCH, mode & LM_HORZDOCK); } return CalcLayout(length,mode); }
void CMonitorBarCtrl::OnSkinChange() { HBITMAP hWatermark = Skin.GetWatermark( _T("CMonitorBar") ); if ( m_bmWatermark.m_hObject != NULL ) m_bmWatermark.DeleteObject(); if ( hWatermark != NULL ) m_bmWatermark.Attach( hWatermark ); if ( m_hTab ) DestroyIcon( m_hTab ); m_hTab = CoolInterface.ExtractIcon( IDI_POINTER_ARROW, Settings.General.LanguageRTL ); if ( m_hUpDown ) DestroyIcon( m_hUpDown ); m_hUpDown = CoolInterface.ExtractIcon( IDI_UPDOWN_ARROW, Settings.General.LanguageRTL ); m_pRxItem->m_nColour = CoolInterface.m_crMonitorDownloadBar; m_pTxItem->m_nColour = CoolInterface.m_crMonitorUploadBar; if ( m_hWnd != NULL && IsWindowVisible() ) { CalcFixedLayout( FALSE, FALSE ); Invalidate(); } }
void CCoolBarCtrl::OnUpdated() { if ( ! m_bStretch ) { CSize czLast = m_czLast; if ( CalcFixedLayout( FALSE, TRUE ) != czLast ) { CMDIFrameWnd* pOwner = (CMDIFrameWnd*)GetOwner(); if ( pOwner && pOwner->IsKindOf( RUNTIME_CLASS(CMDIFrameWnd) ) ) { if ( pOwner->IsIconic() ) m_bRecalc = TRUE; else pOwner->RecalcLayout(); } } } Invalidate(); }
void CMainFrameControls::GetDockZonesInternal(unsigned& uTop, unsigned& uLeft, unsigned& uRight, unsigned& uBottom, bool bDoEnum, bool bOnlyVisible) { if (bDoEnum) { EnumPanelZones(); } auto calcDock = [&](DockZone zone) { bool bHorz = (zone == DOCK_TOP || zone == DOCK_BOTTOM); const auto& panels = m_panelZones.find(zone)->second; auto pDock = m_panelDocks.find(zone)->second; unsigned stackSize = 0; bool bNewRow = true; for (int i = 0; i < pDock->m_arrBars.GetCount(); i++) { auto pBar = static_cast<CPlayerBar*>(pDock->m_arrBars[i]); if (!pBar && !bNewRow) { bNewRow = true; } if (bNewRow && pBar) { for (const auto panel : panels) { if (m_panels[panel] == pBar && (!bOnlyVisible || IsWindowVisible(*pBar))) { CSize size = pBar->CalcFixedLayout(TRUE, bHorz); stackSize += (bHorz ? size.cy - 2 : (stackSize ? size.cx - 2 : size.cx - 4)); bNewRow = false; break; } } } } return stackSize; }; uTop = (m_panelZones.find(DOCK_TOP) != std::end(m_panelZones)) ? calcDock(DOCK_TOP) : 0; uLeft = (m_panelZones.find(DOCK_LEFT) != std::end(m_panelZones)) ? calcDock(DOCK_LEFT) : 0; uRight = (m_panelZones.find(DOCK_RIGHT) != std::end(m_panelZones)) ? calcDock(DOCK_RIGHT) : 0; uBottom = (m_panelZones.find(DOCK_BOTTOM) != std::end(m_panelZones)) ? calcDock(DOCK_BOTTOM) : 0; unsigned uToolbars = bOnlyVisible ? GetVisibleToolbarsHeight() : GetToolbarsHeight(); uBottom += uToolbars; }
LRESULT CProgressBar::OnSizeParent(WPARAM, LPARAM lParam) // This overrides the normal OnSizeParent method (CControlBar) // Normal control bars can never overlap - each is opened using the parent's // client rectangle, and then their area is subtracted from the available client // area, so that they never overlap. // However, the progress bar wants to sit over the top of the status bar if // possible, so before allowing the normal action to proceed... // If the status window's client rectangle butts onto the layout rect passed in, // then we extend the layout rectangle to include the status bar, and hence we // will be placed over the top of the SB. // NOTE - currently only does this if attached to the BOTTOM of the window. // If this fails (sttaus bar not open, or at top of window, etc), the progress // bar will appear normally (above/below all other control bars) { AFX_SIZEPARENTPARAMS FAR* lpLayout = (AFX_SIZEPARENTPARAMS FAR*)lParam; CRect StatusRect; ((CMainFrame *) AfxGetApp()->m_pMainWnd)->GetStatusBarWindowRect(&StatusRect); if (!StatusRect.IsRectEmpty()) // Cover status bar (if open) { // JustinF says: this is a quick bodge so that the progress-bar respects any // overriding prefix displayed in the status line by StatusLine::SetPrefix. StatusRect.left = StatusLine::GetPrefixWidth(); // We just move our window so it is covering the status bar, using the // HWDP supplied in the AFX_SIZEPARENTPARAMS structure. lpLayout->hDWP = ::DeferWindowPos(lpLayout->hDWP, m_hWnd, HWND_TOP, StatusRect.left, StatusRect.top, StatusRect.right - StatusRect.left, StatusRect.bottom - StatusRect.top, SWP_NOACTIVATE); } else { #if _MFC_VER < 0x300 // No status bar - just plonk the progress bar where we can... return (CControlBar::OnSizeParent((WPARAM)0, lParam)); #else // resize and reposition this control bar based on styles DWORD dwStyle = (m_dwStyle & (CBRS_ALIGN_ANY|CBRS_BORDER_ANY)) | (GetStyle() & WS_VISIBLE); if ((dwStyle & WS_VISIBLE) && (dwStyle & CBRS_ALIGN_ANY) != 0) { // align the control bar CRect rect; if (StatusRect.IsRectEmpty()) { // Status bar is not open - just fit in where we can. // (This code copied from barcore.cpp in MFC 3) rect.CopyRect(&lpLayout->rect); CSize sizeAvail = rect.Size(); // maximum size available // get maximum requested size CSize size = CalcFixedLayout(lpLayout->bStretch, (dwStyle & CBRS_ORIENT_HORZ) ? TRUE : FALSE); size.cx = min(size.cx, sizeAvail.cx); size.cy = BarHeight; lpLayout->sizeTotal.cy += size.cy; lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx); rect.top = rect.bottom - size.cy; lpLayout->rect.bottom -= size.cy; rect.right = rect.left + size.cx; rect.bottom = rect.top + size.cy; // only resize the window if doing layout and not just rect query if (lpLayout->hDWP != NULL) { AfxRepositionWindow(lpLayout, m_hWnd, &rect); } } } #endif } return 0; }
CSize CIVToolBar::CalcDynamicLayout(int nLength, DWORD dwMode) { return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZDOCK); }
CSize CControlBar::CalcDynamicLayout( int nLength, DWORD nMode ) /**************************************************************/ { UNUSED_ALWAYS( nLength ); return( CalcFixedLayout( nMode & LM_STRETCH, nMode & LM_HORZ ) ); }
CSize CControlBar::CalcDynamicLayout(int, DWORD nMode) { return CalcFixedLayout(nMode & LM_STRETCH, nMode & LM_HORZ); }
CSize CSizableReBar::CalcDynamicLayout( int /*nLength*/, DWORD dwMode ) { return CalcFixedLayout( dwMode & LM_STRETCH, dwMode & LM_HORZ ); }
LRESULT CControlBar::OnSizeParent(WPARAM, LPARAM lParam) { AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam; DWORD dwStyle = RecalcDelayShow(lpLayout); if ((dwStyle & WS_VISIBLE) && (dwStyle & CBRS_ALIGN_ANY) != 0) { // align the control bar CRect rect; rect.CopyRect(&lpLayout->rect); CSize sizeAvail = rect.Size(); // maximum size available // get maximum requested size CSize size = CalcFixedLayout(lpLayout->bStretch, dwStyle & CBRS_ORIENT_HORZ); size.cx = min(size.cx, sizeAvail.cx); size.cy = min(size.cy, sizeAvail.cy); if (dwStyle & CBRS_ORIENT_HORZ) { lpLayout->sizeTotal.cy += size.cy; lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx); if (dwStyle & CBRS_ALIGN_TOP) lpLayout->rect.top += size.cy; else if (dwStyle & CBRS_ALIGN_BOTTOM) { rect.top = rect.bottom - size.cy; lpLayout->rect.bottom -= size.cy; } } else if (dwStyle & CBRS_ORIENT_VERT) { lpLayout->sizeTotal.cx += size.cx; lpLayout->sizeTotal.cy = max(lpLayout->sizeTotal.cy, size.cy); if (dwStyle & CBRS_ALIGN_LEFT) lpLayout->rect.left += size.cx; else if (dwStyle & CBRS_ALIGN_RIGHT) { rect.left = rect.right - size.cx; lpLayout->rect.right -= size.cx; } } else { ASSERT(FALSE); // can never happen } rect.right = rect.left + size.cx; rect.bottom = rect.top + size.cy; #ifdef _MAC // account for the Macintosh grow box, if there is one CWnd* pWnd = GetParentFrame(); if (pWnd != NULL) { DWORD dwWndStyle = pWnd->GetStyle(); DWORD dwExStyle = pWnd->GetExStyle(); if (!(dwExStyle & WS_EX_MDIFRAME) && (dwExStyle & WS_EX_FORCESIZEBOX) && !(dwWndStyle & (WS_VSCROLL|WS_HSCROLL))) { CRect rectParent; pWnd->GetClientRect(rectParent); if (dwStyle & CBRS_ALIGN_BOTTOM) { if (rect.bottom > rectParent.bottom - afxData.cxVScroll + 1) rect.right -= (afxData.cxVScroll - 1); } else if (dwStyle & CBRS_ALIGN_RIGHT) { if (rect.bottom > rectParent.bottom - afxData.cyHScroll + 1) rect.bottom -= (afxData.cxVScroll - 1); } } } #endif // only resize the window if doing layout and not just rect query if (lpLayout->hDWP != NULL) AfxRepositionWindow(lpLayout, m_hWnd, &rect); } return 0; }