void CToolbarWnd::OnSize(UINT nType, int cx, int cy) { CDialogBar::OnSize(nType, cx, cy); if (m_btnBar->m_hWnd == 0) return; if (cx >= MIN_HORZ_WIDTH) { CRect rcClient; GetClientRect(&rcClient); CalcInsideRect(rcClient, TRUE); m_btnBar->MoveWindow(rcClient.left + 1, rcClient.top, rcClient.Width() - 8, 22); //int iWidthOpts = rcClient.right - (rcClient.left + m_rcOpts.left); /*HDWP hdwp = BeginDeferWindowPos(0); if (hdwp) { UINT uFlags = SWP_NOZORDER | SWP_NOACTIVATE; //hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_MSTATIC3), NULL, rcClient.left + m_rcNameLbl.left, rcClient.top + m_rcNameLbl.top, m_rcNameLbl.Width(), m_rcNameLbl.Height(), uFlags); VERIFY( EndDeferWindowPos(hdwp) ); }*/ } else if (cx < MIN_HORZ_WIDTH) { CRect rcClient; GetClientRect(&rcClient); CalcInsideRect(rcClient, FALSE); m_btnBar->MoveWindow(rcClient.left, rcClient.top + 1, 24, rcClient.Height() - 1); } }
int CFormatBar::GetDefaultHeight(void) { CRect rectSize; rectSize.SetRectEmpty(); #ifdef WIN32 CalcInsideRect(rectSize, TRUE); // will be negative size #else CalcInsideRect(rectSize); // will be negative size #endif return m_sizeButton.cy - rectSize.Height(); }
int CInfoBar::GetHeight(int cx) { // Get border size (values will be negative) CRect rBorder; rBorder.SetRectEmpty(); CalcInsideRect(rBorder, TRUE); // Based on the available width minus the border area, // calculate the necessary Y value to hold the text CRect rCalc(0, 0, cx - (-rBorder.Width()), 0); CClientDC dc(this); CFont* pOldFont = dc.SelectObject(&m_font); UINT nFormat = DT_CALCRECT|DT_EDITCONTROL|DT_EXTERNALLEADING|DT_LEFT|DT_WORDBREAK; dc.DrawText(m_sCaption, -1, rCalc, nFormat); if (pOldFont != NULL) dc.SelectObject(pOldFont); // The Y value is the sum of the calculated height from DrawText, // plus the top and bottom border. int cy = rCalc.Height(); cy += (-rBorder.Height()); return cy; }
void CInfoBar::OnPaint() { CPaintDC dc(this); // device context for painting CRect r; GetClientRect(r); CalcInsideRect(r, TRUE); r.InflateRect(0, 2); CFont* pOldFont = dc.SelectObject(&m_font); dc.SetTextColor(m_crTextColor); UINT nFormat = DT_EDITCONTROL|DT_EXTERNALLEADING|DT_LEFT|DT_WORDBREAK|DT_END_ELLIPSIS; dc.DrawText(m_sCaption, -1, r, nFormat); if (m_bPictureSet) { if (m_hIcon == NULL) dc.DrawState(CPoint(r.right - m_sizeBitmap.cx,(r.bottom - m_sizeBitmap.cy)/2), m_sizeBitmap, &m_bm, DST_BITMAP); else dc.DrawState(CPoint(r.right - m_sizeBitmap.cx,(r.bottom - m_sizeBitmap.cy)/2), m_sizeBitmap, m_hIcon, DST_ICON, HBRUSH(NULL) ); } if (pOldFont != NULL) dc.SelectObject(pOldFont); }
CSize CInfoBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { // Get border size (values will be negative) CRect rBorder; rBorder.SetRectEmpty(); CalcInsideRect(rBorder, bHorz); // Based on the available width minus the border area, // calculate the necessary Y value to hold the text CRect rCalc(0, 0, m_cxAvailable - (-rBorder.Width()), 0); { CClientDC dc(this); CFont* pOldFont = dc.SelectObject(&m_font); dc.DrawText(m_caption, -1, rCalc, DT_CALCRECT | DT_EDITCONTROL | DT_EXTERNALLEADING | DT_LEFT | DT_WORDBREAK); if (pOldFont != NULL) dc.SelectObject(pOldFont); } // The Y value is the sum of the calculated height from DrawText, // plus the top and bottom border. CSize size; size.cx = 32767; size.cy = rCalc.Height(); size.cy += (-rBorder.Height()); return size; }
void CFlatToolbar::GetItemRect(int nIndex, LPRECT lpRect) const { ASSERT_VALID(this); ASSERT(nIndex >= 0 && nIndex < m_nCount); ASSERT(AfxIsValidAddress(lpRect, sizeof(RECT))); BOOL bHorz = (m_dwStyle & CBRS_ORIENT_HORZ) ? TRUE : FALSE; CRect rect; rect.SetRectEmpty(); // only need top and left CalcInsideRect(rect, bHorz); AFX_TBBUTTON* pTBB = (AFX_TBBUTTON*)m_pData; for (int iButton = 0; iButton < nIndex; iButton++, pTBB++) { ASSERT(pTBB != NULL); // skip this button or separator if (bHorz) { rect.left += (pTBB->nStyle & TBBS_SEPARATOR) ? pTBB->iImage : m_sizeButton.cx; rect.left -= m_cxSharedBorder; // go back for overlap } else { rect.top += (pTBB->nStyle & TBBS_SEPARATOR) ? pTBB->iImage : m_sizeButton.cy; rect.top -= m_cySharedBorder; // go back for overlap } } ASSERT(iButton == nIndex); ASSERT(pTBB == _GetButtonPtr(nIndex)); // button or image width if (bHorz) { // TONYCL: START: OFFICE97 LOOK AND FEEL // If we are not floating then shift the buttons right to allow for a gripper if (!IsFloating()) { rect.left += 3; } // TONYCL: END: OFFICE97 LOOK AND FEEL int cx = (pTBB->nStyle & TBBS_SEPARATOR) ? pTBB->iImage : m_sizeButton.cx; lpRect->right = (lpRect->left = rect.left) + cx; lpRect->bottom = (lpRect->top = rect.top) + m_sizeButton.cy; } else { // TONYCL: START: OFFICE97 LOOK AND FEEL // If we are not floating then shift the buttons down to allow for a gripper if (!IsFloating()) { rect.top += 3; } // TONYCL: END: OFFICE97 LOOK AND FEEL int cy = (pTBB->nStyle & TBBS_SEPARATOR) ? pTBB->iImage : m_sizeButton.cy; lpRect->bottom = (lpRect->top = rect.top) + cy; lpRect->right = (lpRect->left = rect.left) + m_sizeButton.cx; } }
CSize CRulerBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { ASSERT(bHorz); CSize m_size = CControlBar::CalcFixedLayout(bStretch, bHorz); CRect rectSize; rectSize.SetRectEmpty(); CalcInsideRect(rectSize, bHorz); // will be negative size m_size.cy = RULERBARHEIGHT - rectSize.Height(); return m_size; }
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()); }
void CDockBar::OnNcCalcSize(BOOL /*bCalcValidRects*/, NCCALCSIZE_PARAMS* lpncsp) { // calculate border space (will add to top/bottom, subtract from right/bottom) CRect rect; rect.SetRectEmpty(); CalcInsideRect(rect, m_dwStyle & CBRS_ORIENT_HORZ); // adjust non-client area for border space lpncsp->rgrc[0].left += rect.left; lpncsp->rgrc[0].top += rect.top; lpncsp->rgrc[0].right += rect.right; lpncsp->rgrc[0].bottom += rect.bottom; }
void CStatusBar::UpdateAllPanes( BOOL bUpdateRects, BOOL bUpdateText ) /********************************************************************/ { STATUSBAR_PANE_INFO *pPanes = (STATUSBAR_PANE_INFO *)m_pData; if( bUpdateRects ) { int iBorders[3]; ::SendMessage( m_hWnd, SB_GETBORDERS, 0, (LPARAM)iBorders ); CRect rect; ::GetWindowRect( m_hWnd, &rect ); CalcInsideRect( rect, TRUE ); UINT *pParts = new UINT[m_nCount]; UINT nLeftOver = rect.right - rect.left; UINT nStretchPanes = 0; for( int i = 0; i < m_nCount; i++ ) { if( pPanes[i].dwStyle & SBPS_STRETCH ) { nStretchPanes++; } else { nLeftOver -= pPanes[i].nWidth; nLeftOver -= iBorders[2] + PANE_BORDER_LENGTH; } } for( int i = 0; i < m_nCount; i++ ) { if( i == 0 ) { pParts[i] = 0; } else { pParts[i] = pParts[i - 1]; } if( pPanes[i].dwStyle & SBPS_STRETCH ) { ASSERT( nStretchPanes > 0 ); pParts[i] += nLeftOver / nStretchPanes; } else { pParts[i] += pPanes[i].nWidth; pParts[i] += iBorders[2] + PANE_BORDER_LENGTH; } } ::SendMessage( m_hWnd, SB_SETPARTS, m_nCount, (LPARAM)pParts ); } if( bUpdateText ) { for( int i = 0; i < m_nCount; i++ ) { if( pPanes[i].dwStyle & SBPS_DISABLED ) { ::SendMessage( m_hWnd, SB_SETTEXT, i | pPanes[i].dwStyle, (LPARAM)NULL ); } else { ::SendMessage( m_hWnd, SB_SETTEXT, i | pPanes[i].dwStyle, (LPARAM)(LPCTSTR)pPanes[i].strText ); } } } }
void CCoolBarCtrl::PrepareRect(CRect* pRect) const { CRect rcClient; GetClientRect( &rcClient ); CalcInsideRect( rcClient, FALSE ); rcClient.left -= m_cyTopBorder; rcClient.top -= m_cxLeftBorder; rcClient.right += m_cyBottomBorder; rcClient.bottom += m_cxRightBorder; pRect->SetRect( rcClient.left + MARGIN_WIDTH, rcClient.top + 1, rcClient.right - MARGIN_WIDTH, rcClient.bottom - 1 ); if ( m_bGripper ) pRect->left += GRIPPER_WIDTH; }
CSize CDocSelector::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { // Get border size (values will be negative) CRect rBorder; rBorder.SetRectEmpty(); CalcInsideRect( rBorder, bHorz ); // The Y value is the sum of the calculated height from DrawText, // plus the top and bottom border. CSize size; size.cx = 32767; size.cy = DS_HEIGHT; size.cy += ( -rBorder.Height() ); return size; }
int CFlatToolbar::HitTest(CPoint point) // in window relative coords { if (m_pData == NULL) return -1; // no buttons BOOL bHorz = (m_dwStyle & CBRS_ORIENT_HORZ) ? TRUE : FALSE; CRect rect; rect.SetRectEmpty(); // only need top and left CalcInsideRect(rect, bHorz); AFX_TBBUTTON* pTBB = (AFX_TBBUTTON*)m_pData; ASSERT(pTBB != NULL); if (bHorz) { if (point.y < rect.top || point.y >= rect.top + m_sizeButton.cy) return -1; // no Y hit for (int iButton = 0; iButton < m_nCount; iButton++, pTBB++) { if (point.x < rect.left) break; // missed it rect.left += (pTBB->nStyle & TBBS_SEPARATOR) ? pTBB->iImage : m_sizeButton.cx; if (point.x < rect.left && !(pTBB->nStyle & TBBS_SEPARATOR)) return iButton; // hit ! rect.left -= m_cxSharedBorder; // go back for overlap } } else { if (point.x < rect.left || point.x >= rect.left + m_sizeButton.cx) return -1; // no X hit for (int iButton = 0; iButton < m_nCount; iButton++, pTBB++) { if (point.y < rect.top) break; // missed it rect.top += (pTBB->nStyle & TBBS_SEPARATOR) ? pTBB->iImage : m_sizeButton.cy; if (point.y < rect.top && !(pTBB->nStyle & TBBS_SEPARATOR)) return iButton; // hit ! rect.top -= m_cySharedBorder; // go back for overlap } } return -1; // nothing hit }
void CCoolBarCtrl::DoPaint(CDC* pDC) { ASSERT_VALID( this ); ASSERT_VALID( pDC ); CRect rc; GetClientRect( &rc ); if ( m_bBuffered || m_bmImage.m_hObject != NULL ) { CDC* pBuffer = CoolInterface.GetBuffer( *pDC, rc.Size() ); if ( CoolInterface.DrawWatermark( pBuffer, &rc, &m_bmImage ) ) { CalcInsideRect( rc, FALSE ); rc.left -= m_cyTopBorder; rc.top -= m_cxLeftBorder; rc.right += m_cyBottomBorder; rc.bottom += m_cxRightBorder; } else { DrawBorders( pBuffer, rc ); } DoPaint( pBuffer, rc, TRUE ); GetClientRect( &rc ); pDC->BitBlt( 0, 0, rc.Width(), rc.Height(), pBuffer, 0, 0, SRCCOPY ); pBuffer->SelectClipRgn( NULL ); } else { DrawBorders( pDC, rc ); DoPaint( pDC, rc, FALSE ); pDC->FillSolidRect( &rc, CoolInterface.m_crMidtone ); } }
void CInfoBar::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CRect r; GetClientRect(r); CalcInsideRect(r, TRUE); r.InflateRect(0, 2); CFont* pOldFont = dc.SelectObject(&m_font); dc.SetTextColor(m_crTextColor); dc.DrawText(m_caption, -1, r, DT_EDITCONTROL | DT_EXTERNALLEADING | DT_LEFT | DT_WORDBREAK | DT_END_ELLIPSIS); dc.DrawState(CPoint((r.right - m_sizeBitmap.cx), (r.bottom - m_sizeBitmap.cy)/2), m_sizeBitmap, &m_bm, DST_BITMAP); if (pOldFont != NULL) dc.SelectObject(pOldFont); }
CSize CFlatToolbar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { ASSERT_VALID(this); CSize size = CControlBar::CalcFixedLayout(bStretch, bHorz); CRect rect; rect.SetRectEmpty(); // only need top and left CalcInsideRect(rect, bHorz); AFX_TBBUTTON* pTBB = (AFX_TBBUTTON*)m_pData; int nButtonDist = 0; if (!bStretch) { for (int iButton = 0; iButton < m_nCount; iButton++, pTBB++) { ASSERT(pTBB != NULL); // skip this button or separator nButtonDist += (pTBB->nStyle & TBBS_SEPARATOR) ? pTBB->iImage : (bHorz ? m_sizeButton.cx : m_sizeButton.cy); // go back one for overlap nButtonDist -= bHorz ? m_cxSharedBorder : m_cySharedBorder; } if (bHorz) size.cx = nButtonDist - rect.Width() + m_cxSharedBorder; else size.cy = nButtonDist - rect.Height() + m_cySharedBorder; } if (bHorz) size.cy = m_sizeButton.cy - rect.Height(); // rect.Height() < 0 else size.cx = m_sizeButton.cx - rect.Width(); // rect.Width() < 0 return size; }
LRESULT CProgressBar::OnSetFont(WPARAM wParam, LPARAM) // Copied verbatim from barcore.cpp { m_hFont = (HFONT)wParam; ASSERT(m_hFont != NULL); // recalculate based on font height + borders TEXTMETRIC tm; // get text metrics of font { CClientDC dcScreen(NULL); CFont *OurFont = CHECKFONT(CFont::FromHandle(m_hFont)); CFont *OldFont = CHECKFONT(dcScreen.SelectObject(OurFont)); VERIFY(dcScreen.GetTextMetrics(&tm)); CHECKFONT(dcScreen.SelectObject(OldFont)); } CRect rectSize; rectSize.SetRectEmpty(); CalcInsideRect(rectSize); // will be negative size #if _MFC_VER < 0x300 m_sizeFixedLayout.cy = (tm.tmHeight - tm.tmInternalLeading) + CY_BORDER*3 /* 1 extra on top, 2 on bottom */ - rectSize.Height(); ASSERT(m_sizeFixedLayout.cx == 32767); // max size #else BarHeight = (tm.tmHeight - tm.tmInternalLeading) + CY_BORDER*3 /* 1 extra on top, 2 on bottom */ - rectSize.Height(); #endif m_FontDescent = tm.tmDescent; // Cache descent size return 0L; // does not re-draw or invalidate - resize parent instead }
CSize CGuiToolBarWnd::CalcLayout(DWORD dwMode, int nLength) { ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); if (dwMode & LM_HORZDOCK) ASSERT(dwMode & LM_HORZ); if (dwMode & LM_HORZ) bVertDocked=FALSE; else bVertDocked=TRUE; int nCount; TBBUTTON* pData = NULL; CSize sizeResult(0,0); //BLOCK: Load Buttons { nCount = DefWindowProc(TB_BUTTONCOUNT, 0, 0); if (nCount != 0) { int i; pData = new TBBUTTON[nCount]; for (i = 0; i < nCount; i++) _GetButton(i, &pData[i]); } } if (nCount > 0) { if (!(m_dwStyle & CBRS_SIZE_FIXED)) { BOOL bDynamic = m_dwStyle & CBRS_SIZE_DYNAMIC; if (bDynamic && (dwMode & LM_MRUWIDTH)) SizeToolBar(pData, nCount, m_nMRUWidth); else if (bDynamic && (dwMode & LM_HORZDOCK)) SizeToolBar(pData, nCount, 32767); else if (bDynamic && (dwMode & LM_VERTDOCK)) SizeToolBar(pData, nCount, 0); else if (bDynamic && (nLength != -1)) { CRect rect; rect.SetRectEmpty(); CalcInsideRect(rect, (dwMode & LM_HORZ)); BOOL bVert = (dwMode & LM_LENGTHY); int nLen = nLength + (bVert ? rect.Height() : rect.Width()); SizeToolBar(pData, nCount, nLen, bVert); } else if (bDynamic && (m_dwStyle & CBRS_FLOATING)) SizeToolBar(pData, nCount, m_nMRUWidth); else SizeToolBar(pData, nCount, (dwMode & LM_HORZ) ? 32767 : 0); } sizeResult = CalcSize(pData, nCount); if (dwMode & LM_COMMIT) { _AFX_CONTROLPOS* pControl = NULL; int nControlCount = 0; BOOL bIsDelayed = m_bDelayedButtonLayout; m_bDelayedButtonLayout = FALSE; for (int i = 0; i < nCount; i++) if ((pData[i].fsStyle & TBSTYLE_SEP) && (pData[i].idCommand != 0)) nControlCount++; if (nControlCount > 0) { pControl = new _AFX_CONTROLPOS[nControlCount]; nControlCount = 0; for(int i = 0; i < nCount; i++) { if ((pData[i].fsStyle & TBSTYLE_SEP) && (pData[i].idCommand != 0)) { pControl[nControlCount].nIndex = i; pControl[nControlCount].nID = pData[i].idCommand; CRect rect; GetItemRect(i, &rect); ClientToScreen(&rect); pControl[nControlCount].rectOldPos = rect; nControlCount++; } } } if ((m_dwStyle & CBRS_FLOATING) && (m_dwStyle & CBRS_SIZE_DYNAMIC)) m_nMRUWidth = sizeResult.cx; for (i = 0; i < nCount; i++) _SetButton(i, &pData[i]); if (nControlCount > 0) { for (int i = 0; i < nControlCount; i++) { CWnd* pWnd = GetDlgItem(pControl[i].nID); if (pWnd != NULL) { CRect rect; pWnd->GetWindowRect(&rect); CPoint pt = rect.TopLeft() - pControl[i].rectOldPos.TopLeft(); GetItemRect(pControl[i].nIndex, &rect); pt = rect.TopLeft() + pt; pWnd->SetWindowPos(NULL, pt.x, pt.y, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); } } delete[] pControl; } m_bDelayedButtonLayout = bIsDelayed; } delete[] pData; } //BLOCK: Adjust Margins { CRect rect; rect.SetRectEmpty(); CalcInsideRect(rect, (dwMode & LM_HORZ)); sizeResult.cy -= rect.Height(); sizeResult.cx -= rect.Width(); CSize size = CControlBar::CalcFixedLayout((dwMode & LM_STRETCH), (dwMode & LM_HORZ)); sizeResult.cx = max(sizeResult.cx, size.cx); sizeResult.cy = max(sizeResult.cy, size.cy); } return sizeResult; }
void COXStatusBar::UpdateAllPanes(BOOL bUpdateRects, BOOL bUpdateText) { ASSERT_VALID(this); ASSERT(::IsWindow(m_hWnd)); // update the status pane locations if (bUpdateRects) { // get border information and client work area CRect rect; GetWindowRect(rect); rect.OffsetRect(-rect.left, -rect.top); CalcInsideRect(rect, TRUE); int rgBorders[3]; VERIFY((BOOL)DefWindowProc(SB_GETBORDERS, 0, (LPARAM)&rgBorders)); // determine extra space for stretchy pane int cxExtra=rect.Width() + rgBorders[2]; int nStretchyCount=0; AFX_STATUSPANE* pSBP=_GetPanePtr(0); int i=0; for (i=0; i < m_nCount; i++) { if (pSBP->nStyle & SBPS_STRETCH) ++nStretchyCount; cxExtra -= (pSBP->cxText+CX_PANE_BORDER + rgBorders[2]); ++pSBP; } // determine right edge of each pane int* rgRights=(int*)_alloca(m_nCount * sizeof(int)); int right=rgBorders[0]; pSBP=_GetPanePtr(0); for (i=0; i < m_nCount; i++) { // determine size of the pane ASSERT(pSBP->cxText >= 0); right += pSBP->cxText+CX_PANE_BORDER; if ((pSBP->nStyle & SBPS_STRETCH) && cxExtra > 0) { ASSERT(nStretchyCount != 0); int cxAddExtra=cxExtra / nStretchyCount; right += cxAddExtra; --nStretchyCount; cxExtra -= cxAddExtra; } rgRights[i]=right; // next pane ++pSBP; right += rgBorders[2]; } // set new right edges for all panes DefWindowProc(SB_SETPARTS, m_nCount, (LPARAM)rgRights); // Move all ProgressWindow Ctrls pSBP=_GetPanePtr(0); CEvolInfo* pEvolInfo=NULL; for (i=0; i < m_nCount; i++) { pEvolInfo=(CEvolInfo*)m_EvolArray[i]; if (pEvolInfo != NULL) { if (pSBP->nStyle & SBPS_PERCENT) { CDC* pDC=GetDC(); CFont* pPaneFont=(CFont*)m_PaneFont[i]; CFont* pOldFont=NULL; if(pPaneFont!=NULL) pOldFont=pDC->SelectObject(pPaneFont); CRect rect(0, 0, 0, 0); pDC->DrawText(_T("999%"),rect,DT_CALCRECT|DT_SINGLELINE|DT_LEFT); if(pOldFont!=NULL) pDC->SelectObject(pOldFont); ReleaseDC(pDC); if (!pEvolInfo->m_bRectInitialized) pEvolInfo->m_bRectInitialized=CreateEvolutionPane(i,pEvolInfo); if (pEvolInfo->m_bRectInitialized && CalcInsideBorder(i, pEvolInfo->m_ProgressRect, TRUE)) { if (pEvolInfo->m_bPercentText) pEvolInfo->m_ProgressRect.left+=rect.Width(); pEvolInfo->m_ProgressPane.SetWindowPos(NULL, pEvolInfo->m_ProgressRect.left, pEvolInfo->m_ProgressRect.top, pEvolInfo->m_ProgressRect.Width(), pEvolInfo->m_ProgressRect.Height(), SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW); } } } // next pane ++pSBP; } } // update text in the status panes if specified if (bUpdateText) { AFX_STATUSPANE* pSBP=_GetPanePtr(0); for (int i=0; i < m_nCount; i++) { if (pSBP->nFlags & SBPF_UPDATE) CStatusBar::SetPaneText(i, pSBP->strText); ++pSBP; } } }
CSize CGuiDocBarExten::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { ASSERT_VALID(this); CSize sizeFixed = CControlBar::CalcFixedLayout(bStretch, bHorz); // get max size CSize sizeMax; if (!m_rectLayout.IsRectEmpty()) { CRect rect = m_rectLayout; CalcInsideRect(rect, bHorz); sizeMax = rect.Size(); } else { CRect rectFrame; CFrameWnd* pFrame = GetParentFrame(); pFrame->GetClientRect(&rectFrame); sizeMax = rectFrame.Size(); } // prepare for layout AFX_SIZEPARENTPARAMS layout; layout.hDWP = m_bLayoutQuery ? NULL : ::BeginDeferWindowPos(m_arrBars.GetSize()); int cxBorder = 2, cyBorder = 2; CPoint pt(-cxBorder, -cyBorder); int nWidth = 0; BOOL bWrapped = FALSE; // layout all the control bars for (int nPos = 0; nPos < m_arrBars.GetSize(); nPos++) { CControlBar* pBar = GetDockedControlBar(nPos); void* pVoid = m_arrBars[nPos]; if (pBar != NULL) { if(pBar->IsKindOf(RUNTIME_CLASS(CGuiToolBarWnd)) || pBar->IsKindOf(RUNTIME_CLASS(CMenuBar)) ) cxBorder = cyBorder = 0; else cxBorder = cyBorder = 2; if (pBar->IsVisible()) { // get ideal rect for bar DWORD dwMode = 0; if ((pBar->m_dwStyle & CBRS_SIZE_DYNAMIC) && (pBar->m_dwStyle & CBRS_FLOATING)) dwMode |= LM_HORZ | LM_MRUWIDTH; else if (pBar->m_dwStyle & CBRS_ORIENT_HORZ) dwMode |= LM_HORZ | LM_HORZDOCK; else dwMode |= LM_VERTDOCK; CSize sizeBar = pBar->CalcDynamicLayout(-1, dwMode); CRect rect(pt, sizeBar); // get current rect for bar CRect rectBar; pBar->GetWindowRect(&rectBar); ScreenToClient(&rectBar); if (bHorz) { // Offset Calculated Rect out to Actual if (rectBar.left > rect.left && !m_bFloating) rect.OffsetRect(rectBar.left - rect.left, 0); // If ControlBar goes off the right, then right justify if (rect.right > sizeMax.cx && !m_bFloating) { int x = rect.Width() - cxBorder; x = max(sizeMax.cx - x, pt.x); rect.OffsetRect(x - rect.left, 0); } // If ControlBar has been wrapped, then left justify if (bWrapped) { bWrapped = FALSE; rect.OffsetRect(-(rect.left + cxBorder), 0); } // If ControlBar is completely invisible, then wrap it else if ((rect.left >= (sizeMax.cx - cxBorder)) && (nPos > 0) && (m_arrBars[nPos - 1] != NULL)) { m_arrBars.InsertAt(nPos, (CObject*)NULL); pBar = NULL; pVoid = NULL; bWrapped = TRUE; } if (!bWrapped) { if (rect != rectBar) { if (!m_bLayoutQuery && !(pBar->m_dwStyle & CBRS_FLOATING)) { pBar->m_pDockContext->m_rectMRUDockPos = rect; } AfxRepositionWindow(&layout, pBar->m_hWnd, &rect); } pt.x = rect.left + sizeBar.cx - cxBorder; nWidth = max(nWidth, sizeBar.cy); } } else { // Offset Calculated Rect out to Actual if (rectBar.top > rect.top && !m_bFloating) rect.OffsetRect(0, rectBar.top - rect.top); // If ControlBar goes off the bottom, then bottom justify if (rect.bottom > sizeMax.cy && !m_bFloating) { int y = rect.Height() - cyBorder; y = max(sizeMax.cy - y, pt.y); rect.OffsetRect(0, y - rect.top); } // If ControlBar has been wrapped, then top justify if (bWrapped) { bWrapped = FALSE; rect.OffsetRect(0, -(rect.top + cyBorder)); } // If ControlBar is completely invisible, then wrap it else if ((rect.top >= (sizeMax.cy - cyBorder)) && (nPos > 0) && (m_arrBars[nPos - 1] != NULL)) { m_arrBars.InsertAt(nPos, (CObject*)NULL); pBar = NULL; pVoid = NULL; bWrapped = TRUE; } if (!bWrapped) { if (rect != rectBar) { if (!m_bLayoutQuery && !(pBar->m_dwStyle & CBRS_FLOATING)) { pBar->m_pDockContext->m_rectMRUDockPos = rect; } AfxRepositionWindow(&layout, pBar->m_hWnd, &rect); } pt.y = rect.top + sizeBar.cy - cyBorder; nWidth = max(nWidth, sizeBar.cx); } } } if (!bWrapped) { // handle any delay/show hide for the bar pBar->RecalcDelayShow(&layout); } } if (pBar == NULL && pVoid == NULL && nWidth != 0) { // end of row because pBar == NULL if (bHorz) { pt.y += nWidth - cyBorder; sizeFixed.cx = max(sizeFixed.cx, pt.x); sizeFixed.cy = max(sizeFixed.cy, pt.y); pt.x = -cxBorder; } else { pt.x += nWidth - cxBorder; sizeFixed.cx = max(sizeFixed.cx, pt.x); sizeFixed.cy = max(sizeFixed.cy, pt.y); pt.y = -cyBorder; } nWidth = 0; } } if (!m_bLayoutQuery) { // move and resize all the windows at once! if (layout.hDWP == NULL || !::EndDeferWindowPos(layout.hDWP)) TRACE0("Warning: DeferWindowPos failed - low system resources.\n"); } // adjust size for borders on the dock bar itself CRect rect; rect.SetRectEmpty(); CalcInsideRect(rect, bHorz); if ((!bStretch || !bHorz) && sizeFixed.cx != 0) sizeFixed.cx += -rect.right + rect.left; if ((!bStretch || bHorz) && sizeFixed.cy != 0) sizeFixed.cy += -rect.bottom + rect.top; return sizeFixed; }
void CFlatToolbar::DoPaint(CDC* pDC) { ASSERT_VALID(this); ASSERT_VALID(pDC); #ifdef _MAC #ifdef _DEBUG // turn off validation to speed up button drawing int wdSav = WlmDebug(WD_NOVALIDATE | WD_ASSERT); #endif #endif CControlBar::DoPaint(pDC); // draw border // if no toolbar loaded, don't draw any buttons if (m_hbmImageWell == NULL) return; BOOL bHorz = m_dwStyle & CBRS_ORIENT_HORZ ? TRUE : FALSE; CRect rect; GetClientRect(rect); CalcInsideRect(rect, bHorz); // force the full size of the button if (bHorz) rect.bottom = rect.top + m_sizeButton.cy; else rect.right = rect.left + m_sizeButton.cx; DrawState ds; if (!PrepareDrawButton(ds)) return; // something went wrong // TONYCL: START: OFFICE97 LOOK AND FEEL // Only draw the gripper stripes when we are docked if (!IsFloating()) { { CRect rect; GetClientRect(rect); // Draw the two gripper stripes if (bHorz) { // Adjust the sizes to fit into the client area properly rect.left += 3; rect.top += 3; rect.bottom -= 3; pDC->Draw3dRect(rect.left, rect.top, 3, rect.Height(), globalData.clrBtnHilite, globalData.clrBtnShadow); rect.left += 4; pDC->Draw3dRect(rect.left, rect.top, 3, rect.Height(), globalData.clrBtnHilite, globalData.clrBtnShadow); } else { // Adjust the sizes to fit into the client area properly rect.top += 3; rect.left += 3; rect.right -= 3; pDC->Draw3dRect(rect.left, rect.top, rect.Width(), 3, globalData.clrBtnHilite, globalData.clrBtnShadow); rect.top += 4; pDC->Draw3dRect(rect.left, rect.top, rect.Width(), 3, globalData.clrBtnHilite, globalData.clrBtnShadow); } } // Shift the buttons 3 pixels to allow for the grippers if (bHorz) rect.left += 3; else rect.top += 3; } // TONYCL: END: OFFICE97 LOOK AND FEEL AFX_TBBUTTON* pTBB = (AFX_TBBUTTON*)m_pData; for (int iButton = 0; iButton < m_nCount; iButton++, pTBB++) { ASSERT(pTBB != NULL); if (pTBB->nStyle & TBBS_SEPARATOR) { // separator if (bHorz) rect.right = rect.left + pTBB->iImage; else rect.bottom = rect.top + pTBB->iImage; // TONYCL: START: OFFICE97 LOOK AND FEEL { // MATTGR // the +1 moved the seperator too far // Draw a 3D seperator if (bHorz) { int nOffset; nOffset = rect.left /* +1 */ + ((rect.Width() - 2) / 2); pDC->Draw3dRect(nOffset, rect.top, 2, rect.Height(), globalData.clrBtnShadow, globalData.clrBtnHilite); } else { int nOffset; nOffset = rect.top /* +1 */ + ((rect.Height() - 2) / 2); pDC->Draw3dRect(rect.left, nOffset, rect.Width(), 2, globalData.clrBtnShadow, globalData.clrBtnHilite); } } // TONYCL: END: OFFICE97 LOOK AND FEEL } else { if (bHorz) rect.right = rect.left + m_sizeButton.cx; else rect.bottom = rect.top + m_sizeButton.cy; if (!globalData.bWin32s || pDC->RectVisible(&rect)) { DrawButton(pDC, rect.left, rect.top, pTBB->iImage, pTBB->nStyle); } } // adjust for overlap if (bHorz) rect.left = rect.right - m_cxSharedBorder; else rect.top = rect.bottom - m_cySharedBorder; } EndDrawButton(ds); #ifdef _MAC #ifdef _DEBUG WlmDebug(wdSav); #endif #endif }
CSize CToolbarWnd::CalcDynamicLayout(int nLength, DWORD dwMode) { CFrameWnd* pFrm = GetDockingFrame(); // This function is typically called with // CSize sizeHorz = m_pBar->CalcDynamicLayout(0, LM_HORZ | LM_HORZDOCK); // CSize sizeVert = m_pBar->CalcDynamicLayout(0, LM_VERTDOCK); // CSize sizeFloat = m_pBar->CalcDynamicLayout(0, LM_HORZ | LM_MRUWIDTH); CRect rcFrmClnt; pFrm->GetClientRect(&rcFrmClnt); CRect rcInside = rcFrmClnt; CalcInsideRect(rcInside, dwMode & LM_HORZDOCK); CRect rcBorders; rcBorders.left = rcInside.left - rcFrmClnt.left; rcBorders.top = rcInside.top - rcFrmClnt.top; rcBorders.bottom = rcFrmClnt.bottom - rcInside.bottom; rcBorders.right = rcFrmClnt.right - rcInside.right; if (dwMode & (LM_HORZDOCK | LM_VERTDOCK)) { if (dwMode & LM_VERTDOCK) { CSize szFloat; szFloat.cx = MIN_VERT_WIDTH; szFloat.cy = rcFrmClnt.Height() + GetSystemMetrics(SM_CYEDGE) * 2; m_szFloat = szFloat; return szFloat; } else if (dwMode & LM_HORZDOCK) { CSize szFloat; szFloat.cx = rcFrmClnt.Width() + GetSystemMetrics(SM_CXEDGE) * 2; szFloat.cy = m_sizeDefault.cy + rcBorders.top + rcBorders.bottom; m_szFloat = szFloat; return szFloat; } return CDialogBar::CalcDynamicLayout(nLength, dwMode); } if (dwMode & LM_MRUWIDTH) { return m_szMRU; } if (dwMode & LM_COMMIT) { m_szMRU = m_szFloat; return m_szFloat; } CSize szFloat; if ((dwMode & LM_LENGTHY) == 0) { szFloat.cx = nLength; if (nLength < m_sizeDefault.cx + rcBorders.left + rcBorders.right) { szFloat.cx = MIN_VERT_WIDTH; szFloat.cy = MIN_HORZ_WIDTH; } else { szFloat.cy = m_sizeDefault.cy + rcBorders.top + rcBorders.bottom; } } else { szFloat.cy = nLength; if (nLength < MIN_HORZ_WIDTH) { szFloat.cx = m_sizeDefault.cx + rcBorders.left + rcBorders.right; szFloat.cy = m_sizeDefault.cy + rcBorders.top + rcBorders.bottom; } else { szFloat.cx = MIN_VERT_WIDTH; } } m_szFloat = szFloat; return szFloat; }
CSize CExtDockBar::CalcFixedLayout( BOOL bStretch, BOOL bHorz ) { // based on MFC's source of // CDockBar::CalcFixedLayout() ASSERT_VALID(this); CSize sizeFixed = CControlBar::CalcFixedLayout( bStretch, bHorz ); // get max size CSize sizeMax; if( !m_rectLayout.IsRectEmpty() ) sizeMax = m_rectLayout.Size(); else { CFrameWnd * pFrame = GetParentFrame(); CRect rcFrameWindow; pFrame->GetClientRect( &rcFrameWindow ); sizeMax = rcFrameWindow.Size(); } // prepare for layout AFX_SIZEPARENTPARAMS layout; layout.hDWP = m_bLayoutQuery ? NULL : ::BeginDeferWindowPos( m_arrBars.GetSize() ); CPoint pt( 0, 0 ); int nWidth = 0; BOOL bWrapped = FALSE; for( int nPos = 0; nPos < m_arrBars.GetSize(); nPos++ ) { // layout all the control bars CControlBar * pBar = GetDockedControlBar(nPos); void * pVoid = m_arrBars[nPos]; if( pBar != NULL ) { CRect rcBarWin, rcBarClient; pBar->GetWindowRect( &rcBarWin ); pBar->ScreenToClient( & rcBarWin ); pBar->GetClientRect( &rcBarClient ); CSize sizeBarMin = rcBarWin.Size() - rcBarClient.Size(); if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) ) { if( ! ((CExtControlBar*)pBar)->m_bFixedMode ) { sizeBarMin = CSize( ((CExtControlBar *)pBar)->_CalcDesiredMinHW(), ((CExtControlBar *)pBar)->_CalcDesiredMinVH() ); } // if( ! ((CExtControlBar*)pBar)->m_bFixedMode ) } // if( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) ) if( pBar->IsVisible() ) { // get ideal rect for bar DWORD dwMode = 0; if( (pBar->m_dwStyle & CBRS_SIZE_DYNAMIC) && (pBar->m_dwStyle & CBRS_FLOATING) ) dwMode |= LM_HORZ | LM_MRUWIDTH; else if(pBar->m_dwStyle & CBRS_ORIENT_HORZ) dwMode |= LM_HORZ | LM_HORZDOCK; else dwMode |= LM_VERTDOCK; CSize sizeBar = pBar->CalcDynamicLayout(-1, dwMode); BOOL bIsMenuBar = FALSE; if( pBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) ) { bIsMenuBar = TRUE; if(dwMode & LM_HORZDOCK) sizeBar.cx = sizeMax.cx; else if(dwMode & LM_VERTDOCK) sizeBar.cy = sizeMax.cy; } CRect rc(pt, sizeBar); // get current rect for bar CRect rcBar; pBar->GetWindowRect( &rcBar ); ScreenToClient( &rcBar ); BOOL bMenuIsCutted = FALSE; if( bHorz ) { // Offset Calculated Rect out to Actual if( rcBar.left > rc.left && !m_bFloating ) rc.OffsetRect( rcBar.left - rc.left, 0 ); // If ControlBar goes off the right, then right justify if( rc.right > sizeMax.cx && !m_bFloating ) { int x = rc.Width(); x = max(sizeMax.cx - x, pt.x); rc.OffsetRect( x - rc.left, 0 ); if( bIsMenuBar ) bMenuIsCutted = TRUE; if( rc.right > sizeMax.cx ) rc.right -= rc.right - sizeMax.cx; } // If ControlBar has been wrapped, then left justify if( bWrapped ) { bWrapped = FALSE; rc.OffsetRect( -rc.left, 0 ); } // If ControlBar is completely invisible, then wrap it else if( rc.Width() < sizeBarMin.cx || (rc.left >= sizeMax.cx || bMenuIsCutted ) && (nPos > 0) && (m_arrBars[nPos - 1] != NULL) ) { if( !pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) || ( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) && ((CExtControlBar*)pBar)->m_bFixedMode ) ) { m_arrBars.InsertAt( nPos, (CObject*)NULL ); pBar = NULL; pVoid = NULL; bWrapped = TRUE; } } if( !bWrapped ) { if(rc != rcBar) { if( !m_bLayoutQuery && !(pBar->m_dwStyle & CBRS_FLOATING) ) pBar->m_pDockContext-> m_rectMRUDockPos = rc; AfxRepositionWindow( &layout, pBar->m_hWnd, &rc ); } pt.x = rc.left + sizeBar.cx; nWidth = max(nWidth, sizeBar.cy); } // if( !bWrapped ) } // if( bHorz ) else { // Offset Calculated Rect out to Actual if( rcBar.top > rc.top && !m_bFloating ) rc.OffsetRect( 0, rcBar.top - rc.top ); // If ControlBar goes off the bottom, then bottom justify if( rc.bottom > sizeMax.cy && !m_bFloating ) { int y = rc.Height(); y = max(sizeMax.cy - y, pt.y); rc.OffsetRect( 0, y - rc.top ); if(bIsMenuBar) bMenuIsCutted = TRUE; if( rc.bottom > sizeMax.cy ) rc.bottom -= rc.bottom - sizeMax.cy; } // If ControlBar has been wrapped, then top justify if( bWrapped ) { bWrapped = FALSE; rc.OffsetRect( 0, -rc.top ); } // If ControlBar is completely invisible, then wrap it else if( rc.Height() < sizeBarMin.cy || (rc.top >= sizeMax.cy || bMenuIsCutted ) && (nPos > 0) && (m_arrBars[nPos - 1] != NULL) ) { if( !pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) || ( pBar->IsKindOf(RUNTIME_CLASS(CExtControlBar)) && ((CExtControlBar*)pBar)->m_bFixedMode ) ) { m_arrBars.InsertAt( nPos, (CObject*)NULL ); pBar = NULL; pVoid = NULL; bWrapped = TRUE; } } if( !bWrapped ) { if(rc != rcBar) { if( !m_bLayoutQuery && !(pBar->m_dwStyle & CBRS_FLOATING) && pBar->m_pDockContext != NULL ) pBar->m_pDockContext-> m_rectMRUDockPos = rc; AfxRepositionWindow( &layout, pBar->m_hWnd, &rc ); } pt.y = rc.top + sizeBar.cy; nWidth = max(nWidth, sizeBar.cx); } // if( !bWrapped ) } // else from if( bHorz ) } // if( pBar->IsVisible() ) if( !bWrapped ) // handle any delay/show hide for the bar pBar->RecalcDelayShow( &layout ); } // if( pBar != NULL ) else { if( g_bExtendedRepositioning ) { // try to remove wrapping: // are we have free space in the end of previouse row? if( nPos > 0 && nPos != m_arrBars.GetSize()-1 ) { int nPosPrev = nPos-1; CControlBar * pPrevBar = NULL; do { pPrevBar = GetDockedControlBar(nPosPrev--); if( pPrevBar != NULL && pPrevBar->IsVisible() && (!pPrevBar->IsFloating()) ) { if( pPrevBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) ) { pPrevBar = NULL; break; } // get ideal rect for prev bar DWORD dwMode = 0; if( (pPrevBar->m_dwStyle & CBRS_SIZE_DYNAMIC) && (pPrevBar->m_dwStyle & CBRS_FLOATING) ) dwMode |= LM_HORZ | LM_MRUWIDTH; else if(pPrevBar->m_dwStyle & CBRS_ORIENT_HORZ) dwMode |= LM_HORZ | LM_HORZDOCK; else dwMode |= LM_VERTDOCK; CSize sizePrevBar = pPrevBar->CalcDynamicLayout(-1, dwMode); CRect rcPrev(pt, sizePrevBar); if( bHorz ) { if( rcPrev.right > sizeMax.cx && !m_bFloating ) pPrevBar = NULL; } else { if( rcPrev.bottom > sizeMax.cy && !m_bFloating ) pPrevBar = NULL; } if( pPrevBar != NULL ) break; } pPrevBar = NULL; } while( nPosPrev >= 0 ); if( pPrevBar != NULL ) { m_arrBars.RemoveAt(nPos); nPos--; continue; } } // if( nPos > 0 && nPos != m_arrBars.GetSize()-1 ) } // if( g_bExtendedRepositioning ) } // else from if( pBar != NULL ) if( pBar == NULL && pVoid == NULL && nWidth != 0 ) { // end of row because pBar == NULL if( bHorz ) { pt.y += nWidth; sizeFixed.cx = max(sizeFixed.cx, pt.x); sizeFixed.cy = max(sizeFixed.cy, pt.y); pt.x = 0; sizeFixed.cy--; } else { pt.x += nWidth; sizeFixed.cx = max(sizeFixed.cx, pt.x); sizeFixed.cy = max(sizeFixed.cy, pt.y); pt.y = 0; sizeFixed.cx--; } nWidth = 0; } } // layout all the control bars if( !m_bLayoutQuery ) { VERIFY( layout.hDWP != NULL ); if( layout.hDWP != NULL ) { VERIFY( ::EndDeferWindowPos(layout.hDWP) ); } } // if( !m_bLayoutQuery ) // adjust size for borders on the dock bar itself CRect rc( 0, 0, 0, 0 ); CalcInsideRect(rc, bHorz); if( (!bStretch || !bHorz) && sizeFixed.cx != 0 ) sizeFixed.cx += -rc.right + rc.left + g_bControlBarFixSizePixel ? 1 : 0; if( (!bStretch || bHorz) && sizeFixed.cy != 0 ) sizeFixed.cy += -rc.bottom + rc.top + g_bControlBarFixSizePixel ? 1 : 0; return sizeFixed; }
void CInfoBarStatus::OnPaint() { CPaintDC dc(this); // device context for painting CRect r; GetClientRect(r); CalcInsideRect(r, TRUE); r.InflateRect(0, 2); CFont* pOldFont = dc.SelectObject(&m_font); dc.SetTextColor(m_crTextColor); if (m_bPictureSet) { if (m_hIcon == NULL) dc.DrawState(CPoint(0,(r.bottom - m_sizeBitmap.cy)/2), m_sizeBitmap, &m_bm, DST_BITMAP); else ::DrawIconEx(dc.m_hDC, 0,(r.bottom - m_sizeBitmap.cy)/2, m_hIcon, // HICON m_sizeBitmap.cx, m_sizeBitmap.cy, // cx,cy 0, // frame num N/A NULL, // background brush DI_NORMAL); // flags } const char* szText = "0.123456789012345"; CSize size = dc.GetOutputTextExtent(szText); switch (m_messageStatus) { case msNone: case msInformation: dc.SetTextColor(m_crTextColor); break; case msWarning: dc.SetTextColor(RGB(255,255,0)); // yellow break; case msError: dc.SetTextColor(RGB(0x0,0x0,0x0)); // black break; } r.left += m_sizeBitmap.cx + 1; r.right -= 2 * size.cx; UINT nFormat = DT_EDITCONTROL|DT_EXTERNALLEADING|DT_LEFT|DT_WORDBREAK|DT_END_ELLIPSIS; dc.DrawText(m_sCaption, -1, r, nFormat); CRect r1 = r; CRect r2 = r; r1.left = r.right; r1.right = r1.left + size.cx; r2.left = r1.right + 2; r2.right = r2.left + size.cx; r1.InflateRect(0, 2); //dc.DrawEdge(r1, EDGE_RAISED, BF_RECT); dc.DrawEdge(r1, EDGE_SUNKEN, BF_RECT); r1.DeflateRect(2, 2); dc.SetTextColor(m_crTextColor); dc.DrawText(m_sFrom, r1, DT_RIGHT|DT_VCENTER); r2.InflateRect(0, 2); //dc.DrawEdge(r2, EDGE_RAISED, BF_RECT); dc.DrawEdge(r2, EDGE_SUNKEN, BF_RECT); r2.DeflateRect(2, 2); dc.SetTextColor(m_crTextColor); dc.DrawText(m_sTo, r2, DT_RIGHT|DT_VCENTER); if (pOldFont != NULL) { dc.SelectObject(pOldFont); } }
CSize CDockBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { ASSERT_VALID(this); CSize sizeFixed = CControlBar::CalcFixedLayout(bStretch, bHorz); // prepare for layout AFX_SIZEPARENTPARAMS layout; layout.hDWP = m_bLayoutQuery ? NULL : ::BeginDeferWindowPos(m_arrBars.GetSize()); CPoint pt(-afxData.cxBorder2, -afxData.cyBorder2); int nWidth = 0; // layout all the control bars for (int nPos = 0; nPos < m_arrBars.GetSize(); nPos++) { CControlBar* pBar = (CControlBar*)m_arrBars[nPos]; if (pBar != NULL) { if (pBar->IsVisible()) { // get ideal rect for bar CSize sizeBar = pBar->CalcFixedLayout(FALSE, (pBar->m_dwStyle & CBRS_ORIENT_HORZ) ? TRUE : FALSE); CRect rect(pt, sizeBar); // get current rect for bar CRect rectBar; pBar->GetWindowRect(&rectBar); ScreenToClient(&rectBar); if (bHorz) { // change position if size changed or top not the same or // rectbar.left < rect.left // if floating compress pt.x = rectBar.left; if (rect.Size() != rectBar.Size() || rect.top != rectBar.top || (rectBar.left < rect.left && !m_bFloating) || (rectBar.left != rect.left && m_bFloating)) { if (rectBar.left > rect.left && !m_bFloating) rect.OffsetRect(rectBar.left - rect.left, 0); AfxRepositionWindow(&layout, pBar->m_hWnd, &rect); pt.x = rect.left; } pt.x += sizeBar.cx - afxData.cxBorder2; nWidth = max(nWidth, sizeBar.cy); } else { // change position if size changed or top not the same or // rectbar.left < rect.left // if floating compress pt.y = rectBar.top; if (rect.Size() != rectBar.Size() || rect.left != rectBar.left || (rectBar.top < rect.top && !m_bFloating) || (rectBar.top != rect.top && m_bFloating)) { if (rectBar.top > rect.top && !m_bFloating) rect.OffsetRect(0, rectBar.top - rect.top); AfxRepositionWindow(&layout, pBar->m_hWnd, &rect); pt.y = rect.top; } pt.y += sizeBar.cy - afxData.cyBorder2; nWidth = max(nWidth, sizeBar.cx); } } // handle any delay/show hide for the bar pBar->RecalcDelayShow(&layout); } else if (nWidth != 0) { // end of row because pBar == NULL if (bHorz) { pt.y += nWidth - afxData.cyBorder2; sizeFixed.cx = max(sizeFixed.cx, pt.x); sizeFixed.cy = max(sizeFixed.cy, pt.y); pt.x = -afxData.cxBorder2; } else { pt.x += nWidth - afxData.cxBorder2; sizeFixed.cx = max(sizeFixed.cx, pt.x); sizeFixed.cy = max(sizeFixed.cy, pt.y); pt.y = -afxData.cyBorder2; } nWidth = 0; } } if (!m_bLayoutQuery) { // move and resize all the windows at once! if (layout.hDWP == NULL || !::EndDeferWindowPos(layout.hDWP)) TRACE0("Warning: DeferWindowPos failed - low system resources.\n"); } // adjust size for borders on the dock bar itself CRect rect; rect.SetRectEmpty(); CalcInsideRect(rect, bHorz); if ((!bStretch || !bHorz) && sizeFixed.cx != 0) sizeFixed.cx += -rect.right + rect.left; if ((!bStretch || bHorz) && sizeFixed.cy != 0) sizeFixed.cy += -rect.bottom + rect.top; return sizeFixed; }
void CProgressBar::DoPaint(CDC* pDC) // Paints the bar, assuming that the background has already been cleared to grey. // The bar has a percentage display on the left, followed by a progress bar // which is sized to fit the available space up to a maximum of MAXBARWIDTH pixels // If there is enough room, the current Job Description will also be displayed, to // the right of the bar. { ASSERT_VALID(this); ASSERT_VALID(pDC); CControlBar::DoPaint(pDC); // draw border CRect rect; GetClientRect(rect); CalcInsideRect(rect); ASSERT(m_hFont != NULL); CFont *OurFont = CHECKFONT(CFont::FromHandle(m_hFont)); // Get a CFont* for this HFONT CFont *OldFont = CHECKFONT(pDC->SelectObject(OurFont)); rect.InflateRect(-CX_BORDER, -CY_BORDER); CString PercentText("00%"); // Generate %age string if (CurrentPercent > 0 && CurrentPercent < 100) { if (CurrentPercent > 9) PercentText.SetAt(0, (CurrentPercent / 10) + '0'); PercentText.SetAt(1, (CurrentPercent % 10) + '0'); } pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT)); // Draw %age string pDC->SetBkColor(GetSysColor(COLOR_BTNFACE)); pDC->SetBkMode(OPAQUE); SetTextAlign(pDC->m_hDC, TA_LEFT | TA_BOTTOM); pDC->TextOut(rect.left, rect.bottom, PercentText); CSize TextSize = pDC->GetTextExtent(PercentText, 3); INT32 BarStart = rect.left + TextSize.cx + 4; // Calc bar position, size INT32 WindowEnd = rect.right - 4; INT32 BarWidth = WindowEnd - BarStart; if (BarWidth < 10) return; // Not enough room to do a bar! if (BarWidth > MAXBARWIDTH) BarWidth = MAXBARWIDTH; if (JobDescription != NULL && WindowEnd - BarStart > MAXBARWIDTH + 64) { // If enough room for some text, add the job description CString OutText = TEXT(*JobDescription); rect.left = BarStart + BarWidth + 4; rect.right = WindowEnd; pDC->TextOut(rect.left, rect.bottom, OutText); } CHECKFONT(pDC->SelectObject(OldFont)); // Restore previous font rect.left = BarStart; // Finally, calc and paint the bar,,, rect.right = BarStart+BarWidth; rect.bottom -= m_FontDescent - 2; // Line up bar bottom with text baseline Paint3dPlinth(pDC, &rect, FALSE); BarWidth -= 4; // Bar is 2 pixels inside plinth rectangle rect.left = BarStart + 2; rect.top += 2; rect.bottom -= 2; rect.right = rect.left + (INT32) (((WORD)BarWidth * (WORD)CurrentPercent) / 100); CBrush BlueBrush(RGB(0,0,255)); pDC->FillRect(rect, &BlueBrush); }
void CSearchParamsWnd::OnSize(UINT nType, int cx, int cy) { CDialogBar::OnSize(nType, cx, cy); if (m_ctlName.m_hWnd == NULL) return; if (cx >= MIN_HORZ_WIDTH) { CRect rcClient; GetClientRect(&rcClient); CalcInsideRect(rcClient, TRUE); // resizing the name field instead the filter fields makes sense, because the filter input mostly stays small while a bigger // name filed allows longer search queries without scrolling. // however it doesn't looks nice at all, because of the asymmetry which is created by not resizing the method selectors // but resizing them wouldn't make any sense at all, so we need to find a better build up at some point, but for now // stay with the old method which is not perfect but looks fair enough /* HDWP hdwp = BeginDeferWindowPos(12); if (hdwp) { UINT uFlags = SWP_NOZORDER | SWP_NOACTIVATE; int iWidthOpts = (rcClient.Width() * 35) / 100; if (iWidthOpts < m_rcOpts.Width()) iWidthOpts = m_rcOpts.Width(); int iXPosOpts = rcClient.right - iWidthOpts; ASSERT( m_rcStart.Width() == m_rcMore.Width() && m_rcStart.Width() == m_rcCancel.Width() ); int iXPosButtons = iXPosOpts - m_rcStart.Width() - 2; int iXPosDDArrow = iXPosButtons - 2 - m_rcDropDownArrow.Width(); int iWidthName = iXPosDDArrow - (rcClient.left + m_rcName.left); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_MSTATIC3), NULL, rcClient.left + m_rcNameLbl.left, rcClient.top + m_rcNameLbl.top, m_rcNameLbl.Width(), m_rcNameLbl.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlName, NULL, rcClient.left + m_rcName.left, rcClient.top + m_rcName.top, iWidthName, m_rcName.Height(), uFlags); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_DD), NULL, iXPosDDArrow, rcClient.top + m_rcDropDownArrow.top, m_rcDropDownArrow.Width(), m_rcDropDownArrow.Height(), uFlags); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_MSTATIC7), NULL, rcClient.left + m_rcFileTypeLbl.left, rcClient.top + m_rcFileTypeLbl.top, m_rcFileTypeLbl.Width(), m_rcFileTypeLbl.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlFileType, NULL, rcClient.left + m_rcFileType.left, rcClient.top + m_rcFileType.top, m_rcFileType.Width(), m_rcFileType.Height(), uFlags); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_SEARCH_RESET), NULL, rcClient.left + m_rcReset.left, rcClient.top + m_rcReset.top, m_rcReset.Width(), m_rcReset.Height(), uFlags); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_METH), NULL, rcClient.left + m_rcMethodLbl.left, rcClient.top + m_rcMethodLbl.top, m_rcMethodLbl.Width(), m_rcMethodLbl.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlMethod, NULL, rcClient.left + m_rcMethod.left, rcClient.top + m_rcMethod.top, m_rcMethod.Width(), m_rcMethod.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlStart, NULL, iXPosButtons, rcClient.top + m_rcStart.top, m_rcStart.Width(), m_rcStart.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlMore, NULL, iXPosButtons, rcClient.top + m_rcMore.top, m_rcMore.Width(), m_rcMore.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlCancel, NULL, iXPosButtons, rcClient.top + m_rcCancel.top, m_rcCancel.Width(), m_rcCancel.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlOpts, NULL, iXPosOpts, rcClient.top + m_rcOpts.top, iWidthOpts, m_rcOpts.Height(), uFlags); VERIFY( EndDeferWindowPos(hdwp) ); } */ int iWidthOpts = rcClient.right - (rcClient.left + m_rcOpts.left); HDWP hdwp = BeginDeferWindowPos(12); if (hdwp) { UINT uFlags = SWP_NOZORDER | SWP_NOACTIVATE; hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_MSTATIC3), NULL, rcClient.left + m_rcNameLbl.left, rcClient.top + m_rcNameLbl.top, m_rcNameLbl.Width(), m_rcNameLbl.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlName, NULL, rcClient.left + m_rcName.left, rcClient.top + m_rcName.top, m_rcName.Width(), m_rcName.Height(), uFlags); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_DD), NULL, rcClient.left + m_rcDropDownArrow.left, rcClient.top + m_rcDropDownArrow.top, m_rcDropDownArrow.Width(), m_rcDropDownArrow.Height(), uFlags); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_MSTATIC7), NULL, rcClient.left + m_rcFileTypeLbl.left, rcClient.top + m_rcFileTypeLbl.top, m_rcFileTypeLbl.Width(), m_rcFileTypeLbl.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlFileType, NULL, rcClient.left + m_rcFileType.left, rcClient.top + m_rcFileType.top, m_rcFileType.Width(), m_rcFileType.Height(), uFlags); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_SEARCH_RESET), NULL, rcClient.left + m_rcReset.left, rcClient.top + m_rcReset.top, m_rcReset.Width(), m_rcReset.Height(), uFlags); hdwp = DeferWindowPos(hdwp, *GetDlgItem(IDC_METH), NULL, rcClient.left + m_rcMethodLbl.left, rcClient.top + m_rcMethodLbl.top, m_rcMethodLbl.Width(), m_rcMethodLbl.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlMethod, NULL, rcClient.left + m_rcMethod.left, rcClient.top + m_rcMethod.top, m_rcMethod.Width(), m_rcMethod.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlStart, NULL, rcClient.left + m_rcStart.left, rcClient.top + m_rcStart.top, m_rcStart.Width(), m_rcStart.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlMore, NULL, rcClient.left + m_rcMore.left, rcClient.top + m_rcMore.top, m_rcMore.Width(), m_rcMore.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlCancel, NULL, rcClient.left + m_rcCancel.left, rcClient.top + m_rcCancel.top, m_rcCancel.Width(), m_rcCancel.Height(), uFlags); hdwp = DeferWindowPos(hdwp, m_ctlOpts, NULL, rcClient.left + m_rcOpts.left, rcClient.top + m_rcOpts.top, iWidthOpts, m_rcOpts.Height(), uFlags); VERIFY( EndDeferWindowPos(hdwp) ); } m_ctlOpts.ModifyStyle(0, LVS_NOCOLUMNHEADER); CRect rcOptsClnt; m_ctlOpts.GetClientRect(&rcOptsClnt); m_ctlOpts.SetColumnWidth(0, LVSCW_AUTOSIZE); // (**1) Adjust for Windows Classic Theme and Flat Style control int iCol2Width = rcOptsClnt.Width() - m_ctlOpts.GetColumnWidth(0) - 2/*(**1)*/; if (m_ctlOpts.GetColumnWidth(1) != iCol2Width) m_ctlOpts.SetColumnWidth(1, iCol2Width); } else if (cx < MIN_HORZ_WIDTH) { CRect rcClient; GetClientRect(&rcClient); CalcInsideRect(rcClient, FALSE); int y = rcClient.top; CRect rcNameLbl; GetDlgItem(IDC_MSTATIC3)->GetWindowRect(&rcNameLbl); ScreenToClient(&rcNameLbl); GetDlgItem(IDC_MSTATIC3)->MoveWindow(rcClient.left, y, rcNameLbl.Width(), rcNameLbl.Height()); y += rcNameLbl.Height() + 2; CRect rcName; m_ctlName.GetWindowRect(&rcName); ScreenToClient(&rcName); CRect rcDropDownArrow; GetDlgItem(IDC_DD)->GetWindowRect(&rcDropDownArrow); ScreenToClient(&rcDropDownArrow); int iNameWidth = rcClient.Width() - 4 - rcDropDownArrow.Width(); m_ctlName.MoveWindow(rcClient.left, y, iNameWidth, rcName.Height()); GetDlgItem(IDC_DD)->MoveWindow(rcClient.left + iNameWidth + 4, y, rcDropDownArrow.Width(), rcDropDownArrow.Height()); y += rcName.Height() + 2; CRect rcFileTypeLbl; GetDlgItem(IDC_MSTATIC7)->GetWindowRect(&rcFileTypeLbl); ScreenToClient(&rcFileTypeLbl); GetDlgItem(IDC_MSTATIC7)->MoveWindow(rcClient.left, y, rcFileTypeLbl.Width(), rcFileTypeLbl.Height()); y += rcFileTypeLbl.Height() + 2; CRect rcFileType; m_ctlFileType.GetWindowRect(&rcFileType); ScreenToClient(&rcFileType); m_ctlFileType.MoveWindow(rcClient.left, y, rcFileType.Width(), rcFileType.Height()); CRect rcReset; GetDlgItem(IDC_SEARCH_RESET)->GetWindowRect(&rcReset); ScreenToClient(&rcReset); GetDlgItem(IDC_SEARCH_RESET)->MoveWindow(rcClient.left + rcFileType.Width() + 8, y, rcReset.Width(), rcReset.Height()); y += rcFileType.Height() + 8; CRect rcMethodLbl; GetDlgItem(IDC_METH)->GetWindowRect(&rcMethodLbl); ScreenToClient(&rcMethodLbl); GetDlgItem(IDC_METH)->MoveWindow(rcClient.left, y, rcMethodLbl.Width(), rcMethodLbl.Height()); y += rcMethodLbl.Height() + 2; CRect rcMethod; m_ctlMethod.GetWindowRect(&rcMethod); ScreenToClient(&rcMethod); m_ctlMethod.MoveWindow(rcClient.left, y, rcMethod.Width(), rcMethod.Height()); y += rcMethod.Height() + 8; m_ctlStart.MoveWindow(rcClient.left, y, m_rcStart.Width(), m_rcStart.Height()); m_ctlMore.MoveWindow(rcClient.left + m_rcStart.Width() + 4, y, m_rcMore.Width(), m_rcMore.Height()); y += m_rcStart.Height() + 4; m_ctlCancel.MoveWindow(rcClient.left, y, m_rcCancel.Width(), m_rcCancel.Height()); y += m_rcStart.Height() + 4; int iOptsHeight = rcClient.bottom - y - 2; m_ctlOpts.MoveWindow(rcClient.left, y, rcClient.Width(), iOptsHeight); CRect rcOptsClnt; m_ctlOpts.GetClientRect(&rcOptsClnt); m_ctlOpts.SetColumnWidth(1, rcOptsClnt.Width() - m_ctlOpts.GetColumnWidth(0)); y += iOptsHeight + 4; m_ctlOpts.ModifyStyle(LVS_NOCOLUMNHEADER, 0); } }