Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

CtrlTipFolder.cpp

Go to the documentation of this file.
00001 //
00002 // CtrlTipFolder.cpp
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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         //{{AFX_MSG_MAP(CFolderTipCtrl)
00042         //}}AFX_MSG_MAP
00043 END_MESSAGE_MAP()
00044 
00045 
00047 // CFolderTipCtrl construction
00048 
00049 CFolderTipCtrl::CFolderTipCtrl()
00050 {
00051 }
00052 
00053 CFolderTipCtrl::~CFolderTipCtrl()
00054 {
00055 }
00056 
00058 // CFolderTipCtrl prepare
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 // CFolderTipCtrl compute size
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 // CFolderTipCtrl painting
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 

Generated on Thu Dec 15 10:39:38 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2