Exemplo n.º 1
0
//绘制子项
void CListCtrlEx::DrawSubItem(CDC *pDC, int nItem, int nSubItem, CRect &rSubItem)
{
	CRect Temp=rSubItem;
	DrawBkItem(pDC,nItem,rSubItem);
	long Key = MAKELONG(nItem,nSubItem);
	CRect DrawRect=rSubItem;
	DrawRect.left++;
	DrawRect.top++;
	DrawRect.right--;
	DrawRect.bottom--;
	map<long,sItemStyle>::iterator it=m_ItemStyleMap.find(Key);
	if(it != m_ItemStyleMap.end())
	{
		if(m_ShowVedio)
		{
			//绘制视频的新显示方式
			DrawShowVedio(pDC,nItem,nSubItem,DrawRect,&it->second);
		}
		else
			DrawByStyle(pDC,nItem,nSubItem,DrawRect,&it->second);
	}
	else
	{
		map<int,sItemStyle>::iterator ItemIt=m_ColumnStyleMap.find(nSubItem);
		if(ItemIt != m_ColumnStyleMap.end())
		{
			DrawByStyle(pDC,nItem,nSubItem,DrawRect,&ItemIt->second);
		}
	}
	
}
Exemplo n.º 2
0
void duSplitter::DrawObject(HDC hDC)
{
	duRect rectSplitter;
	Plugin_GetRect(this, &rectSplitter);
	rectSplitter.OffsetRect(-rectSplitter.left, -rectSplitter.top);

	DrawByStyle(this, GetStyle(), hDC, &rectSplitter, GetState(), GetText(), GetAlpha());
}
Exemplo n.º 3
0
void duTreeCtrl::DrawObject(HDC hDC)
{
	duRect rcTreeCtrl;
	Plugin_GetRect(this, &rcTreeCtrl);
	rcTreeCtrl.OffsetRect(-rcTreeCtrl.left, -rcTreeCtrl.top);

	BITMAPINFO bmInfo;
	BYTE *pBits;

	HDC hMemDC = ::CreateCompatibleDC(hDC);
	InitBitmapInfo(&bmInfo, rcTreeCtrl.Width(), rcTreeCtrl.Height());
	HBITMAP hBmp = ::CreateDIBSection(hDC, &bmInfo, DIB_RGB_COLORS,(void**)&pBits, 0, 0);
	HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDC, hBmp);

	BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
	::AlphaBlend(hMemDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), hDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), bf);


	duStyleGroup *pStyleGroup = (duStyleGroup *)GetResObj(GetStyle(), DU_RES_STYLEGROUP);
	if (pStyleGroup)
		pStyleGroup->Draw(hMemDC, &rcTreeCtrl, GetState(), NULL, GetAlpha());
	
	int nOffsetY = 0;
	TreeCtrlItem *pFirstVisible = GetFirstVisibleItem(nOffsetY);
	if (pFirstVisible == NULL || pFirstVisible == m_pRoot)
		return;
		
	duRect rcClient = _GetClientRect();
	
	POINT ptView = GetViewPoint();
	duFont *pFont = (duFont *)GetResObj(m_szFont, DU_RES_FONT);
	
	duSize sizeView;
	GetViewSize(&sizeView);
	
	int nDrawHeight = -nOffsetY;
	TreeCtrlItem *pItem = pFirstVisible;
	while (pItem)
	{
		duRect rcItem;
		
		rcItem.left   = -ptView.x;
		rcItem.right  = rcClient.right;
		rcItem.top    = nDrawHeight;
		rcItem.bottom = rcItem.top + m_nItemHeight;

		UINT uItemState = DU_STATE_NORMAL;
		if (pItem == m_pHot)
			uItemState = DU_STATE_OVER;
		
		if (pItem == m_pSelect)
			uItemState = DU_STATE_PRESS;
		
		DrawByStyle(this, m_szItemStyle, hMemDC, &rcItem, uItemState, NULL, GetAlpha());

		// draw indent[-+]
		int nLeft = (pItem->nLevel - 1) * m_nIndentWidth;
		duRect rcIndent = CalcVCenterRect(rcItem, nLeft, m_nIndentWidth, m_nIndentHeight);
		if (ItemHasChildren(pItem))
		{
			UINT nIndentState = pItem->fExpand ? DU_STATE_NORMAL : DU_STATE_CHECKED;
			DrawByStyle(this, m_szIndentStyle, hMemDC, &rcIndent, nIndentState, NULL, GetAlpha());
		}

		// draw icon
		nLeft += (m_nIndentWidth + m_nIndentIconSpace);
		duRect rcIcon = CalcVCenterRect(rcItem, nLeft, m_nIconWidth, m_nIconHeight);
		duImage *pIcon = (duImage *)GetResObj(pItem->strImage.c_str(), DU_RES_IMAGE);
		if (pIcon)
			DrawNormal(hMemDC, rcIcon.left, rcIcon.top, rcIcon.Width(), rcIcon.Height(), pIcon, 0, 0, GetAlpha());

		// draw text
		duRect rcText;
		nLeft += (m_nIconWidth + m_nIconTextSpace);
		rcText = rcItem;
		rcText.left = rcItem.left + nLeft;
		if (pItem->strText.length() > 0)
			DrawText32Bpp(hMemDC, pFont, m_clrText, pItem->strText.c_str(), pItem->strText.length(), &rcText, DT_LEFT|DT_VCENTER|DT_SINGLELINE, GetAlpha());

		if (nDrawHeight - nOffsetY > rcTreeCtrl.Height())
			break;

		nDrawHeight += m_nItemHeight;
		pItem = GetNextVisibleItem(pItem);
	}

	::AlphaBlend(hDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), hMemDC, 0, 0, rcTreeCtrl.Width(), rcTreeCtrl.Height(), bf);

	::SelectObject(hMemDC, hOldBitmap);
	::DeleteObject(hBmp);
	::DeleteDC(hMemDC);
}