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

PageSettingsMedia.cpp

Go to the documentation of this file.
00001 //
00002 // PageSettingsMedia.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 "PageSettingsMedia.h"
00026 #include "DlgMediaVis.h"
00027 
00028 #ifdef _DEBUG
00029 #define new DEBUG_NEW
00030 #undef THIS_FILE
00031 static char THIS_FILE[] = __FILE__;
00032 #endif
00033 
00034 IMPLEMENT_DYNCREATE(CMediaSettingsPage, CSettingsPage)
00035 
00036 BEGIN_MESSAGE_MAP(CMediaSettingsPage, CSettingsPage)
00037         //{{AFX_MSG_MAP(CMediaSettingsPage)
00038         ON_BN_CLICKED(IDC_MEDIA_PLAY, OnMediaPlay)
00039         ON_BN_CLICKED(IDC_MEDIA_ENQUEUE, OnMediaEnqueue)
00040         ON_CBN_SELCHANGE(IDC_MEDIA_TYPES, OnSelChangeMediaTypes)
00041         ON_CBN_EDITCHANGE(IDC_MEDIA_TYPES, OnEditChangeMediaTypes)
00042         ON_BN_CLICKED(IDC_MEDIA_ADD, OnMediaAdd)
00043         ON_BN_CLICKED(IDC_MEDIA_REMOVE, OnMediaRemove)
00044         ON_BN_CLICKED(IDC_MEDIA_VIS, OnMediaVis)
00045         //}}AFX_MSG_MAP
00046 END_MESSAGE_MAP()
00047 
00048 
00050 // CMediaSettingsPage property page
00051 
00052 CMediaSettingsPage::CMediaSettingsPage() : CSettingsPage(CMediaSettingsPage::IDD)
00053 {
00054         //{{AFX_DATA_INIT(CMediaSettingsPage)
00055         m_sType = _T("");
00056         m_bEnablePlay = FALSE;
00057         m_bEnableEnqueue = FALSE;
00058         //}}AFX_DATA_INIT
00059 }
00060 
00061 CMediaSettingsPage::~CMediaSettingsPage()
00062 {
00063 }
00064 
00065 void CMediaSettingsPage::DoDataExchange(CDataExchange* pDX)
00066 {
00067         CSettingsPage::DoDataExchange(pDX);
00068         //{{AFX_DATA_MAP(CMediaSettingsPage)
00069         DDX_Control(pDX, IDC_MEDIA_REMOVE, m_wndRemove);
00070         DDX_Control(pDX, IDC_MEDIA_ADD, m_wndAdd);
00071         DDX_Control(pDX, IDC_MEDIA_TYPES, m_wndList);
00072         DDX_CBString(pDX, IDC_MEDIA_TYPES, m_sType);
00073         DDX_Check(pDX, IDC_MEDIA_PLAY, m_bEnablePlay);
00074         DDX_Check(pDX, IDC_MEDIA_ENQUEUE, m_bEnableEnqueue);
00075         //}}AFX_DATA_MAP
00076 }
00077 
00079 // CMediaSettingsPage message handlers
00080 
00081 BOOL CMediaSettingsPage::OnInitDialog()
00082 {
00083         CSettingsPage::OnInitDialog();
00084 
00085         m_bEnablePlay           = Settings.MediaPlayer.EnablePlay;
00086         m_bEnableEnqueue        = Settings.MediaPlayer.EnableEnqueue;
00087 
00088         for ( CString strList = Settings.MediaPlayer.FileTypes + '|' ; strList.GetLength() ; )
00089         {
00090                 CString strType = strList.SpanExcluding( _T(" |") );
00091                 strList = strList.Mid( strType.GetLength() + 1 );
00092                 strType.TrimLeft();
00093                 strType.TrimRight();
00094                 if ( strType.GetLength() ) m_wndList.AddString( strType );
00095         }
00096 
00097         UpdateData( FALSE );
00098 
00099         m_wndList.EnableWindow( m_bEnablePlay || m_bEnableEnqueue );
00100         m_wndAdd.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetWindowTextLength() > 0 );
00101         m_wndRemove.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetCurSel() >= 0 );
00102 
00103         return TRUE;
00104 }
00105 
00106 void CMediaSettingsPage::OnMediaPlay()
00107 {
00108         UpdateData();
00109         m_wndList.EnableWindow( m_bEnablePlay || m_bEnableEnqueue );
00110         m_wndAdd.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetWindowTextLength() > 0 );
00111         m_wndRemove.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetCurSel() >= 0 );
00112 }
00113 
00114 void CMediaSettingsPage::OnMediaEnqueue()
00115 {
00116         UpdateData();
00117         m_wndList.EnableWindow( m_bEnablePlay || m_bEnableEnqueue );
00118         m_wndAdd.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetWindowTextLength() > 0 );
00119         m_wndRemove.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetCurSel() >= 0 );
00120 }
00121 
00122 void CMediaSettingsPage::OnSelChangeMediaTypes()
00123 {
00124         m_wndRemove.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetCurSel() >= 0 );
00125 }
00126 
00127 void CMediaSettingsPage::OnEditChangeMediaTypes()
00128 {
00129         m_wndAdd.EnableWindow( ( m_bEnablePlay || m_bEnableEnqueue ) && m_wndList.GetWindowTextLength() > 0 );
00130 }
00131 
00132 void CMediaSettingsPage::OnMediaAdd()
00133 {
00134         UpdateData();
00135 
00136         CharLower( m_sType.GetBuffer() );
00137         m_sType.ReleaseBuffer();
00138         m_sType.TrimLeft();
00139         m_sType.TrimRight();
00140         if ( m_sType.IsEmpty() ) return;
00141 
00142         if ( m_wndList.FindStringExact( -1, m_sType ) >= 0 ) return;
00143 
00144         m_wndList.AddString( m_sType );
00145         m_sType.Empty();
00146         UpdateData( FALSE );
00147 }
00148 
00149 void CMediaSettingsPage::OnMediaRemove()
00150 {
00151         int nItem = m_wndList.GetCurSel();
00152         if ( nItem >= 0 ) m_wndList.DeleteString( nItem );
00153         m_wndRemove.EnableWindow( FALSE );
00154 }
00155 
00156 void CMediaSettingsPage::OnMediaVis()
00157 {
00158         CMediaVisDlg dlg( NULL );
00159         dlg.DoModal();
00160 }
00161 
00162 void CMediaSettingsPage::OnOK()
00163 {
00164         UpdateData();
00165 
00166         Settings.MediaPlayer.EnablePlay         = m_bEnablePlay;
00167         Settings.MediaPlayer.EnableEnqueue      = m_bEnableEnqueue;
00168 
00169         Settings.MediaPlayer.FileTypes.Empty();
00170 
00171         for ( int nItem = 0 ; nItem < m_wndList.GetCount() ; nItem++ )
00172         {
00173                 CString str;
00174                 m_wndList.GetLBText( nItem, str );
00175 
00176                 if ( str.GetLength() )
00177                 {
00178                         if ( Settings.MediaPlayer.FileTypes.IsEmpty() )
00179                                 Settings.MediaPlayer.FileTypes += '|';
00180                         Settings.MediaPlayer.FileTypes += str;
00181                         Settings.MediaPlayer.FileTypes += '|';
00182                 }
00183         }
00184 
00185         CSettingsPage::OnOK();
00186 }

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