Esempio n. 1
0
void CMSOffice2007DemoView::OnInsertTable()
{
	WPD_CHARFORMAT cf = GetCharFormatSelection();
	InsertBitmap(IDB_TABLE);
	SetCharFormat (cf);
	SyncFont ();
}
Esempio n. 2
0
void CEditFrameView::OnFontSize ()
{
	CBCGPRibbonBar* pRibbon = ((CEditFrameDialog*) GetTopLevelFrame ())->GetRibbonBar ();
	ASSERT_VALID (pRibbon);

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

	int nSize = GetTwipSize (pSizeCombo->GetItem (-1));

	if (nSize == -2)
	{
		return;
	}

	if ((nSize >= 0 && nSize < 20) || nSize > 32760)
	{
		return;
	}

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

		SetCharFormat (cf);
	}
}
Esempio n. 3
0
void CMSOffice2007DemoView::OnInsertPicture()
{
	WPD_CHARFORMAT cf = GetCharFormatSelection();
	InsertBitmap(IDB_PICTURE);
	SetCharFormat (cf);
	SyncFont ();
}
Esempio n. 4
0
void CitbookView::OnCharundeline()
{
	// TODO: 在此添加命令处理程序代码
	CHARFORMAT2 cf;   
    onCharFormatgetEx(cf,CFM_UNDERLINE,CFE_UNDERLINE);  
    SetCharFormat (cf);
}
Esempio n. 5
0
void CitbookView::OnCharstrikeout()
{
	// TODO: 在此添加命令处理程序代码
	CHARFORMAT2 cf;   
    onCharFormatgetEx(cf,CFM_STRIKEOUT,CFE_STRIKEOUT);  
    SetCharFormat (cf);
}
void CBCGPMSOffice2007DemoView::OnInitialUpdate ()
{
	CRichEditView::OnInitialUpdate();

	SendMessage (EM_SHOWSCROLLBAR, SB_HORZ, FALSE);
	SendMessage (EM_SHOWSCROLLBAR, SB_VERT, FALSE);

	GetRichEditCtrl ().SetEventMask (GetRichEditCtrl ().GetEventMask() | (ENM_REQUESTRESIZE | ENM_SCROLL));

	CScrollBar* pScrollBar = ((CMainFrame*) GetTopLevelFrame ())->GetScrollBar ();
	if (pScrollBar->GetSafeHwnd () != NULL && GetRichEditCtrl().GetTextLength () == 0)
	{
		ASSERT_VALID (pScrollBar);
		pScrollBar->EnableScrollBar (ESB_DISABLE_BOTH);
	}

	// Set the printing margins (720 twips = 1/2 inch).
	SetMargins(CRect(720, 720, 720, 720));

	CCharFormat cf;
	GetDefaultFont (cf);

	SetCharFormat (cf);
	SyncFont ();
}
void CBCGPMSOffice2007DemoView::OnFontname() 
{
	USES_CONVERSION;

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

	CBCGPRibbonFontComboBox* pFontCombo = DYNAMIC_DOWNCAST (
		CBCGPRibbonFontComboBox, pRibbon->FindByID (ID_FONT_FONT));
	if (pFontCombo == NULL)
	{
		return;
	}

	CCharFormat cf;
	cf.szFaceName[0] = NULL;
	cf.dwMask = CFM_FACE | CFM_CHARSET;

	const CBCGPFontDesc* pDesc = pFontCombo->GetFontDesc ();
	ASSERT_VALID (pDesc);
	ASSERT(pDesc->m_strName.GetLength() < LF_FACESIZE);

#if _MSC_VER >= 1300
	lstrcpyn(cf.szFaceName, pDesc->m_strName, LF_FACESIZE);
#else
	lstrcpynA(cf.szFaceName,
		T2A((LPTSTR) (LPCTSTR) pDesc->m_strName), LF_FACESIZE);
#endif

	cf.bCharSet = pDesc->m_nCharSet;
	cf.bPitchAndFamily = pDesc->m_nPitchAndFamily;

	SetCharFormat (cf);
}
Esempio n. 8
0
void CEditFrameView::OnFontClear()
{
	GetCharFormatSelection();
	m_charformat.dwMask    = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR;
	m_charformat.dwEffects = CFE_AUTOCOLOR;
	SetCharFormat(m_charformat);
}
Esempio n. 9
0
void CitbookView::OnCharbold()
{
	// TODO: 在此添加命令处理程序代码
	CHARFORMAT2 cf;   
    onCharFormatgetEx(cf,CFM_BOLD,CFE_BOLD);  
    SetCharFormat (cf);
}
Esempio n. 10
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. 11
0
void CBCGPMSOffice2007DemoView::OnFontGrow()
{
	WPD_CHARFORMAT cf = GetCharFormatSelection ();

	cf.yHeight += 20;
	SetCharFormat (cf);
	SyncFont ();
}
Esempio n. 12
0
void CitbookView::OnCharitalic()
{
	// TODO: 在此添加命令处理程序代码

	CHARFORMAT2 cf;   
    onCharFormatgetEx(cf,CFM_ITALIC,CFE_ITALIC);  
    SetCharFormat (cf);

}
Esempio n. 13
0
void CBCGPMSOffice2007DemoView::OnFontShrink()
{
	WPD_CHARFORMAT cf = GetCharFormatSelection ();
	if (cf.yHeight <= 20)
	{
		return;
	}

	cf.yHeight -= 20;
	SetCharFormat (cf);
	SyncFont ();
}
Esempio n. 14
0
void CMSOffice2007DemoView::OnInitialUpdate()
{
	CRichEditView::OnInitialUpdate();

	// Set the printing margins(720 twips = 1/2 inch).
	SetMargins(CRect(720, 720, 720, 720));

	CCharFormat cf;
	GetDefaultFont(cf);

	SetCharFormat(cf);
	SyncFont();
}
void CMyRichEditView::OnCharUnderline ()
{
    CHARFORMAT2 cf;
    cf = GetCharFormatSelection();

    if (!(cf.dwMask & CFM_UNDERLINE) || !(cf.dwEffects & CFE_UNDERLINE))
        cf.dwEffects = CFE_UNDERLINE;
    else
        cf.dwEffects = 0;

    cf.dwMask = CFM_UNDERLINE;
    SetCharFormat(cf);
}
Esempio n. 16
0
void CMSOffice2007DemoView::OnInsertTableGallery()
{
	if (CRibbonTableButton::GetRows() > 0 && CRibbonTableButton::GetColumns() > 0)
	{
		CString str;
		str.Format(_T("Demo: insert %dx%d table"), CRibbonTableButton::GetColumns(), CRibbonTableButton::GetRows());

		MessageBox(str);

		WPD_CHARFORMAT cf = GetCharFormatSelection();
		InsertBitmap(IDB_TABLE);
		SetCharFormat (cf);
		SyncFont ();
	}
}
Esempio n. 17
0
void CEditFrameView::OnInitialUpdate()
{
	CRichEditView::OnInitialUpdate();

	// Set the printing margins (720 twips = 1/2 inch).
	SetMargins(CRect(720, 720, 720, 720));

	OnFontName ();
	OnFontSize ();

	CCharFormat cf;
	cf.dwMask    = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_COLOR;
	cf.dwEffects = CFE_AUTOCOLOR;
	SetCharFormat (cf);
}
Esempio n. 18
0
void CFormatBar::OnFontNameKillFocus()
{
	// get the current font from the view and update
	NotifyOwner(NM_KILLFOCUS);

	CCharFormat cf;
	cf.szFaceName[0] = NULL;

	// this will retrieve the font entered in the edit control
	// it tries to match the font to something already present in the combo box
	// this effectively ignores case of a font the user enters
	// if a user enters arial, this will cause it to become Arial
	CString str;
	m_comboFontName.GetTheText(str);    // returns "arial"
	m_comboFontName.SetTheText(str);                    // selects "Arial"
	m_comboFontName.GetTheText(str);    // returns "Arial"

	// if font name box is not empty
	if (str[0] != NULL)
	{
		cf.dwMask = CFM_FACE | CFM_CHARSET;
		int nIndex = m_comboFontName.FindStringExact(-1, str);
		if (nIndex != CB_ERR)
		{
			CFontDesc* pDesc = (CFontDesc*)m_comboFontName.GetItemData(nIndex);
			ASSERT(pDesc != NULL);
			ASSERT(pDesc->m_strName.GetLength() < LF_FACESIZE);
			lstrcpynA(cf.szFaceName,
				(LPTSTR) (LPCTSTR) pDesc->m_strName, LF_FACESIZE);
			cf.bCharSet = pDesc->m_nCharSet;
			cf.bPitchAndFamily = pDesc->m_nPitchAndFamily;
		}
		else // unknown font
		{
			ASSERT(str.GetLength() < LF_FACESIZE);
			lstrcpynA(cf.szFaceName,
				(LPTSTR) (LPCTSTR) str, LF_FACESIZE);
			cf.bCharSet = DEFAULT_CHARSET;
			cf.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
		}
		SetCharFormat(cf);
	}
}
Esempio n. 19
0
void CMSOffice2007DemoView::OnFontname()
{
	USES_CONVERSION;

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

	CMFCRibbonFontComboBox* pFontCombo = DYNAMIC_DOWNCAST(CMFCRibbonFontComboBox, pRibbon->FindByID(ID_FONT_FONT));
	if (pFontCombo == NULL)
	{
		return;
	}

	CString strWarning;
	CString strFontName = pFontCombo->GetEditText();
	if (pFontCombo->FindItem(strFontName) == -1)
	{
		// Restore current name:
		pFontCombo->SetEditText (GetCharFormatSelection ().szFaceName);
		strWarning.Format(CString((LPCTSTR)ID_FONT_NOT_FOUND), strFontName);
		AfxMessageBox(strWarning, MB_OK | MB_ICONWARNING);
		return;
	}

	CCharFormat cf;
	cf.szFaceName[0] = NULL;
	cf.dwMask = CFM_FACE | CFM_CHARSET;

	const CMFCFontInfo* pDesc = pFontCombo->GetFontDesc();
	ASSERT_VALID(pDesc);
	ASSERT(pDesc->m_strName.GetLength() < LF_FACESIZE);

#if _MSC_VER >= 1300
	lstrcpyn(cf.szFaceName, pDesc->m_strName, LF_FACESIZE);
#else
	lstrcpynA(cf.szFaceName, T2A((LPTSTR)(LPCTSTR) pDesc->m_strName), LF_FACESIZE);
#endif

	cf.bCharSet = pDesc->m_nCharSet;
	cf.bPitchAndFamily = pDesc->m_nPitchAndFamily;

	SetCharFormat(cf);
}
Esempio n. 20
0
void CFormatBar::OnFontSizeKillFocus()
{
	NotifyOwner(NM_KILLFOCUS);
	int nSize = m_comboFontSize.GetTwipSize();
	if (nSize == -2)
	{
		nSize = m_comboFontSize.m_nTwipsLast;
	}
	else if ((nSize >= 0 && nSize < 20) || nSize > 32760)
	{
		nSize = m_comboFontSize.m_nTwipsLast;
	}
	else if (nSize > 0)
	{
		CCharFormat cf;
		cf.dwMask = CFM_SIZE;
		cf.yHeight = nSize;
		SetCharFormat(cf);
	}
}
Esempio n. 21
0
BOOL CBCGPMSOffice2007DemoView::InsertBitmap (UINT uiBmpResID)
{
	CWaitCursor wait;

	CBitmap bmp;
	if (!bmp.LoadBitmap(uiBmpResID))
	{
		return FALSE;
	}
	
	COleDataSource* pDataSrc = new COleDataSource;
	COleDataObject* pData = new COleDataObject;
	
	CBCGPMSOffice2007DemoCntrItem* pItem = NULL;
	
	TRY
	{
		WPD_CHARFORMAT cf = GetCharFormatSelection();

		STGMEDIUM stgm;
		stgm.hGlobal = bmp.GetSafeHandle();
		stgm.tymed = TYMED_GDI;
		stgm.pUnkForRelease = NULL;

		pDataSrc->CacheData (CF_BITMAP, &stgm);
		
		LPDATAOBJECT lpdata;

		if (FAILED (pDataSrc->m_xDataObject.QueryInterface (IID_IDataObject,
			(LPVOID FAR*) &lpdata)))
		{
			AfxThrowUserException();
		}
		
		pData->Attach (lpdata);
		
		CBCGPMSOffice2007DemoDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		pItem = new CBCGPMSOffice2007DemoCntrItem (NULL, pDoc);
		ASSERT_VALID(pItem);

		if (!pItem->CreateStaticFromData (pData))
		{
			AfxThrowUserException();
		}
		
		pItem->m_uiCategoryID = uiBmpResID;
		InsertItem (pItem);

		pDoc->UpdateAllViews (this);

		SetCharFormat (cf);
		SyncFont ();
	}
	CATCH(CException, e)
	{
		if (pItem != NULL)
		{
			ASSERT_VALID(pItem);
			pItem->Delete ();
		}

		delete pData;
		delete pDataSrc;

		return FALSE;
	}
	END_CATCH

	delete pData;
	delete pDataSrc;

	CMainFrame* pMainFrame = ((CMainFrame*) GetTopLevelFrame ());
	ASSERT_VALID (pMainFrame);

	pMainFrame->ActivateRibbonContextCategory (uiBmpResID);

	return TRUE;
}
Esempio n. 22
0
void CitbookView::OnSetCharFormat(NMHDR* pNMHDR, LRESULT* pRes)
{
	SetCharFormat(((CHARNMHDR*)pNMHDR)->cf);
	*pRes =1;
}
Esempio n. 23
0
// 设置字体信息
void CitbookView::onCharFormatsetEx(CHARFORMAT2& cf)
{
	SetCharFormat(cf);
}