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

WndMedia.cpp

Go to the documentation of this file.
00001 //
00002 // WndMedia.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 "ImageServices.h"
00026 #include "Skin.h"
00027 #include "WndMedia.h"
00028 
00029 #ifdef _DEBUG
00030 #define new DEBUG_NEW
00031 #undef THIS_FILE
00032 static char THIS_FILE[] = __FILE__;
00033 #endif
00034 
00035 IMPLEMENT_SERIAL(CMediaWnd, CPanelWnd, 1)
00036 
00037 BEGIN_MESSAGE_MAP(CMediaWnd, CPanelWnd)
00038         //{{AFX_MSG_MAP(CMediaWnd)
00039         ON_WM_CREATE()
00040         ON_WM_DESTROY()
00041         ON_WM_SIZE()
00042         ON_WM_PAINT()
00043         ON_WM_NCLBUTTONUP()
00044         ON_WM_SETCURSOR()
00045         ON_WM_SYSCOMMAND()
00046         ON_WM_NCACTIVATE()
00047         //}}AFX_MSG_MAP
00048         ON_MESSAGE(WM_IDLEUPDATECMDUI, OnIdleUpdateCmdUI)
00049         ON_MESSAGE(0x0319, OnMediaKey)
00050         ON_MESSAGE(WM_DEVMODECHANGE, OnDevModeChange)
00051         ON_MESSAGE(WM_DISPLAYCHANGE, OnDisplayChange)
00052         ON_WM_DROPFILES()
00053 END_MESSAGE_MAP()
00054 
00055 
00057 // CMediaWnd construction
00058 
00059 CMediaWnd::CMediaWnd() : CPanelWnd( TRUE, FALSE )
00060 {
00061         m_bPanelClose = TRUE;
00062         Create( IDR_MEDIAFRAME );
00063 }
00064 
00065 CMediaWnd::~CMediaWnd()
00066 {
00067 }
00068 
00070 // CMediaWnd operations
00071 
00072 BOOL CMediaWnd::PlayFile(LPCTSTR pszFile)
00073 {
00074         return m_wndFrame.PlayFile( pszFile );
00075 }
00076 
00077 BOOL CMediaWnd::EnqueueFile(LPCTSTR pszFile)
00078 {
00079         return m_wndFrame.EnqueueFile( pszFile );
00080 }
00081 
00082 BOOL CMediaWnd::IsPlaying()
00083 {
00084         return m_wndFrame.IsPlaying();
00085 }
00086 
00087 void CMediaWnd::OnFileDelete(LPCTSTR pszFile)
00088 {
00089         m_wndFrame.OnFileDelete( pszFile );
00090 }
00091 
00093 // CMediaWnd message handlers
00094 
00095 int CMediaWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
00096 {
00097         if ( CPanelWnd::OnCreate( lpCreateStruct ) == -1 ) return -1;
00098 
00099         m_wndFrame.Create( this );
00100         LoadState();
00101 
00102         DragAcceptFiles();
00103 
00104         return 0;
00105 }
00106 
00107 void CMediaWnd::OnDestroy()
00108 {
00109         SaveState();
00110         CPanelWnd::OnDestroy();
00111 }
00112 
00113 void CMediaWnd::OnSkinChange()
00114 {
00115         CPanelWnd::OnSkinChange();
00116         m_wndFrame.OnSkinChange();
00117 }
00118 
00119 BOOL CMediaWnd::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
00120 {
00121         if ( m_wndFrame.m_hWnd != NULL )
00122         {
00123                 if ( m_wndFrame.OnCmdMsg( nID, nCode, pExtra, pHandlerInfo ) ) return TRUE;
00124         }
00125 
00126         return CPanelWnd::OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
00127 }
00128 
00129 LONG CMediaWnd::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM lParam)
00130 {
00131         if ( m_wndFrame.m_hWnd != NULL && m_wndFrame.GetParent() != this )
00132         {
00133                 m_wndFrame.OnUpdateCmdUI();
00134         }
00135 
00136         CPanelWnd::OnIdleUpdateCmdUI();
00137 
00138         return 0;
00139 }
00140 
00141 BOOL CMediaWnd::PreTranslateMessage(MSG* pMsg)
00142 {
00143         if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN )
00144         {
00145                 if ( m_wndFrame.m_hWnd && m_wndFrame.PreTranslateMessage( pMsg ) ) return TRUE;
00146         }
00147 
00148         return CPanelWnd::PreTranslateMessage(pMsg);
00149 }
00150 
00151 void CMediaWnd::OnSysCommand(UINT nID, LPARAM lParam)
00152 {
00153         if ( ( nID & 0xFFF0 ) == SC_CLOSE )
00154         {
00155                 PostMessage( WM_CLOSE );
00156                 return;
00157         }
00158 
00159         CPanelWnd::OnSysCommand( nID, lParam );
00160 }
00161 
00162 void CMediaWnd::OnSize(UINT nType, int cx, int cy)
00163 {
00164         CPanelWnd::OnSize( nType, cx, cy );
00165 
00166         if ( m_wndFrame.m_hWnd != NULL && m_wndFrame.GetParent() == this )
00167         {
00168                 m_wndFrame.SetWindowPos( NULL, 0, 0, cx, cy, SWP_NOZORDER );
00169         }
00170 }
00171 
00172 void CMediaWnd::OnPaint()
00173 {
00174         CPaintDC dc( this );
00175 
00176         if ( m_wndFrame.m_hWnd == NULL || m_wndFrame.GetParent() != this )
00177         {
00178                 CRect rc;
00179                 GetClientRect( &rc );
00180                 dc.FillSolidRect( &rc, 0 );
00181         }
00182 }
00183 
00184 LONG CMediaWnd::OnMediaKey(WPARAM wParam, LPARAM lParam)
00185 {
00186         return m_wndFrame.SendMessage( 0x0319, wParam, lParam );
00187 }
00188 
00189 LONG CMediaWnd::OnDevModeChange(WPARAM wParam, LPARAM lParam)
00190 {
00191         return m_wndFrame.SendMessage( WM_DEVMODECHANGE, wParam, lParam );
00192 }
00193 
00194 LONG CMediaWnd::OnDisplayChange(WPARAM wParam, LPARAM lParam)
00195 {
00196         return m_wndFrame.SendMessage( WM_DISPLAYCHANGE, wParam, lParam );
00197 }
00198 
00199 BOOL CMediaWnd::OnDropFiles(CStringList& pFiles, const CPoint& ptScreen, BOOL bDrop)
00200 {
00201         if ( bDrop == FALSE ) return TRUE;
00202 
00203         CPoint pt( ptScreen );
00204 
00205         m_wndFrame.ScreenToClient( &pt );
00206         CWnd* pDropped = m_wndFrame.ChildWindowFromPoint( pt );
00207 
00208         BOOL bEnqueue;
00209         if ( pDropped != NULL )
00210                 bEnqueue = ( pDropped->IsKindOf( RUNTIME_CLASS(CMediaListCtrl) ) );
00211         else
00212                 bEnqueue = FALSE;
00213 
00214         for ( POSITION pos = pFiles.GetHeadPosition() ; pos ; )
00215         {
00216                 CString strFile = pFiles.GetNext( pos );
00217 
00218                 if ( bEnqueue )
00219                         EnqueueFile( strFile );
00220                 else
00221                         PlayFile( strFile );
00222         }
00223 
00224         return TRUE;
00225 }
00226 
00227 void CMediaWnd::OnDropFiles(HDROP hDropInfo)
00228 {
00229         if ( hDropInfo != NULL )
00230         {
00231                 CStringList oFileList;
00232                 TCHAR szFileName[MAX_PATH + 1];
00233                 UINT nFiles = DragQueryFile( hDropInfo, (UINT)-1, NULL, 0 );
00234                 for( UINT nNames = 0; nNames < nFiles; nNames++ )
00235                 {
00236                         ZeroMemory( szFileName, MAX_PATH + 1 );
00237                         DragQueryFile( hDropInfo, nNames, (LPTSTR)szFileName, MAX_PATH + 1 );
00238                 oFileList.AddTail( szFileName ); 
00239                 }
00240                 CPoint oPoint;
00241                 POINT pt;
00242                 DragQueryPoint( hDropInfo, &pt );
00243                 oPoint.SetPoint( pt.x, pt.y );
00244 
00245                 OnDropFiles( oFileList, oPoint, TRUE );
00246         }
00247 }
00248 
00249 BOOL CMediaWnd::OnNcActivate(BOOL bActive)
00250 {
00251         m_wndFrame.UpdateScreenSaverStatus( bActive );
00252 
00253         return CPanelWnd::OnNcActivate(bActive);
00254 }

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