//************************************ // 函数名称: SetItemExpand // 返回类型: void // 参数信息: bool _Expanded // 参数信息: CTreeNodeUI * _TreeNode // 函数说明: //************************************ void CTreeViewUI::SetItemExpand( bool _Expanded,CTreeNodeUI* _TreeNode /*= NULL*/ ) { if(_TreeNode) { if(_TreeNode->GetCountChild() > 0) { int nCount = _TreeNode->GetCountChild(); for(int nIndex = 0;nIndex < nCount;nIndex++) { CTreeNodeUI* pItem = _TreeNode->GetChildNode(nIndex); pItem->SetVisible(_Expanded); if(pItem->GetCountChild() && !pItem->GetFolderButton()->IsSelected()) SetItemExpand(_Expanded,pItem); } } } else { int nIndex = 0; int nCount = GetCount(); while(nIndex < nCount) { CTreeNodeUI* pItem = (CTreeNodeUI*)GetItemAt(nIndex); pItem->SetVisible(_Expanded); if(pItem->GetCountChild() && !pItem->GetFolderButton()->IsSelected()) SetItemExpand(_Expanded,pItem); nIndex++; } } }
//************************************ // 函数名称: SetVisibleFolderBtn // 返回类型: void // 参数信息: bool _IsVisibled // 函数说明: //************************************ void CTreeViewUI::SetVisibleFolderBtn( bool _IsVisibled ) { m_bVisibleFolderBtn = _IsVisibled; int nCount = this->GetCount(); for(int nIndex = 0; nIndex < nCount; nIndex++) { CTreeNodeUI* pItem = static_cast<CTreeNodeUI*>(this->GetItemAt(nIndex)); pItem->GetFolderButton()->SetVisible(m_bVisibleFolderBtn); } }
//************************************ // 函数名称: OnDBClickItem // 返回类型: bool // 参数信息: void * param // 函数说明: //************************************ bool CTreeViewUI::OnDBClickItem( void* param ) { TNotifyUI* pMsg = (TNotifyUI*)param; if(_tcsicmp(pMsg->sType, DUI_MSGTYPE_TREEITEMDBCLICK) == 0) { CTreeNodeUI* pItem = static_cast<CTreeNodeUI*>(pMsg->pSender); CCheckBoxUI* pFolder = pItem->GetFolderButton(); pFolder->Selected(!pFolder->IsSelected()); pItem->SetVisibleTag(!pFolder->GetCheck()); SetItemExpand(!pFolder->GetCheck(),pItem); return TRUE; } return FALSE; }
//************************************ // 函数名称: OnDBClickItem // 返回类型: bool // 参数信息: void * param // 函数说明: //************************************ bool CTreeViewUI::OnDBClickItem( void* param ) { TNotifyUI* pMsg = (TNotifyUI*)param; if(pMsg->sType == _T("itemdbclick")) { CTreeNodeUI* pItem = static_cast<CTreeNodeUI*>(pMsg->pSender); CCheckBoxUI* pFolder = pItem->GetFolderButton(); pFolder->Selected(!pFolder->IsSelected()); pItem->SetVisibleTag(!pFolder->GetCheck()); SetItemExpand(!pFolder->GetCheck(),pItem); return true; } return false; }
CTreeNodeUI * CWndMoveOrPasteTo::CreateTreeNode( CFileHandle *pFileHandle ) { CTreeNodeUI *pRetNode = new CTreeNodeUI; pRetNode->SetItemText(pFileHandle->GetFileName().c_str()); pRetNode->SetAttribute(_T("endellipsis"), _T("true")); pRetNode->GetTreeNodeHoriznotal()->SetToolTip(pFileHandle->GetFileName().c_str()); pRetNode->GetItemButton()->SetFont(6); pRetNode->SetFixedHeight(20); pRetNode->SetTag((UINT_PTR)pFileHandle); pRetNode->SetAttribute(_T("itemattr"), _T("textpadding=\"2,0,0,0\" textcolor=\"#FF000000\"")); pRetNode->SetAttribute(_T("checkboxattr"), _T("width=\"20\" height=\"20\" enabled=\"false\" bkimage=\"file='dir_icon_small' dest='4,2,20,18'\"")); pRetNode->SetAttribute(_T("folderattr"), _T("padding=\"0,5,0,5\" width=\"7\" height=\"1\"")); pRetNode->GetFolderButton()->SetVisible(false); return pRetNode; }