void CMonitorBarCtrl::OnLButtonDown(UINT nFlags, CPoint point) { if ( m_rcTrack.PtInRect( point ) ) { MSG* pMsg = &AfxGetThreadState()->m_msgCur; CRect rcTrack( &m_rcTrack ); ClientToScreen( &rcTrack ); ClipCursor( &rcTrack ); ScreenToClient( &rcTrack ); rcTrack.DeflateRect( m_rcTab.Width() / 2, 0 ); m_bTab = TRUE; Invalidate(); while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 ) { while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) ); if ( ! AfxGetThread()->PumpMessage() ) { AfxPostQuitMessage( 0 ); break; } CPoint pt; GetCursorPos( &pt ); ScreenToClient( &pt ); int nPosition = (DWORD)( 110.0f * (float)( pt.x - rcTrack.left ) / (float)rcTrack.Width() ); if ( nPosition < 0 ) nPosition = 0; else if ( nPosition >= 105 ) nPosition = 101; else if ( nPosition >= 100 ) nPosition = 100; if ( nPosition != (int)Settings.Live.BandwidthScale ) { Settings.Live.BandwidthScale = (DWORD)nPosition; Invalidate(); } } m_bTab = FALSE; ReleaseCapture(); ClipCursor( NULL ); Invalidate(); } else { CControlBar::OnLButtonDown( nFlags, point ); } }
void CRemoteWnd::TrackSeek() { MSG* pMsg = &AfxGetThreadState()->m_msgCur; CRect rcTrack( &m_rcsMediaSeekTrack ); CPoint point; CMediaFrame* pMediaFrame = CMediaFrame::GetMediaFrame(); if ( pMediaFrame == NULL ) return; ClientToScreen( &rcTrack ); ClipCursor( &rcTrack ); ScreenToClient( &rcTrack ); SetCapture(); rcTrack.DeflateRect( m_rcMediaSeekTab.Width() / 2, 0 ); while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 ) { while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) ); if ( ! AfxGetThread()->PumpMessage() ) { AfxPostQuitMessage( 0 ); break; } GetCursorPos( &point ); ScreenToClient( &point ); float fPosition = (float)( point.x - rcTrack.left ) / (float)rcTrack.Width(); if ( fPosition < 0.0f ) fPosition = 0.0f; if ( fPosition > 1.0f ) fPosition = 1.0f; if ( fPosition != m_nMediaSeek ) { m_nMediaSeek = fPosition; Invalidate(); } } ReleaseCapture(); ClipCursor( NULL ); pMediaFrame->SeekTo( m_nMediaSeek ); m_nMediaSeek = -1; Invalidate(); }
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 CRemoteWnd::TrackScaler() { MSG* pMsg = &AfxGetThreadState()->m_msgCur; CRect rcTrack( &m_rcsScalerTrack ); CPoint point; ClientToScreen( &rcTrack ); ClipCursor( &rcTrack ); ScreenToClient( &rcTrack ); SetCapture(); rcTrack.DeflateRect( m_rcScalerTab.Width() / 2, 0 ); while ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 ) { while ( ::PeekMessage( pMsg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE ) ); if ( ! AfxGetThread()->PumpMessage() ) { AfxPostQuitMessage( 0 ); break; } GetCursorPos( &point ); ScreenToClient( &point ); int nPosition = (int)( 105.0f * (float)( point.x - rcTrack.left ) / (float)rcTrack.Width() ); if ( nPosition < 0 ) nPosition = 0; else if ( nPosition >= 102 ) nPosition = 101; else if ( nPosition >= 100 ) nPosition = 100; // ToDo: Settings.Live.BandwidthScaleOut if ( nPosition != (int)Settings.Live.BandwidthScaleIn ) { Settings.Live.BandwidthScaleIn = (DWORD)nPosition; Invalidate(); } } ReleaseCapture(); ClipCursor( NULL ); Invalidate(); }
BOOL CLibraryAlbumView::GetItemRect(CLibraryAlbumTrack* pTrack, CRect* pRect) { CRect rcClient, rcTrack( 0, 0, m_szTrack.cx, m_szTrack.cy ); GetClientRect( &rcClient ); rcClient.top += m_szTrack.cy; rcTrack.OffsetRect( rcClient.left, rcClient.top - m_nScroll ); CLibraryAlbumTrack** pList = m_pList; for ( int nItem = m_nCount ; nItem ; nItem--, pList++ ) { if ( *pList == pTrack ) { *pRect = rcTrack; return TRUE; } rcTrack.OffsetRect( 0, m_szTrack.cy ); } return FALSE; }
CLibraryAlbumTrack* CLibraryAlbumView::HitTest(const CPoint& point, CRect* pRect) const { CRect rcClient, rcTrack( 0, 0, m_szTrack.cx, m_szTrack.cy * 2 ); GetClientRect( &rcClient ); rcTrack.OffsetRect( rcClient.left, rcClient.top - m_nScroll ); CLibraryAlbumTrack** pList = m_pList; for ( int nItem = m_nCount ; nItem && rcTrack.top < rcClient.bottom ; nItem--, pList++ ) { CLibraryAlbumTrack* pTrack = *pList; if ( rcTrack.PtInRect( point ) ) { if ( pRect ) *pRect = rcTrack; return pTrack; } rcTrack.OffsetRect( 0, m_szTrack.cy ); } return NULL; }
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 ); } } }
//+--------------------------------------------------------------------------- // // Member: CScrollbar::Draw // // Synopsis: Draw the scroll bar in the given direction. // // Arguments: direction 0 for horizontal, 1 for vertical // rcScrollbar bounds of entire scroll bar // rcRedraw bounds to be redrawn // contentSize size of content controlled by scroll bar // containerSize size of area to scroll within // scrollAmount amount that the content is scrolled // partPressed which part, if any, is pressed // hdc DC to draw into // params customizable scroll bar parameters // pDI draw info // dwFlags rendering flags // // Notes: // //---------------------------------------------------------------------------- void CScrollbar::Draw( int direction, const CRect& rcScrollbar, const CRect& rcRedraw, long contentSize, long containerSize, long scrollAmount, SCROLLBARPART partPressed, HDC hdc, const CScrollbarParams& params, CDrawInfo* pDI, DWORD dwFlags) { Assert(hdc != NULL); // for now, we're using CDrawInfo, which should have the same hdc Assert(pDI->_hdc == hdc); // trivial rejection if nothing to draw if(!rcScrollbar.Intersects(rcRedraw)) { return; } BOOL fDisabled = (params._fForceDisabled) || (containerSize>=contentSize); long scaledButtonWidth = GetScaledButtonWidth(direction, rcScrollbar, params._buttonWidth); // compute rects for buttons and track CRect rcTrack(rcScrollbar); rcTrack[direction] += scaledButtonWidth; rcTrack[direction+2] -= scaledButtonWidth; // draw buttons unless requested not to (it's expensive to draw these!) if((dwFlags & DISPSCROLLBARHINT_NOBUTTONDRAW) == 0) { CRect rcButton[2]; rcButton[0] = rcScrollbar; rcButton[0][direction+2] = rcTrack[direction]; rcButton[1] = rcScrollbar; rcButton[1][direction] = rcTrack[direction+2]; // draw buttons CSize sizeButton; pDI->DocumentFromWindow( &sizeButton, rcButton[0].Width(), rcButton[0].Height()); for(int i=0; i<2; i++) { if(rcRedraw.Intersects(rcButton[i])) { BOOL fButtonPressed = (i==0 && partPressed==SBP_PREVBUTTON) || (i==1 && partPressed==SBP_NEXTBUTTON); CScrollButton scrollButton(params._pColors, params._fFlat); scrollButton.DrawButton( pDI, NULL, // no hwnd, we don't want to invalidate (direction==0?(i==0?BG_LEFT:BG_RIGHT):(i==0?BG_UP:BG_DOWN)), fButtonPressed, !fDisabled, FALSE, // never focused rcButton[i], sizeButton, 0); // assume both button glyphs are the same size } } } // draw track if(rcRedraw.Intersects(rcTrack)) { if(fDisabled) { // no thumb, so draw non-pressed track DrawTrack(rcTrack, FALSE, fDisabled, hdc, params); } else { // calculate thumb rect CRect rcThumb; GetPartRect( &rcThumb, SBP_THUMB, direction, rcScrollbar, contentSize, containerSize, scrollAmount, params._buttonWidth, pDI, FALSE); // can track contain the thumb? if(!rcTrack.Contains(rcThumb)) { DrawTrack(rcTrack, FALSE, fDisabled, hdc, params); } else { // draw previous track CRect rcTrackPart(rcTrack); rcTrackPart[direction+2] = rcThumb[direction]; if(rcRedraw.Intersects(rcTrackPart)) { DrawTrack(rcTrackPart, partPressed==SBP_PREVTRACK, fDisabled, hdc, params); } // draw thumb if(rcRedraw.Intersects(rcThumb)) { DrawThumb(rcThumb, partPressed==SBP_THUMB, hdc, params, pDI ); } // draw next track rcTrackPart = rcTrack; rcTrackPart[direction] = rcThumb[direction+2]; if(rcRedraw.Intersects(rcTrackPart)) { DrawTrack(rcTrackPart, partPressed==SBP_NEXTTRACK, fDisabled, hdc, params); } } } } }