void CCoolBar::NcCalcClient(LPRECT pRc, UINT nDockBarID) { CRect rcBar(pRc); // save the bar rect // subtract edges baseCCoolBar::NcCalcClient(pRc, nDockBarID); if (!HasGripper()) return; CRect rc(pRc); // the client rect as calculated by the base class BOOL bHorz = (nDockBarID == AFX_IDW_DOCKBAR_TOP) || (nDockBarID == AFX_IDW_DOCKBAR_BOTTOM); if (bHorz) rc.DeflateRect(m_cyGripper, 0, 0, 0); else rc.DeflateRect(0, m_cyGripper, 0, 0); // set position for the "x" (hide bar) button CPoint ptOrgBtn; if (bHorz) ptOrgBtn = CPoint(rc.left - 14, rc.top); else ptOrgBtn = CPoint(rc.right - 12, rc.top - 14); m_biHide.Move(ptOrgBtn - rcBar.TopLeft()); *pRc = rc; }
void CTextProgressCtrl::OnPaint() { CPaintDC dc(this); // device context for painting int saveDC = dc.SaveDC(); CRect rcClient; GetClientRect(&rcClient); CBrush brHollow; brHollow.Attach(::GetStockObject(NULL_BRUSH)); dc.SelectObject(&brHollow); // frame CPen pen(PS_SOLID, SCALEX(1), ::GetSysColor(COLOR_WINDOWFRAME)); dc.SelectObject(&pen); HIDPI_BorderRectangle(dc.GetSafeHdc(), rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); // inside rcClient.DeflateRect(SCALEX(1), SCALEY(1)); int nWd = (Hi - Lo); double pos = (double) Pos / nWd; // bar int nPhysPos = (int) (rcClient.Width() * pos); COLORREF clrBar = ::GetSysColor(COLOR_HIGHLIGHT); CRect rcBar(rcClient.left, rcClient.top, rcClient.left + nPhysPos, rcClient.bottom); dc.FillSolidRect(&rcBar, clrBar); COLORREF clrBkgnd = ::GetSysColor(COLOR_3DSHADOW); CRect rcBack(rcClient.left + nPhysPos, rcClient.top, rcClient.right, rcClient.bottom); dc.FillSolidRect(&rcBack, clrBkgnd); // draw text over the progress bar rcClient.DeflateRect(SCALEX(4), -1, SCALEX(4), 1); dc.SetBkMode(TRANSPARENT); dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); CRect rcSize(0, 0, 0, 0); if (!m_strSize.IsEmpty()) { dc.SelectObject(&m_fntSize); rcSize = rcClient; dc.DrawText(m_strSize, rcSize, DT_RIGHT | DT_BOTTOM | DT_SINGLELINE | DT_NOPREFIX | DT_CALCRECT); dc.DrawText(m_strSize, rcClient, DT_RIGHT | DT_BOTTOM | DT_SINGLELINE | DT_NOPREFIX); } dc.SelectObject(&m_fntText); CRect rcProgress = rcClient; rcProgress.right -= rcSize.Width() - SCALEX(6); DrawTextEndEllipsis(dc, m_strText, rcProgress, DT_LEFT | DT_BOTTOM | DT_SINGLELINE | DT_NOPREFIX); // validate GetClientRect(&rcClient); ValidateRect(rcClient); dc.RestoreDC(saveDC); }
void CSearchWnd::OnPaint() { CPaintDC dc( this ); CRect rcClient; GetClientRect( &rcClient ); rcClient.bottom -= Settings.Skin.ToolbarHeight; if ( m_wndDetails && m_wndDetails.IsWindowVisible() ) { CRect rcBar( rcClient.left, rcClient.bottom - m_nDetails - Settings.Skin.Splitter, rcClient.right, rcClient.bottom - m_nDetails ); if ( m_bPanel ) rcBar.left += Settings.Skin.SidebarWidth; dc.FillSolidRect( rcBar.left, rcBar.top, rcBar.Width(), 1, Colors.m_crResizebarEdge ); dc.FillSolidRect( rcBar.left, rcBar.top + 1, rcBar.Width(), 1, Colors.m_crResizebarHighlight ); dc.FillSolidRect( rcBar.left, rcBar.bottom - 1, rcBar.Width(), 1, Colors.m_crResizebarShadow ); dc.FillSolidRect( rcBar.left, rcBar.top + 2, rcBar.Width(), rcBar.Height() - 3, Colors.m_crResizebarFace ); } if ( m_bPaused || m_bWaitMore) return; CRect rc( &rcClient ); rc.bottom = rc.top + STATUS_HEIGHT; int nTop = rc.top + 4; if ( m_bPanel ) { rc.left += Settings.Skin.SidebarWidth; rc.bottom --; dc.FillSolidRect( rc.left, rc.bottom, rc.Width(), 1, RGB( 255, 255, 255 ) ); dc.Draw3dRect( &rc, CColors::CalculateColor( Colors.m_crBannerBack, RGB(255,255,255), 100 ), CColors::CalculateColor( Colors.m_crBannerBack, 0, 150 ) ); rc.DeflateRect( 1, 1 ); nTop --; } CoolInterface.Draw( &dc, IDR_SEARCHFRAME, 16, rc.left + 4, nTop, Colors.m_crBannerBack ); dc.ExcludeClipRect( rc.left + 4, nTop, rc.left + 4 + 16, nTop + 16 ); CFont* pFont = (CFont*)dc.SelectObject( &CoolInterface.m_fntNormal ); CString str; LoadString( str, IDS_SEARCH_ACTIVE ); dc.SetBkColor( Colors.m_crBannerBack ); dc.SetTextColor( Colors.m_crBannerText ); dc.ExtTextOut( rc.left + 8 + 16, nTop + 1, ETO_CLIPPED|ETO_OPAQUE, &rc, str, NULL ); dc.SelectObject( pFont ); }
void CProgressCtrlX::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CDrawInfo info; GetClientRect(&info.rcClient); // retrieve current position and range info.nCurPos = GetPos(); GetRange(info.nLower, info.nUpper); // Draw to memory DC CMemDC memDC(&dc); info.pDC = &memDC; // fill background if(m_pbrBk) memDC.FillRect(&info.rcClient, m_pbrBk); else memDC.FillSolidRect(&info.rcClient, m_clrBk); // apply borders info.rcClient.DeflateRect(m_rcBorders); // if current pos is out of range return if (info.nCurPos < info.nLower || info.nCurPos > info.nUpper) return; info.dwStyle = GetStyle(); BOOL fVert = info.dwStyle&PBS_VERTICAL; BOOL fSnake = info.dwStyle&PBS_SNAKE; BOOL fRubberBar = info.dwStyle&PBS_RUBBER_BAR; // calculate visible gradient width CRect rcBar(0,0,0,0); CRect rcMax(0,0,0,0); rcMax.right = fVert ? info.rcClient.Height() : info.rcClient.Width(); rcBar.right = (int)((float)(info.nCurPos-info.nLower) * rcMax.right / ((info.nUpper-info.nLower == 0) ? 1 : info.nUpper-info.nLower)); if(fSnake) rcBar.left = (int)((float)(m_nTail-info.nLower) * rcMax.right / ((info.nUpper-info.nLower == 0) ? 1 : info.nUpper-info.nLower)); // draw bar if(m_pbrBar) memDC.FillRect(&ConvertToReal(info, rcBar), m_pbrBar); else DrawMultiGradient(info, fRubberBar ? rcBar : rcMax, rcBar); // Draw text DrawText(info, rcMax, rcBar); // Do not call CProgressCtrl::OnPaint() for painting messages }
// Determine the location of the specified point relative to the client area // of a dialog. // point - contains the x- and y-coordinates of the cursor. int CNoteDlg::HitTest(CPoint point) { CRect rc; int nRes = HT_NOWHERE; GetClientRect(&rc); // Bar rectangle CRect rcBar(rc.left + 42, 0, rc.right - 22, 20); if (point.x <= m_nSizeFrame) { // Handle top left, bottom left and left sizing if (point.y <= m_nSizeFrame) nRes = HT_TOPLEFT; else if (point.y >= rc.Height() - m_nSizeFrame) nRes = HT_BOTTOMLEFT; else nRes = HT_LEFT; } else if (point.x >= rc.Width() - m_nSizeFrame) { // Handle top right, bottom right and right sizing if (point.y <= m_nSizeFrame) nRes = HT_TOPRIGHT; else if (point.y <= rc.Height() - m_nSizeFrame) nRes = HT_RIGHT; else nRes = HT_BOTTOMRIGHT; } else if (point.y <= m_nSizeFrame) { // Handle top sizing nRes = HT_TOP; } else if (point.y >= rc.Height() - m_nSizeFrame) { // Handle bottom sizing nRes = HT_BOTTOM; } else if (rcBar.PtInRect(point)) { // Handle the dialog moving nRes = HT_BAR; } return nRes; }
void CRemoteWnd::PaintScaler(CDC* pDC) { // MonitorBar Download throttle (ToDo: Also Settings.Live.BandwidthScaleOut) if ( m_bsScalerTrack ) { CRect rcTrack( &m_rcsScalerTrack ), rcPart; float fPosition = 0; if ( Settings.Live.BandwidthScaleIn > 100 ) fPosition = 1.0f; else fPosition = (float)Settings.Live.BandwidthScaleIn / 105.0f; if ( m_bsScalerTab ) { rcPart.CopyRect( &m_rcsScalerTab ); if ( m_bScaler ) rcPart.OffsetRect( rcPart.Width(), 0 ); m_rcScalerTab.left = rcTrack.left + (int)( fPosition * ( rcTrack.Width() - rcPart.Width() ) ); m_rcScalerTab.right = m_rcScalerTab.left + rcPart.Width(); m_rcScalerTab.top = rcTrack.top; m_rcScalerTab.bottom = rcTrack.top + rcPart.Height(); pDC->BitBlt( m_rcScalerTab.left, m_rcScalerTab.top, m_rcScalerTab.Width(), m_rcScalerTab.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY ); pDC->ExcludeClipRect( &m_rcScalerTab ); rcTrack.right = m_rcScalerTab.left; } if ( m_bsScalerBar ) { rcPart.CopyRect( &m_rcsScalerBar ); CRect rcBar( &rcTrack ); while ( rcBar.left < rcBar.right ) { pDC->BitBlt( rcBar.left, rcBar.top, min( rcBar.Width(), rcPart.Width() ), rcPart.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY ); rcBar.left += rcPart.Width(); } } } }
void CSizingControlBarG::NcCalcClient(LPRECT pRc, UINT nDockBarID) { CRect rcBar(pRc); // save the bar rect // subtract edges baseCSizingControlBarG::NcCalcClient(pRc, nDockBarID); if (!HasGripper()) return; CRect rc(pRc); // the client rect as calculated by the base class BOOL bHorz = (nDockBarID == AFX_IDW_DOCKBAR_TOP) || (nDockBarID == AFX_IDW_DOCKBAR_BOTTOM); if (bHorz) rc.DeflateRect(m_cyGripper, 0, 0, 0); else rc.DeflateRect(0, m_cyGripper, 0, 0); // set position for the "x" (hide bar) button CPoint ptOrgBtn; if (bHorz) ptOrgBtn = CPoint(rc.left - 13, rc.top); else ptOrgBtn = CPoint(rc.right - 12, rc.top - 13); m_biHide.Move(ptOrgBtn - rcBar.TopLeft()); // MDM // Now move the max button. if ( m_bUseMaxButton ) { if (bHorz) ptOrgBtn = CPoint(rc.left - 13 - 13, rc.top); else ptOrgBtn = CPoint(rc.right - 12 - 13, rc.top - 13); // MDM huh? m_btnMax.Move(ptOrgBtn - rcBar.TopLeft()); } *pRc = rc; }
void CExtProgressWnd::OnPaintProgress( CDC & dc, CRect rcClient ) { ASSERT_VALID( this ); ASSERT_VALID( (&dc) ); ASSERT( dc.GetSafeHdc() != NULL ); if( rcClient.Width() <= 0 || rcClient.Height() <= 0 ) return; if( ! dc.RectVisible( &rcClient ) ) return; CExtPaintManager * pPM = PmBridge_GetPM(); ASSERT_VALID( pPM ); int nRangeMin, nRangeMax; GetRange( nRangeMin, nRangeMax ); int nRange = nRangeMax - nRangeMin; int nPos = GetPos() - nRangeMin; DWORD dwStyle = GetStyle(); bool bHorz = ( ( dwStyle & PBS_VERTICAL ) == 0 ) ? true : false; bool bSmooth = ( ( dwStyle & PBS_SMOOTH ) != 0 ) ? true : false; bool bBorder = m_bHasBorder; //( ( dwStyle & WS_BORDER ) != 0 ) ? true : false; CRect rcProgress( rcClient ); if( ( ! pPM->GetCb2DbTransparentMode( this ) ) || ( ! pPM->PaintDockerBkgnd( true, dc, this ) ) ) { COLORREF clrBackgroundArea = ( m_clrBackgroundArea == COLORREF(-1L) ) ? pPM->GetColor( COLOR_3DFACE ) : m_clrBackgroundArea ; clrBackgroundArea = dc.GetNearestColor( clrBackgroundArea ); dc.FillSolidRect( &rcProgress, clrBackgroundArea ); } if( m_bUsePaintManager ) { CExtPaintManager::PAINTPROGRESSDATA _ppd( nPos, nRange, rcClient, bHorz, bSmooth, bBorder, this ); _ppd.m_bEndlessMode = m_bEndlessMode; _ppd.m_nEndlessNominator = m_nEndlessNominator; _ppd.m_nEndlessDenominator = m_nEndlessDenominator; if( pPM->PaintProgress( dc, _ppd ) ) return; } // if( m_bUsePaintManager ) if( bBorder ) { COLORREF clrBorderLT = ( m_clrBorderLT == COLORREF(-1L) ) ? pPM->GetColor( COLOR_3DDKSHADOW ) : m_clrBorderLT ; COLORREF clrBorderRB = ( m_clrBorderRB == COLORREF(-1L) ) ? clrBorderLT : m_clrBorderRB ; clrBorderLT = dc.GetNearestColor( clrBorderLT ); clrBorderRB = dc.GetNearestColor( clrBorderRB ); dc.Draw3dRect( &rcProgress, clrBorderLT, clrBorderRB ); rcProgress.DeflateRect( pPM->UiScalingDo( m_sizeBorderSpace.cx, CExtPaintManager::__EUIST_X ), pPM->UiScalingDo( m_sizeBorderSpace.cy, CExtPaintManager::__EUIST_Y ) ); if( rcProgress.Width() <= 0 || rcProgress.Height() <= 0 ) return; } // if( bBorder ) CRect rcBar( rcProgress ); if( m_bEndlessMode ) { ASSERT( m_nEndlessNominator > 0 ); ASSERT( m_nEndlessDenominator > 0 ); ASSERT( m_nEndlessNominator < m_nEndlessDenominator ); if( bHorz ) { LONG nBasic = rcBar.Width(); LONG nCross = rcBar.Height(); if( nCross <= 0 ) nCross = 1; LONG nAll = nBasic - ( bSmooth ? 0 : ( nBasic % nCross ) ); LONG nPart = ::MulDiv( nAll, m_nEndlessNominator, m_nEndlessDenominator ); LONG nExt = nAll - nPart; rcBar.left += ::MulDiv( nExt, nPos, nRange ); rcBar.right = rcBar.left + nPart; } else { LONG nBasic = rcBar.Height(); LONG nCross = rcBar.Width(); if( nCross <= 0 ) nCross = 1; LONG nAll = nBasic - ( bSmooth ? 0 : ( nBasic % nCross ) ); LONG nPart = ::MulDiv( nAll, m_nEndlessNominator, m_nEndlessDenominator ); LONG nExt = nAll - nPart; rcBar.bottom -= ::MulDiv( nExt, nPos, nRange ); rcBar.top = rcBar.bottom - nPart; } } // if( m_bEndlessMode ) else { if( nPos <= 0 || nRange <= 0 ) return; if( bHorz ) rcBar.right = rcBar.left + ::MulDiv( rcBar.Width(), nPos, nRange ); else rcBar.top = rcBar.bottom - ::MulDiv( rcBar.Height(), nPos, nRange ); } // else from if( m_bEndlessMode ) if( dc.RectVisible( &rcBar ) ) { COLORREF clrProgressBarFrom = ( m_clrProgressBarFrom == COLORREF(-1L) ) ? pPM->GetColor( COLOR_HIGHLIGHT ) : m_clrProgressBarFrom ; COLORREF clrProgressBarTo = ( m_clrProgressBarTo == COLORREF(-1L) ) ? clrProgressBarFrom : m_clrProgressBarTo ; if( m_lfEnlightClrProgressBarFrom != 0.0 ) clrProgressBarFrom = CExtPaintManager::stat_HLS_Adjust( clrProgressBarFrom, 0.0, m_lfEnlightClrProgressBarFrom ); if( m_lfEnlightClrProgressBarTo != 0.0 ) clrProgressBarTo = CExtPaintManager::stat_HLS_Adjust( clrProgressBarFrom, 0.0, m_lfEnlightClrProgressBarTo ); clrProgressBarFrom = dc.GetNearestColor( clrProgressBarFrom ); clrProgressBarTo = dc.GetNearestColor( clrProgressBarTo ); if( bSmooth ) { if( clrProgressBarFrom != clrProgressBarTo ) CExtPaintManager::stat_PaintGradientRect( dc, &rcBar, clrProgressBarFrom, clrProgressBarTo, m_bHorizontalGradientBars ); else dc.FillSolidRect( &rcBar, clrProgressBarFrom ); } // if( bSmooth ) else { INT nDistanceBetweenBlocks = pPM->UiScalingDo( bHorz ? m_sizeDistanceBetweenBlocks.cx : m_sizeDistanceBetweenBlocks.cy, bHorz ? CExtPaintManager::__EUIST_X : CExtPaintManager::__EUIST_Y ); CRect rcBlock; if( m_bEndlessMode ) rcBlock = rcBar; else rcBlock = rcProgress; if( bHorz ) rcBlock.right = rcBlock.left + ::MulDiv( rcBlock.Height(), m_sizeBlockScaleFactorH.cx, m_sizeBlockScaleFactorH.cy ); else rcBlock.top = rcBlock.bottom - ::MulDiv( rcBlock.Width(), m_sizeBlockScaleFactorV.cx, m_sizeBlockScaleFactorV.cy ); if( rcBlock.Width() <= 0 ) rcBlock.right = rcBlock.left + 1; if( rcBlock.Height() <= 0 ) rcBlock.top = rcBlock.bottom - 1; for( INT nIndex = 0; true; nIndex ++ ) { if( bHorz ) { if( rcBlock.left > rcBar.right ) break; if( dc.RectVisible( &rcBlock ) ) { if( clrProgressBarFrom != clrProgressBarTo ) CExtPaintManager::stat_PaintGradientRect( dc, &rcBlock, clrProgressBarFrom, clrProgressBarTo, m_bHorizontalGradientBars ); else dc.FillSolidRect( &rcBlock, clrProgressBarFrom ); } // if( dc.RectVisible( &rcBlock ) ) rcBlock.OffsetRect( rcBlock.Width() + nDistanceBetweenBlocks, 0 ); } // if( bHorz ) else { if( rcBlock.bottom < rcBar.top ) break; if( dc.RectVisible( &rcBlock ) ) { if( clrProgressBarFrom != clrProgressBarTo ) CExtPaintManager::stat_PaintGradientRect( dc, &rcBlock, clrProgressBarFrom, clrProgressBarTo, m_bHorizontalGradientBars ); else dc.FillSolidRect( &rcBlock, clrProgressBarFrom ); } // if( dc.RectVisible( &rcBlock ) ) rcBlock.OffsetRect( 0, - rcBlock.Height() - nDistanceBetweenBlocks ); } // else from if( bHorz ) } // for( INT nIndex = 0; true; nIndex ++ ) } // else from if( bSmooth ) } // if( dc.RectVisible( &rcBar ) ) }
void CRemoteWnd::PaintMedia(CDC* pDC) { if ( m_bsMediaSeekTrack ) { CRect rcTrack( &m_rcsMediaSeekTrack ), rcPart; float fPosition = m_nMediaSeek; if ( fPosition < 0 ) { fPosition = 0; if ( CMediaFrame* pMediaFrame = CMediaFrame::GetMediaFrame() ) fPosition = pMediaFrame->GetPosition(); } if ( m_bsMediaSeekTab ) { rcPart.CopyRect( &m_rcsMediaSeekTab ); if ( m_bMediaSeek || m_nMediaSeek >= 0 ) rcPart.OffsetRect( rcPart.Width(), 0 ); m_rcMediaSeekTab.left = rcTrack.left + (int)( fPosition * ( rcTrack.Width() - rcPart.Width() ) ); m_rcMediaSeekTab.right = m_rcMediaSeekTab.left + rcPart.Width(); m_rcMediaSeekTab.top = rcTrack.top; m_rcMediaSeekTab.bottom = rcTrack.top + rcPart.Height(); pDC->BitBlt( m_rcMediaSeekTab.left, m_rcMediaSeekTab.top, m_rcMediaSeekTab.Width(), m_rcMediaSeekTab.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY ); pDC->ExcludeClipRect( &m_rcMediaSeekTab ); rcTrack.right = m_rcMediaSeekTab.left; } if ( m_bsMediaSeekBar ) { rcPart.CopyRect( &m_rcsMediaSeekBar ); CRect rcBar( &rcTrack ); while ( rcBar.left < rcBar.right ) { pDC->BitBlt( rcBar.left, rcBar.top, min( rcBar.Width(), rcPart.Width() ), rcPart.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY ); rcBar.left += rcPart.Width(); } } } if ( m_bsMediaVolTrack ) { float fPosition = (float)Settings.MediaPlayer.Volume; CRect rcTrack( &m_rcsMediaVolTrack ), rcPart; if ( m_bsMediaVolTab ) { rcPart.CopyRect( &m_rcsMediaVolTab ); if ( m_bMediaVol || m_nMediaVol >= 0 ) rcPart.OffsetRect( rcPart.Width(), 0 ); m_rcMediaVolTab.left = rcTrack.left + (int)( fPosition * ( rcTrack.Width() - rcPart.Width() ) ); m_rcMediaVolTab.right = m_rcMediaVolTab.left + rcPart.Width(); m_rcMediaVolTab.top = rcTrack.top; m_rcMediaVolTab.bottom = rcTrack.top + rcPart.Height(); pDC->BitBlt( m_rcMediaVolTab.left, m_rcMediaVolTab.top, m_rcMediaVolTab.Width(), m_rcMediaVolTab.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY ); pDC->ExcludeClipRect( &m_rcMediaVolTab ); rcTrack.right = m_rcMediaVolTab.left; } if ( m_bsMediaVolBar ) { rcPart.CopyRect( &m_rcsMediaVolBar ); rcTrack.right = min( rcTrack.right, rcTrack.left + rcPart.Width() ); pDC->BitBlt( rcTrack.left, rcTrack.top, rcTrack.Width(), rcPart.Height(), &m_pSkin->m_dcSkin, rcPart.left, rcPart.top, SRCCOPY ); } } if ( CMediaFrame* pMediaFrame = CMediaFrame::GetMediaFrame() ) { if ( m_bsStatusText && ! m_bStatus ) m_bStatus |= pMediaFrame->PaintStatusMicro( *pDC, m_rcsStatusText ); MediaState nState = pMediaFrame->GetState(); int nImage = 0; if ( nState >= smsPlaying ) nImage = 1; else if ( nState >= smsPaused ) nImage = 2; if ( m_bsMediaStates[0][nImage] && m_bsMediaStates[1][nImage] ) { CRect* prcAnchor = &m_rcsMediaStates[0][nImage]; CRect* prcPart = &m_rcsMediaStates[1][nImage]; pDC->BitBlt( prcAnchor->left, prcAnchor->top, prcAnchor->Width(), prcAnchor->Height(), &m_pSkin->m_dcSkin, prcPart->left, prcPart->top, SRCCOPY ); } } }