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 "Library.h"
00025 #include "SharedFile.h"
00026 #include "CoolInterface.h"
00027 #include "ShellIcons.h"
00028 #include "Skin.h"
00029 #include "DlgFilePropertiesSheet.h"
00030 #include "DlgFilePropertiesPage.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(CFilePropertiesPage, CPropertyPage)
00039
00040 BEGIN_MESSAGE_MAP(CFilePropertiesPage, CPropertyPage)
00041
00042 ON_WM_PAINT()
00043
00044 ON_WM_CTLCOLOR()
00045 END_MESSAGE_MAP()
00046
00047
00049
00050
00051 CFilePropertiesPage::CFilePropertiesPage(UINT nIDD) : CPropertyPage( nIDD )
00052 {
00053
00054
00055 m_nIcon = -1;
00056 }
00057
00058 CFilePropertiesPage::~CFilePropertiesPage()
00059 {
00060 }
00061
00062 void CFilePropertiesPage::DoDataExchange(CDataExchange* pDX)
00063 {
00064 CPropertyPage::DoDataExchange(pDX);
00065
00066
00067 }
00068
00070
00071
00072 CLibraryFile* CFilePropertiesPage::GetFile()
00073 {
00074 CLibraryList* pList = GetList();
00075 if ( pList->GetCount() != 1 ) return NULL;
00076 CQuickLock oLock( Library.m_pSection );
00077 CLibraryFile* pFile = Library.LookupFile( pList->GetHead() );
00078 if ( pFile != NULL ) return pFile;
00079 PostMessage( WM_CLOSE );
00080 return NULL;
00081 }
00082
00083 CLibraryList* CFilePropertiesPage::GetList() const
00084 {
00085 CFilePropertiesSheet* pSheet = (CFilePropertiesSheet*)GetParent();
00086 return &pSheet->m_pList;
00087 }
00088
00090
00091
00092 BOOL CFilePropertiesPage::OnInitDialog()
00093 {
00094 CPropertyPage::OnInitDialog();
00095
00096 Skin.Apply( NULL, this );
00097
00098 CSingleLock oLock( &Library.m_pSection, TRUE );
00099 if ( CLibraryFile* pFile = GetFile() )
00100 {
00101 if ( CWnd* pNameWnd = GetDlgItem( IDC_FILE_NAME ) )
00102 {
00103 if ( theApp.m_bRTL )
00104 {
00105 CRect rc, rcPage;
00106 pNameWnd->GetWindowRect( &rc );
00107 GetWindowRect( &rcPage );
00108 pNameWnd->MoveWindow( rcPage.right - rc.right,
00109 rc.top - rcPage.top, rc.Width(), rc.Height(), FALSE );
00110 pNameWnd->ModifyStyleEx( WS_EX_RTLREADING, WS_EX_LTRREADING, 0 );
00111 }
00112 pNameWnd->SetWindowText( pFile->m_sName );
00113 }
00114 m_nIcon = ShellIcons.Get( pFile->m_sName, 48 );
00115
00116 oLock.Unlock();
00117 }
00118 else
00119 {
00120 oLock.Unlock();
00121 if ( CLibraryList* pList = GetList() )
00122 {
00123 if ( CWnd* pNameWnd = GetDlgItem( IDC_FILE_NAME ) )
00124 {
00125 if ( theApp.m_bRTL )
00126 {
00127 CRect rc, rcPage;
00128 pNameWnd->GetWindowRect( &rc );
00129 GetWindowRect( &rcPage );
00130 pNameWnd->MoveWindow( rcPage.right - rc.right,
00131 rc.top - rcPage.top, rc.Width(), rc.Height(), FALSE );
00132 pNameWnd->ModifyStyleEx( 0, WS_EX_RTLREADING, 0 );
00133 }
00134 CString strFormat, strMessage;
00135 LoadString( strFormat, IDS_LIBRARY_METADATA_EDIT );
00136 strMessage.Format( strFormat, pList->GetCount() );
00137 pNameWnd->SetWindowText( strMessage );
00138
00139 }
00140 m_nIcon = SHI_EXECUTABLE;
00141 }
00142 }
00143
00144 return TRUE;
00145 }
00146
00147 void CFilePropertiesPage::OnPaint()
00148 {
00149 CPaintDC dc( this );
00150 if ( theApp.m_bRTL ) theApp.m_pfnSetLayout( dc.m_hDC, LAYOUT_RTL );
00151
00152 if ( m_nIcon >= 0 )
00153 {
00154 ShellIcons.Draw( &dc, m_nIcon, 48, 4, 4 );
00155 }
00156
00157 for ( CWnd* pWnd = GetWindow( GW_CHILD ) ; pWnd ; pWnd = pWnd->GetNextWindow() )
00158 {
00159 if ( pWnd->GetStyle() & WS_VISIBLE ) continue;
00160
00161 TCHAR szClass[16];
00162 GetClassName( pWnd->GetSafeHwnd(), szClass, 16 );
00163 if ( _tcsicmp( szClass, _T("STATIC") ) ) continue;
00164
00165 CString str;
00166 CRect rc;
00167
00168 pWnd->GetWindowText( str );
00169 pWnd->GetWindowRect( &rc );
00170 ScreenToClient( &rc );
00171
00172 if ( str.IsEmpty() || str.GetAt( 0 ) != '-' )
00173 PaintStaticHeader( &dc, &rc, str );
00174 }
00175
00176 dc.SetBkColor( CCoolInterface::GetDialogBkColor() );
00177 }
00178
00179 void CFilePropertiesPage::PaintStaticHeader(CDC* pDC, CRect* prc, LPCTSTR psz)
00180 {
00181 CFont* pOldFont = (CFont*)pDC->SelectObject( GetFont() );
00182 CSize sz = pDC->GetTextExtent( psz );
00183
00184 pDC->SetBkMode( OPAQUE );
00185 pDC->SetBkColor( Skin.m_crBannerBack );
00186 pDC->SetTextColor( Skin.m_crBannerText );
00187
00188 CRect rc( prc );
00189 rc.bottom = rc.top + min( rc.Height(), 16 );
00190 rc.right = rc.left + sz.cx + 10;
00191
00192 pDC->ExtTextOut( rc.left + 4, rc.top + 1, ETO_CLIPPED|ETO_OPAQUE,
00193 &rc, psz, _tcslen( psz ), NULL );
00194
00195 rc.SetRect( rc.right, rc.top, prc->right, rc.top + 1 );
00196 pDC->ExtTextOut( rc.left, rc.top, ETO_OPAQUE, &rc, NULL, 0, NULL );
00197
00198 pDC->SelectObject( pOldFont );
00199 }
00200
00201 HBRUSH CFilePropertiesPage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00202 {
00203 HBRUSH hbr = CPropertyPage::OnCtlColor( pDC, pWnd, nCtlColor );
00204
00205 if ( nCtlColor == CTLCOLOR_DLG || nCtlColor == CTLCOLOR_STATIC )
00206 {
00207 pDC->SetBkColor( Skin.m_crDialog );
00208 hbr = Skin.m_brDialog;
00209 }
00210
00211 return hbr;
00212 }