Example #1
0
void WLTreeItemAL::OnNotifyChildItemHeightChanged(LPNMWLHDR pNMWLHDR, LRESULT * pResult) 
{
	LPNMTIHEIGHTINFO pHeightChangedInfo = (LPNMTIHEIGHTINFO)pNMWLHDR ;
	*pResult = 1 ;

	if (pHeightChangedInfo->lOldHeight == pHeightChangedInfo->lNewHeight)
		return ;

	// 目前的树节点只关心高度变化
	// 记录旧高度
	long lOldHeight = m_szClient.cy ;

	// 获得高度变化
	long lOffset = pHeightChangedInfo->lNewHeight - pHeightChangedInfo->lOldHeight ;

	// 移动后面的孩子
	// 这个函数比较低效
	OffsetChildItemsY(pHeightChangedInfo->hItem->GetNextSibling(), NULL, lOffset) ;

	if (IsExpand())
	{
		SetWndLessPos(
			0, 0, 0, lOffset,
			SWLP_CY | SWLP_CY_OFFSET
			) ;

		// 如果是显示的,则通知父窗体变高
		if (IsVisible())
		{
			long lNewHeight = m_szClient.cy ;
			NotifyParentHeightChanged(lOldHeight, lNewHeight, pHeightChangedInfo->bNoScroll) ;
		}
	}
}
Example #2
0
BOOL		CDUITreeNode::SetExpand(BOOL bExpand)
{
	//DUI_ASSERT(HaveChild());

	BOOL bOld = IsExpand();
	if ( bOld != bExpand )
	{
		m_bExpand = bExpand;

		INT nCount = GetControlCount();
		for ( int i=0;i<nCount;i++)
		{
			HDUITREEITEM pItem = GetChild(i);
			if ( pItem )
			{
				if ( bExpand )
					pItem->ModifyStyle(0, CONTROL_STYLE_VISIBLE);
				else
					pItem->ModifyStyle(CONTROL_STYLE_VISIBLE,0);
			}
		}
	}

	return bOld;
}
Example #3
0
void WLTreeItemAL::CustomOnDrawChild(HDC hDC, RECT const &rcUpdate, RECT const &rcViewInThis) 
{
	CRect rcInHost ;
	GetRectInHost(rcInHost) ;

	if (IsExpand())
	{
		WLTreeItemAL* hChild = GetFirstVisibleChild(rcViewInThis.top) ;

		for ( ; hChild != NULL ; hChild = (WLTreeItemAL*)hChild->GetNextSibling())
		{
			if (!hChild->IsVisible() || !hChild->IsWndLessVisible())
				continue ;

			CRect rcChild ;
			hChild->GetRectInParent(rcChild) ;

			if (rcChild.bottom + rcInHost.top > rcUpdate.top)
			{
				if (rcChild.top >= rcViewInThis.bottom || rcChild.top + rcInHost.top > rcUpdate.bottom)
					break ;

				CRect rcViewInChild(rcViewInThis) ;
				rcViewInChild.OffsetRect(0, -rcChild.top) ;

				hChild->_CustomInternalDraw(hDC, rcUpdate, rcViewInChild) ;
			}
		}
	}
}
Example #4
0
VOID CDUITreeNode::SetControlRect(const RECT& rt)
{
	m_rtControl = rt;

	if ( HaveChild() && IsExpand() && IsVisible() )
	{
		
	}
}
Example #5
0
// 插入孩子
BOOL WLTreeItemAL::InsertChild(HWLTREEITEM hItem, HWLTREEITEM hInsertAfter) 
{
	if (!__super::InsertChild(hItem, hInsertAfter))
		return FALSE ;

	int nY = m_nItemHeight ;
	HWLTREEITEM hPrevSibling = hItem->GetPrevSibling() ;
	while (hPrevSibling != NULL)
	{
		if (hPrevSibling->IsVisible())
		{
			CRect rc ;
			hPrevSibling->GetRectInParent(rc) ;
			nY = rc.bottom ;
			break ;
		}
		hPrevSibling = hPrevSibling->GetPrevSibling() ;
	}

	hItem->SetWndLessPos(0, nY, m_szClient.cx, 0, SWLP_Y | SWLP_CX | SWLP_NOREDRAW) ;

	// 如果节点不显示,不影响其他兄弟节点和父节点
	if (!hItem->IsVisible())
		return TRUE ;

	// 后面的孩子往下移动
	CRect rcItem ;
	hItem->GetRectInParent(rcItem) ;
	OffsetChildItemsY(hItem->GetNextSibling(), NULL, rcItem.Height()) ;

	// 如果是展开的,则调整高度
	if (IsExpand())
	{
		// 记录旧高度
		long lOldHeight = m_szClient.cy ;

		// 自己变高
		SetWndLessPos(0, 0, 0, rcItem.Height(), SWLP_CY | SWLP_CY_OFFSET) ;

		// 通知父窗体变高
		long lNewHeight = m_szClient.cy ;
		NotifyParentHeightChanged(lOldHeight, lNewHeight, FALSE) ;
	}

	return TRUE ;
}
Example #6
0
void WLTreeItemAL::DeleteAllChild() 
{
	__super::DeleteAllChild() ;

	if (IsExpand())
	{
		// 记录旧高度
		long lOldHeight = m_szClient.cy ;

		// 自己变矮
		SetWndLessPos(0, 0, 0, m_nItemHeight, SWLP_CY) ;

		// 通知父窗体变矮
		long lNewHeight = m_szClient.cy ;
		NotifyParentHeightChanged(lOldHeight, lNewHeight, FALSE) ;
	}
}
Example #7
0
//include itself
INT			CDUITreeNode::GetTotalHeight()
{
	if ( !IsVisible() )
		return 0;

	int nTotalHeight = GetFixedSize().cy;

	if (  IsExpand() && HaveChild()  )
	{
		INT nCount = m_arChildControl.size();
		for ( int i=0;i<nCount;i++)
		{
			HDUITREEITEM	hChild = (HDUITREEITEM)m_arChildControl[i]->GetInterface(ITreeViewItemName);
			if ( hChild )
				nTotalHeight += hChild->GetTotalHeight();
		}
	}

	return 	 nTotalHeight;
}
Example #8
0
// 计算分支高度(包括节点高度)
int WLTreeItemAL::CalcBranchHeight() 
{
	if (!IsVisible())
		return 0 ;

	int nRes = m_nItemHeight ;

	if (IsExpand())
	{
		WLTreeItemAL* hChild = (WLTreeItemAL*)m_hFirstChild ;
		while (hChild != NULL)
		{
			nRes += hChild->CalcBranchHeight() ;

			hChild = (WLTreeItemAL*)(hChild->m_hNextSibling) ;
		}
	}

	return nRes ;
}
Example #9
0
// 删除孩子
BOOL WLTreeItemAL::DeleteChild(HWLTREEITEM hChild) 
{
	if (hChild == NULL)
		return FALSE ;

	CRect rcChild ;
	hChild->GetRectInParent(rcChild) ;
	HWLTREEITEM hNextChild = hChild->GetNextSibling() ;

	// 记录旧高度
	long lOldHeight = m_szClient.cy ;

	BOOL bIsChildShow = hChild->IsVisible() ;

	if (!__super::DeleteChild(hChild))
		return FALSE ;

	if (bIsChildShow)
	{
		// 后面的孩子往上移动
		OffsetChildItemsY(hNextChild, NULL, -rcChild.Height()) ;

		// 如果是展开的,则调整高度
		if (IsExpand())
		{
			// 自己变矮
			SetWndLessPos(0, 0, 0, -rcChild.Height(), SWLP_CY | SWLP_CY_OFFSET) ;

			// 通知父窗体变矮
			long lNewHeight = m_szClient.cy ;
			NotifyParentHeightChanged(lOldHeight, lNewHeight, FALSE) ;
		}
	}

	return TRUE ;
}