00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "StdAfx.h"
00023 #include "Shareaza.h"
00024 #include "Settings.h"
00025 #include "Library.h"
00026 #include "LibraryFolders.h"
00027 #include "AlbumFolder.h"
00028 #include "Schema.h"
00029 #include "CoolInterface.h"
00030 #include "ShellIcons.h"
00031 #include "CtrlTipAlbum.h"
00032
00033 #ifdef _DEBUG
00034 #define new DEBUG_NEW
00035 #undef THIS_FILE
00036 static char THIS_FILE[] = __FILE__;
00037 #endif
00038
00039 IMPLEMENT_DYNAMIC(CAlbumTipCtrl, CCoolTipCtrl)
00040
00041 BEGIN_MESSAGE_MAP(CAlbumTipCtrl, CCoolTipCtrl)
00042
00043
00044 END_MESSAGE_MAP()
00045
00046
00048
00049
00050 CAlbumTipCtrl::CAlbumTipCtrl()
00051 {
00052 m_crLight = CCoolInterface::CalculateColour( CoolInterface.m_crTipBack, RGB( 255, 255, 255 ), 128 );
00053 }
00054
00055 CAlbumTipCtrl::~CAlbumTipCtrl()
00056 {
00057 }
00058
00060
00061
00062 BOOL CAlbumTipCtrl::OnPrepare()
00063 {
00064 CSingleLock pLock( &Library.m_pSection );
00065 if ( ! pLock.Lock( 250 ) ) return FALSE;
00066
00067 CAlbumFolder* pFolder = (CAlbumFolder*)m_pContext;
00068 if ( ! LibraryFolders.CheckAlbum( pFolder ) ) return FALSE;
00069
00070
00071
00072 m_sName = pFolder->m_sName;
00073 m_sType = _T("Virtual Folder");
00074
00075 m_nIcon32 = SHI_FOLDER_OPEN;
00076 m_nIcon48 = SHI_FOLDER_OPEN;
00077 m_bCollection = pFolder->m_bCollSHA1;
00078
00079
00080
00081 m_pMetadata.Clear();
00082
00083 if ( pFolder->m_pSchema != NULL )
00084 {
00085 CString strText;
00086 LPCTSTR pszColon = _tcschr( pFolder->m_pSchema->m_sTitle, ':' );
00087 m_sType = pszColon ? pszColon + 1 : pFolder->m_pSchema->m_sTitle;
00088 LoadString( strText, IDS_TIP_FOLDER );
00089
00090 if ( theApp.m_bRTL )
00091 m_sType = _T("\x202A") + m_sType + _T(" \x200E") + strText;
00092 else
00093 m_sType += " " + strText;
00094
00095 m_nIcon48 = pFolder->m_pSchema->m_nIcon48;
00096 m_nIcon32 = pFolder->m_pSchema->m_nIcon32;
00097
00098 if ( pFolder->m_pXML != NULL )
00099 {
00100 m_pMetadata.Setup( pFolder->m_pSchema, FALSE );
00101 m_pMetadata.Combine( pFolder->m_pXML );
00102 m_pMetadata.Clean();
00103 }
00104 }
00105
00106 CalcSizeHelper();
00107
00108 return m_sz.cx > 0;
00109 }
00110
00112
00113
00114 void CAlbumTipCtrl::OnCalcSize(CDC* pDC)
00115 {
00116 AddSize( pDC, m_sName );
00117 m_sz.cy += TIP_TEXTHEIGHT;
00118 pDC->SelectObject( &CoolInterface.m_fntNormal );
00119 AddSize( pDC, m_sType );
00120 m_sz.cy += TIP_TEXTHEIGHT;
00121
00122 m_sz.cy += TIP_RULE;
00123
00124 int nMetaHeight = m_pMetadata.GetCount() * TIP_TEXTHEIGHT;
00125 int nValueWidth = 0;
00126 m_nKeyWidth = 0;
00127
00128 m_pMetadata.ComputeWidth( pDC, m_nKeyWidth, nValueWidth );
00129
00130 if ( m_nKeyWidth ) m_nKeyWidth += TIP_GAP;
00131 m_sz.cx = max( m_sz.cx, LONG(m_nKeyWidth + nValueWidth + 102) );
00132 m_sz.cy += max( nMetaHeight, 96 );
00133 }
00134
00136
00137
00138 void CAlbumTipCtrl::OnPaint(CDC* pDC)
00139 {
00140 CPoint pt( 0, 0 );
00141
00142 DrawText( pDC, &pt, m_sName );
00143 pt.y += TIP_TEXTHEIGHT;
00144 pDC->SelectObject( &CoolInterface.m_fntNormal );
00145 DrawText( pDC, &pt, m_sType );
00146 pt.y += TIP_TEXTHEIGHT;
00147
00148 DrawRule( pDC, &pt );
00149
00150 CRect rcThumb( pt.x, pt.y, pt.x + 96, pt.y + 96 );
00151 CRect rcWork( &rcThumb );
00152 DrawThumb( pDC, rcWork );
00153 pDC->ExcludeClipRect( &rcThumb );
00154
00155 int nCount = 0;
00156
00157 for ( POSITION pos = m_pMetadata.GetIterator() ; pos ; )
00158 {
00159 CMetaItem* pItem = m_pMetadata.GetNext( pos );
00160
00161 DrawText( pDC, &pt, pItem->m_sKey + ':', 100 );
00162 DrawText( pDC, &pt, pItem->m_sValue, 100 + m_nKeyWidth );
00163 pt.y += TIP_TEXTHEIGHT;
00164
00165 if ( ++nCount == 5 )
00166 {
00167 pt.x += 98; pt.y -= 2;
00168 DrawRule( pDC, &pt, TRUE );
00169 pt.x -= 98; pt.y -= 2;
00170 }
00171 }
00172 }
00173
00174 void CAlbumTipCtrl::DrawThumb(CDC* pDC, CRect& rcThumb)
00175 {
00176 pDC->Draw3dRect( &rcThumb, CoolInterface.m_crTipBorder, CoolInterface.m_crTipBorder );
00177 rcThumb.DeflateRect( 1, 1 );
00178
00179 CPoint pt( ( rcThumb.left + rcThumb.right ) / 2 - 24,
00180 ( rcThumb.top + rcThumb.bottom ) / 2 - 24 );
00181
00182 UINT nStyle = ( m_bCollection ? INDEXTOOVERLAYMASK(SHI_O_COLLECTION) : 0 );
00183
00184 if ( m_nIcon48 >= 0 )
00185 {
00186 ImageList_DrawEx( ShellIcons.GetHandle( 48 ), m_nIcon48, *pDC,
00187 pt.x, pt.y, 48, 48, m_crLight, CLR_DEFAULT, nStyle );
00188 pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 48, pt.y + 48 );
00189 }
00190 else if ( m_nIcon32 >= 0 )
00191 {
00192 pt.x += 8; pt.y += 8;
00193 ImageList_DrawEx( ShellIcons.GetHandle( 32 ), m_nIcon32, *pDC,
00194 pt.x, pt.y, 32, 32, m_crLight, CLR_DEFAULT, nStyle );
00195 pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 32, pt.y + 32 );
00196 }
00197
00198 pDC->FillSolidRect( &rcThumb, m_crLight );
00199 }
00200