Esempio n. 1
0
void CSizeComboBox::InsertSize(int nSize)
{
	ASSERT(nSize > 0);
	DWORD dwSize = (DWORD)nSize;
	TCHAR buf[10];
	TwipsToPointString(buf, nSize);
	if (FindStringExact(-1, buf) == CB_ERR)
	{
		int nIndex = -1;
		int nPos = 0;
		DWORD dw;
		while ((dw = GetItemData(nPos)) != CB_ERR)
		{
			if (dw > dwSize)
			{
				nIndex = nPos;
				break;
			}
			nPos++;
		}
		nIndex = InsertString(nIndex, buf);
		ASSERT(nIndex != CB_ERR);
		if (nIndex != CB_ERR)
			SetItemData(nIndex, dwSize);
	}
}
Esempio n. 2
0
void CMSOffice2007DemoView::OnFontsize()
{
	CMFCRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame())->GetRibbonBar();
	ASSERT_VALID(pRibbon);

	CMFCRibbonComboBox* pSizeCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox, pRibbon->FindByID(ID_FONT_FONTSIZE));
	if (pSizeCombo == NULL)
	{
		return;
	}

	int nSize = GetTwipSize(pSizeCombo->GetEditText());

	if (nSize == -2 || (nSize >= 0 && nSize < 20) || nSize > 32760)
	{
		// Restore current size:
		pSizeCombo->SetEditText (TwipsToPointString (GetCharFormatSelection ().yHeight));

		MessageBox (_T("The number must be between 1 and 1638."));                               
		return;
	}

	if (nSize > 0)
	{
		CCharFormat cf;
		cf.dwMask = CFM_SIZE;
		cf.yHeight = nSize;

		SetCharFormat(cf);
	}
}
Esempio n. 3
0
void CSizeComboBox::SetTwipSize(int nTwips)
{
	if (nTwips != GetTwipSize())
	{
		TCHAR buf[10];
		TwipsToPointString(buf, nTwips);
		SetTheText(buf, TRUE);
	}
	m_nTwipsLast = nTwips;
}
void CBCGPMSOffice2007DemoView::SyncFont ()
{
	USES_CONVERSION;

	CString strFontName;

	// get the current font from the view and update
	WPD_CHARFORMAT cf = GetCharFormatSelection ();

	CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

	// sync font name:
	CBCGPRibbonFontComboBox* pFontCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonFontComboBox, pRibbon->FindByID (ID_FONT_FONT));

	if (pFontCombo != NULL && !pFontCombo->HasFocus ())
	{
		if ((cf.dwMask & (CFM_FACE|CFM_CHARSET)) == (CFM_FACE|CFM_CHARSET))
		{
#if _MSC_VER >= 1300
			strFontName = cf.szFaceName;
#else
			strFontName = A2T(cf.szFaceName);
#endif
			pFontCombo->SetFont (strFontName, DEFAULT_CHARSET, TRUE);
		}
		else
		{
			pFontCombo->SetText(_T(""));
		}
	}

	// sync font size:
	CBCGPRibbonComboBox* pFontSizeCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonComboBox, pRibbon->FindByID (ID_FONT_FONTSIZE));

	if (pFontSizeCombo != NULL && !pFontSizeCombo->HasFocus ())
	{
		pFontSizeCombo->SetEditText (TwipsToPointString (cf.yHeight));
	}

	SetFocus ();
}