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

DlgExistingFile.cpp

Go to the documentation of this file.
00001 //
00002 // DlgExistingFile.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 "SharedFile.h"
00027 #include "DlgExistingFile.h"
00028 #include "TigerTree.h"
00029 #include "SHA.h"
00030 
00031 #ifdef _DEBUG
00032 #define new DEBUG_NEW
00033 #undef THIS_FILE
00034 static char THIS_FILE[] = __FILE__;
00035 #endif
00036 
00037 IMPLEMENT_DYNAMIC(CExistingFileDlg, CSkinDialog)
00038 
00039 BEGIN_MESSAGE_MAP(CExistingFileDlg, CSkinDialog)
00040         //{{AFX_MSG_MAP(CExistingFileDlg)
00041         ON_WM_CTLCOLOR()
00042         ON_BN_CLICKED(IDC_ACTION_0, OnAction0)
00043         ON_BN_CLICKED(IDC_ACTION_1, OnAction1)
00044         ON_BN_CLICKED(IDC_ACTION_2, OnAction2)
00045         //}}AFX_MSG_MAP
00046 END_MESSAGE_MAP()
00047 
00048 
00050 // CExistingFileDlg dialog
00051 
00052 CExistingFileDlg::CExistingFileDlg(CLibraryFile* pFile, CWnd* pParent) : CSkinDialog( CExistingFileDlg::IDD, pParent )
00053 {
00054         //{{AFX_DATA_INIT(CExistingFileDlg)
00055         m_sName = _T("");
00056         m_sURN = _T("");
00057         m_nAction = 0;
00058         //}}AFX_DATA_INIT
00059 
00060         m_sName = pFile->m_sName;
00061 
00062         if ( pFile->m_bSHA1 && pFile->m_bTiger )
00063         {
00064                 m_sURN  = _T("bitprint:") + CSHA::HashToString( &pFile->m_pSHA1 )
00065                                 + '.' + CTigerNode::HashToString( &pFile->m_pTiger );
00066         }
00067         else if ( pFile->m_bSHA1 )
00068         {
00069                 m_sURN = CSHA::HashToString( &pFile->m_pSHA1, TRUE );
00070         }
00071         else if ( pFile->m_bTiger )
00072         {
00073                 m_sURN = CTigerNode::HashToString( &pFile->m_pTiger, TRUE );
00074         }
00075 
00076         m_bAvailable    = pFile->IsAvailable();
00077         m_sComments             = pFile->m_sComments;
00078 }
00079 
00080 void CExistingFileDlg::DoDataExchange(CDataExchange* pDX)
00081 {
00082         CSkinDialog::DoDataExchange(pDX);
00083         //{{AFX_DATA_MAP(CExistingFileDlg)
00084         DDX_Control(pDX, IDOK, m_wndOK);
00085         DDX_Control(pDX, IDC_FILE_NAME, m_wndName);
00086         DDX_Text(pDX, IDC_FILE_NAME, m_sName);
00087         DDX_Text(pDX, IDC_FILE_URN, m_sURN);
00088         DDX_Radio(pDX, IDC_ACTION_0, m_nAction);
00089         //}}AFX_DATA_MAP
00090         DDX_Control(pDX, IDC_FILE_COMMENTS, m_wndComments);
00091         DDX_Control(pDX, IDC_MESSAGE_AVAILABLE, m_wndMessageAvailable);
00092         DDX_Control(pDX, IDC_MESSAGE_DELETED, m_wndMessageDeleted);
00093         DDX_Control(pDX, IDC_ACTION_0, m_wndLocate);
00094         DDX_Text(pDX, IDC_FILE_COMMENTS, m_sComments);
00095 }
00096 
00098 // CExistingFileDlg message handlers
00099 
00100 BOOL CExistingFileDlg::OnInitDialog()
00101 {
00102         CSkinDialog::OnInitDialog();
00103 
00104         SkinMe( NULL, IDR_DOWNLOADSFRAME );
00105 
00106         if ( ! m_bAvailable ) m_nAction = 1;
00107         UpdateData( FALSE );
00108 
00109         m_wndComments.ShowWindow( m_sComments.GetLength() > 0 ? SW_SHOW : SW_HIDE );
00110         m_wndMessageAvailable.ShowWindow( m_bAvailable ? SW_SHOW : SW_HIDE );
00111         m_wndMessageDeleted.ShowWindow( m_bAvailable ? SW_HIDE : SW_SHOW );
00112         m_wndLocate.EnableWindow( m_bAvailable );
00113 
00114         return TRUE;
00115 }
00116 
00117 HBRUSH CExistingFileDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00118 {
00119         HBRUSH hbr = CSkinDialog::OnCtlColor( pDC, pWnd, nCtlColor );
00120 
00121         if ( pWnd == &m_wndName || pWnd == &m_wndMessageAvailable || pWnd == &m_wndMessageDeleted )
00122                 pDC->SelectObject( &theApp.m_gdiFontBold );
00123         if ( pWnd == &m_wndComments && ! m_bAvailable )
00124                 pDC->SetTextColor( RGB( 255, 0, 0 ) );
00125 
00126         return hbr;
00127 }
00128 
00129 void CExistingFileDlg::OnAction0()
00130 {
00131         if ( m_wndLocate.IsWindowEnabled() ) m_wndOK.EnableWindow( TRUE );
00132 }
00133 
00134 void CExistingFileDlg::OnAction1()
00135 {
00136         m_wndOK.EnableWindow( TRUE );
00137 }
00138 
00139 void CExistingFileDlg::OnAction2()
00140 {
00141         m_wndOK.EnableWindow( TRUE );
00142 }
00143 
00144 void CExistingFileDlg::OnOK()
00145 {
00146         UpdateData();
00147         if ( ! m_bAvailable && m_nAction == 0 ) return;
00148         CSkinDialog::OnOK();
00149 }

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