📄 dirsplitter.cpp
字号:
//////////////////////////////////////////////////////////////////////
// FileFury
// Copyright (c) 2000 Tenebril Incorporated
// All rights reserved.
//
// This source code is governed by the Tenebril open source
// license (http://www.tenebril.com/developers/opensource/license.html)
//
// For more information on this and other open source applications,
// visit the Tenebril OpenSource page:
// http://www.tenebril.com/developers/opensource
//
//////////////////////////////////////////////////////////////////////
// DirSplitter.cpp : implementation file
//
#include "stdafx.h"
#include "Oscar.h"
#include "DirSplitter.h"
#include "DirListView.h"
#include "DirTreeView.h"
#include "NetworkFileSystem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDirSplitter
// IMPLEMENT_DYNCREATE(CDirSplitter, CSplitterWnd)
CDirSplitter::CDirSplitter()
{
m_bHasInit = false;
m_bHasPanes = FALSE;
m_pFileSystem = NULL;
}
CDirSplitter::~CDirSplitter()
{
if(m_pFileSystem)
delete m_pFileSystem;
}
BEGIN_MESSAGE_MAP(CDirSplitter, CSplitterWnd)
//{{AFX_MSG_MAP(CDirSplitter)
ON_WM_CREATE()
ON_WM_MOUSEWHEEL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDirSplitter message handlers
afx_msg int CDirSplitter::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
int iRet = CSplitterWnd::OnCreate(lpCreateStruct);
return iRet;
}
BOOL CDirSplitter::OnMouseWheel(UINT fFlags, short zDelta, CPoint point)
{
BOOL bRetVal = FALSE;
int row;
int col;
CScrollBar* pBar;
CWnd* pPane;
CScrollView* pView;
int nOldPos;
for (row = 0; row < m_nRows; row++)
{
for (col = 0; col < m_nCols; col++)
{
pPane = GetPane(row, col);
// This used to check; we don't want this, it's too restrictive
// pView = STATIC_DOWNCAST(CScrollView, pPane);
pView = (CScrollView *)pPane;
if (pView != NULL)
{
pBar = pView->GetScrollBarCtrl(SB_VERT);
if (pBar == NULL)
{
pBar = pView->GetScrollBarCtrl(SB_HORZ);
if (pBar == NULL)
continue;
}
nOldPos = pBar->GetScrollPos();
if (pView->DoMouseWheel(fFlags, zDelta, point))
{
bRetVal = TRUE;
}
if (col < m_nCols -1)
pBar->SetScrollPos(nOldPos, FALSE);
}
}
}
return TRUE;
}
void CDirSplitter::SetupPanes(int nSysType, LPCTSTR cszTargetMachine,
CCreateContext* pContext)
{
CRect rectClient;
CWnd *pParentWnd = GetParent();
// We don't have a defined client area yet
ASSERT(pParentWnd);
pParentWnd->GetClientRect(&rectClient);
switch(nSysType)
{
case 0: default:
m_pFileSystem = new CFileSystem;
break;
case 1:
m_pFileSystem = new CNetworkFileSystem(cszTargetMachine);
break;
}
// Get the zeroth column width.
COscarApp *pApp = (COscarApp *)AfxGetApp();
ASSERT(pApp);
CSettingsArchive *pArchive = pApp->GetArchive();
ASSERT(pArchive);
int nZeroColumnWidth = pArchive->m_arch1.nExplorerWidth;
if(nZeroColumnWidth < 30) nZeroColumnWidth = 30;
SetRowInfo(0, rectClient.Height(), 10);
SetColumnInfo(0, nZeroColumnWidth, 10);
SetColumnInfo(1, rectClient.Width() - nZeroColumnWidth, 10);
// Setup the splitter's panes
if(!CreateView(0, 0, RUNTIME_CLASS(CDirTreeView),
CSize(nZeroColumnWidth, rectClient.Height()),
pContext))
{
TRACE0("Failed to create view 0\n");
return;
}
if(!CreateView(0, 1, RUNTIME_CLASS(CDirListView),
CSize(rectClient.Width() - nZeroColumnWidth, rectClient.Height()),
pContext))
{
TRACE0("Failed to create view 1\n");
return;
}
m_bHasInit = true;
m_bHasPanes = true;
m_strDirectory = CString(_T("C:\\"));
// Initialize the tree view
CDirTreeView *TreeView = (CDirTreeView *)GetPane(0, 0);
if(!TreeView)
{
TRACE0("Failed to get view 0\n");
return;
}
TreeView->AllowReload(TRUE);
TreeView->DisplayTree(NULL);
// Initialize the list view
CDirListView *ListView = (CDirListView *)GetPane(0, 1);
if(!ListView)
{
TRACE0("Failed to get view 1\n");
return;
}
ListView->DisplayList("C:\\");
ListView->AllowReload(TRUE); // The view type set will handle it.
return;
}
void CDirSplitter::SetDirectory(LPCTSTR strDirectory, BOOL bForceUpdate)
{
CDirListView *pListView;
CDirTreeView *pTreeView;
CString cszDirectory = strDirectory;
// Show the wait cursor.
CWaitCursor waitCursor;
// Check to see if the string length is zero.
CString strLenCheck = strDirectory;
if(strLenCheck.GetLength() == 0)
{
ASSERT(0);
return;
}
m_strDirectory = strDirectory;
pListView = (CDirListView *)GetPane(0, 1);
pTreeView = (CDirTreeView *)GetPane(0, 0);
if(!pListView || !pTreeView)
return;
// Make sure we have a directory name; not just a colon ending it.
if(cszDirectory.GetAt(cszDirectory.GetLength() - 1) != _T('\\'))
cszDirectory += _T('\\');
// We need to massage our input, which might be in the 8.3 character
// format (which is unsupported by some of our functions)
CString stClearPath = m_pFileSystem->GetFullPathName(cszDirectory);
pTreeView->SetSelPath(stClearPath);
pListView->DisplayList(stClearPath, bForceUpdate);
return;
}
void CDirSplitter::UpdateListDir(LPCTSTR strDirectory)
{
CDirListView *pListView;
pListView = (CDirListView *)GetPane(0, 1);
if(!pListView)
return;
// No redundant updates
if(m_strDirectory == CString(strDirectory))
return;
m_strDirectory = strDirectory;
pListView->DisplayList(strDirectory);
return;
}
void CDirSplitter::Refresh(BOOL bRefreshTree)
{
SetDirectory(m_strDirectory, TRUE);
if(bRefreshTree)
{
CDirTreeView *pTreeView = (CDirTreeView *)GetPane(0, 0);
if(!pTreeView)
return;
pTreeView->DisplayTree(NULL);
pTreeView->SetSelPath(m_strDirectory);
}
}
void CDirSplitter::GetColumnInfo(int col, int & cxCur, int & czMin)
{
if(m_bHasPanes)
{
CSplitterWnd::GetColumnInfo(col, cxCur, czMin);
return;
}
cxCur = -1;
czMin = -1;
}
CWnd *CDirSplitter::GetPane(int row, int col)
{
if(m_bHasPanes)
return CSplitterWnd::GetPane(row, col);
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -