Esempio n. 1
0
//****************************************************************************************
void CBCGPRibbonFontComboBox::RebuildFonts ()
{
	RemoveAllItems ();

	CObList lstFonts;

	CBCGPToolbarFontCombo tlbFontCombo (
		&lstFonts, m_nFontType, m_nCharSet, m_nPitchAndFamily);

	POSITION pos = NULL;

	for (pos = lstFonts.GetHeadPosition (); pos != NULL;)
	{
		CBCGPFontDesc* pDesc = (CBCGPFontDesc*) lstFonts.GetNext (pos);
		ASSERT_VALID (pDesc);

		if ((m_nFontType & pDesc->m_nType) != 0)
		{
			BOOL bIsUnique = GetFontsCount (pDesc->m_strName, lstFonts) <= 1;
			AddItem (bIsUnique ? pDesc->m_strName : pDesc->GetFullName (), (DWORD_PTR) pDesc);
		}
	}

	// Delete unused items:
	for (pos = lstFonts.GetHeadPosition (); pos != NULL;)
	{
		CBCGPFontDesc* pDesc = (CBCGPFontDesc*) lstFonts.GetNext (pos);
		ASSERT_VALID (pDesc);

		if ((m_nFontType & pDesc->m_nType) == 0)
		{
			delete pDesc;
		}
	}
}
Esempio n. 2
0
//********************************************************************************
BOOL CBCGPRibbonFontComboBox::OnDrawDropListItem (CDC* pDC, 
											  int nIndex, 	
											  CBCGPToolbarMenuButton* pItem,
											  BOOL /*bHighlight*/)
{
	ASSERT_VALID (this);

	if (m_Images.GetCount() == 0)
	{
		CBCGPLocalResource locaRes;
		
		m_Images.SetImageSize(CSize(nImageWidth, nImageHeight));

		if (globalData.Is32BitIcons())
		{
			m_Images.Load(IDB_BCGBARRES_FONT32);
		}
		else
		{
			m_Images.SetTransparentColor(RGB (255, 255, 255));
			m_Images.Load(IDB_BCGBARRES_FONT);
		}
	}

	CRect rc = pItem->Rect ();

	CBCGPFontDesc* pDesc = (CBCGPFontDesc*) GetItemData (nIndex);
	LPCTSTR lpszText = GetItem (nIndex);

	if (pDesc == NULL || lpszText == NULL)
	{
		return FALSE;
	}

	ASSERT_VALID (pDesc);

	CFont fontSelected;
	CFont* pOldFont = NULL;

	if (pDesc->m_nType & (DEVICE_FONTTYPE | TRUETYPE_FONTTYPE))
	{
		m_Images.DrawEx(pDC, rc, pDesc->GetImageIndex (), CBCGPToolBarImages::ImageAlignHorzLeft, CBCGPToolBarImages::ImageAlignVertCenter);
	}

	rc.left += nImageWidth + nImageMargin;
	
	if (m_bDrawUsingFont && pDesc->m_nCharSet != SYMBOL_CHARSET)
	{
		LOGFONT lf;
		globalData.fontRegular.GetLogFont (&lf);

		lstrcpy (lf.lfFaceName, pDesc->m_strName);

		if (pDesc->m_nCharSet != DEFAULT_CHARSET)
		{
			lf.lfCharSet = pDesc->m_nCharSet;
		}

		if (lf.lfHeight < 0)
		{
			lf.lfHeight -= 4;
		}
		else
		{
			lf.lfHeight += 4;
		}

		fontSelected.CreateFontIndirect (&lf);
		pOldFont = pDC->SelectObject (&fontSelected);
	}

	CString strText = lpszText;

	pDC->DrawText (strText, rc, DT_SINGLELINE | DT_VCENTER);

	if (pOldFont != NULL)
	{
		pDC->SelectObject (pOldFont);
	}

	return TRUE;
}
void CKofBCGPFontComboBox::OnPaint()
{
	if ((GetStyle () & 0x0003L) == CBS_SIMPLE)
	{
		Default ();
		return;
	}

	if (!m_bVisualManagerStyle && !m_bOnGlass)
	{
		Default ();
		return;
	}

	CPaintDC dc(this); // device context for painting
	BYTE alpha = 0;
	if (m_bOnGlass)
	{
		alpha = 255;
	}
	CBCGPMemDC memDC (dc, this, alpha);
	CDC* pDC = &memDC.GetDC ();

	CRect rectClient;
	GetClientRect (rectClient);

	CBCGPDrawManager dm (*pDC);
	dm.DrawRect (rectClient, globalData.clrWindow, (COLORREF)-1);
//  得注释掉这句话
// 	SendMessage (WM_PRINTCLIENT, (WPARAM) pDC->GetSafeHdc (), (LPARAM) PRF_CLIENT);
	const int cxDropDown = ::GetSystemMetrics (SM_CXVSCROLL) + 4;

	int nCurSel = GetCurSel();
	if (CB_ERR != nCurSel)
	{
		if (m_Images.GetSafeHandle () == NULL)
		{
			CBCGPLocalResource locaRes;
			m_Images.Create (IDB_BCGBARRES_FONT, nImageWidth, 0, RGB (255, 255, 255));
		}

		CFont fontSelected;
		CFont* pOldFont = NULL;
		CRect rc(rectClient);		
		rc.right -= cxDropDown;

		CBCGPFontDesc* pDesc = (CBCGPFontDesc*)GetItemDataPtr(nCurSel);
		if (pDesc != NULL)
		{			
			if (pDesc->m_nType & (DEVICE_FONTTYPE | TRUETYPE_FONTTYPE))
			{
				CPoint ptImage (rc.left + 3, rc.top + (rc.Height () - nImageHeight) / 2);
				m_Images.Draw (pDC, pDesc->GetImageIndex (), ptImage, ILD_NORMAL);
			}

			rc.left += nImageWidth + 9;

			if (m_bDrawUsingFont && pDesc->m_nCharSet != SYMBOL_CHARSET)
			{
				LOGFONT lf;
				globalData.fontRegular.GetLogFont (&lf);

				lstrcpy (lf.lfFaceName, pDesc->m_strName);

				if (pDesc->m_nCharSet != DEFAULT_CHARSET)
				{
					lf.lfCharSet = pDesc->m_nCharSet;
				}

				if (lf.lfHeight < 0)
				{
					lf.lfHeight -= 4;
				}
				else
				{
					lf.lfHeight += 4;
				}

				fontSelected.CreateFontIndirect (&lf);
				pOldFont = pDC->SelectObject (&fontSelected);
			}
		}

		CString strText;
		GetLBText (nCurSel, strText);

		pDC->DrawText (strText, rc, DT_SINGLELINE | DT_VCENTER);

		if (pOldFont != NULL)
		{
			pDC->SelectObject (pOldFont);
		}
	}

	m_rectBtn = rectClient;
	m_rectBtn.left = m_rectBtn.right - cxDropDown;

	m_rectBtn.DeflateRect (2, 2);

	CBCGPDrawOnGlass dog (m_bOnGlass);

	CKofBCGPToolbarComboBoxButton buttonDummy;
#ifndef _BCGSUITE_
	buttonDummy.m_bIsCtrl = TRUE;

	CBCGPVisualManager::GetInstance ()->OnDrawComboDropButton (
		pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown,
		m_bIsButtonHighlighted,
		&buttonDummy);
#else
	CMFCVisualManager::GetInstance ()->OnDrawComboDropButton (
		pDC, m_rectBtn, !IsWindowEnabled (), m_bIsDroppedDown,
		m_bIsButtonHighlighted,
		&buttonDummy);
#endif

	dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrBarShadow);
	rectClient.DeflateRect (1, 1);
	dm.DrawRect (rectClient, (COLORREF)-1, globalData.clrWindow);
}