BOOL CXTPSyntaxEditTipWnd::CalcItemRect(int iItem, CRect& rItem)
{
	ASSERT_VALID(this);

	if (m_pListBox->GetItemRect(iItem, &rItem) == LB_ERR)
		return FALSE;

	if (IsOwnerDrawn())
		return FALSE;

	CString csItem;
	m_pListBox->GetText(iItem, csItem);
	m_pListBox->ClientToScreen(rItem);

	if (csItem.IsEmpty())
		return FALSE;

	CWindowDC dc(NULL);
	CXTPFontDC fontDC(&dc, m_pListBox->GetFont());
	int iAdjust = dc.GetTextExtent(csItem).cx + (::GetSystemMetrics(SM_CXEDGE)*2);

	m_rWindow.CopyRect(rItem);
	m_rWindow.right = max(rItem.right, rItem.left + iAdjust);

	return TRUE;
}
int CXTFlatComboBoxTheme::GetDropArrowWidth() const
{
	TEXTMETRIC tm;

	CWindowDC dc(NULL);
	CXTPFontDC fontDC(&dc, &XTPAuxData().font);
	dc.GetTextMetrics(&tm);

	int nThumbWidth = __max(15, tm.tmAveCharWidth * 2 + 4);

	return min(nThumbWidth, GetSystemMetrics(SM_CXVSCROLL) + 1);

}
void CShareFilesCountStatic::DrawText(CDC *pDC, const CRect &rect)
{
	CFaceManager::GetInstance()->DrawFace(FI_SHARE_FILE_COUNT, pDC->GetSafeHdc(), FS_NORMAL, rect);

	CRect	rtText;
	rtText = rect;

	CString	str;
	GetWindowText(str);

	CFontDC	fontDC(pDC->GetSafeHdc(), _T("宋体"), RGB(255, 255, 255));
	fontDC = 12;

	int			iOldBkMode = pDC->SetBkMode(TRANSPARENT);
	pDC->DrawText(str, &rtText, DT_CENTER | DT_SINGLELINE | DT_VCENTER | DT_WORD_ELLIPSIS);
	pDC->SetBkMode(iOldBkMode);
}
BOOL CXTPSyntaxEditTipWnd::DrawTip(CDC* pDC, CRect rClient)
{
	ASSERT_VALID(this);

	CString csItemText;
	m_pListBox->GetText(m_iIndex, csItemText);

	CXTPFontDC fontDC(pDC, m_pListBox->GetFont(), GetTextColor());

	pDC->SetBkColor(GetBackColor());
	pDC->FillSolidRect(rClient, pDC->GetBkColor());
	pDC->SetBkMode(TRANSPARENT);

	pDC->DrawText(csItemText, rClient,
		DT_VCENTER | DT_CENTER |DT_SINGLELINE | DT_NOPREFIX | DT_EXPANDTABS);

	return TRUE;
}
int CXTPSyntaxEditDrawTextProcessor::RecalcRowHeight(CDC* pDC, CFont* pFont)
{
	ASSERT(pDC && pFont);
	if (!pDC || !pFont)
		return m_nRowHeight;

	m_bUseOutputDC = FALSE;

	CXTPFontDC fontDC(pDC, pFont);

	BOOL bRes = pDC->GetTextMetrics(&m_tmText);
	ASSERT(bRes);

	if (bRes)
		m_nRowHeight = m_tmText.tmHeight;

	if (pDC->IsPrinting())
	{
		TEXTMETRIC tmText;
		bRes = pDC->GetOutputTextMetrics(&tmText);
		ASSERT(bRes);
		if (bRes)
		{
			if (tmText.tmHeight > m_nRowHeight)
			{
				m_nRowHeight = tmText.tmHeight;
			}

			m_bUseOutputDC = //tmText.tmHeight > m_tmText.tmHeight ||
				tmText.tmAveCharWidth > m_tmText.tmAveCharWidth ||
				tmText.tmMaxCharWidth > m_tmText.tmMaxCharWidth;

			if (m_bUseOutputDC)
				m_tmText = tmText;
		}
	}

	if (m_bUseOutputDC)
		m_nSpaceWidth = pDC->GetOutputTextExtent(_T(" "), 1).cx;
	else
		m_nSpaceWidth = pDC->GetTextExtent(_T(" "), 1).cx;

	return m_nRowHeight;
}
BOOL CXTPHeaderCtrlThemeExplorer::Layout(LPHDLAYOUT lpHDL, CXTPHeaderCtrl* pHeaderCtrl)
{
	ASSERT_VALID(pHeaderCtrl);

	LPRECT      pRC = lpHDL->prc;
	LPWINDOWPOS pWP = lpHDL->pwpos;

	CWindowDC dc(NULL);
	CXTPFontDC fontDC(&dc, pHeaderCtrl->GetFont());

	TEXTMETRIC tm;
	dc.GetTextMetrics(&tm);
	int iHeight = tm.tmHeight + 6;

	pWP->hwndInsertAfter = 0;
	pWP->x = pRC->left;
	pWP->cx = pRC->right - pRC->left;
	pWP->cy = iHeight;
	pWP->y = pRC->top;
	pRC->top += iHeight;
	pWP->flags = SWP_NOACTIVATE | SWP_NOZORDER;

	return TRUE;
}
Пример #7
0
void CXTPColorDialog::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	dc.SetBkMode(TRANSPARENT);
	dc.SetTextColor(GetXtremeColor(COLOR_WINDOWTEXT));

	CXTPFontDC fontDC(&dc, GetFont());

	// get the Cancel button size.
	CXTPWindowRect rcBtnCancel(GetDlgItem(IDCANCEL));
	ScreenToClient(&rcBtnCancel);

	// construct the size for the the new / current color box.
	CXTPClientRect rect(this);
	rect.right = rcBtnCancel.right;
	rect.left = rcBtnCancel.left;
	rect.top = rcBtnCancel.bottom + (::IsWindow(m_wndHexEdit.m_hWnd) ? 46 : 23);
	rect.bottom = rect.top + 66;

	// draw the borders for the new / current color box.
	if (m_dwStyle & CPS_XTP_SHOW3DSELECTION)
	{
		dc.Draw3dRect(&rect, GetXtremeColor(COLOR_3DHILIGHT),
			GetXtremeColor(COLOR_3DDKSHADOW));

		rect.DeflateRect(3, 3);
		dc.Draw3dRect(&rect, GetXtremeColor(COLOR_3DSHADOW),
			GetXtremeColor(COLOR_3DHILIGHT));
	}
	else
	{
		dc.Draw3dRect(&rect, GetXtremeColor(COLOR_WINDOWFRAME),
			GetXtremeColor(COLOR_WINDOWFRAME));
	}

	// draw the new text string.
	CRect rcText = rect;
	rcText = rect;
	rcText.top -= 22;
	rcText.bottom = rcText.top + 22;

	CString strText;
	CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strText, XTP_IDS_NEW));
	dc.DrawText(strText, rcText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

	// draw the current text string.
	rcText = rect;
	rcText.top = rcText.bottom;
	rcText.bottom = rcText.top + 22;

	CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strText, XTP_IDS_CURRENT));
	dc.DrawText(strText, rcText, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

	rect.DeflateRect(1, 1);
	int cy = rect.Height()/2;

	// fill the new color box.
	m_rcNew = rect;
	m_rcNew.bottom = rect.top + cy;
	dc.FillSolidRect(&m_rcNew, m_clrNew);

	// fill the current color box.
	m_rcCurrent = rect;
	m_rcCurrent.top = rect.bottom - cy;
	dc.FillSolidRect(&m_rcCurrent, m_clrCurrent);
}
void CXTPHeaderCtrlThemeResource::OnDrawItemText(LPDRAWITEMSTRUCT lpDIS, CXTPHeaderCtrl* pHeaderCtrl)
{
	ASSERT_VALID(pHeaderCtrl);

	CDC* pDC = CDC::FromHandle(lpDIS->hDC);
	LPHDITEM lpHDI = (LPHDITEM)lpDIS->itemData;

	// prepare the device context to draw text.
	CXTPFontDC fontDC(pDC, pHeaderCtrl->GetFont());

	// construct text size.
	CRect rcItem(lpDIS->rcItem);
	rcItem.DeflateRect(m_sizePadding.cx, 0);

	BOOL bSortAsc;
	UINT nSortItem = pHeaderCtrl->GetSortedCol(&bSortAsc);
	if (nSortItem == lpDIS->itemID)
		rcItem.right -= m_sizeArrow.cx + m_iArrowPadding*2;

	CRect rcText(rcItem);
	CSize sizeText = pDC->GetTextExtent(lpHDI->pszText);

	rcText.top = (m_sizePadding.cy > 0) ?
		m_sizePadding.cy : (rcItem.Height()-sizeText.cy)/2;
	rcText.bottom = rcText.top + sizeText.cy;

	if ((lpHDI->fmt & HDF_BITMAP && lpHDI->hbm != NULL) || (lpHDI->fmt & HDF_IMAGE))
	{
		if (lpHDI->fmt & HDF_BITMAP_ON_RIGHT)
		{
			CRect rcImage(rcText);
			rcImage.left += sizeText.cx + m_sizePadding.cx;
			OnDrawItemBitmap(lpDIS, rcImage, pHeaderCtrl);
		}
		else
		{
			OnDrawItemBitmap(lpDIS, rcText, pHeaderCtrl);
		}
	}

	// determine justification for text.
	switch (lpHDI->fmt & HDF_JUSTIFYMASK)
	{
	case HDF_LEFT:
		rcText.right = rcText.left + sizeText.cx;
		break;
	case HDF_CENTER:
		rcText.left += (rcItem.Width()-sizeText.cx)/2;
		rcText.right = rcText.left + sizeText.cx;
		break;
	case HDF_RIGHT:
		rcText.left = rcText.right - sizeText.cx;
		break;
	}

	// size text to fit available display area.
	rcText.left = __max(rcText.left, rcItem.left);
	rcText.right = __min(rcText.right, rcItem.right);

	// check if we are sorting.
	if (HasSortArrow() && nSortItem == lpDIS->itemID)
	{
		lpDIS->rcItem = rcText;
		OnDrawItemSortArrow(lpDIS, bSortAsc);
	}

	if (rcText.Width() > 0)
	{
		// draw text.
		pDC->DrawText(lpHDI->pszText, &rcText,
			DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS);
	}
}
void CXTPHeaderCtrlTheme::DrawHeader(CDC* pDC, CXTPHeaderCtrl* pHeaderCtrl)
{
	ASSERT_VALID(pHeaderCtrl);

	CXTPClientRect rcClient(pHeaderCtrl);

	DRAWITEMSTRUCT dis;
	dis.CtlType = ODT_BUTTON;
	dis.CtlID = 0;
	dis.itemID = 0;
	dis.itemAction = ODA_DRAWENTIRE;
	dis.itemState = 0;
	dis.hwndItem = pHeaderCtrl->m_hWnd;
	dis.hDC = pDC->m_hDC;
	dis.rcItem = rcClient;
	dis.itemData = 0;

	// draw background.
	if (!m_bUseWinThemes || !OnDrawBackgroundWinThemed(&dis))
		OnDrawBackground(&dis);

	// set text attributes.
	CXTPFontDC fontDC(pDC, pHeaderCtrl->GetFont());
	pDC->SetBkColor(m_cr3DFace);
	pDC->SetTextColor(m_crText);
	pDC->SetBkMode(TRANSPARENT);

	// Set up the header item order array.
	HD_ITEM hdi;
	::ZeroMemory(&hdi, sizeof(HD_ITEM));

	hdi.fmt = HDF_STRING | HDF_LEFT | HDF_BITMAP;
	hdi.mask = HDI_WIDTH | HDI_TEXT | HDI_FORMAT | HDI_ORDER | HDI_BITMAP | HDI_LPARAM;

	int cxy = 0;
	int iItem = 0;
	int iItemCount = pHeaderCtrl->GetItemCount();
	int *plItems = new int[iItemCount];

	for (iItem = 0; iItem < iItemCount; iItem++)
	{
		pHeaderCtrl->GetItem(iItem, &hdi);
		plItems[hdi.iOrder] = iItem;
	}

	hdi.fmt = HDF_STRING | HDF_LEFT | HDF_BITMAP;
	hdi.mask = HDI_WIDTH | HDI_TEXT | HDI_FORMAT | HDI_BITMAP | HDI_LPARAM;

	// get cursor position.
	CPoint point;
	::GetCursorPos(&point);
	pHeaderCtrl->ScreenToClient(&point);

	// Draw each header item
	for (iItem = 0; iItem < iItemCount; ++iItem)
	{
		// Get the header item text and format
		TCHAR szBuffer[256];
		hdi.pszText = szBuffer;
		hdi.cchTextMax = 255;
		pHeaderCtrl->GetItem(plItems[iItem], &hdi);

		// initialize draw item structure.
		dis.itemID = plItems[iItem];
		dis.itemState = 0;
		dis.rcItem = rcClient;
		dis.rcItem.left = cxy;
		dis.rcItem.right = dis.rcItem.left + hdi.cxy;
		dis.itemData = (DWORD_PTR)&hdi;

		// if hot tracking is enabled, set the state.
		if (GetDrawStyle() & HDR_XTP_HOTTRACKING)
		{
			if (pHeaderCtrl->HitTest(point) == plItems[iItem])
				dis.itemState = ODS_HOTLIGHT;
		}

		// check if the item is selected
		if (pHeaderCtrl->ItemPressed(plItems[iItem]))
			dis.itemState = ODS_SELECTED;

		// draw the item background.
		if (!m_bUseWinThemes || !OnDrawItemBackgroundWinThemed(&dis))
			OnDrawItemBackground(&dis);

		// draw the item text.
		OnDrawItemText(&dis, pHeaderCtrl);
		cxy += hdi.cxy;
	}

	delete [] plItems;
}
Пример #10
0
void CToolBarCtrlZ::DrawItem(CDC *pDC, int iIndex, const CRect &rtItem, BOOL bHover)
{
	UINT			uItemId;
	UINT			uItemState;
	TBBUTTON		tbb;


	TCHAR			szText[1024];
	TBBUTTONINFO	tbi;
	CArray<CxImage*, CxImage*>	*parrImgs = NULL;
	CxImage			*pIconImg = NULL;		
	int				iIconTop;
	CRect			rtDraw;
	CRect			rtText;
	COLORREF		clrText;
	
	CClientRect		rtClient(this);
	rtDraw = rtItem;
	rtDraw.top = rtClient.top;
	rtDraw.bottom = rtClient.bottom;

	if (!GetButton(iIndex, &tbb))
		return;

	uItemId = tbb.idCommand;
	uItemState = GetState(uItemId);

	parrImgs = &m_arrImgs;
	if ( !IsButtonEnabled(uItemId) )
	{
		clrText = RGB(204, 128, 128);
		if (0 != m_arrDisableImgs.GetCount())
			parrImgs = &m_arrDisableImgs;
	}
	else
	{
		clrText = RGB(255, 254, 253);

		if (TBSTATE_PRESSED & uItemState/*IsButtonPressed(uItemId)*/)
			rtDraw.OffsetRect(1, 1);
		else if (bHover/*iIndex == GetHotItem()*/)
			rtDraw.OffsetRect(-1, -2);
	}


	ZeroMemory(&tbi, sizeof(TBBUTTONINFO));
	tbi.cbSize = sizeof(TBBUTTONINFO);
	tbi.dwMask = TBIF_TEXT | TBIF_IMAGE;
	tbi.pszText = szText;
	tbi.cchText = 1024;
	//if (GetButtonInfo(p->nmcd.dwItemSpec, &tbi))
	GetButtonInfo(uItemId, &tbi);
	{

		rtText = rtDraw;

		if (tbi.iImage < parrImgs->GetCount())
		{
			pIconImg = parrImgs->GetAt(tbi.iImage);
			if (NULL != pIconImg)
			{
				iIconTop = rtDraw.Height() - pIconImg->GetHeight();
				iIconTop /= 2;
				iIconTop += rtDraw.top;
				pIconImg->Draw(pDC->GetSafeHdc(), rtDraw.left, iIconTop);
				rtText.left += pIconImg->GetWidth() + 4;
			}
		}


		{
			CWndFontDC	fontDC(pDC->GetSafeHdc(), GetSafeHwnd());
			CTextDC		textDC(pDC->GetSafeHdc(), clrText);
			
			pDC->DrawText(tbi.pszText, -1, &rtText, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
		}
	}

}
void CXTPSkinObjectHeader::OnDraw(CDC* pDC)
{
	CXTPClientRect rcClient(this);
	CRect rcBackground(rcClient);

	CXTPBufferDC dc(*pDC, rcClient);

	BOOL bFilterBar = (GetStyle() & HDS_FILTERBAR) && XTPSystemVersion()->GetComCtlVersion() >= MAKELONG(80, 5);
	CRect rcFilter(0, 0, 0, 0);

	dc.FillSolidRect(rcClient, GetColor(COLOR_3DFACE));

	if (bFilterBar)
	{
		INT cyFilter = (rcClient.Height() - 1)/2;

		rcFilter = rcClient;

		rcClient.bottom = rcClient.top + cyFilter;
		rcFilter.top = rcClient.bottom;

		DefWindowProc(WM_PAINT, (WPARAM)dc.GetSafeHdc(), 0);
	}

	CXTPSkinManagerClass* pClass = GetSkinClass();

	CXTPFontDC fontDC(&dc, GetFont());
	dc.SetTextColor(GetColor(COLOR_BTNTEXT));
	dc.SetBkMode(TRANSPARENT);

	CHeaderCtrl* pHeaderCtrl = (CHeaderCtrl*)this;

	int iItemCount = pHeaderCtrl->GetItemCount();



	// Draw each header item
	for (int iItem = 0; iItem < iItemCount; ++iItem)
	{
		int nIndex = Header_OrderToIndex(m_hWnd, iItem);

		// initialize draw item structure.
		CRect rcItem(0, 0, 0, 0);
		Header_GetItemRect(m_hWnd, nIndex, &rcItem);

		if ((rcItem.right < rcClient.left) || (rcItem.left > rcClient.right))
			continue;

		if (bFilterBar)
		{
			rcItem.bottom = rcFilter.top;
		}

		int nState = HIS_NORMAL;

		if (nIndex == m_nHotItem)
		{
			nState = m_bLBtnDown ? HIS_PRESSED : HIS_HOT;
		}

		rcBackground.left = max(rcBackground.left, rcItem.right);


		pClass->DrawThemeBackground(&dc, HP_HEADERITEM, nState, &rcItem);

		DrawItemEntry(&dc, nIndex, rcItem, nState);
	}

	if (rcBackground.left < rcBackground.right)
		pClass->DrawThemeBackground(&dc, 0, 0, &rcBackground);

}