示例#1
0
文件: tree.cpp 项目: jetlive/skiaming
BOOL CTreeItem::Expand( HTREEITEM hitem )
{
	BOOL fExpand = FALSE ;

	switch(m_Type)
	{
	case typeUnknown:
	case typeUnknown2:
	break ;

	case typeTypeLib:
		fExpand = ExpandTypeLib( hitem );
	break ;

	case typeTypeLib2:
	{
		// CTypeLibWnd::m_fGroupByType == TRUE
		CTreeItem* pItem ;

		TV_INSERTSTRUCT tvis ;
		tvis.hParent = hitem ;
		tvis.hInsertAfter = TVI_LAST ;
		tvis.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE ;
		tvis.item.iImage = CTreeItem::typeUnknown ;
		tvis.item.iSelectedImage = tvis.item.iImage + 1 ;
		tvis.item.cChildren = 1 ;

		#pragma warning (suppress: 6211) // Not Leaking. pItem is inserted into m_pTree
		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeEnums ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Enums") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeRecords ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Structs") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeModules ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Modules") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeInterfaces ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Interfaces") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeDispinterfaces ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Dispinterfaces") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeCoClasses ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("CoClasses") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeAliases ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Typedefs") ;
		m_pTree->InsertItem(&tvis) ;

		pItem = new CTreeItem(m_pTree) ;
		pItem->SetTypeLib( GetTypeLib() ) ;
		GetTypeLib()->AddRef() ;
		pItem->m_Type = CTreeItem::typeUnions ;
		tvis.item.lParam = (LPARAM)pItem ;
		tvis.item.pszText = _T("Unions") ;
		m_pTree->InsertItem(&tvis) ;

		fExpand = TRUE ;
	}
	break ;

	case typeEnums:
	case typeRecords:
	case typeModules:
	case typeInterfaces:
	case typeDispinterfaces:
	case typeCoClasses:
	case typeAliases:
	case typeUnions:
		fExpand = ExpandTypeLib( hitem ) ;
	break ;

	case typeTypeInfo:
	case typeTypeInfo2:
	case typeEnum:
	case typeRecord:
	case typeModule:
	case typeInterface:
	case typeDispinterface:
	case typeCoClass:
	case typeAlias:
	case typeUnion:
		fExpand = ExpandTypeInfo( hitem ) ;
	break ;

	case typeMethods:
	case typeMethods2:
		fExpand = ExpandFuncs( hitem ) ;
	break ;

	case typeProperties:
	case typeProperties2:
	case typeConstants:
	case typeConstants2:
		fExpand = ExpandVars( hitem ) ;
	break ;

	case typeImplTypes:
	case typeImplTypes2:
		fExpand = ExpandImplTypes( hitem ) ;
	break ;

	case typeMethod:
	case typeProperty:
	case typeConstant:
	default:
	break ;
	}

	return fExpand ;
}
示例#2
0
void CTypeLibTreeView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
	if (lHint != NULL || (lHint & UPDF_NOTREEVIEW))
		return ;

	TRACE(_T("OnUpdate\n")) ;
	m_tree.SetRedraw( FALSE ) ;
	BeginWaitCursor() ;

	m_tree.DeleteAllItems() ;
	m_hTypeInfos = NULL ;

	TV_INSERTSTRUCT tvis ;
	tvis.hParent = TVI_ROOT ;
	tvis.hInsertAfter = TVI_FIRST ;
	tvis.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE ;
	tvis.item.iImage = CTreeItem::typeTypeLib ;
	tvis.item.iSelectedImage = tvis.item.iImage + 1 ;

	HRESULT hr = S_OK ;
	CString strError ;
	TRY
	{
		CTypeLibWnd* pFrame = (CTypeLibWnd*)GetParent()->GetParent() ;
		if (pFrame == NULL)
		{
			strError = _T("Internal Application error.");
			AfxThrowMemoryException() ;
		}

		if (pFrame->m_fGroupByKind)
		{
			tvis.item.cChildren = 1 ;
		}
		else
		{
			tvis.item.cChildren = m_ptlb->GetTypeInfoCount() ;
		}

		BSTR    bstrName = NULL ;
		BSTR    bstrDoc = NULL ;
		BSTR    bstrHelp = NULL ;
		DWORD   dwHelpID ;
		hr = m_ptlb->GetDocumentation( MEMBERID_NIL, &bstrName, &bstrDoc, &dwHelpID, &bstrHelp ) ;
		if (FAILED(hr))
		{
			strError = _T("ITypeLib::GetDocumentation failed.") ;
			AfxThrowMemoryException() ;
		}

		#pragma warning (suppress: 6014)
		CTreeItem* pItem = new CTreeItem(&m_tree) ;
		if (pFrame->m_fGroupByKind)
			pItem->m_Type = CTreeItem::typeTypeLib2 ;
		else
			pItem->m_Type = CTreeItem::typeTypeLib ;
		pItem->SetTypeLib( m_ptlb ) ;
		m_ptlb->AddRef() ;
		tvis.item.lParam = (LPARAM)pItem ;

		COLE2CT lpszName(bstrName);
		if (::SysStringLen(bstrDoc) != 0)
		{
			COLE2CT lpszDoc(bstrDoc);
			CString str;
			str.Format( _T("%s (%s)"), lpszName, lpszDoc);
			tvis.item.pszText = str.GetBuffer(0);
			m_hTypeInfos = m_tree.InsertItem( &tvis ) ;
			str.ReleaseBuffer(-1) ;
		}
		else
		{
			tvis.item.pszText = (LPTSTR)lpszName;
			m_hTypeInfos = m_tree.InsertItem( &tvis ) ;
		}

		::SysFreeString( bstrName ) ;
		::SysFreeString( bstrDoc ) ;
		::SysFreeString( bstrHelp ) ;
	}
	CATCH(CException, pException)
	{
	}
	END_CATCH

	if (m_hTypeInfos)
	{
		m_tree.Expand( m_hTypeInfos, TVE_EXPAND ) ;
		//m_tree.SelectItem( m_hTypeInfos ) ;
	}

	m_tree.SetRedraw( TRUE ) ;
	EndWaitCursor() ;
}