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 "SharedFolder.h"
00028 #include "CoolInterface.h"
00029 #include "ShellIcons.h"
00030 #include "CtrlTipFolder.h"
00031
00032 #ifdef _DEBUG
00033 #define new DEBUG_NEW
00034 #undef THIS_FILE
00035 static char THIS_FILE[] = __FILE__;
00036 #endif
00037
00038 IMPLEMENT_DYNAMIC(CFolderTipCtrl, CCoolTipCtrl)
00039
00040 BEGIN_MESSAGE_MAP(CFolderTipCtrl, CCoolTipCtrl)
00041
00042
00043 END_MESSAGE_MAP()
00044
00045
00047
00048
00049 CFolderTipCtrl::CFolderTipCtrl()
00050 {
00051 }
00052
00053 CFolderTipCtrl::~CFolderTipCtrl()
00054 {
00055 }
00056
00058
00059
00060 BOOL CFolderTipCtrl::OnPrepare()
00061 {
00062 CSingleLock pLock( &Library.m_pSection );
00063 if ( ! pLock.Lock( 250 ) ) return FALSE;
00064
00065 CLibraryFolder* pFolder = (CLibraryFolder*)m_pContext;
00066 if ( ! LibraryFolders.CheckFolder( pFolder, TRUE ) ) return FALSE;
00067
00068 m_sName = pFolder->m_sName;
00069 m_sPath = pFolder->m_sPath;
00070
00071 m_sFiles.Format( _T("%lu"), pFolder->m_nFiles );
00072 m_sVolume = Settings.SmartVolume( pFolder->m_nVolume, TRUE );
00073
00074 QWORD nTotal;
00075 CString strText;
00076 LibraryMaps.GetStatistics( NULL, &nTotal );
00077
00078 LoadString( strText, IDS_TIP_LIBRARY_PERCENT );
00079 m_sPercentage.Format( _T("%.2f%% %s"),
00080 100.0 * pFolder->m_nVolume / nTotal, strText );
00081
00082 CalcSizeHelper();
00083
00084 return m_sz.cx > 0;
00085 }
00086
00088
00089
00090 void CFolderTipCtrl::OnCalcSize(CDC* pDC)
00091 {
00092 AddSize( pDC, m_sName );
00093 m_sz.cy += TIP_TEXTHEIGHT;
00094 pDC->SelectObject( &CoolInterface.m_fntNormal );
00095 AddSize( pDC, m_sPath );
00096
00097 m_sz.cy += TIP_RULE;
00098
00099 AddSize( pDC, m_sFiles, 120 );
00100 AddSize( pDC, m_sVolume, 120 );
00101 AddSize( pDC, m_sPercentage, 40 );
00102
00103 m_sz.cy += TIP_TEXTHEIGHT * 4;
00104 }
00105
00107
00108
00109 void CFolderTipCtrl::OnPaint(CDC* pDC)
00110 {
00111 CPoint pt( 0, 0 );
00112
00113 DrawText( pDC, &pt, m_sName );
00114 pt.y += TIP_TEXTHEIGHT;
00115 pDC->SelectObject( &CoolInterface.m_fntNormal );
00116 DrawText( pDC, &pt, m_sPath );
00117 pt.y += TIP_TEXTHEIGHT;
00118
00119 DrawRule( pDC, &pt );
00120
00121 ShellIcons.Draw( pDC, SHI_FOLDER_OPEN, 32, pt.x, pt.y, CoolInterface.m_crTipBack );
00122
00123 CString strText;
00124 LoadString( strText, IDS_TIP_TOTAL_FILES );
00125 DrawText( pDC, &pt, strText, 40 );
00126 DrawText( pDC, &pt, m_sFiles, 120 );
00127 pt.y += TIP_TEXTHEIGHT;
00128 LoadString( strText, IDS_TIP_TOTAL_VOLUME );
00129 DrawText( pDC, &pt, strText, 40 );
00130 DrawText( pDC, &pt, m_sVolume, 120 );
00131 pt.y += TIP_TEXTHEIGHT;
00132 DrawText( pDC, &pt, m_sPercentage, 40 );
00133 pt.y += TIP_TEXTHEIGHT;
00134 }
00135