void CLibraryMetaPanel::OnPaint()
{
	CSingleLock pLock( &m_pSection, TRUE );
	CPaintDC dc( this );
	CRect rcClient;
	CString str;
	DWORD dwFlags = ( Settings.General.LanguageRTL ? ETO_RTLREADING : 0 );

	GetClientRect( &rcClient );

	CFont* pOldFont = dc.GetCurrentFont();
	dc.SetTextColor( CoolInterface.m_crText );
	dc.SetBkColor( CoolInterface.m_crWindow );
	dc.SetBkMode( OPAQUE );

	if ( m_nSelected == 0 )
	{
		dc.SelectObject( &CoolInterface.m_fntNormal );
		LoadString( str, IDS_LIBPANEL_NO_SELECTION );
		CSize sz = dc.GetTextExtent( str );
		CPoint pt = rcClient.CenterPoint();
		pt.x -= sz.cx / 2; pt.y -= sz.cy / 2;
		dc.ExtTextOut( pt.x, pt.y, ETO_OPAQUE|dwFlags, &rcClient, str, NULL );
		dc.SelectObject( pOldFont );
		return;
	}

	// Draw thumbnail or icon
	int nThumbSize = min( max( rcClient.Height() - 16, 64 ), (int)Settings.Library.ThumbSize );
	CRect rcWork( rcClient.left + 8, rcClient.top + 8,
		rcClient.left + 8 + nThumbSize, rcClient.top + 8 + nThumbSize );
	CoolInterface.DrawThumbnail( &dc, rcWork, TRUE, FALSE, m_bmThumb, m_nIcon48, m_nIcon32,
		IsThreadAlive() ? LoadString( IDS_SEARCH_DETAILS_PREVIEWING ) : CString() );
	rcWork.SetRect( rcWork.right + 8, rcWork.top, rcClient.right - 8, rcClient.bottom );

	dc.SetViewportOrg( 0, -GetScrollPos( SB_VERT ) );

	dc.SetBkColor( CoolInterface.m_crWindow );

	if ( m_nRating > 1 )
	{
		CPoint ptStar( rcWork.right - 3, rcWork.top - 2 );
		m_rcRating.SetRectEmpty();

		for ( int nRating = m_nRating - 1 ; nRating ; nRating-- )
		{
			ptStar.x -= 16;
			CoolInterface.Draw( &dc, IDI_STAR, 16, ptStar.x, ptStar.y, CoolInterface.m_crWindow );
			dc.ExcludeClipRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 );
			m_rcRating.UnionRect( &m_rcRating, CRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 ) );
		}
	}
	else if ( m_nRating == 1 )
	{
		CPoint ptStar( rcWork.right - 3, rcWork.top - 2 );
		m_rcRating.SetRectEmpty();
		ptStar.x -= 16;
		CoolInterface.Draw( &dc, IDI_FAKE, 16, ptStar.x, ptStar.y, CoolInterface.m_crWindow );
		dc.ExcludeClipRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 );
		m_rcRating.UnionRect( &m_rcRating, CRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 ) );
	}
	else
	{
		m_rcRating.SetRectEmpty();
		dc.SelectObject( &CoolInterface.m_fntUnder );
		dc.SetTextColor( CoolInterface.m_crTextLink );
		LoadString( str, IDS_LIBPANEL_RATE_FILE );
		CSize szText = dc.GetTextExtent( str );
		DrawText( &dc, rcWork.right - szText.cx, rcWork.top, str, &m_rcRating );
	}

	dc.SelectObject( &CoolInterface.m_fntCaption );
	dc.SetTextColor( CoolInterface.m_crText );
	DrawText( &dc, rcWork.left, rcWork.top, m_sName, NULL, rcWork.Width() - m_rcRating.Width() - 4 );

	rcWork.top += 20;
	dc.FillSolidRect( rcWork.left, rcWork.top, rcWork.Width(), 1, CoolInterface.m_crMargin );
	dc.ExcludeClipRect( rcWork.left, rcWork.top, rcWork.right, rcWork.top + 1 );
	dc.SetBkColor( CoolInterface.m_crWindow );
	dc.SetTextColor( CoolInterface.m_crText );
	rcWork.top += 4;

	dc.SelectObject( &CoolInterface.m_fntBold );
	LoadString( str, IDS_TIP_LOCATION );
	if ( Settings.General.LanguageRTL )
		DrawText( &dc, rcWork.left, rcWork.top, ':' + str );
	else
		DrawText( &dc, rcWork.left, rcWork.top, str + ':' );
	LoadString( str, IDS_TIP_SIZE );
	DrawText( &dc, rcWork.right - 125, rcWork.top, str + ':' );
	dc.SelectObject( &CoolInterface.m_fntNormal );
	DrawText( &dc, rcWork.right - 60, rcWork.top, m_sSize );

	if ( m_sFolder.Find( '\\' ) >= 0 )
	{
		dc.SelectObject( &CoolInterface.m_fntUnder );
		dc.SetTextColor( CoolInterface.m_crTextLink );
		str = m_sFolder;
		long nTextLength = dc.GetTextExtent( str + _T('\x2026') ).cx;
		const long nLimit = rcWork.Width() - 125 - 68 - 10;
		if ( nTextLength > nLimit && nLimit > 0 )
		{
			while ( nTextLength > nLimit )
			{
				if ( str.IsEmpty() ) break;
				str = str.Left( str.GetLength() - 1 );
				nTextLength = dc.GetTextExtent( str + _T('\x2026') ).cx;
			}
			str += _T('\x2026');
		}
		else if ( nLimit <= 0 ) str.Empty();
	}
	else str.Empty();

	DrawText( &dc, rcWork.left + 68, rcWork.top, str, &m_rcFolder );
	if ( m_sFolder.Find( '\\' ) < 0 ) m_rcFolder.SetRectEmpty();
	rcWork.top += 18;

	m_pMetadata->Paint( &dc, &rcWork );

	dc.SetViewportOrg( 0, 0 );

	dc.SelectObject( pOldFont );
	dc.FillSolidRect( &rcClient, CoolInterface.m_crWindow );
}
void CLibraryAlbumTrack::Paint(CLibraryAlbumView* pView, CDC* pDC, const CRect& rcTrack, int nCount)
{
	COLORREF crBack = m_bSelected ? Colors.m_crHighlight : CLibraryAlbumView::m_crRows[ nCount & 1 ];

	pDC->SetBkColor( crBack );
	pDC->SetTextColor( m_bSelected ? Colors.m_crHiText : Colors.m_crText );

	CRect rcLine( &rcTrack );
	rcLine.DeflateRect( 2, 1 );

	// Icon Box

	CRect rcTemp( rcLine.left, rcLine.top, rcLine.left + ICON_WIDTH, rcLine.bottom );
	rcLine.left += ICON_WIDTH;

	if ( nCount >= 0 )
		PaintText( pDC, rcTemp, 0, 100, NULL );

	ShellIcons.Draw( pDC, m_nShell, 16, rcTemp.left + 4,
		( rcTemp.top + rcTemp.bottom ) / 2 - 8, CLR_NONE, m_bSelected );

	// Rating Stars Box

	rcTemp.SetRect( rcLine.right - RATING_WIDTH, rcLine.top, rcLine.right, rcLine.bottom );
	rcLine.right -= RATING_WIDTH;

	CPoint ptStar( rcTemp.left + 4, ( rcTemp.top + rcTemp.bottom ) / 2 - 6 );
	PaintText( pDC, rcTemp, 0, 100, NULL, TRUE );

	if ( pView->m_pRating == this && m_nSetRating < 7 )
	{
		for ( int nRating = 2 ; nRating <= 6 ; nRating++ )
		{
			ImageList_DrawEx( pView->m_pStars, m_nSetRating >= nRating ? 2 : 1,
				*pDC, ptStar.x, ptStar.y, 12, 12,
				m_bSelected ? CLR_NONE : crBack, crBack,
				m_nSetRating >= nRating ? ILD_NORMAL : ILD_BLEND50 );
			ptStar.x += 12;
		}
	}
	else
	{
		for ( int nRating = 2 ; nRating <= 6 ; nRating++ )
		{
			ImageList_DrawEx( pView->m_pStars, m_nRating >= nRating ? 0 : 1,
				*pDC, ptStar.x, ptStar.y, 12, 12,
				m_bSelected ? CLR_NONE : crBack, crBack,
				m_nRating >= nRating ? ILD_NORMAL : ILD_BLEND50 );
			ptStar.x += 12;
		}
	}

	ptStar.x++;	// Comment icon gap

	if ( pView->m_pRating == this && m_nSetRating == 7 )
	{
		ImageList_DrawEx( pView->m_pStars, 5,
			*pDC, ptStar.x, ptStar.y, 12, 12, CLR_NONE, crBack, ILD_NORMAL );
	}
	else
	{
		ImageList_DrawEx( pView->m_pStars, m_bComments ? 3 : 4,
			*pDC, ptStar.x, ptStar.y, 12, 12,
			m_bSelected ? CLR_NONE : crBack, crBack,
			m_bComments ? ILD_NORMAL : ILD_BLEND50 );
	}

	// Metadata Boxes  (Available space %)

	if ( pView->m_pStyle == CSchema::uriMusicAlbum )
	{
		// Track, Title, Length, Bitrate
		PaintText( pDC, rcLine, 0, 5, &m_sTrack, TRUE );
		PaintText( pDC, rcLine, 5, 84, &m_sTitle );
		PaintText( pDC, rcLine, 84, 92, &m_sLength, TRUE );
		PaintText( pDC, rcLine, 92, 100, &m_sBitrate, TRUE );
	}
	else if ( pView->m_pStyle == CSchema::uriMusicArtist )
	{
		// Album, Title, Length, Bitrate
		PaintText( pDC, rcLine, 0, 30, &m_sAlbum );
		PaintText( pDC, rcLine, 30, 84, &m_sTitle );
		PaintText( pDC, rcLine, 84, 92, &m_sLength, TRUE );
		PaintText( pDC, rcLine, 92, 100, &m_sBitrate, TRUE );
	}
	else if ( pView->m_pStyle == CSchema::uriMusicAll ) // Genre
	{
		// Artist, Album, Title, Length, Bitrate
		PaintText( pDC, rcLine, 0, 25, &m_sArtist );
		PaintText( pDC, rcLine, 25, 50, &m_sAlbum );
		PaintText( pDC, rcLine, 50, 84, &m_sTitle );
		PaintText( pDC, rcLine, 84, 92, &m_sLength, TRUE );
		PaintText( pDC, rcLine, 92, 100, &m_sBitrate, TRUE );
	}
	else // Non-music
	{
		// Title, Artist, Length
		PaintText( pDC, rcLine,  0, 66, &m_sTitle );
		PaintText( pDC, rcLine, 66, 88, &m_sArtist );
		PaintText( pDC, rcLine, 88, 100, &m_sLength, TRUE );
	}
}
Beispiel #3
0
void CMatchTipCtrl::OnPaint(CDC* pDC)
{
	CPoint pt( 0, 0 );
	CSize sz( m_sz.cx, TIP_TEXTHEIGHT );

	DrawText( pDC, &pt, m_sName );
	pt.y += TIP_TEXTHEIGHT;

	pDC->SelectObject( &CoolInterface.m_fntNormal );

	if ( m_sUser.GetLength() )
	{
		DrawText( pDC, &pt, m_sUser );
		pt.y += TIP_TEXTHEIGHT;
	}

	if ( m_sCountry.GetLength() )
	{
		int nFlagIndex = Flags.GetFlagIndex( m_sCountryCode );
		if ( nFlagIndex >= 0 )
		{
			Flags.Draw( nFlagIndex, *pDC, pt.x, pt.y, CoolInterface.m_crTipBack, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
		}
		pt.x += 16 + 4;
		DrawText( pDC, &pt, m_sCountry );
		pt.x -= 16 + 4;
		pt.y += max( 16, TIP_TEXTHEIGHT );
	}

	if ( m_sStatus.GetLength() )
	{
		DrawRule( pDC, &pt );

		pDC->SetTextColor( m_crStatus );
		pDC->SelectObject( &CoolInterface.m_fntBold );
		DrawText( pDC, &pt, m_sStatus );
		pDC->SelectObject( &CoolInterface.m_fntNormal );
		pDC->SetTextColor( CoolInterface.m_crTipText );
		pt.y += TIP_TEXTHEIGHT;
	}

	DrawRule( pDC, &pt );

	ShellIcons.Draw( pDC, m_nIcon, 32, pt.x, pt.y, CoolInterface.m_crTipBack );
	pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 32, pt.y + 32 );

	if ( m_nRating > 1 )
	{
		CPoint ptStar( m_sz.cx - 3, pt.y - 2 );

		for ( int nRating = m_nRating - 1 ; nRating ; nRating-- )
		{
			ptStar.x -= 16;
			CoolInterface.Draw( pDC, IDI_STAR, 16, ptStar.x, ptStar.y, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 );
		}
	}

	pt.x += 40;
	DrawText( pDC, &pt, m_sSize );
	pt.y += TIP_TEXTHEIGHT;
	DrawText( pDC, &pt, m_sType );
	pt.y -= TIP_TEXTHEIGHT;
	pt.x -= 40;

	pt.y += max( 32, TIP_TEXTHEIGHT * 2 );

	//Hashes
	if ( m_sSHA1.GetLength() || m_sTiger.GetLength() || m_sED2K.GetLength() || m_sBTH.GetLength() || m_sMD5.GetLength() )
	{
		DrawRule( pDC, &pt );

		if ( m_sSHA1.GetLength() )
		{
			DrawText( pDC, &pt, m_sSHA1 );
			pt.y += TIP_TEXTHEIGHT;
		}

		if ( m_sTiger.GetLength() )
		{
			DrawText( pDC, &pt, m_sTiger );
			pt.y += TIP_TEXTHEIGHT;
		}

		if ( m_sED2K.GetLength() )
		{
			DrawText( pDC, &pt, m_sED2K );
			pt.y += TIP_TEXTHEIGHT;
		}

		if ( m_sBTH.GetLength() )
		{
			DrawText( pDC, &pt, m_sBTH );
			pt.y += TIP_TEXTHEIGHT;
		}

		if ( m_sMD5.GetLength() )
		{
			DrawText( pDC, &pt, m_sMD5 );
			pt.y += TIP_TEXTHEIGHT;
		}
	}

	//Busy, firewalled, unstabled warnings. Queue info
	if ( m_sBusy.GetLength() || m_sPush.GetLength() || m_sUnstable.GetLength() || m_sQueue.GetLength() )
	{
		DrawRule( pDC, &pt );

		pDC->SetTextColor( CoolInterface.m_crTipWarnings );
		pDC->SelectObject( &CoolInterface.m_fntBold );

		//Source busy warning
		if (m_sBusy.GetLength())
		{
			CoolInterface.Draw( pDC, IDI_BUSY, 16, pt.x, pt.y, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
			pt.x += 20;
			DrawText( pDC, &pt, m_sBusy);
			pt.x -= 20;
			pt.y += max( 16, TIP_TEXTHEIGHT );
		}

		pDC->SetTextColor( CoolInterface.m_crTipText );
		pDC->SelectObject( &CoolInterface.m_fntNormal );

		//Queue info
		if ( m_sQueue.GetLength() )
		{
			if ( m_sBusy.GetLength() || m_sPush.GetLength() || m_sUnstable.GetLength() ) // Align queue info with above (if present)
			{
				pt.x += 20;
				DrawText( pDC, &pt, m_sQueue );
				pt.x -= 20;
			}
			else
				DrawText( pDC, &pt, m_sQueue );

			pt.y += TIP_TEXTHEIGHT;
		}

		pDC->SetTextColor( CoolInterface.m_crTipWarnings );
		pDC->SelectObject( &CoolInterface.m_fntBold );

		//Source firewalled warning
		if (m_sPush.GetLength())
		{
			CoolInterface.Draw( pDC, IDI_FIREWALLED, 16, pt.x, pt.y, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
			pt.x += 20;
			DrawText( pDC, &pt, m_sPush);
			pt.x -= 20;
			pt.y += max( 16, TIP_TEXTHEIGHT );
		}

		//Source unstable warning
		if (m_sUnstable.GetLength())
		{
			CoolInterface.Draw( pDC, IDI_UNSTABLE, 16, pt.x, pt.y, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
			pt.x += 20;
			DrawText( pDC, &pt, m_sUnstable);
			pt.x -= 20;
			pt.y += max( 16, TIP_TEXTHEIGHT );
		}
		pDC->SetTextColor( CoolInterface.m_crTipText );
		pDC->SelectObject( &CoolInterface.m_fntNormal );
	}

	//Partial warning
	if ( m_sPartial.GetLength() )
	{
		DrawRule( pDC, &pt );
		DrawText( pDC, &pt, m_sPartial );
		pt.y += TIP_TEXTHEIGHT;
	}

	//Metadata
	if ( m_pMetadata.GetCount( TRUE ) )
	{
		DrawRule( pDC, &pt );
		for ( POSITION pos = m_pMetadata.GetIterator() ; pos ; )
		{
			const CMetaItem* pItem = m_pMetadata.GetNext( pos );
			if ( pItem->m_pMember && pItem->m_pMember->m_bHidden ) continue;

			DrawText( pDC, &pt, Settings.General.LanguageRTL ? _T(':') + pItem->m_sKey : pItem->m_sKey + _T(':') );
			pt.x += m_nKeyWidth;
			DrawText( pDC, &pt, pItem->m_sValue );
			pt.x -= m_nKeyWidth;
			pt.y += TIP_TEXTHEIGHT;
		}
	}
}
void CLibraryAlbumTrack::Paint(CLibraryAlbumView* pView, CDC* pDC, const CRect& rcTrack, int nCount)
{
	COLORREF crBack1 = CLibraryAlbumView::m_crRows[ nCount & 1 ];
	COLORREF crBack2 = m_bSelected ? CoolInterface.m_crHighlight : crBack1;
	
	CRect rcLine( &rcTrack );
	rcLine.DeflateRect( 1, 1 );
	rcLine.left ++; rcLine.right --;
	
	CRect rcTemp( rcLine.left, rcLine.top, rcLine.left + 22, rcLine.bottom );
	rcLine.left += 22;
	
	pDC->SetBkColor( m_bSelected ? crBack2 : crBack1 );
	
	ShellIcons.Draw( pDC, m_nShell, 16, rcTemp.left + 3,
		( rcTemp.top + rcTemp.bottom ) / 2 - 8, CLR_NONE, m_bSelected );
	
	pDC->SetTextColor( m_bSelected ? CoolInterface.m_crHiText : CoolInterface.m_crText );
	
	rcTemp.SetRect( rcLine.right - 78, rcLine.top, rcLine.right, rcLine.bottom );
	rcLine.right -= 78;
	
	CPoint ptStar( rcTemp.left + 3, ( rcTemp.top + rcTemp.bottom ) / 2 - 6 );
	PaintText( pDC, rcTemp, 0, 100, NULL );
	
	if ( pView->m_pRating == this && m_nSetRating < 7 )
	{
		for ( int nRating = 2 ; nRating <= 6 ; nRating++ )
		{
			ImageList_DrawEx( pView->m_pStars, m_nSetRating >= nRating ? 2 : 1,
				*pDC, ptStar.x, ptStar.y, 12, 12, crBack2, crBack2,
				m_nSetRating >= nRating ? ILD_NORMAL : ILD_BLEND50 );
			ptStar.x += 12;
		}
	}
	else
	{
		for ( int nRating = 2 ; nRating <= 6 ; nRating++ )
		{
			ImageList_DrawEx( pView->m_pStars, m_nRating >= nRating ? 0 : 1,
				*pDC, ptStar.x, ptStar.y, 12, 12, crBack2, crBack2,
				m_nRating >= nRating ? ILD_NORMAL : ILD_BLEND50 );
			ptStar.x += 12;
		}
	}
	
	if ( pView->m_pRating == this && m_nSetRating == 7 )
	{
		ImageList_DrawEx( pView->m_pStars, 5,
			*pDC, ptStar.x, ptStar.y, 12, 12, crBack2, crBack2, ILD_NORMAL );
	}
	else
	{
		ImageList_DrawEx( pView->m_pStars, m_bComments ? 3 : 4,
			*pDC, ptStar.x, ptStar.y, 12, 12, crBack2, crBack2,
			m_bComments ? ILD_NORMAL : ILD_BLEND50 );
	}
	
	if ( pView->m_pStyle == CSchema::uriMusicAlbum )
	{
		// Track, Title, Length, Bitrate
		PaintText( pDC, rcLine, 0, 5, &m_sTrack, TRUE );
		PaintText( pDC, rcLine, 5, 84, &m_sTitle );
		PaintText( pDC, rcLine, 84, 92, &m_sLength, TRUE );
		PaintText( pDC, rcLine, 92, 100, &m_sBitrate, TRUE );
	}
	else if ( pView->m_pStyle == CSchema::uriMusicArtist )
	{
		// Album, Title, Length, Bitrate
		PaintText( pDC, rcLine, 0, 30, &m_sAlbum );
		PaintText( pDC, rcLine, 30, 84, &m_sTitle );
		PaintText( pDC, rcLine, 84, 92, &m_sLength, TRUE );
		PaintText( pDC, rcLine, 92, 100, &m_sBitrate, TRUE );
	}
	else
	{
		// Artist, Album, Title, Length, Bitrate
		PaintText( pDC, rcLine, 0, 25, &m_sArtist );
		PaintText( pDC, rcLine, 25, 50, &m_sAlbum );
		PaintText( pDC, rcLine, 50, 84, &m_sTitle );
		PaintText( pDC, rcLine, 84, 92, &m_sLength, TRUE );
		PaintText( pDC, rcLine, 92, 100, &m_sBitrate, TRUE );
	}
}