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

PageSettingsNetworks.cpp

Go to the documentation of this file.
00001 //
00002 // PageSettingsNetworks.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 "WndSettingsSheet.h"
00026 #include "PageSettingsNetworks.h"
00027 #include "PageSettingsGnutella.h"
00028 #include "PageSettingsDonkey.h"
00029 
00030 #ifdef _DEBUG
00031 #define new DEBUG_NEW
00032 #undef THIS_FILE
00033 static char THIS_FILE[] = __FILE__;
00034 #endif
00035 
00036 IMPLEMENT_DYNCREATE(CNetworksSettingsPage, CSettingsPage)
00037 
00038 BEGIN_MESSAGE_MAP(CNetworksSettingsPage, CSettingsPage)
00039         //{{AFX_MSG_MAP(CNetworksSettingsPage)
00040         ON_BN_CLICKED(IDC_G2_ENABLE, OnG2Enable)
00041         ON_BN_CLICKED(IDC_G1_ENABLE, OnG1Enable)
00042         ON_BN_CLICKED(IDC_ED2K_ENABLE, OnEd2kEnable)
00043         ON_WM_CTLCOLOR()
00044         ON_WM_SETCURSOR()
00045         ON_WM_LBUTTONUP()
00046         //}}AFX_MSG_MAP
00047 END_MESSAGE_MAP()
00048 
00049 
00051 // CNetworksSettingsPage property page
00052 
00053 CNetworksSettingsPage::CNetworksSettingsPage() : CSettingsPage( CNetworksSettingsPage::IDD )
00054 {
00055         //{{AFX_DATA_INIT(CNetworksSettingsPage)
00056         m_bG2Enable = FALSE;
00057         m_bG1Enable = FALSE;
00058         m_bEDEnable = FALSE;
00059         //}}AFX_DATA_INIT
00060 }
00061 
00062 CNetworksSettingsPage::~CNetworksSettingsPage()
00063 {
00064 }
00065 
00066 void CNetworksSettingsPage::DoDataExchange(CDataExchange* pDX)
00067 {
00068         CSettingsPage::DoDataExchange(pDX);
00069         //{{AFX_DATA_MAP(CNetworksSettingsPage)
00070         DDX_Control(pDX, IDC_ED2K_SETUP, m_wndEDSetup);
00071         DDX_Control(pDX, IDC_G1_SETUP, m_wndG1Setup);
00072         DDX_Control(pDX, IDC_G2_SETUP, m_wndG2Setup);
00073         DDX_Check(pDX, IDC_G2_ENABLE, m_bG2Enable);
00074         DDX_Check(pDX, IDC_G1_ENABLE, m_bG1Enable);
00075         DDX_Check(pDX, IDC_ED2K_ENABLE, m_bEDEnable);
00076         //}}AFX_DATA_MAP
00077 }
00078 
00080 // CNetworksSettingsPage message handlers
00081 
00082 BOOL CNetworksSettingsPage::OnInitDialog()
00083 {
00084         CSettingsPage::OnInitDialog();
00085 
00086         m_bG2Enable             = Settings.Gnutella2.EnableToday;
00087         m_bG1Enable             = Settings.Gnutella1.EnableToday;
00088         m_bEDEnable             = Settings.eDonkey.EnableToday;
00089 
00090         UpdateData( FALSE );
00091         // m_wndG2Setup.EnableWindow( m_bG2Enable );
00092         // m_wndG1Setup.EnableWindow( m_bG1Enable );
00093         // m_wndEDSetup.EnableWindow( m_bEDEnable );
00094 
00095         return TRUE;
00096 }
00097 
00098 HBRUSH CNetworksSettingsPage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00099 {
00100         HBRUSH hbr = CSettingsPage::OnCtlColor(pDC, pWnd, nCtlColor);
00101 
00102         if ( pWnd == &m_wndG2Setup || pWnd == &m_wndG1Setup || pWnd == &m_wndEDSetup )
00103         {
00104                 if ( pWnd->IsWindowEnabled() )
00105                 {
00106                         pDC->SetTextColor( RGB( 0, 0, 255 ) );
00107                         pDC->SelectObject( &theApp.m_gdiFontLine );
00108                 }
00109         }
00110 
00111         return hbr;
00112 }
00113 
00114 BOOL CNetworksSettingsPage::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
00115 {
00116         CWnd* pLinks[] = { &m_wndG2Setup, &m_wndG1Setup, &m_wndEDSetup, NULL };
00117         CPoint point;
00118         CRect rc;
00119 
00120         GetCursorPos( &point );
00121 
00122         for ( int nLink = 0 ; pLinks[ nLink ] ; nLink++ )
00123         {
00124                 pLinks[ nLink ]->GetWindowRect( &rc );
00125 
00126                 if ( pLinks[ nLink ]->IsWindowEnabled() && rc.PtInRect( point ) )
00127                 {
00128                         SetCursor( theApp.LoadCursor( IDC_HAND ) );
00129                         return TRUE;
00130                 }
00131         }
00132 
00133         return CSettingsPage::OnSetCursor( pWnd, nHitTest, message );
00134 }
00135 
00136 void CNetworksSettingsPage::OnLButtonUp(UINT nFlags, CPoint point)
00137 {
00138         CRect rc;
00139 
00140         ClientToScreen( &point );
00141 
00142         m_wndG2Setup.GetWindowRect( &rc );
00143         if ( m_wndG2Setup.IsWindowEnabled() && rc.PtInRect( point ) )
00144         {
00145                 GetSheet()->SetActivePage( GetSheet()->GetPage( RUNTIME_CLASS(CGnutellaSettingsPage) ) );
00146         }
00147 
00148         m_wndG1Setup.GetWindowRect( &rc );
00149         if ( m_wndG1Setup.IsWindowEnabled() && rc.PtInRect( point ) )
00150         {
00151                 GetSheet()->SetActivePage( GetSheet()->GetPage( RUNTIME_CLASS(CGnutellaSettingsPage) ) );
00152         }
00153 
00154         m_wndEDSetup.GetWindowRect( &rc );
00155         if ( m_wndEDSetup.IsWindowEnabled() && rc.PtInRect( point ) )
00156         {
00157                 GetSheet()->SetActivePage( GetSheet()->GetPage( RUNTIME_CLASS(CDonkeySettingsPage) ) );
00158         }
00159 
00160         CSettingsPage::OnLButtonUp( nFlags, point );
00161 }
00162 
00163 BOOL CNetworksSettingsPage::OnSetActive()
00164 {
00165         CGnutellaSettingsPage* ppGnutella =
00166                 (CGnutellaSettingsPage*)GetPage( RUNTIME_CLASS(CGnutellaSettingsPage) );
00167 
00168         if ( ppGnutella->GetSafeHwnd() != NULL )
00169         {
00170                 ppGnutella->UpdateData();
00171                 m_bG2Enable = ppGnutella->m_bG2Today;
00172                 m_bG1Enable = ppGnutella->m_bG1Today;
00173         }
00174 
00175         CDonkeySettingsPage* ppDonkey =
00176                 (CDonkeySettingsPage*)GetPage( RUNTIME_CLASS(CDonkeySettingsPage) );
00177 
00178         if ( ppDonkey->GetSafeHwnd() != NULL )
00179         {
00180                 ppDonkey->UpdateData();
00181                 m_bEDEnable = ppDonkey->m_bEnableToday;
00182         }
00183 
00184         UpdateData( FALSE );
00185         // m_wndG2Setup.EnableWindow( m_bG2Enable );
00186         // m_wndG1Setup.EnableWindow( m_bG1Enable );
00187         // m_wndEDSetup.EnableWindow( m_bEDEnable );
00188 
00189         return CSettingsPage::OnSetActive();
00190 }
00191 
00192 void CNetworksSettingsPage::OnG2Enable()
00193 {
00194         UpdateData();
00195 
00196         if ( ! m_bG2Enable )
00197         {
00198                 CString strMessage;
00199                 LoadString( strMessage, IDS_NETWORK_DISABLE_G2 );
00200 
00201                 if ( AfxMessageBox( strMessage, MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2 ) != IDYES )
00202                 {
00203                         m_bG2Enable = TRUE;
00204                         UpdateData( FALSE );
00205                 }
00206         }
00207 
00208         CGnutellaSettingsPage* ppGnutella =
00209                 (CGnutellaSettingsPage*)GetPage( RUNTIME_CLASS(CGnutellaSettingsPage) );
00210 
00211         if ( ppGnutella->GetSafeHwnd() != NULL )
00212         {
00213                 ppGnutella->UpdateData( TRUE );
00214                 ppGnutella->m_bG2Today = m_bG2Enable;
00215                 ppGnutella->UpdateData( FALSE );
00216         }
00217 
00218         // m_wndG2Setup.EnableWindow( m_bG2Enable );
00219 }
00220 
00221 void CNetworksSettingsPage::OnG1Enable()
00222 {
00223         UpdateData();
00224 
00225         if ( m_bG1Enable && ( Settings.GetOutgoingBandwidth() < 2 ) )
00226         {
00227                 CString strMessage;
00228                 LoadString( strMessage, IDS_NETWORK_BANDWIDTH_LOW );
00229                 AfxMessageBox( strMessage, MB_OK );
00230                 m_bG1Enable = FALSE;
00231                 UpdateData( FALSE );
00232         }
00233 
00234         CGnutellaSettingsPage* ppGnutella =
00235                 (CGnutellaSettingsPage*)GetPage( RUNTIME_CLASS(CGnutellaSettingsPage) );
00236 
00237         if ( ppGnutella->GetSafeHwnd() != NULL )
00238         {
00239                 ppGnutella->UpdateData( TRUE );
00240                 ppGnutella->m_bG1Today = m_bG1Enable;
00241                 ppGnutella->UpdateData( FALSE );
00242         }
00243 
00244         // m_wndG1Setup.EnableWindow( m_bG1Enable );
00245 }
00246 
00247 void CNetworksSettingsPage::OnEd2kEnable()
00248 {
00249         UpdateData();
00250 
00251         if ( m_bEDEnable && ( Settings.GetOutgoingBandwidth() < 2 ) )
00252         {
00253                 CString strMessage;
00254                 LoadString( strMessage, IDS_NETWORK_BANDWIDTH_LOW );
00255                 AfxMessageBox( strMessage, MB_OK );
00256                 m_bEDEnable = FALSE;
00257                 UpdateData( FALSE );
00258         }
00259 
00260         CDonkeySettingsPage* ppDonkey =
00261                 (CDonkeySettingsPage*)GetPage( RUNTIME_CLASS(CDonkeySettingsPage) );
00262 
00263         if ( ppDonkey->GetSafeHwnd() != NULL )
00264         {
00265                 ppDonkey->UpdateData( TRUE );
00266                 ppDonkey->m_bEnableToday = m_bEDEnable;
00267                 ppDonkey->UpdateData( FALSE );
00268         }
00269 
00270         // m_wndEDSetup.EnableWindow( m_bEDEnable );
00271 }
00272 
00273 void CNetworksSettingsPage::OnOK()
00274 {
00275         UpdateData( TRUE );
00276 
00277         Settings.Gnutella2.EnableToday  = m_bG2Enable;
00278         Settings.Gnutella1.EnableToday  = m_bG1Enable;
00279         Settings.eDonkey.EnableToday    = m_bEDEnable;
00280 
00281         CSettingsPage::OnOK();
00282 }
00283 

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