示例#1
0
bool SGraphPanel::IsNodeTitleVisible(const class UEdGraphNode* Node, bool bRequestRename)
{
	bool bTitleVisible = false;
	TSharedRef<SNode>* pWidget = NodeToWidgetLookup.Find(Node);

	if (pWidget != NULL)
	{
		TWeakPtr<SGraphNode> GraphNode = StaticCastSharedRef<SGraphNode>(*pWidget);
		if(GraphNode.IsValid() && !HasMouseCapture())
		{
			FSlateRect TitleRect = GraphNode.Pin()->GetTitleRect();
			const FVector2D TopLeft = FVector2D( TitleRect.Left, TitleRect.Top );
			const FVector2D BottomRight = FVector2D( TitleRect.Right, TitleRect.Bottom );

			if( IsRectVisible( TopLeft, BottomRight ))
			{
				bTitleVisible = true;
			}
			else if( bRequestRename )
			{
				bTitleVisible = JumpToRect( TopLeft, BottomRight );
			}

			if( bTitleVisible && bRequestRename )
			{
				GraphNode.Pin()->RequestRename();
				SelectAndCenterObject(Node, false);
			}
		}
	}
	return bTitleVisible;
}
void CHTMLListCtrl::DrawItem(CDC *pDC, CRect rcItem, HTMLLIST_ITEM *pItem, BOOL bSelected)
{
	CRect rcClipBox;
	pDC->GetClipBox(&rcClipBox);

	if(!IsRectVisible(rcClipBox,rcItem))
	{
		return;
	}

	COLORREF clrText = RGB(0,0,0);
	COLORREF clrOld;
	CRect rcImage(0,0,0,0);
		
	if(bSelected)
	{
		clrText = m_clrTextSelectedItem;
		pDC->FillSolidRect(&rcItem,m_clrBkSelectedItem);
	}
	else
	{
		clrText = m_clrTextCtrlItem;
		pDC->FillSolidRect(&rcItem,m_clrBkCtrlItem);
	}

	if(m_dwExtendedStyles & HTMLLIST_STYLE_GRIDLINES)
	{
		pDC->DrawEdge(&rcItem,BDR_SUNKENINNER,BF_LEFT|BF_BOTTOM|BF_FLAT);
	}
	
	CPoint ptCheckBox = rcItem.TopLeft();

	if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
	{
		ptCheckBox.x += ITEM_PADDING_CHECKBOX_LEFT;
		ptCheckBox.y += rcItem.Height() / 2 - 8;
		
		m_ImageList.Draw(pDC,pItem->bChecked?1:0,ptCheckBox,ILD_TRANSPARENT);
		ptCheckBox.x += ITEM_CHECKBOX_WIDTH;
	}
	
	//Draw image if an imagelist is attached
	if(m_dwExtendedStyles & HTMLLIST_STYLE_IMAGES)
	{
		if(m_pImageList)
		{
			IMAGEINFO imgInfo = {0};
			m_pImageList->GetImageInfo(0,&imgInfo);
			rcImage = imgInfo.rcImage;
			
			CPoint pt = ptCheckBox;
			pt.x += ITEM_IMAGE_PADDING_LEFT;
			pt.y = rcItem.top;
			pt.y += rcItem.Height() / 2 - rcImage.Height()/2;
			
			m_pImageList->Draw(pDC,pItem->uiImage,pt,ILD_TRANSPARENT);			
		}
	}
	
	if(pItem->nStyle == NORMAL_TEXT)
	{
		clrOld = pDC->SetTextColor(clrText);
		
		CRect rc = rcItem;
		
		if(rcImage.Width())
		{
			//make space for the Image already drawn
			rc.DeflateRect(rcImage.Width() + ITEM_IMAGE_PADDING_LEFT + ITEM_IMAGE_PADDING_RIGHT,0,0,0);
		}
		
		if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
		{
			rc.left += ITEM_PADDING_LEFT + ITEM_CHECKBOX_WIDTH;
		}
		else
		{
			rc.left += ITEM_PADDING_LEFT;
		}
		
		if(!pItem->bHeightSpecified)
			rc.top += ITEM_PADDING_TOP;
		
		pDC->DrawText(pItem->sItemText,pItem->sItemText.GetLength(),&rc,
			DT_LEFT|DT_WORDBREAK);
	}
	else if(pItem->nStyle == HTML_TEXT)
	{
		//Draw HTML
		clrOld = pDC->SetTextColor(clrText);
		
		CRect rc = rcItem;
		if(rcImage.Width())
		{
			//make space for the Image already drawn
			rc.DeflateRect(rcImage.Width() + ITEM_IMAGE_PADDING_LEFT + ITEM_IMAGE_PADDING_RIGHT,0,0,0);
		}
		if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
		{
			rc.left += ITEM_PADDING_LEFT + ITEM_CHECKBOX_WIDTH;
		}
		else
		{
			rc.left += ITEM_PADDING_LEFT;
		}
		
		if(!pItem->bHeightSpecified)
			rc.top += ITEM_PADDING_TOP;
		
		DrawHTML(pDC->GetSafeHdc(),pItem->sItemText,pItem->sItemText.GetLength(),
			&rc,DT_LEFT|DT_WORDBREAK);
	}
	else if(pItem->nStyle == SINGLE_LINE_TEXT)
	{
		clrOld = pDC->SetTextColor(clrText);
		
		CRect rc = rcItem;
		if(rcImage.Width())
		{
			//make space for the Image already drawn
			rc.DeflateRect(rcImage.Width() + ITEM_IMAGE_PADDING_LEFT + ITEM_IMAGE_PADDING_RIGHT,0,0,0);
		}
		if(m_dwExtendedStyles & HTMLLIST_STYLE_CHECKBOX)
		{
			rc.left += ITEM_PADDING_LEFT + ITEM_CHECKBOX_WIDTH;
		}
		else
		{
			rc.left += ITEM_PADDING_LEFT;
		}
		
		if(!pItem->bHeightSpecified)
			rc.top += ITEM_PADDING_TOP;
		
		//See if we can fit the text in one line
		char szBuffer[_MAX_PATH];
		memset(szBuffer,0,_MAX_PATH);
		
		_tcscpy(szBuffer,pItem->sItemText);
		
		if(PathCompactPath(pDC->GetSafeHdc(),szBuffer,rc.Width()))
		{
			pDC->DrawText(szBuffer,_tcslen(szBuffer),&rc,
				DT_LEFT|DT_SINGLELINE|DT_VCENTER);	
		}
		else
		{
			pDC->DrawText(pItem->sItemText,pItem->sItemText.GetLength(),&rc,
				DT_LEFT|DT_SINGLELINE|DT_VCENTER);
		}
	}
	
	pDC->SetTextColor(clrOld);
	
	//Draw the focus rect if focused
	if(m_bHasFocus && (bSelected))
	{
		pDC->DrawFocusRect(&rcItem);
	}
}