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

CtrlLibraryView.cpp

Go to the documentation of this file.
00001 //
00002 // CtrlLibraryView.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 "Library.h"
00026 #include "AlbumFolder.h"
00027 #include "Schema.h"
00028 #include "ShellIcons.h"
00029 #include "Skin.h"
00030 #include "CtrlLibraryFrame.h"
00031 #include "CtrlLibraryView.h"
00032 #include "CtrlLibraryTree.h"
00033 
00034 #ifdef _DEBUG
00035 #define new DEBUG_NEW
00036 #undef THIS_FILE
00037 static char THIS_FILE[] = __FILE__;
00038 #endif
00039 
00040 IMPLEMENT_DYNAMIC(CLibraryView, CWnd)
00041 
00042 BEGIN_MESSAGE_MAP(CLibraryView, CWnd)
00043         //{{AFX_MSG_MAP(CLibraryView)
00044         ON_WM_SIZE()
00045         ON_WM_ERASEBKGND()
00046         //}}AFX_MSG_MAP
00047 END_MESSAGE_MAP()
00048 
00049 
00051 // CLibraryView construction
00052 
00053 CLibraryView::CLibraryView()
00054 {
00055         m_nCommandID    = ID_LIBRARY_VIEW;
00056         m_pszToolBar    = NULL;
00057         m_bAvailable    = FALSE;
00058 }
00059 
00060 CLibraryView::~CLibraryView()
00061 {
00062 }
00063 
00065 // CLibraryView operations
00066 
00067 BOOL CLibraryView::Create(CWnd* pParentWnd)
00068 {
00069         CRect rect;
00070         SelClear( FALSE );
00071         return CWnd::Create( NULL, NULL, WS_CHILD, rect, pParentWnd, IDC_LIBRARY_VIEW, NULL );
00072 }
00073 
00074 BOOL CLibraryView::CheckAvailable(CLibraryTreeItem* pSel)
00075 {
00076         return ( m_bAvailable = FALSE );
00077 }
00078 
00079 void CLibraryView::GetHeaderContent(int& nImage, CString& str)
00080 {
00081         CString strFormat;
00082         int nCount = 0;
00083 
00084         for ( CLibraryTreeItem* pItem = GetFolderSelection() ; pItem ;
00085                   pItem = pItem->m_pSelNext ) nCount++;
00086 
00087         if ( nCount == 1 )
00088         {
00089         CLibraryTreeItem* pItem = GetFolderSelection();
00090                 for ( ; pItem->m_pParent ;
00091                         pItem = pItem->m_pParent )
00092                 {
00093                         if ( str.GetLength() ) str = '\\' + str;
00094                         str = pItem->m_sText + str;
00095                 }
00096 
00097                 LoadString( strFormat, IDS_LIBHEAD_EXPLORE_FOLDER );
00098                 if ( theApp.m_bRTL ) 
00099                         str =  _T("\x202A") + str + _T(" \x200E") + strFormat;
00100                 else
00101                         str = strFormat + str;
00102 
00103                 nImage  = SHI_FOLDER_OPEN;
00104                 pItem   = GetFolderSelection();
00105 
00106                 if ( pItem->m_pVirtual && pItem->m_pVirtual->m_pSchema )
00107                         nImage = pItem->m_pVirtual->m_pSchema->m_nIcon16;
00108 
00109         }
00110         else if ( nCount > 1 )
00111         {
00112                 LoadString( strFormat, IDS_LIBHEAD_EXPLORE_MANY );
00113                 str.Format( strFormat, nCount );
00114                 nImage = SHI_FOLDER_OPEN;
00115         }
00116 }
00117 
00118 void CLibraryView::Update()
00119 {
00120 }
00121 
00122 BOOL CLibraryView::Select(DWORD nObject)
00123 {
00124         return FALSE;
00125 }
00126 
00127 void CLibraryView::CacheSelection()
00128 {
00129 }
00130 
00132 // CLibraryView helper operations
00133 
00134 void CLibraryView::PostUpdate()
00135 {
00136         GetOwner()->PostMessage( WM_COMMAND, ID_LIBRARY_REFRESH );
00137 }
00138 
00139 CLibraryFrame* CLibraryView::GetFrame() const
00140 {
00141         CLibraryFrame* pFrame = (CLibraryFrame*)GetOwner();
00142         ASSERT_KINDOF(CLibraryFrame, pFrame );
00143         return pFrame;
00144 }
00145 
00146 CLibraryTipCtrl* CLibraryView::GetToolTip() const
00147 {
00148         return &GetFrame()->m_wndViewTip;
00149 }
00150 
00151 DWORD CLibraryView::GetFolderCookie() const
00152 {
00153         return GetFrame()->m_nFolderCookie;
00154 }
00155 
00156 CLibraryTreeItem* CLibraryView::GetFolderSelection() const
00157 {
00158         return GetFrame()->m_pFolderSelection;
00159 }
00160 
00161 CAlbumFolder* CLibraryView::GetSelectedAlbum(CLibraryTreeItem* pSel) const
00162 {
00163         if ( pSel == NULL && m_hWnd != NULL ) pSel = GetFolderSelection();
00164         if ( pSel == NULL ) return NULL;
00165         if ( pSel->m_pSelNext != NULL ) return NULL;
00166         return pSel->m_pVirtual;
00167 }
00168 
00169 void CLibraryView::DragObjects(CImageList* pImage, const CPoint& ptMouse)
00170 {
00171         CLibraryFrame* pFrame   = (CLibraryFrame*)GetOwner();
00172         CLibraryList* pList             = new CLibraryList( GetSelectedCount() );
00173 
00174         for ( POSITION pos = m_pSelection.GetHeadPosition() ; pos ; )
00175                 pList->AddTail( m_pSelection.GetNext( pos ) );
00176 
00177         pFrame->DragObjects( pList, pImage, ptMouse );
00178 }
00179 
00181 // CLibraryView selection operations
00182 
00183 BOOL CLibraryView::SelAdd(DWORD nObject, BOOL bNotify)
00184 {
00185         if ( m_pSelection.Find( nObject ) ) return FALSE;
00186         m_pSelection.AddTail( nObject );
00187 
00188         if ( bNotify )
00189         {
00190                 CLibraryFrame* pFrame = (CLibraryFrame*)GetOwner();
00191                 pFrame->OnViewSelection();
00192         }
00193 
00194         return TRUE;
00195 }
00196 
00197 BOOL CLibraryView::SelRemove(DWORD nObject, BOOL bNotify)
00198 {
00199         POSITION pos = m_pSelection.Find( nObject );
00200         if ( pos == NULL ) return FALSE;
00201         m_pSelection.RemoveAt( pos );
00202 
00203         if ( bNotify )
00204         {
00205                 CLibraryFrame* pFrame = (CLibraryFrame*)GetOwner();
00206                 pFrame->OnViewSelection();
00207         }
00208 
00209         return TRUE;
00210 }
00211 
00212 BOOL CLibraryView::SelClear(BOOL bNotify)
00213 {
00214         if ( m_pSelection.GetCount() == 0 ) return FALSE;
00215         m_pSelection.RemoveAll();
00216 
00217         if ( bNotify )
00218         {
00219                 CLibraryFrame* pFrame = (CLibraryFrame*)GetOwner();
00220                 pFrame->OnViewSelection();
00221         }
00222 
00223         return TRUE;
00224 }
00225 
00226 int CLibraryView::GetSelectedCount() const
00227 {
00228         return m_pSelection.GetCount();
00229 }
00230 
00232 // CLibraryView message handlers
00233 

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