Пример #1
0
void LineBatcher::DrawIrradianceCross(const Vector& Center, const float Radius,
                                      const Vector4 m_AddColors[6]) {
#if BUILD_RELEASE
  if (m_IsDebug) {
    return;
  }
#endif

  Vector X(Radius, 0.0f, 0.0f);
  Vector Y(0.0f, Radius, 0.0f);
  Vector Z(0.0f, 0.0f, Radius);

  DrawGradientLine(Center + X, Center - X, m_AddColors[0].ToColor(),
                   m_AddColors[1].ToColor());
  DrawGradientLine(Center + Y, Center - Y, m_AddColors[2].ToColor(),
                   m_AddColors[3].ToColor());
  DrawGradientLine(Center + Z, Center - Z, m_AddColors[4].ToColor(),
                   m_AddColors[5].ToColor());
}
Пример #2
0
void CMyPropertySheet::OnNMCustomDraw(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLVCUSTOMDRAW  pLVCD = reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);


	CRect rectRow, rectList;

	m_wndList.GetWindowRect(&rectList);
	ScreenToClient(&rectList);
	m_wndList.GetItemRect(0, &rectRow, LVIR_BOUNDS);
	int iItemHeight = rectRow.Height();
	int iItemTop = rectRow.top ;


	::SelectObject(pLVCD->nmcd.hdc, m_ftList);


	switch (pLVCD->nmcd.dwDrawStage)
	{


	case CDDS_PREPAINT:
		*pResult = CDRF_NOTIFYITEMDRAW;
		break;
	case CDDS_ITEMPREPAINT:


		*pResult = CDRF_NOTIFYSUBITEMDRAW;
		break;
	case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
		{
			int iCol = pLVCD->iSubItem ;
			int iRow = (int)pLVCD->nmcd.dwItemSpec;
			CRect rectItem(pLVCD->nmcd.rc), rectIcon;

			//计算每个子项的矩形

			rectItem.top = iItemTop + iRow * iItemHeight;
			rectItem.bottom = rectItem.top + iItemHeight;

			rectItem.left +=3;
			rectItem.right -=3;

			if (iRow == 0)
				rectItem.top +=3;
			CDC *pDC = CDC::FromHandle(pLVCD->nmcd.hdc);			

			LOGFONT lf;
			::ZeroMemory(&lf, sizeof(lf));
			pDC->GetCurrentFont()->GetLogFont(&lf);


			//获得第图标所在的矩形
			m_wndList.GetSubItemRect(iRow,0, LVIR_ICON, rectIcon);

			const COLORREF clrBlack = RGB(0,0,0);
			const COLORREF clrWhite = RGB(255,255,255);

			if ((pLVCD->nmcd.uItemState & (CDIS_FOCUS | CDIS_SELECTED)) == (CDIS_FOCUS | CDIS_SELECTED))
			{
					
					
					pDC->FillSolidRect(&rectItem, m_clrTextBkSele);
					pDC->SetTextColor(clrWhite);
					pDC->TextOut(rectItem.left + rectIcon.Width() + 8, (iRow == 0?(rectItem.top - 3):rectItem.top) + (iItemHeight - abs(lf.lfHeight))/2, m_wndList.GetItemText(iRow, iCol), (int)_tcslen(m_wndList.GetItemText(iRow, iCol)));
					
					::DrawIconEx(*pDC,rectIcon.left, rectIcon.top + (iItemHeight - 16) / 2,m_imgList.ExtractIcon(iRow),16,16,NULL,NULL,DI_NORMAL);						
					
					pDC->SetTextColor(clrBlack);
					
					DrawGradientLine(pDC,m_clrSeprator,CPoint(rectItem.left, rectItem.bottom-1), CPoint(rectItem.right, rectItem.bottom-1));					

			
			}
			
			else
			
			{
				
					pDC->FillSolidRect(&rectItem, clrWhite);

					pDC->TextOut(rectItem.left + rectIcon.Width() + 8, (iRow == 0?(rectItem.top - 3):rectItem.top) + (iItemHeight - abs(lf.lfHeight))/2, m_wndList.GetItemText(iRow, iCol), (int)_tcslen(m_wndList.GetItemText(iRow, iCol)));

					::DrawIconEx(*pDC,rectIcon.left, rectIcon.top + (iItemHeight - 16) / 2, m_imgList.ExtractIcon(iRow),16,16,NULL,NULL,DI_NORMAL);

					DrawGradientLine(pDC,m_clrSeprator,CPoint(rectItem.left, rectItem.bottom-1), CPoint(rectItem.right, rectItem.bottom-1));					

			

			}
			
			
			*pResult = CDRF_SKIPDEFAULT;
			break;
		}


	default:
		*pResult = CDRF_SKIPDEFAULT;
		break;
	}	



}