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

PageSettingsGeneral.cpp

Go to the documentation of this file.
00001 //
00002 // PageSettingsGeneral.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 "PageSettingsGeneral.h"
00026 #include "DlgHelp.h"
00027 #include "Schema.h"
00028 #include "SchemaCache.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(CGeneralSettingsPage, CSettingsPage)
00037 
00038 BEGIN_MESSAGE_MAP(CGeneralSettingsPage, CSettingsPage)
00039         //{{AFX_MSG_MAP(CGeneralSettingsPage)
00040         ON_CBN_DROPDOWN(IDC_CLOSE_MODE, OnDropdownCloseMode)
00041         ON_CBN_DROPDOWN(IDC_TRAY_MINIMISE, OnDropdownTrayMinimise)
00042         //}}AFX_MSG_MAP
00043 END_MESSAGE_MAP()
00044 
00045 
00047 // CGeneralSettingsPage property page
00048 
00049 CGeneralSettingsPage::CGeneralSettingsPage() : CSettingsPage(CGeneralSettingsPage::IDD)
00050 {
00051         //{{AFX_DATA_INIT(CGeneralSettingsPage)
00052         m_bRatesInBytes = -1;
00053         m_bExpandMatches = FALSE;
00054         m_bAutoConnect = FALSE;
00055         m_nCloseMode = -1;
00056         m_bTrayMinimise = -1;
00057         m_bSwitchToTransfers = FALSE;
00058         m_bExpandDownloads = FALSE;
00059         m_bSimpleBar = FALSE;
00060         m_bStartup = FALSE;
00061         m_bPromptURLs = FALSE;
00062         m_bHideSearch = FALSE;
00063         m_bAdultFilter = FALSE;
00064         m_nTipDelay = 0;
00065         //}}AFX_DATA_INIT
00066 }
00067 
00068 CGeneralSettingsPage::~CGeneralSettingsPage()
00069 {
00070 }
00071 
00072 void CGeneralSettingsPage::DoDataExchange(CDataExchange* pDX)
00073 {
00074         CSettingsPage::DoDataExchange(pDX);
00075         //{{AFX_DATA_MAP(CGeneralSettingsPage)
00076         DDX_CBIndex(pDX, IDC_RATES_IN_BYTES, m_bRatesInBytes);
00077         DDX_Check(pDX, IDC_EXPAND_MATCHES, m_bExpandMatches);
00078         DDX_Check(pDX, IDC_AUTO_CONNECT, m_bAutoConnect);
00079         DDX_CBIndex(pDX, IDC_CLOSE_MODE, m_nCloseMode);
00080         DDX_CBIndex(pDX, IDC_TRAY_MINIMISE, m_bTrayMinimise);
00081         DDX_Check(pDX, IDC_SWITCH_TO_TRANSFERS, m_bSwitchToTransfers);
00082         DDX_Check(pDX, IDC_EXPAND_DOWNLOAD, m_bExpandDownloads);
00083         DDX_Check(pDX, IDC_DOWNLOADS_SIMPLEBAR, m_bSimpleBar);
00084         DDX_Check(pDX, IDC_AUTO_START, m_bStartup);
00085         DDX_Check(pDX, IDC_PROMPT_URLS, m_bPromptURLs);
00086         DDX_Check(pDX, IDC_HIDE_SEARCH, m_bHideSearch);
00087         DDX_Check(pDX, IDC_ADULT_FILTER, m_bAdultFilter);
00088         DDX_Control(pDX, IDC_TIP_DELAY_SPIN, m_wndTipSpin);
00089         DDX_Control(pDX, IDC_TIP_DISPLAY, m_wndTips);
00090         DDX_Control(pDX, IDC_TIP_ALPHA, m_wndTipAlpha);
00091         DDX_Text(pDX, IDC_TIP_DELAY, m_nTipDelay);
00092         DDX_Control(pDX, IDC_CLOSE_MODE, m_wndCloseMode);
00093         DDX_Control(pDX, IDC_TRAY_MINIMISE, m_wndTrayMinimise);
00094         //}}AFX_DATA_MAP
00095 }
00096 
00098 // CGeneralSettingsPage message handlers
00099 
00100 BOOL CGeneralSettingsPage::OnInitDialog() 
00101 {
00102         CSettingsPage::OnInitDialog();
00103         
00104         m_bStartup                              = Settings.CheckStartup();
00105         m_bAutoConnect                  = Settings.Connection.AutoConnect;
00106         m_nCloseMode                    = Settings.General.CloseMode;
00107         m_bTrayMinimise                 = Settings.General.TrayMinimise;
00108         m_bExpandMatches                = Settings.Search.ExpandMatches;
00109         m_bSwitchToTransfers    = Settings.Search.SwitchToTransfers;
00110         m_bExpandDownloads              = Settings.Downloads.AutoExpand;
00111         m_bSimpleBar                    = Settings.Downloads.SimpleBar;
00112         m_bPromptURLs                   = ! Settings.General.AlwaysOpenURLs;
00113         m_bHideSearch                   = Settings.Search.HideSearchPanel;
00114         m_bAdultFilter                  = Settings.Search.AdultFilter;
00115         
00116         m_bRatesInBytes                 = Settings.General.RatesInBytes
00117                                                         + Settings.General.RatesUnit * 2;
00118         
00119         CRect rc;
00120         CString strTitle( _T("Search Results") );
00121 
00122         m_wndTips.GetClientRect( &rc );
00123         rc.right -= GetSystemMetrics( SM_CXVSCROLL ) + 1;
00124         
00125         m_wndTips.InsertColumn( 0, _T("Name"), LVCFMT_LEFT, rc.right, 0 );
00126         m_wndTips.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE,
00127                 LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES|LVS_EX_LABELTIP, 
00128                 LVS_EX_FULLROWSELECT|LVS_EX_CHECKBOXES|LVS_EX_LABELTIP );
00129         
00130         if ( CSchema* pSchema = SchemaCache.Get( CSchema::uriSearchFolder ) )
00131         {
00132                 strTitle = pSchema->m_sTitle;
00133                 int nColon = strTitle.Find( ':' );
00134                 if ( nColon >= 0 ) 
00135                         strTitle = strTitle.Mid( nColon + 1 ).Trim();
00136         }
00137 
00138         Add( strTitle, Settings.Interface.TipSearch );
00139         LoadString( strTitle, IDR_LIBRARYFRAME );
00140         Add( strTitle, Settings.Interface.TipLibrary );
00141         LoadString( strTitle, IDR_DOWNLOADSFRAME );
00142         Add( strTitle, Settings.Interface.TipDownloads );
00143         LoadString( strTitle, IDR_UPLOADSFRAME );
00144         Add( strTitle, Settings.Interface.TipUploads );
00145         LoadString( strTitle, IDR_NEIGHBOURSFRAME );
00146         Add( strTitle, Settings.Interface.TipNeighbours );
00147         LoadString( strTitle, IDR_MEDIAFRAME );
00148         Add( strTitle, Settings.Interface.TipMedia );
00149         
00150         m_wndTipSpin.SetRange( 100, 5000 );
00151         m_nTipDelay     = Settings.Interface.TipDelay;
00152         
00153         m_wndTipAlpha.SetRange( 0, 255 );
00154         m_wndTipAlpha.SetPos( Settings.Interface.TipAlpha );
00155         
00156         UpdateData( FALSE );
00157         
00158         return TRUE;
00159 }
00160 
00161 void CGeneralSettingsPage::Add(LPCTSTR pszName, BOOL bState)
00162 {
00163         int nItem = m_wndTips.InsertItem( LVIF_TEXT, m_wndTips.GetItemCount(),
00164                 pszName, 0, 0, 0, 0 );
00165         
00166         if ( bState )
00167                 m_wndTips.SetItemState( nItem, 2 << 12, LVIS_STATEIMAGEMASK );
00168 }
00169 
00170 void CGeneralSettingsPage::OnOK() 
00171 {
00172         UpdateData();
00173 
00174         if ( ( Settings.Search.AdultFilter == FALSE ) && ( m_bAdultFilter == TRUE ) 
00175                 && ( Settings.Live.AdultWarning == FALSE ) )
00176         {
00177                 Settings.Live.AdultWarning = TRUE;
00178                 CHelpDlg::Show( _T("GeneralHelp.AdultFilter") );
00179         }
00180         
00181         Settings.SetStartup( m_bStartup );
00182         Settings.Connection.AutoConnect         = m_bAutoConnect;
00183         Settings.General.CloseMode                      = m_nCloseMode;
00184         Settings.General.TrayMinimise           = m_bTrayMinimise;
00185         Settings.Search.ExpandMatches           = m_bExpandMatches;
00186         Settings.Search.SwitchToTransfers       = m_bSwitchToTransfers;
00187         Settings.Downloads.AutoExpand           = m_bExpandDownloads;
00188         Settings.Downloads.SimpleBar            = m_bSimpleBar;
00189         Settings.General.AlwaysOpenURLs         = ! m_bPromptURLs;
00190         Settings.Search.HideSearchPanel         = m_bHideSearch;
00191         Settings.Search.AdultFilter                     = m_bAdultFilter;
00192         
00193         Settings.General.RatesInBytes           = m_bRatesInBytes % 2;
00194         Settings.General.RatesUnit                      = m_bRatesInBytes / 2;
00195         
00196         Settings.Interface.TipSearch            = m_wndTips.GetItemState( 0, LVIS_STATEIMAGEMASK ) == ( 2 << 12 );
00197         Settings.Interface.TipLibrary           = m_wndTips.GetItemState( 1, LVIS_STATEIMAGEMASK ) == ( 2 << 12 );
00198         Settings.Interface.TipDownloads         = m_wndTips.GetItemState( 2, LVIS_STATEIMAGEMASK ) == ( 2 << 12 );
00199         Settings.Interface.TipUploads           = m_wndTips.GetItemState( 3, LVIS_STATEIMAGEMASK ) == ( 2 << 12 );
00200         Settings.Interface.TipNeighbours        = m_wndTips.GetItemState( 4, LVIS_STATEIMAGEMASK ) == ( 2 << 12 );
00201         Settings.Interface.TipMedia                     = m_wndTips.GetItemState( 5, LVIS_STATEIMAGEMASK ) == ( 2 << 12 );
00202         
00203         Settings.Interface.TipDelay     = m_nTipDelay;
00204         Settings.Interface.TipAlpha     = m_wndTipAlpha.GetPos();
00205         
00206         CSettingsPage::OnOK();
00207 }
00208 
00209 
00210 void CGeneralSettingsPage::OnDropdownCloseMode()
00211 {
00212         RecalcDropWidth( &m_wndCloseMode );
00213 }
00214 
00215 void CGeneralSettingsPage::OnDropdownTrayMinimise()
00216 {
00217         RecalcDropWidth( &m_wndTrayMinimise );
00218 }

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