Exemple #1
0
BOOL duTreeListCtrl::DeleteItem(TreeListItem *pItem)
{
	if (pItem == TCVIL_ROOT || pItem == NULL)
		pItem = &m_RootItem;

	if (pItem != &m_RootItem)
	{
		TreeListItem *pPreItem = NULL;
		TreeListItem *pParent = pItem->pParent;
		pPreItem = pParent->pFirstChild;
		for (; pPreItem->pNextSibling; pPreItem = pPreItem->pNextSibling)
			if (pPreItem->pNextSibling == pItem)
				break;

		if (pParent->pFirstChild == pItem)
			pParent->pFirstChild = pItem->pNextSibling;
		else
			pPreItem->pNextSibling = pItem->pNextSibling;

		DeleteItemT(pItem);
	}
	else
	{
		DeleteItemT(pItem);
		m_RootItem.pFirstChild = NULL;
	}

	UpdateScroll();
	CompleteAdjustLine();
	return TRUE;
}
Exemple #2
0
BOOL WINAPI duListCtrl::DeleteLine(int nIndex, BOOL fAdjust)
{
	int nLineCount = GetLineCount();
	if (nIndex < 0 || nIndex >= nLineCount)
		return FALSE;

	duPlugin *pDelete = m_vtLines[nIndex];
	if (pDelete == NULL)
		return FALSE;

	duRect rcDelete;
	pDelete->GetRect(&rcDelete);

	if (nIndex < m_nFirstLine)
		m_nFLTotalHeight -= rcDelete.Height();

	m_nViewCy -= rcDelete.Height();
	
	vector<duPlugin *>::iterator iterDelete = m_vtLines.begin() + nIndex;
	m_vtLines.erase(iterDelete);
	UpdateScroll();

	if (pDelete == m_pSel)
		m_pSel = NULL;

	if (pDelete == m_pHot)
		m_pHot = NULL;
	
	Plugin_Delete(pDelete);
	CompleteAdjustLine();

	return TRUE;
}
Exemple #3
0
void duTreeListCtrl::ExpandItem(TreeListItem *pItem, BOOL fExpand)
{
	if (pItem == NULL || pItem == &m_RootItem)
		return;

	if (pItem->fExpand == fExpand || pItem->pFirstChild == NULL)
		return;
		
	duPlugin *pNextSibling = NULL;
	if (pItem->pNextSibling)
		pNextSibling = pItem->pNextSibling->pPlugin;
	
	if (!fExpand)
	{
		pItem->fExpand = FALSE;
		
		vector<int> vtRemoveIndex;
		vtRemoveIndex.clear();

		//////////////////////////////////////////////////////////////////////////////////////
		// TreeListItem
		// bug: nIndex return -1
		// 
		// 
		// 
		// 
		//////////////////////////////////////////////////////////////////////////////////////
		
		int i;
		int nIndex = GetTreeItemIndex(pItem);
		for (i = nIndex + 1;i < GetLineCount(); i++)
		{
			duPlugin *pTemp = m_vtLines[i];
			if (pTemp == pNextSibling)
				break;
		
			duRect rcTemp;
			pTemp->GetRect(&rcTemp);
			pTemp->SetVisible(FALSE);

			m_nViewCy -= rcTemp.Height();
			vtRemoveIndex.push_back(i);
		}

		m_vtLines.erase(m_vtLines.begin() + nIndex + 1, m_vtLines.begin() + i);
		UpdateScroll();
		CompleteAdjustLine();
	}
	else
	{
		pItem->fExpand = TRUE;
		
		vector<duPlugin *> vtInsert;
		vtInsert.clear();
		int nIndex = GetInsertItem(pItem, vtInsert);
		
		int i;
		int nInsertCount = vtInsert.size();
		for (i = 0;i < nInsertCount; i++)
		{
			duPlugin *pTemp = vtInsert[i];
			
			duRect rcTemp;
			pTemp->GetRect(&rcTemp);
			
			m_nViewCy += rcTemp.Height();
			m_vtLines.insert(m_vtLines.begin() + nIndex + i + 1, pTemp);
		}
		
		UpdateScroll();
		CompleteAdjustLine();
	}
	
	duPlugin *pFirstCol = pItem->pPlugin->GetFirstChild();
	if (pFirstCol && lstrcmpi(pFirstCol->GetType(), _T("treelistitem")) == 0)
	{
		duTreeListItem *pTreeListItem = (duTreeListItem *)pFirstCol;
		pTreeListItem->SetExpand(fExpand);
	}

	Plugin_Redraw(this, TRUE);
}