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

DlgBitziDownload.cpp

Go to the documentation of this file.
00001 //
00002 // DlgBitziDownload.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 "ShellIcons.h"
00025 #include "BitziDownloader.h"
00026 #include "DlgBitziDownload.h"
00027 
00028 #ifdef _DEBUG
00029 #define new DEBUG_NEW
00030 #undef THIS_FILE
00031 static char THIS_FILE[] = __FILE__;
00032 #endif
00033 
00034 BEGIN_MESSAGE_MAP(CBitziDownloadDlg, CSkinDialog)
00035         //{{AFX_MSG_MAP(CBitziDownloadDlg)
00036         ON_WM_TIMER()
00037         ON_WM_SETCURSOR()
00038         ON_WM_LBUTTONDOWN()
00039         ON_WM_CTLCOLOR()
00040         //}}AFX_MSG_MAP
00041 END_MESSAGE_MAP()
00042 
00043 
00045 // CBitziDownloadDlg dialog
00046 
00047 CBitziDownloadDlg::CBitziDownloadDlg(CWnd* pParent) : CSkinDialog(CBitziDownloadDlg::IDD, pParent)
00048 {
00049         //{{AFX_DATA_INIT(CBitziDownloadDlg)
00050         //}}AFX_DATA_INIT
00051 }
00052 
00053 void CBitziDownloadDlg::DoDataExchange(CDataExchange* pDX)
00054 {
00055         CSkinDialog::DoDataExchange(pDX);
00056         //{{AFX_DATA_MAP(CBitziDownloadDlg)
00057         DDX_Control(pDX, IDC_WEB, m_wndWeb);
00058         DDX_Control(pDX, IDC_FILES, m_wndFiles);
00059         DDX_Control(pDX, IDCANCEL, m_wndCancel);
00060         DDX_Control(pDX, IDC_PROGRESS, m_wndProgress);
00061         //}}AFX_DATA_MAP
00062 }
00063 
00065 // CBitziDownloadDlg message handlers
00066 
00067 BOOL CBitziDownloadDlg::OnInitDialog()
00068 {
00069         CSkinDialog::OnInitDialog();
00070 
00071         SkinMe( _T("CBitziDownloadDlg"), IDR_MAINFRAME );
00072 
00073         if ( theApp.m_bRTL ) m_wndProgress.ModifyStyleEx( WS_EX_LAYOUTRTL, 0, 0 );
00074         m_wndProgress.SetRange( 0, m_pDownloader.GetFileCount() * 2 );
00075         m_wndFiles.SetImageList( ShellIcons.GetObject( 16 ), LVSIL_SMALL );
00076         m_wndFiles.InsertColumn( 0, _T("Filename"), LVCFMT_LEFT, 190, -1 );
00077         m_wndFiles.InsertColumn( 1, _T("Status"), LVCFMT_LEFT, 100, 0 );
00078 
00079         SetTimer( 1, 1000, NULL );
00080         m_nFailures = 0;
00081 
00082         m_pDownloader.Start( this );
00083 
00084         return TRUE;
00085 }
00086 
00087 void CBitziDownloadDlg::AddFile(DWORD nIndex)
00088 {
00089         m_pDownloader.AddFile( nIndex );
00090 }
00091 
00092 void CBitziDownloadDlg::OnNextFile(DWORD nIndex)
00093 {
00094         m_wndProgress.OffsetPos( 1 );
00095 }
00096 
00097 void CBitziDownloadDlg::OnRequesting(DWORD nIndex, LPCTSTR pszName)
00098 {
00099         CString strMessage;
00100 
00101         int nImage      = ShellIcons.Get( pszName, 16 );
00102         int nItem       = m_wndFiles.InsertItem( LVIF_TEXT|LVIF_IMAGE, m_wndFiles.GetItemCount(),
00103                                         pszName, 0, 0, nImage, nIndex );
00104 
00105         m_wndFiles.EnsureVisible( nItem, FALSE );
00106         LoadString( strMessage, IDS_BITZI_REQUESTING );
00107         m_wndFiles.SetItemText( nItem, 1, strMessage );
00108 }
00109 
00110 void CBitziDownloadDlg::OnSuccess(DWORD nIndex)
00111 {
00112         CString strMessage;
00113 
00114         LoadString( strMessage, IDS_BITZI_SUCCESS );
00115         m_wndFiles.SetItemText( m_wndFiles.GetItemCount() - 1, 1, strMessage );
00116 }
00117 
00118 void CBitziDownloadDlg::OnFailure(DWORD nIndex, LPCTSTR pszMessage)
00119 {
00120         m_wndFiles.SetItemText( m_wndFiles.GetItemCount() - 1, 1,
00121                 pszMessage );
00122         m_nFailures++;
00123 }
00124 
00125 void CBitziDownloadDlg::OnFinishedFile(DWORD nIndex)
00126 {
00127         m_wndProgress.OffsetPos( 1 );
00128 }
00129 
00130 void CBitziDownloadDlg::OnTimer(UINT nIDEvent)
00131 {
00132         CString strMessage;
00133 
00134         if ( ! m_pDownloader.IsWorking() )
00135         {
00136                 KillTimer( 1 );
00137 
00138                 LoadString( strMessage, IDS_BITZI_FINISHED );
00139                 int nItem = m_wndFiles.InsertItem( LVIF_TEXT|LVIF_IMAGE, m_wndFiles.GetItemCount(),
00140                         strMessage, 0, 0, -1, 0 );
00141                 m_wndFiles.EnsureVisible( nItem, FALSE );
00142                 LoadString( strMessage, IDS_BITZI_CLOSE );
00143                 m_wndCancel.SetWindowText( strMessage );
00144 
00145                 if ( ! m_nFailures ) PostMessage( WM_COMMAND, IDCANCEL );
00146         }
00147 }
00148 
00149 void CBitziDownloadDlg::OnCancel()
00150 {
00151         m_pDownloader.Stop();
00152 
00153         CSkinDialog::OnCancel();
00154 }
00155 
00156 HBRUSH CBitziDownloadDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00157 {
00158         HBRUSH hbr = CSkinDialog::OnCtlColor(pDC, pWnd, nCtlColor);
00159 
00160         if ( pWnd == &m_wndWeb )
00161         {
00162                 pDC->SelectObject( &theApp.m_gdiFontLine );
00163                 pDC->SetTextColor( RGB( 0, 0, 255 ) );
00164         }
00165 
00166         return hbr;
00167 }
00168 
00169 BOOL CBitziDownloadDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
00170 {
00171         CPoint point;
00172         CRect rc;
00173 
00174         GetCursorPos( &point );
00175         m_wndWeb.GetWindowRect( &rc );
00176 
00177         if ( rc.PtInRect( point ) )
00178         {
00179                 SetCursor( theApp.LoadCursor( IDC_HAND ) );
00180                 return TRUE;
00181         }
00182 
00183         return CSkinDialog::OnSetCursor(pWnd, nHitTest, message);
00184 }
00185 
00186 void CBitziDownloadDlg::OnLButtonDown(UINT nFlags, CPoint point)
00187 {
00188         CRect rc;
00189 
00190         m_wndWeb.GetWindowRect( &rc );
00191         ScreenToClient( &rc );
00192 
00193         if ( rc.PtInRect( point ) )
00194         {
00195                 ShellExecute( GetSafeHwnd(), _T("open"),
00196                         _T("http://www.bitzi.com/?ref=shareaza"),
00197                         NULL, NULL, SW_SHOWNORMAL );
00198         }
00199 }
00200 

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