Exemple #1
0
void CLibraryTileView::OnPaint()
{
	CPaintDC dc( this );

	CDC* pBuffer = CoolInterface.GetBuffer( dc, m_szBlock );
	CRect rcBuffer( 0, 0, m_szBlock.cx, m_szBlock.cy );

	CFont* pOldFont = (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntNormal );
	pBuffer->SetBkMode( OPAQUE );
	pBuffer->SetBkColor( Colors.m_crWindow );
	pBuffer->SetTextColor( Colors.m_crText );

	CDC dcMem;
	dcMem.CreateCompatibleDC( &dc );

	CRect rcClient;
	GetClientRect( &rcClient );
	CPoint pt( rcClient.left, rcClient.top - m_nScroll );

	CSingleLock oLock( &Library.m_pSection );
	if ( oLock.Lock( 100 ) )
	{
		for ( iterator pTile = begin(); pTile != end() && pt.y < rcClient.bottom; ++pTile )
		{
			CRect rcBlock( pt.x, pt.y, pt.x + m_szBlock.cx, pt.y + m_szBlock.cy );

			if ( rcBlock.bottom >= rcClient.top && dc.RectVisible( &rcBlock ) )
			{
				pBuffer->FillSolidRect( &rcBuffer, Colors.m_crWindow );
				bool bSelected = (*pTile)->m_bSelected;
				CAlbumFolder* pAlbum = (*pTile)->GetAlbum();
				if ( pAlbum && m_oDropItem == CLibraryListItem( pAlbum ) )
					(*pTile)->m_bSelected = true;

				(*pTile)->Paint( pBuffer, rcBuffer, &dcMem, pTile == m_pFocus );
				(*pTile)->m_bSelected = bSelected;
				dc.BitBlt( rcBlock.left, rcBlock.top, m_szBlock.cx, m_szBlock.cy, pBuffer, 0, 0, SRCCOPY );
				dc.ExcludeClipRect( &rcBlock );
			}

			pt.x += m_szBlock.cx;

			if ( pt.x + m_szBlock.cx > rcClient.right )
			{
				pt.x = rcClient.left;
				pt.y += m_szBlock.cy;
			}
		}
	}
	else
	{
		Invalidate( FALSE );
	}

	pBuffer->SelectObject( pOldFont );
	dc.FillSolidRect( &rcClient, Colors.m_crWindow );
}
HBITMAP CLibraryAlbumView::CreateDragImage(const CPoint& ptMouse, CPoint& ptMiddle)
{
	CRect rcClient, rcOne, rcAll( 32000, 32000, -32000, -32000 );

	GetClientRect( &rcClient );

	for ( POSITION pos = m_pSelTrack.GetHeadPosition() ; pos ; )
	{
		CLibraryAlbumTrack* pTrack = m_pSelTrack.GetNext( pos );
		GetItemRect( pTrack, &rcOne );

		if ( rcOne.IntersectRect( &rcClient, &rcOne ) )
		{
			rcAll.left		= min( rcAll.left, rcOne.left );
			rcAll.top		= min( rcAll.top, rcOne.top );
			rcAll.right		= max( rcAll.right, rcOne.right );
			rcAll.bottom	= max( rcAll.bottom, rcOne.bottom );
		}
	}

	BOOL bClipped = rcAll.Height() > MAX_DRAG_SIZE;

	if ( bClipped )
	{
		rcAll.left		= max( rcAll.left, ptMouse.x - MAX_DRAG_SIZE_2 );
		rcAll.right		= max( rcAll.right, ptMouse.x + MAX_DRAG_SIZE_2 );
		rcAll.top		= max( rcAll.top, ptMouse.y - MAX_DRAG_SIZE_2 );
		rcAll.bottom	= max( rcAll.bottom, ptMouse.y + MAX_DRAG_SIZE_2 );
	}

	CClientDC dcClient( this );
	CBitmap bmDrag;
	CDC dcDrag;

	if ( ! dcDrag.CreateCompatibleDC( &dcClient ) )
		return NULL;
	if ( ! bmDrag.CreateCompatibleBitmap( &dcClient, rcAll.Width(), rcAll.Height() ) )
		return NULL;

	CBitmap *pOldDrag = dcDrag.SelectObject( &bmDrag );

	dcDrag.FillSolidRect( 0, 0, rcAll.Width(), rcAll.Height(), DRAG_COLOR_KEY );

	CRgn pRgn;

	ptMiddle.SetPoint( ptMouse.x - rcAll.left, ptMouse.y - rcAll.top );
	if ( bClipped )
	{
		pRgn.CreateEllipticRgn(	ptMiddle.x - MAX_DRAG_SIZE_2, ptMiddle.y - MAX_DRAG_SIZE_2,
								ptMiddle.x + MAX_DRAG_SIZE_2, ptMiddle.y + MAX_DRAG_SIZE_2 );
		dcDrag.SelectClipRgn( &pRgn );
	}

	CDC* pBuffer = CoolInterface.GetBuffer( dcClient, m_szTrack );
	CRect rcBuffer( 0, 0, m_szTrack.cx, m_szTrack.cy );

	CFont* pOldFont = (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntNormal );

	for ( POSITION pos = m_pSelTrack.GetHeadPosition() ; pos ; )
	{
		CLibraryAlbumTrack* pTrack = m_pSelTrack.GetNext( pos );
		GetItemRect( pTrack, &rcOne );
		CRect rcDummy;

		if ( rcDummy.IntersectRect( &rcAll, &rcOne ) )
		{
			pBuffer->FillSolidRect( &rcBuffer, DRAG_COLOR_KEY );
			pTrack->Paint( this, pBuffer, rcBuffer, -1 );
			dcDrag.BitBlt( rcOne.left - rcAll.left, rcOne.top - rcAll.top,
				m_szTrack.cx, m_szTrack.cy, pBuffer, 0, 0, SRCCOPY );
		}
	}

	pBuffer->SelectObject( pOldFont );
	dcDrag.SelectObject( pOldDrag );
	dcDrag.DeleteDC();

	return (HBITMAP) bmDrag.Detach();
}
void CLibraryAlbumView::OnPaint()
{
	CPaintDC dc( this );

	CRect rcBuffer( 0, 0, m_szTrack.cx, m_szTrack.cy );
	CDC* pBuffer = CoolInterface.GetBuffer( dc, m_szTrack );
	if ( Settings.General.LanguageRTL ) pBuffer->SetTextAlign( TA_RTLREADING );

	CFont* pOldFont = (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntNormal );
	pBuffer->SetBkMode( OPAQUE );
	pBuffer->SetBkColor( Colors.m_crWindow );
	pBuffer->SetTextColor( Colors.m_crText );

	m_crRows[0] = CColors::CalculateColor( Colors.m_crWindow, Colors.m_crSchemaRow[0], 128 );
	m_crRows[1] = CColors::CalculateColor( Colors.m_crWindow, Colors.m_crSchemaRow[1], 128 );

	CRect rcClient, rcTrack;
	GetClientRect( &rcClient );

	rcTrack = rcBuffer;
	rcTrack.OffsetRect( rcClient.left, 0 );

	CLibraryAlbumTrack** pList = m_pList;

	// Column headers

	pBuffer->SelectObject( &CoolInterface.m_fntBold );
	CRect rcLine(rcTrack);
	rcLine.left += ICON_WIDTH;
	rcLine.right -= RATING_WIDTH;
	pBuffer->FillSolidRect( &rcBuffer, Colors.m_crWindow );
	if ( m_pStyle == CSchema::uriMusicAlbum )
	{
		// Track, Title, Length, Bitrate
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine,  0,   5, IDS_LIBRARY_ALBUM_TRACK, TRUE );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine,  5,  84, IDS_LIBRARY_ALBUM_TITLE );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 84,  92, IDS_LIBRARY_ALBUM_LENGTH, TRUE );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 92, 100, IDS_LIBRARY_ALBUM_BITRATE, TRUE );
	}
	else if ( m_pStyle == CSchema::uriMusicArtist )
	{
		// Album, Title, Length, Bitrate
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine,  0,  30, IDS_LIBRARY_ALBUM_ALBUM );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 30,  84, IDS_LIBRARY_ALBUM_TITLE );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 84,  92, IDS_LIBRARY_ALBUM_LENGTH, TRUE );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 92, 100, IDS_LIBRARY_ALBUM_BITRATE, TRUE );
	}
	else if ( m_pStyle == CSchema::uriMusicAll ) // Genre
	{
		// Artist, Album, Title, Length, Bitrate
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine,  0,  25, IDS_LIBRARY_ALBUM_ARTIST );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 25,  50, IDS_LIBRARY_ALBUM_ALBUM );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 50,  84, IDS_LIBRARY_ALBUM_TITLE );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 84,  92, IDS_LIBRARY_ALBUM_LENGTH, TRUE );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 92, 100, IDS_LIBRARY_ALBUM_BITRATE, TRUE );
	}
	else // Non-music
	{
		// Title, Artist, Length
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine,  0,  66, IDS_LIBRARY_ALBUM_TITLE );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 66,  88, IDS_LIBRARY_ALBUM_ARTIST );
		CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 88, 100, IDS_TIP_SIZE, TRUE );
	}
	// Rating
	rcLine.left = rcLine.right;
	rcLine.right += RATING_WIDTH;
	CLibraryAlbumTrack::PaintText( pBuffer, rcLine, 0, 100, IDS_LIBRARY_ALBUM_RATING, TRUE );

	pBuffer->SelectObject( &CoolInterface.m_fntNormal );

	dc.BitBlt( rcTrack.left, rcTrack.top, rcBuffer.right, rcBuffer.bottom, pBuffer, 0, 0, SRCCOPY );
	dc.ExcludeClipRect( &rcTrack );
	rcTrack.OffsetRect( 0, rcClient.top - m_nScroll );
	rcTrack.OffsetRect( 0, m_szTrack.cy );

	for ( int nItem = 0 ; nItem < m_nCount && rcTrack.top < rcClient.bottom ; nItem++, pList++ )
	{
		CLibraryAlbumTrack* pTrack = *pList;

		if ( rcTrack.bottom >= rcClient.top && dc.RectVisible( &rcTrack ) )
		{
			pBuffer->FillSolidRect( &rcBuffer, Colors.m_crWindow );
			pTrack->Paint( this, pBuffer, rcBuffer, nItem );
			dc.BitBlt( rcTrack.left, rcTrack.top, rcBuffer.right, rcBuffer.bottom, pBuffer, 0, 0, SRCCOPY );
			dc.ExcludeClipRect( &rcTrack );
		}

		rcTrack.OffsetRect( 0, m_szTrack.cy );
	}

	pBuffer->SelectObject( pOldFont );
	dc.FillSolidRect( &rcClient, Colors.m_crWindow );
}
Exemple #4
0
HBITMAP CLibraryTileView::CreateDragImage(const CPoint& ptMouse, CPoint& ptMiddle)
{
	ASSUME_LOCK( Library.m_pSection );

	CRect rcClient, rcOne, rcAll( 32000, 32000, -32000, -32000 );

	GetClientRect( &rcClient );

	for ( std::list< iterator >::iterator pTile = m_oSelTile.begin(); pTile != m_oSelTile.end(); ++pTile )
	{
		GetItemRect( *pTile, &rcOne );

		if ( rcOne.IntersectRect( &rcClient, &rcOne ) )
		{
			rcAll.left		= min( rcAll.left, rcOne.left );
			rcAll.top		= min( rcAll.top, rcOne.top );
			rcAll.right		= max( rcAll.right, rcOne.right );
			rcAll.bottom	= max( rcAll.bottom, rcOne.bottom );
		}
	}

	const bool bClipped = rcAll.Height() > MAX_DRAG_SIZE;

	if ( bClipped )
	{
		rcAll.left		= max( rcAll.left, ptMouse.x - MAX_DRAG_SIZE_2 );
		rcAll.right		= max( rcAll.right, ptMouse.x + MAX_DRAG_SIZE_2 );
		rcAll.top		= max( rcAll.top, ptMouse.y - MAX_DRAG_SIZE_2 );
		rcAll.bottom	= max( rcAll.bottom, ptMouse.y + MAX_DRAG_SIZE_2 );
	}

	CClientDC dcClient( this );
	CDC dcMem, dcDrag;
	CBitmap bmDrag;

	if ( ! dcMem.CreateCompatibleDC( &dcClient ) )
		return NULL;
	if ( ! dcDrag.CreateCompatibleDC( &dcClient ) )
		return NULL;
	if ( ! bmDrag.CreateCompatibleBitmap( &dcClient, rcAll.Width(), rcAll.Height() ) )
		return NULL;

	CBitmap *pOldDrag = dcDrag.SelectObject( &bmDrag );

	dcDrag.FillSolidRect( 0, 0, rcAll.Width(), rcAll.Height(), DRAG_COLOR_KEY );

	ptMiddle.SetPoint( ptMouse.x - rcAll.left, ptMouse.y - rcAll.top );

	CRgn pRgn;
	if ( bClipped )
	{
		pRgn.CreateEllipticRgn(	ptMiddle.x - MAX_DRAG_SIZE_2, ptMiddle.y - MAX_DRAG_SIZE_2,
								ptMiddle.x + MAX_DRAG_SIZE_2, ptMiddle.y + MAX_DRAG_SIZE_2 );
		dcDrag.SelectClipRgn( &pRgn );
	}

	CDC* pBuffer = CoolInterface.GetBuffer( dcClient, m_szBlock );
	CRect rcBuffer( 0, 0, m_szBlock.cx, m_szBlock.cy );

	CFont* pOldFont = (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntNormal );

	for ( std::list< iterator >::iterator pTile = m_oSelTile.begin(); pTile != m_oSelTile.end(); ++pTile )
	{
		GetItemRect( *pTile, &rcOne );
		CRect rcDummy;

		if ( rcDummy.IntersectRect( &rcAll, &rcOne ) )
		{
			pBuffer->FillSolidRect( &rcBuffer, DRAG_COLOR_KEY );
			(**pTile)->Paint( pBuffer, rcBuffer, &dcMem, (*pTile) == m_pFocus );
			dcDrag.BitBlt( rcOne.left - rcAll.left, rcOne.top - rcAll.top,
				m_szBlock.cx, m_szBlock.cy, pBuffer, 0, 0, SRCCOPY );
		}
	}

	pBuffer->SelectObject( pOldFont );

	dcDrag.SelectObject( pOldDrag );

	dcDrag.DeleteDC();

	return (HBITMAP) bmDrag.Detach();
}