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

DlgFilePropertiesSheet.cpp

Go to the documentation of this file.
00001 //
00002 // DlgFilePropertiesSheet.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 "DlgFilePropertiesSheet.h"
00026 #include "PageFileGeneral.h"
00027 #include "PageFileMetadata.h"
00028 #include "PageFileSources.h"
00029 #include "PageFileComments.h"
00030 #include "PageFileSharing.h"
00031 
00032 #include "Skin.h"
00033 #include "SkinWindow.h"
00034 
00035 #ifdef _DEBUG
00036 #define new DEBUG_NEW
00037 #undef THIS_FILE
00038 static char THIS_FILE[] = __FILE__;
00039 #endif
00040 
00041 IMPLEMENT_DYNAMIC(CFilePropertiesSheet, CPropertySheet)
00042 
00043 BEGIN_MESSAGE_MAP(CFilePropertiesSheet, CPropertySheet)
00044         //{{AFX_MSG_MAP(CFilePropertiesSheet)
00045         ON_WM_NCCALCSIZE()
00046         ON_WM_NCHITTEST()
00047         ON_WM_NCACTIVATE()
00048         ON_WM_NCPAINT()
00049         ON_WM_NCLBUTTONDOWN()
00050         ON_WM_NCLBUTTONUP()
00051         ON_WM_NCLBUTTONDBLCLK()
00052         ON_WM_NCMOUSEMOVE()
00053         ON_WM_SIZE()
00054         ON_WM_ERASEBKGND()
00055         ON_WM_CTLCOLOR()
00056         //}}AFX_MSG_MAP
00057 END_MESSAGE_MAP()
00058 
00059 
00061 // CFilePropertiesSheet
00062 
00063 CFilePropertiesSheet::CFilePropertiesSheet(UINT nIndex) : CPropertySheet( _T("") )
00064 {
00065         if ( nIndex > 0 ) m_pList.AddTail( nIndex );
00066 
00067         m_pSkin = NULL;
00068         m_psh.dwFlags &= ~PSP_HASHELP;
00069 }
00070 
00071 CFilePropertiesSheet::~CFilePropertiesSheet()
00072 {
00073 }
00074 
00076 // CFilePropertiesSheet operations
00077 
00078 void CFilePropertiesSheet::Add(UINT nIndex)
00079 {
00080         m_pList.CheckAndAdd( nIndex );
00081 }
00082 
00083 void CFilePropertiesSheet::Add(CLibraryList* pList)
00084 {
00085         m_pList.Merge( pList );
00086 }
00087 
00088 int CFilePropertiesSheet::DoModal(int nPage)
00089 {
00090         //TODO: Get page title from defined caption in resources (Rolandas)
00091         CFileGeneralPage        pGeneral;
00092         CFileMetadataPage       pMetadata;
00093         CFileCommentsPage       pComments;
00094         CFileSharingPage        pSharing;
00095         CFileSourcesPage        pSources;
00096 
00097         CString strTabLabel;
00098 
00099         switch ( m_pList.GetCount() )
00100         {
00101         case 0:
00102                 return IDCANCEL;
00103         case 1:
00104                 strTabLabel = Skin.GetDialogCaption( _T("CFileGeneralPage") );
00105                 pGeneral.m_psp.dwFlags |= PSP_USETITLE;
00106                 pGeneral.m_psp.pszTitle = strTabLabel.IsEmpty() ? _T("General") : strTabLabel;
00107                 AddPage( &pGeneral );
00108                 strTabLabel = Skin.GetDialogCaption( _T("CFileMetadataPage") );
00109                 pMetadata.m_psp.dwFlags |= PSP_USETITLE;
00110                 pMetadata.m_psp.pszTitle = strTabLabel.IsEmpty() ? _T("Metadata") : strTabLabel;
00111                 AddPage( &pMetadata );
00112                 strTabLabel = Skin.GetDialogCaption( _T("CFileCommentsPage") );
00113                 pComments.m_psp.dwFlags |= PSP_USETITLE;
00114                 pComments.m_psp.pszTitle = strTabLabel.IsEmpty() ? _T("My Review") : strTabLabel;
00115                 AddPage( &pComments );
00116                 strTabLabel = Skin.GetDialogCaption( _T("CFileSharingPage") );
00117                 pSharing.m_psp.dwFlags |= PSP_USETITLE;
00118                 pSharing.m_psp.pszTitle = strTabLabel.IsEmpty() ? _T("Sharing") : strTabLabel;
00119                 AddPage( &pSharing );
00120                 strTabLabel = Skin.GetDialogCaption( _T("CFileSourcesPage") );
00121                 pSources.m_psp.dwFlags |= PSP_USETITLE;
00122                 pSources.m_psp.pszTitle = strTabLabel.IsEmpty() ? _T("Sources") : strTabLabel;
00123                 AddPage( &pSources );
00124                 break;
00125         default:
00126                 strTabLabel = Skin.GetDialogCaption( _T("CFileMetadataPage") );
00127                 pMetadata.m_psp.dwFlags |= PSP_USETITLE;
00128                 pMetadata.m_psp.pszTitle = strTabLabel.IsEmpty() ? _T("Metadata") : strTabLabel;
00129                 AddPage( &pMetadata );
00130                 strTabLabel = Skin.GetDialogCaption( _T("CFileCommentsPage") );
00131                 pComments.m_psp.dwFlags |= PSP_USETITLE;
00132                 pComments.m_psp.pszTitle = strTabLabel.IsEmpty() ? _T("My Review") : strTabLabel;
00133                 AddPage( &pComments );
00134                 strTabLabel = Skin.GetDialogCaption( _T("CFileSharingPage") );
00135                 pSharing.m_psp.dwFlags |= PSP_USETITLE;
00136                 pSharing.m_psp.pszTitle = strTabLabel.IsEmpty() ? _T("Sharing") : strTabLabel;
00137                 AddPage( &pSharing );
00138                 if ( nPage == 1 ) nPage = 0;
00139                 else if ( nPage == 2 ) nPage = 1;
00140                 break;
00141         }
00142 
00143         m_psh.nStartPage = nPage;
00144         return CPropertySheet::DoModal();
00145 }
00146 
00148 // CFilePropertiesSheet message handlers
00149 
00150 BOOL CFilePropertiesSheet::OnInitDialog()
00151 {
00152         BOOL bResult = CPropertySheet::OnInitDialog();
00153 
00154         SetFont( &theApp.m_gdiFont );
00155         SetIcon( theApp.LoadIcon( IDI_PROPERTIES ), TRUE );
00156 
00157         CString strCaption;
00158         LoadString( strCaption, IDS_FILE_PROPERTIES );
00159         SetWindowText( strCaption );
00160 
00161         m_pSkin = Skin.GetWindowSkin( _T("CFilePropertiesSheet") );
00162         if ( m_pSkin == NULL ) m_pSkin = Skin.GetWindowSkin( this );
00163         if ( m_pSkin == NULL ) m_pSkin = Skin.GetWindowSkin( _T("CDialog") );
00164 
00165         if ( m_pSkin != NULL )
00166         {
00167                 CRect rc;
00168                 GetClientRect( &rc );
00169                 m_pSkin->CalcWindowRect( &rc );
00170                 m_brDialog.CreateSolidBrush( Skin.m_crDialog );
00171                 SetWindowPos( NULL, 0, 0, rc.Width(), rc.Height(), SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED );
00172                 OnSize( 1982, 0, 0 );
00173         }
00174 
00175         if ( GetDlgItem( IDOK ) )
00176         {
00177                 CRect rc;
00178                 GetDlgItem( IDOK )->GetWindowRect( &rc );
00179                 ScreenToClient( &rc );
00180                 GetDlgItem( IDOK )->SetWindowPos( NULL, 6, rc.top, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE );
00181                 GetDlgItem( IDCANCEL )->SetWindowPos( NULL, 11 + rc.Width(), rc.top, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE );
00182         }
00183 
00184         if ( GetDlgItem( 0x3021 ) ) GetDlgItem( 0x3021 )->ShowWindow( SW_HIDE );
00185         if ( GetDlgItem( 0x0009 ) ) GetDlgItem( 0x0009 )->ShowWindow( SW_HIDE );
00186 
00187         return bResult;
00188 }
00189 
00191 // CFilePropertiesSheet skin support
00192 
00193 void CFilePropertiesSheet::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
00194 {
00195         if ( m_pSkin )
00196                 m_pSkin->OnNcCalcSize( this, bCalcValidRects, lpncsp );
00197         else
00198                 CPropertySheet::OnNcCalcSize( bCalcValidRects, lpncsp );
00199 }
00200 
00201 UINT CFilePropertiesSheet::OnNcHitTest(CPoint point)
00202 {
00203         if ( m_pSkin )
00204                 return m_pSkin->OnNcHitTest( this, point, ( GetStyle() & WS_THICKFRAME ) ? TRUE : FALSE );
00205         else
00206                 return CPropertySheet::OnNcHitTest( point );
00207 }
00208 
00209 BOOL CFilePropertiesSheet::OnNcActivate(BOOL bActive)
00210 {
00211         if ( m_pSkin )
00212         {
00213                 BOOL bVisible = IsWindowVisible();
00214                 if ( bVisible ) ModifyStyle( WS_VISIBLE, 0 );
00215                 BOOL bResult = CPropertySheet::OnNcActivate( bActive );
00216                 if ( bVisible ) ModifyStyle( 0, WS_VISIBLE );
00217                 m_pSkin->OnNcActivate( this, bActive || ( m_nFlags & WF_STAYACTIVE ) );
00218                 return bResult;
00219         }
00220         else
00221         {
00222                 return CPropertySheet::OnNcActivate( bActive );
00223         }
00224 }
00225 
00226 void CFilePropertiesSheet::OnNcPaint()
00227 {
00228         if ( m_pSkin )
00229                 m_pSkin->OnNcPaint( this );
00230         else
00231                 CPropertySheet::OnNcPaint();
00232 }
00233 
00234 void CFilePropertiesSheet::OnNcLButtonDown(UINT nHitTest, CPoint point)
00235 {
00236         if ( m_pSkin && m_pSkin->OnNcLButtonDown( this, nHitTest, point ) ) return;
00237         CPropertySheet::OnNcLButtonDown(nHitTest, point);
00238 }
00239 
00240 void CFilePropertiesSheet::OnNcLButtonUp(UINT nHitTest, CPoint point)
00241 {
00242         if ( m_pSkin && m_pSkin->OnNcLButtonUp( this, nHitTest, point ) ) return;
00243         CPropertySheet::OnNcLButtonUp( nHitTest, point );
00244 }
00245 
00246 void CFilePropertiesSheet::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
00247 {
00248         if ( m_pSkin && m_pSkin->OnNcLButtonDblClk( this, nHitTest, point ) ) return;
00249         CPropertySheet::OnNcLButtonDblClk( nHitTest, point );
00250 }
00251 
00252 void CFilePropertiesSheet::OnNcMouseMove(UINT nHitTest, CPoint point)
00253 {
00254         if ( m_pSkin ) m_pSkin->OnNcMouseMove( this, nHitTest, point );
00255         CPropertySheet::OnNcMouseMove( nHitTest, point );
00256 }
00257 
00258 void CFilePropertiesSheet::OnSize(UINT nType, int cx, int cy)
00259 {
00260         if ( m_pSkin ) m_pSkin->OnSize( this );
00261 
00262         if ( nType != 1982 ) CPropertySheet::OnSize( nType, cx, cy );
00263 }
00264 
00265 LONG CFilePropertiesSheet::OnSetText(WPARAM wParam, LPARAM lParam)
00266 {
00267         if ( m_pSkin )
00268         {
00269                 BOOL bVisible = IsWindowVisible();
00270                 if ( bVisible ) ModifyStyle( WS_VISIBLE, 0 );
00271                 LONG lResult = Default();
00272                 if ( bVisible ) ModifyStyle( 0, WS_VISIBLE );
00273                 if ( m_pSkin ) m_pSkin->OnSetText( this );
00274                 return lResult;
00275         }
00276         else
00277         {
00278                 return Default();
00279         }
00280 }
00281 
00282 BOOL CFilePropertiesSheet::OnEraseBkgnd(CDC* pDC)
00283 {
00284         if ( m_pSkin )
00285         {
00286                 if ( m_pSkin->OnEraseBkgnd( this, pDC ) ) return TRUE;
00287         }
00288 
00289         return CPropertySheet::OnEraseBkgnd( pDC );
00290 }
00291 
00292 HBRUSH CFilePropertiesSheet::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00293 {
00294         // if ( m_brDialog.m_hObject ) return m_brDialog;
00295         return CPropertySheet::OnCtlColor( pDC, pWnd, nCtlColor );
00296 }

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