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

DlgSettingsManager.cpp

Go to the documentation of this file.
00001 //
00002 // DlgSettingsManager.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 "Skin.h"
00026 #include "DlgSettingsManager.h"
00027 
00028 #include "PageSettingsRich.h"
00029 #include "PageSettingsGeneral.h"
00030 #include "PageSettingsLibrary.h"
00031 #include "PageSettingsMedia.h"
00032 #include "PageSettingsCommunity.h"
00033 #include "PageSettingsWeb.h"
00034 #include "PageSettingsConnection.h"
00035 #include "PageSettingsDownloads.h"
00036 #include "PageSettingsUploads.h"
00037 #include "PageSettingsRemote.h"
00038 #include "PageSettingsScheduler.h"
00039 #include "PageSettingsNetworks.h"
00040 #include "PageSettingsGnutella.h"
00041 #include "PageSettingsDonkey.h"
00042 #include "PageSettingsBitTorrent.h"
00043 #include "PageSettingsSkins.h"
00044 #include "PageSettingsPlugins.h"
00045 #include "PageSettingsTraffic.h"
00046 #include "PageSettingsProtocols.h"
00047 
00048 #ifdef _DEBUG
00049 #define new DEBUG_NEW
00050 #undef THIS_FILE
00051 static char THIS_FILE[] = __FILE__;
00052 #endif
00053 
00054 BEGIN_MESSAGE_MAP(CSettingsManagerDlg, CSettingsSheet)
00055         //{{AFX_MSG_MAP(CSettingsManagerDlg)
00056         //}}AFX_MSG_MAP
00057         ON_COMMAND(IDRETRY, OnApply)
00058 END_MESSAGE_MAP()
00059 
00060 
00062 // CSettingsManagerDlg dialog
00063 
00064 CSettingsManagerDlg::CSettingsManagerDlg(CWnd* pParent) : CSettingsSheet( pParent, IDS_SETTINGS )
00065 {
00066         m_nTopMargin = 52;
00067 }
00068 
00069 void CSettingsManagerDlg::DoDataExchange(CDataExchange* pDX)
00070 {
00071         CDialog::DoDataExchange( pDX );
00072 }
00073 
00075 // CSettingsManagerDlg operations
00076 
00077 CSettingsManagerDlg* CSettingsManagerDlg::m_pThis = NULL;
00078 
00079 BOOL CSettingsManagerDlg::Run(LPCTSTR pszWindow)
00080 {
00081         if ( m_pThis ) return FALSE;
00082         CSettingsManagerDlg pSheet;
00083         m_pThis = &pSheet;
00084         BOOL bResult = ( pSheet.DoModal( pszWindow ) == IDOK );
00085         m_pThis = NULL;
00086         return bResult;
00087 }
00088 
00089 void CSettingsManagerDlg::OnSkinChange(BOOL bSet)
00090 {
00091         if ( m_pThis == NULL ) return;
00092 
00093         if ( bSet )
00094         {
00095                 m_pThis->SkinMe( _T("CSettingSheet"), IDR_MAINFRAME, TRUE );
00096                 m_pThis->Invalidate();
00097         }
00098         else
00099         {
00100                 m_pThis->m_pSkin = NULL;
00101         }
00102 }
00103 
00104 int CSettingsManagerDlg::DoModal(LPCTSTR pszWindow)
00105 {
00106         BOOL bAdvanced                  = Settings.General.GUIMode != GUI_BASIC;
00107 
00108         CRichSettingsPage               gGeneral( _T("CGeneralSettingsGroup") );
00109         CGeneralSettingsPage    pGeneral;
00110         CLibrarySettingsPage    pLibrary;
00111         CMediaSettingsPage              pMedia;
00112         CCommunitySettingsPage  pCommunity;
00113         CWebSettingsPage                pWeb;
00114         CRichSettingsPage               gInternet( _T("CInternetSettingsGroup") );
00115         CConnectionSettingsPage pConnection;
00116         CDownloadsSettingsPage  pDownloads;
00117         CUploadsSettingsPage    pUploads;
00118         CRemoteSettingsPage             pRemote;
00119         CSchedulerSettingsPage  pScheduler;
00120         CNetworksSettingsPage   gNetworks;
00121         CGnutellaSettingsPage   pGnutella;
00122         CDonkeySettingsPage             pDonkey;
00123         CBitTorrentSettingsPage pTorrent;
00124         CSkinsSettingsPage              pSkins;
00125         CPluginsSettingsPage    pPlugins;
00126         CAdvancedSettingsPage   pAdvanced;
00127         CProtocolsSettingsPage  pProtocols;
00128 
00129         AddGroup( &gGeneral );
00130         AddPage( &pGeneral );
00131         AddPage( &pLibrary );
00132         AddPage( &pMedia );
00133         AddPage( &pCommunity );
00134         AddPage( &pWeb );
00135         AddGroup( &gInternet );
00136         AddPage( &pConnection );
00137         AddPage( &pDownloads );
00138         AddPage( &pUploads );
00139         AddPage( &pRemote );
00140         if ( bAdvanced )
00141         {
00142                 AddPage( &pScheduler );
00143                 AddGroup( &gNetworks );
00144                 AddPage( &pGnutella );
00145                 AddPage( &pDonkey );
00146                 AddPage( &pTorrent );
00147                 AddPage( &pProtocols );
00148         }
00149         AddGroup( &pSkins );
00150         AddGroup( &pPlugins );
00151         if ( bAdvanced ) AddGroup( &pAdvanced );
00152 
00153         if ( pszWindow != NULL )
00154         {
00155                 SetActivePage( GetPage( pszWindow ) );
00156         }
00157         else
00158         {
00159                 SetActivePage( GetPage(
00160                         theApp.GetProfileString( _T("Settings"), _T("LastSettingsPage"), _T("") ) ) );
00161         }
00162 
00163         int nReturn = CSettingsSheet::DoModal();
00164 
00165         if ( m_pFirst )
00166         {
00167                 theApp.WriteProfileString( _T("Settings"), _T("LastSettingsPage"), CString( m_pFirst->GetRuntimeClass()->m_lpszClassName ) );
00168         }
00169 
00170         return nReturn;
00171 }
00172 
00173 void CSettingsManagerDlg::AddPage(CSettingsPage* pPage)
00174 {
00175         CString strCaption = Skin.GetDialogCaption( CString( pPage->GetRuntimeClass()->m_lpszClassName ) );
00176         CSettingsSheet::AddPage( pPage, strCaption.GetLength() ? (LPCTSTR)strCaption : NULL );
00177 }
00178 
00179 void CSettingsManagerDlg::AddGroup(CSettingsPage* pPage)
00180 {
00181         if ( pPage->IsKindOf( RUNTIME_CLASS(CRichSettingsPage) ) )
00182         {
00183                 CString strCaption = ((CRichSettingsPage*)pPage)->m_sCaption;
00184                 CSettingsSheet::AddGroup( pPage, strCaption );
00185         }
00186         else
00187         {
00188                 CString strName = pPage->GetRuntimeClass()->m_lpszClassName;
00189                 CString strCaption = Skin.GetDialogCaption( strName );
00190                 CSettingsSheet::AddGroup( pPage, strCaption.GetLength() ? (LPCTSTR)strCaption : NULL );
00191         }
00192 }
00193 
00195 // CSettingsManagerDlg message handlers
00196 
00197 BOOL CSettingsManagerDlg::OnInitDialog()
00198 {
00199         CSettingsSheet::OnInitDialog();
00200 
00201         m_bmHeader.LoadBitmap( IDB_WIZARD );
00202 
00203         SkinMe( _T("CSettingSheet"), IDR_MAINFRAME, TRUE );
00204 
00205         return TRUE;
00206 }
00207 
00208 void CSettingsManagerDlg::DoPaint(CDC& dc)
00209 {
00210         CRect rc;
00211         GetClientRect( &rc );
00212 
00213         BITMAP pInfo;
00214         m_bmHeader.GetBitmap( &pInfo );
00215 
00216         CDC mdc;
00217         mdc.CreateCompatibleDC( &dc );
00218         CBitmap* pOldBitmap = (CBitmap*)mdc.SelectObject( &m_bmHeader );
00219         dc.BitBlt( 0, 0, pInfo.bmWidth, pInfo.bmHeight, &mdc, 0, 0, SRCCOPY );
00220         mdc.SelectObject( pOldBitmap );
00221         mdc.DeleteDC();
00222 
00223         /*
00224         dc.FillSolidRect( 438, 0, rc.right - 438, 48, RGB( 0xBE, 0, 0 ) );
00225 
00226         dc.Draw3dRect( 438, 48, rc.right - 437, 2,
00227                 RGB( 169, 0, 0 ), RGB( 110, 59, 59 ) );
00228 
00229         dc.Draw3dRect( 0, 50, rc.Width() + 1, 1,
00230                 RGB( 128, 128, 128 ), RGB( 128, 128, 128 ) );
00231         */
00232 
00233         CSettingsSheet::DoPaint( dc );
00234 }
00235 
00236 void CSettingsManagerDlg::OnOK()
00237 {
00238         CSettingsSheet::OnOK();
00239         Settings.Save();
00240         AfxGetMainWnd()->Invalidate();
00241 }
00242 
00243 void CSettingsManagerDlg::OnApply()
00244 {
00245         CSettingsSheet::OnApply();
00246         AfxGetMainWnd()->Invalidate();
00247 }

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