void CEditTreeCtrl::DragMoveItem(HTREEITEM hDrag, HTREEITEM hDrop, EDropHint eHint, bool bCopy) {
	if(eHint == DROP_NODROP)
		return;

	if(IsAncestor(hDrag, hDrop) || !CanDropItem(hDrag, hDrop, eHint))
		return;

	ASSERT(hDrag != 0);
	ASSERT(hDrop != 0 || eHint == DROP_BELOW);

	if(!hDrop && eHint == DROP_BELOW)
		for(hDrop = GetRootItem(); GetNextSiblingItem(hDrop) != 0; hDrop = GetNextSiblingItem(hDrop));

	// Setup insertion parameters
	HTREEITEM hInsertAfter = 0;
	HTREEITEM hParent = 0;
	switch(eHint) {
		case DROP_BELOW:
			hInsertAfter = hDrop;
			hParent = GetParentItem(hDrop);
			break;

		case DROP_ABOVE:
			hInsertAfter = GetPrevSiblingItem(hDrop);
			if(!hInsertAfter)
				hInsertAfter = TVI_FIRST;
			hParent = GetParentItem(hDrop);
			break;

		case DROP_CHILD:
			hInsertAfter = TVI_LAST;
			hParent = hDrop;
			break;

		default:
			ASSERT(false);
			break;
	}

	HTREEITEM hNew = CopyItem(hDrag, hParent, hInsertAfter);
	SelectItem(hNew);

	// If the control-key ist down, we copy the data, otherwise we move
	// it, thus we have to delete the dragged item.
	if(!bCopy)
		DeleteItem(hDrag);
}
Пример #2
0
HTREEITEM KGTreeCtrl::GetFirstSibingItem(HTREEITEM hTreeItem)
{
	HTREEITEM hResultItem = NULL;
	HTREEITEM hPrevItem   = NULL;

	KG_PROCESS_ERROR(hTreeItem);

	hPrevItem = hTreeItem;
	while (hPrevItem)
	{
		hResultItem = hPrevItem;
		hPrevItem = GetPrevSiblingItem(hPrevItem);
	}

Exit0:
	return hResultItem;
}
Пример #3
0
// When starting a mouse-key select, the anchor point, and all contiguous 
// selections that are not in the path of the current item can remain 
// selected.  All other selections are tossed, like Exploder does.
void CMultiSelTreeCtrl::DoKeyedDeselect( BOOL scrollingDown )
{
	CDWordArray keepSet;
	HTREEITEM currentItem= m_AnchorItem;
	
	// Record the contiguous selection's we're keeping
	keepSet.Add( (DWORD) m_AnchorItem );
	while(1)
	{
		if( scrollingDown )
			currentItem= GetPrevSiblingItem( currentItem);
		else
			currentItem= GetNextSiblingItem( currentItem);

		if( currentItem == NULL || !IsSelected( currentItem ) )
			break;

		keepSet.Add( (DWORD) currentItem );
	}

	// Unselect everything
	//
	int i;
	for( i= m_SelectionSet.GetSize()-1; i >= 0; i-- )
	{
		currentItem= (HTREEITEM) m_SelectionSet.GetAt(i);	
		// Undo any display atts
		SetItemState(currentItem, 0, TVIS_CUT | TVIS_BOLD | TVIS_SELECTED);
	}

	// Then select everything in the keepset
	//
	m_SelectionSet.RemoveAll();
	for( i= keepSet.GetSize()-1; i>=0; i-- )
		SetSelectState( (HTREEITEM) keepSet.GetAt(i), TRUE );

	m_PendingKeyedDeselect= FALSE;
	ShowNbrSelected();
}
Пример #4
0
// User mouse-keyed a request to expand the current selection.  Note that
// the selection set can actually shrink if the already selected items are
// not contiguous - per Exploder convention
void CMultiSelTreeCtrl::ExpandSelection( int linesToExpand )
{
	ASSERT( m_SelectionSet.GetSize() > 0 );
	if( m_AnchorItem == NULL )
	{
		ASSERT(0);
		return;
	}

	MainFrame()->WaitAWhileToPoll();	// wait at least 20 secs before autopolling for updates

	HTREEITEM currentItem= m_AnchorItem;

	if( linesToExpand > 0 )
	{
		// Scrolling up
		for( int i=0; i < linesToExpand; i++ )
		{
			HTREEITEM lastGoodItem= currentItem;
			currentItem= GetPrevSiblingItem(currentItem);
			if( currentItem == NULL )
			{
				currentItem= lastGoodItem;
				break;
			}
			else
			{
				if( m_PendingKeyedDeselect )
					DoKeyedDeselect( FALSE );
				if( IsSelected( currentItem ) )
					SetSelectState( lastGoodItem, FALSE );  // Selection shrinking
				else if( OKToAddSelection( currentItem ) )
					SetSelectState( currentItem, TRUE );  // Selection growing
				else
					break;
			}
		}
	}
	else
	{
		// Scrolling down
		for( int i=0; i < (-linesToExpand); i++ )
		{
			HTREEITEM lastGoodItem= currentItem;
			currentItem= GetNextSiblingItem(currentItem);
			if( currentItem == NULL )
			{
				currentItem= lastGoodItem;
				break;
			}
			else
			{
				if( m_PendingKeyedDeselect )
					DoKeyedDeselect( TRUE );

				if( IsSelected( currentItem ) )
					SetSelectState( lastGoodItem, FALSE );  // Selection shrinking
				else if( OKToAddSelection( currentItem ) )
					SetSelectState( currentItem, TRUE );  // Selection growing
				else
					break;
			}

		}
	}

	m_AnchorItem= currentItem;
	EnsureVisible( m_AnchorItem );
}
BOOL CImageTreeCtrl::SetItemImage(HTREEITEM hItem, int nImage, int nSelectedImage)
{
	//tree0412 屏蔽下面原有的
#if 0
	BOOL bReturn=CTreeCtrl::SetItemImage( hItem, nImage, nSelectedImage );

	HTREEITEM hParentItem;//,hBrotherItem;	
	static int dd=0;
	//查找子节点,没有就结束
	hParentItem=GetParentItem(hItem);
	int brother_nImage,brother_nSelectedImage;
	if(hParentItem)
	{	 
//Subnet,Floor_xx,Room_xx 只有当全部设备没有连接时才显示“没连接图标”,否则不改变这三个图标
#if 0  //LSC
		//have parentitem 
		if(!is_connection_by_image(nImage,nSelectedImage))
		{//this is disconnection
			GetItemImage(hParentItem,brother_nImage,brother_nSelectedImage);
			if(is_connection_by_image(brother_nImage,brother_nSelectedImage))
				SetItemImage(hParentItem,6,brother_nSelectedImage);
			return bReturn;////////////////////unconnection return ;
		}	

		/////////////prev
		hBrotherItem=GetPrevSiblingItem(hItem);
		if(hBrotherItem)
			GetItemImage(hBrotherItem,brother_nImage,brother_nSelectedImage);
		while(hBrotherItem)
		{
			if(!is_connection_by_image(brother_nImage,brother_nSelectedImage))
			{//one brother is disconnection
				GetItemImage(hParentItem,brother_nImage,brother_nSelectedImage);
				if(is_connection_by_image(brother_nImage,brother_nSelectedImage))
					SetItemImage(hParentItem,6,brother_nSelectedImage);
				return bReturn;////////////////////unconnection return ;
			}			
			hBrotherItem=GetPrevSiblingItem(hBrotherItem);
			if(hBrotherItem)
				GetItemImage(hBrotherItem,brother_nImage,brother_nSelectedImage);
		}	
		/////////////next
		hBrotherItem=GetNextSiblingItem(hItem);
		if(hBrotherItem)
			GetItemImage(hBrotherItem,brother_nImage,brother_nSelectedImage);
		while(hBrotherItem)
		{
			if(!is_connection_by_image(brother_nImage,brother_nSelectedImage))
			{//one brother is disconnection
				GetItemImage(hParentItem,brother_nImage,brother_nSelectedImage);
				if(is_connection_by_image(brother_nImage,brother_nSelectedImage))
					SetItemImage(hParentItem,6,brother_nSelectedImage);
				return bReturn;////////////////////unconnection return ;
			}
			hBrotherItem=GetNextSiblingItem(hBrotherItem);
			if(hBrotherItem)
				GetItemImage(hBrotherItem,brother_nImage,brother_nSelectedImage);
		}		
#endif
		//every brother is connection
//		GetItemImage(hParentItem,brother_nImage,brother_nSelectedImage);
// 		if(!is_connection_by_image(brother_nImage,brother_nSelectedImage))
// 			SetItemImage(hParentItem,brother_nSelectedImage,brother_nSelectedImage);
	}
	return bReturn;
#endif
//tree0412

//tree0412
	BOOL bReturn=CTreeCtrl::SetItemImage( hItem, nImage, nSelectedImage );
	return bReturn;
//tree0412
}
Пример #6
0
void KUIMulStatusTree::TravelSiblingAndParent(HTREEITEM hItem, int nCheck)
{
    HTREEITEM hNextSiblingItem = NULL;
    HTREEITEM hPrevSiblingItem = NULL;
    HTREEITEM hParentItem = NULL;

    HWND hParent = GetParent();
    UINT nState  = 0;

    //查找父节点,没有就结束
    hParentItem = GetParentItem(hItem);

    int nRetCode = false;

    if(hParentItem != NULL)
    {
        int nState = nCheck;//设初始值,防止没有兄弟节点时出错

        //查找当前节点下面的兄弟节点的状态
        hNextSiblingItem = GetNextSiblingItem(hItem);

        while(hNextSiblingItem != NULL)
        {
            nRetCode = GetCheck(hNextSiblingItem, nState);

            if(nState != nCheck && nRetCode)
                break;
            else 
                hNextSiblingItem = GetNextSiblingItem(hNextSiblingItem);
        }

        if( nCheck == nState)
        {
            //查找当前节点上面的兄弟节点的状态
            hPrevSiblingItem = GetPrevSiblingItem(hItem);

            while(hPrevSiblingItem != NULL)
            {
                nRetCode = GetCheck(hPrevSiblingItem, nState);

                if(nState != nCheck && nRetCode)
                    break;
                else 
                    hPrevSiblingItem = GetPrevSiblingItem(hPrevSiblingItem);
            }
        }

        if( nCheck == nState || nState == 0)
        {
            nRetCode = GetCheck( hParentItem, nState);

            if( nState != 0)
            {
                //如果状态一致,则父节点的状态与当前节点的状态一致
                nState = GetItemState(hParentItem, TVIS_STATEIMAGEMASK);
                if (nState != INDEXTOSTATEIMAGEMASK(nCheck))
                {        
                    SetItemState(hParentItem, INDEXTOSTATEIMAGEMASK(nCheck), TVIS_STATEIMAGEMASK);
                    if (hParent != NULL)
                    {
                       // ::SendMessage(hParent, WM_KAN_NOTIFY_TREE_CHECKED_CHANGE, (WPARAM)hParentItem, (LPARAM)nCheck);
                    }
                }

            }
            //再递归处理父节点的兄弟节点和其父节点

            TravelSiblingAndParent(hParentItem, nCheck);
        }
        else
        {
            //状态不一致,则当前节点的父节点、父节点的父节点……状态均为第三态
            hParentItem = GetParentItem(hItem);

            while(hParentItem != NULL)
            {
                nRetCode = GetCheck(hParentItem, nState);

                if(nState !=0)
                {
                    nState = GetItemState(hParentItem, TVIS_STATEIMAGEMASK);
                    SetItemState(hParentItem, INDEXTOSTATEIMAGEMASK(EM_TVIS_INDETERMINING), TVIS_STATEIMAGEMASK);
                    if (hParent != NULL)
                    {
                        //::SendMessage(hParent, WM_KAN_NOTIFY_TREE_CHECKED_CHANGE, (WPARAM)hParentItem, (LPARAM)EM_TVIS_INDETERMINING);
                    }
                }

                hParentItem = GetParentItem(hParentItem);
            }
        }
    }	
}