void CAutoRichEditCtrl::SetParagraphBulleted()
{
	PARAFORMAT paraformat = GetParagraphFormat();

	if ( (paraformat.dwMask & PFM_NUMBERING) && (paraformat.wNumbering == PFN_BULLET) )
	{
		paraformat.wNumbering = 0;
		paraformat.dxOffset = 0;
		paraformat.dxStartIndent = 0;
		paraformat.dwMask = PFM_NUMBERING | PFM_STARTINDENT | PFM_OFFSET;
	}
	else
	{
		paraformat.wNumbering = PFN_BULLET;
		paraformat.dwMask = PFM_NUMBERING;
		if (paraformat.dxOffset == 0)
		{
			paraformat.dxOffset = 4;
			paraformat.dwMask = PFM_NUMBERING | PFM_STARTINDENT | PFM_OFFSET;
		}
	}
	
	SetParaFormat(paraformat);

}
예제 #2
0
BOOL CScriptEditView::SetTabStopWidth()
{
	CClientDC dc( *this );
	HFONT hOldFont = dc.SelectFont(m_font);

	TEXTMETRIC tm;
	dc.GetTextMetrics( &tm );
	int nLogPix = dc.GetDeviceCaps( LOGPIXELSX );
	dc.SelectFont(hOldFont);

	// 1440 twips = 1 inch
	int cxTab = ::MulDiv( tm.tmAveCharWidth * m_nTabStop, 1440, nLogPix );
	if(cxTab != -1)
	{
		PARAFORMAT pf;
		pf.cbSize = sizeof( PARAFORMAT );
		pf.dwMask = PFM_TABSTOPS;
		pf.cTabCount = MAX_TAB_STOPS;
		for(int i = 0; i < MAX_TAB_STOPS; i++)
			pf.rgxTabs[i] = (i + 1) * cxTab;
		SetParaFormat( pf );
	}

	return TRUE;
}
예제 #3
0
void CCompileEditView::Initialize() 
{
	PARAFORMAT2 pf;
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS ;
	pf.cTabCount = MAX_TAB_STOPS;
	for( int itab = 0 ; itab < pf.cTabCount  ; itab++ )
		pf.rgxTabs[itab] = (itab + 1) * 1440/5 ;

	SetParaFormat( pf );

	CHARFORMAT2A cfDefault;
	GetRichEditCtrl().GetDefaultCharFormat( cfDefault );
	
	//cfDefault.cbSize = sizeof(cfDefault);
	cfDefault.dwEffects = CFE_BOLD | CFE_PROTECTED; 
	cfDefault.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_STRIKEOUT |
		CFM_PROTECTED | CFM_SIZE | CFM_FACE | CFM_CHARSET;
		
		//CFM_BOLD | CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_PROTECTED ;
	//cfDefault.yHeight = 200;
	cfDefault.bCharSet = GB2312_CHARSET;//GB2312_CHARSET|ANSI_CHARSET|CHINESEBIG5_CHARSET|SYMBOL_CHARSET|DEFAULT_CHARSET|SYMBOL_CHARSET|OEM_CHARSET;//0xEE; 
	strcpy(cfDefault.szFaceName, _T("宋体"));  // Courier New // 宋体

	this->SetCharFormat(cfDefault);

	GetRichEditCtrl().SetDefaultCharFormat(cfDefault);
	GetRichEditCtrl().SetWordCharFormat(cfDefault);	

	GetRichEditCtrl().SetEventMask(ENM_CHANGE | ENM_SELCHANGE | ENM_PROTECTED);
}
예제 #4
0
void CEmoticonRichEditCtrl::Initialize() 
{
	PARAFORMAT pf;
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS ;
	pf.cTabCount = MAX_TAB_STOPS;
	for( int itab = 0 ; itab < pf.cTabCount  ; itab++ )
		pf.rgxTabs[itab] = (itab + 1) * 1440/5 ;

	SetParaFormat( pf );		

	SetEventMask(ENM_CHANGE | ENM_SELCHANGE | ENM_PROTECTED);

	//이모티콘		
	m_imgListFaces.Create(20, 20, ILC_COLOR24|ILC_MASK, 0, 1);	
	m_bmpFaces.LoadBitmap(IDB_BITMAP_EMOTICON);
	m_imgListFaces.Add(& m_bmpFaces, RGB(255, 255, 255));	

	m_pRichEditOle = GetIRichEditOle();

	DragAcceptFiles(TRUE);

	/*
	if(m_nRole == ROLE_SEND_INPUT )
	{	
		CHARFORMAT2 cf;
		GetSelectionCharFormat(cf);
		cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE |CFM_PROTECTED ;		
		cf.crTextColor =  CChatSession::Instance().m_ColorMe;			
		cf.dwEffects &=(unsigned long) ~CFE_AUTOCOLOR;	
		SetDefaultCharFormat(cf);			
	}
	*/
	
}
예제 #5
0
void CRichEditCtrlGS::SetJustify(void)
{ PARAFORMAT pf;    
  pf.cbSize     = sizeof(PARAFORMAT);
  pf.dwMask     = PFM_ALIGNMENT;    
  pf.wAlignment = PFA_JUSTIFY;

  SetParaFormat(pf);	// Set the paragraph.
}
void CAutoRichEditCtrl::SetParagraphCenter()
{
	PARAFORMAT paraFormat;    
	paraFormat.cbSize = sizeof(PARAFORMAT);
	paraFormat.dwMask = PFM_ALIGNMENT;    
	paraFormat.wAlignment = PFA_CENTER;
	
	SetParaFormat(paraFormat);	// Set the paragraph.
}
void CAutoRichEditCtrl::SetParagraphRight()
{
	PARAFORMAT paraFormat;
	paraFormat.cbSize = sizeof(PARAFORMAT);
	paraFormat.dwMask = PFM_ALIGNMENT;    
	paraFormat.wAlignment = PFA_RIGHT;
	
	SetParaFormat(paraFormat);
}
예제 #8
0
//用户表情
bool CRichEditMessage::InsertExpression(LPCTSTR pszSendUser, LPCTSTR pszImagePath, bool bMyselfString)
{
	//获取时间
	SYSTEMTIME SystemTime;
	GetLocalTime(&SystemTime);

	//保存选择
	CHARRANGE CharRange;
	GetSel(CharRange);

	//插入前叠
	TCHAR szTimeString[64]=TEXT("");
	_sntprintf(szTimeString,CountArray(szTimeString),TEXT("\r\n%s [ %02d:%02d:%02d ]\r\n"),pszSendUser,SystemTime.wHour,SystemTime.wMinute,SystemTime.wSecond);
	InsertString(szTimeString,(bMyselfString==true)?COLOR_MYSELF:COLOR_USER);

	//格式数据
	PARAFORMAT2 ParaFormat;
	ZeroMemory(&ParaFormat,sizeof(ParaFormat));
	ParaFormat.cbSize=sizeof(ParaFormat);
	ParaFormat.dwMask=PFM_OFFSETINDENT;
	ParaFormat.dxStartIndent=200L;

	//设置缩进
	SetSel(-1L,-1L);
	SetParaFormat(ParaFormat);

	//插入表情
	InsertImage(pszImagePath);
	InsertString(TEXT("\r\n"),RGB(255,255,255));

	//格式数据
	ParaFormat.dwMask=PFM_OFFSETINDENT;
	ParaFormat.dxStartIndent=-200L;

	//还原格式
	SetSel(-1L,-1L);
	SetParaFormat(ParaFormat);

	//恢复信息
	if (CharRange.cpMax!=CharRange.cpMin) SetSel(CharRange);
	else PostMessage(WM_VSCROLL,SB_BOTTOM,0);

	return true;
}
예제 #9
0
//用户私聊
bool CRichEditMessage::InsertWhisperChat(LPCTSTR pszSendUser, LPCTSTR pszString, COLORREF crColor, bool bMyselfString, const SYSTEMTIME &time)
{
	//保存选择
	CHARRANGE CharRange;
	GetSel(CharRange);

	//插入前叠
	TCHAR szTimeString[64]=TEXT("");
	_sntprintf(szTimeString,CountArray(szTimeString),TEXT("\r\n%s [ %02d:%02d:%02d ]\r\n"),pszSendUser,time.wHour,time.wMinute,time.wSecond);
	InsertString(szTimeString,(bMyselfString==true)?COLOR_MYSELF:COLOR_USER);

	//格式数据
	PARAFORMAT2 ParaFormat;
	ZeroMemory(&ParaFormat,sizeof(ParaFormat));
	ParaFormat.cbSize=sizeof(ParaFormat);
	ParaFormat.dwMask=PFM_OFFSETINDENT;
	ParaFormat.dxStartIndent=200L;

	//设置缩进
	SetSel(-1L,-1L);
	SetParaFormat(ParaFormat);

	//插入语句
	TranslateInsertString(pszString,crColor);
	InsertString(TEXT("\r\n"),crColor);

	//格式数据
	ParaFormat.dwMask=PFM_OFFSETINDENT;
	ParaFormat.dxStartIndent=-200L;

	//还原格式
	SetSel(-1L,-1L);
	SetParaFormat(ParaFormat);

	//恢复信息
	if (CharRange.cpMax!=CharRange.cpMin) SetSel(CharRange);
	else PostMessage(WM_VSCROLL,SB_BOTTOM,0);

	return true;
}
예제 #10
0
void CMSOffice2007DemoView::OnPagelayoutIndentRight()
{
	CMFCRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame())->GetRibbonBar();
	ASSERT_VALID(pRibbon);

	CMFCRibbonEdit* pEdit = DYNAMIC_DOWNCAST(CMFCRibbonEdit, pRibbon->FindByID(ID_PAGELAYOUT_INDENT_RIGHT));

	WPD_PARAFORMAT pf;
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_RIGHTINDENT;
	pf.dxRightIndent = _ttol(pEdit->GetEditText()) * 10;

	SetParaFormat(pf);
}
예제 #11
0
LRESULT LogViewRE::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
  DefWindowProc();

  SetReadOnly();
  mFont.CreateFont(
   20,                  // nHeight
   0,                         // nWidth
   0,                         // nEscapement
   0,                         // nOrientation
   FW_NORMAL,                 // nWeight
   FALSE,                     // bItalic
   FALSE,                     // bUnderline
   0,                         // cStrikeOut
   ANSI_CHARSET,              // nCharSet
   OUT_DEFAULT_PRECIS,        // nOutPrecision
   CLIP_DEFAULT_PRECIS,       // nClipPrecision
   DEFAULT_QUALITY,           // nQuality
   DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
   _T("Consolas")                // font face
   );
  SetFont(mFont);
//  SetFont(AtlGetDefaultGuiFont());
  SetBackgroundColor(LOG_BGCOLOR);

  CHARFORMAT cf = {0};
  cf.cbSize = sizeof(CHARFORMAT);
  cf.crTextColor = LOG_DEFAULTCOLOR;
  cf.yHeight = 200;
  cf.dwMask = CFM_COLOR | CFM_SIZE;
  SetDefaultCharFormat(cf);

  PARAFORMAT2 pf;
  memset(&pf, 0, sizeof(PARAFORMAT2));
  pf.cbSize = sizeof(PARAFORMAT2);
  pf.cTabCount = 2;
  pf.rgxTabs[0] = cf.yHeight * 5;
  pf.rgxTabs[1] = cf.yHeight * 10;
  pf.dwMask = PFM_TABSTOPS;
  SetParaFormat(pf);

  return 0;
}
예제 #12
0
void CRichEditCtrlGS::SetBullet(void)
{ int iFormatted = IsBulleted();
  PARAFORMAT pf;
  pf.cbSize     = sizeof(PARAFORMAT);
  pf.dwMask = PFM_NUMBERING | PFM_STARTINDENT | PFM_OFFSET;
  GetParaFormat(pf);
  
  if( 1 == iFormatted )
	{ pf.wNumbering = 0;
	  pf.dxOffset = 0;
	  pf.dwMask = PFM_NUMBERING | PFM_STARTINDENT | PFM_OFFSET;
	}
  else
	{ pf.wNumbering = PFN_BULLET;
	  pf.dwMask = PFM_NUMBERING;
	  if( pf.dxOffset == 0 )
		{ pf.dxOffset = 160;
		  pf.dwMask = PFM_NUMBERING | PFM_STARTINDENT | PFM_OFFSET;
		}
	}
  SetParaFormat(pf);
}
예제 #13
0
void CTWScriptEdit::Initialize() 
{
	PARAFORMAT pf;
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS ;
	pf.cTabCount = MAX_TAB_STOPS;
	for( int itab = 0 ; itab < pf.cTabCount  ; itab++ )
		pf.rgxTabs[itab] = (itab + 1) * 1440/5 ;

	SetParaFormat( pf );

	CHARFORMAT cfDefault;
	cfDefault.cbSize = sizeof(cfDefault);
	cfDefault.dwEffects = CFE_PROTECTED; 
	cfDefault.dwMask = CFM_BOLD | CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_PROTECTED;
	cfDefault.yHeight = 200;
	cfDefault.bCharSet = 0xEE; 
	strcpy(cfDefault.szFaceName, _T("Courier New")); 

	SetDefaultCharFormat(cfDefault);
	
	SetEventMask(ENM_CHANGE | ENM_SELCHANGE | ENM_PROTECTED);
}
예제 #14
0
void ChatCtrl::AppendText(const Identity& i, const tstring& sMyNick, const tstring& sTime, tstring sMsg, CHARFORMAT2& cf, bool bUseEmo/* = true*/) {
	SetRedraw(FALSE);

	SCROLLINFO si = { 0 };
	POINT pt = { 0 };

	si.cbSize = sizeof(si);
	si.fMask = SIF_PAGE | SIF_RANGE | SIF_POS;
	GetScrollInfo(SB_VERT, &si);
	GetScrollPos(&pt);

	LONG lSelBegin = 0, lSelEnd = 0, lTextLimit = 0, lNewTextLen = 0;
	LONG lSelBeginSaved, lSelEndSaved;

	// Unify line endings
	tstring::size_type j = 0; 
	while((j = sMsg.find(_T("\r"), j)) != tstring::npos)
		sMsg.erase(j, 1);

	GetSel(lSelBeginSaved, lSelEndSaved);
	lSelEnd = lSelBegin = GetTextLengthEx(GTL_NUMCHARS);

	bool isMyMessage = i.getUser() == ClientManager::getInstance()->getMe();
	tstring sLine = sTime + sMsg;

	// Remove old chat if size exceeds
	lNewTextLen = sLine.size();
	lTextLimit = GetLimitText();

	if(lSelEnd + lNewTextLen > lTextLimit) {
		LONG lRemoveChars = 0;
		int multiplier = 1;

		if(lNewTextLen >= lTextLimit) {
			lRemoveChars = lSelEnd;
			magnets.clear();
		} else {
			while(lRemoveChars < lNewTextLen)
				lRemoveChars = LineIndex(LineFromChar(multiplier++ * lTextLimit / 10));
		}

		if(magnets.size()) {
			tstring buf;
			buf.resize(lRemoveChars);
			GetTextRange(0, lRemoveChars, &buf[0]);

			CHARFORMAT2 cfSel;
			cfSel.cbSize = sizeof(CHARFORMAT2);

			for(TStringMap::iterator i = magnets.begin(); i != magnets.end();) {
				tstring::size_type j = 0;
				while((j = buf.find(i->first, j)) != tstring::npos) {
					SetSel(j, j + i->first.size());
					GetSelectionCharFormat(cfSel);
					if(cfSel.dwEffects & CFE_LINK) {
						magnets.erase(i++);
						break;
					}
					j += i->first.size();
				} if(j == tstring::npos) {
					++i;
				}
			}
		}

		// Update selection ranges
		lSelEnd = lSelBegin -= lRemoveChars;
		lSelEndSaved -= lRemoveChars;
		lSelBeginSaved -= lRemoveChars;

		// ...and the scroll position
		pt.y -= PosFromChar(lRemoveChars).y;

		SetSel(0, lRemoveChars);
		ReplaceSel(_T(""));
	}


	// Add to the end
	SetSel(lSelBegin, lSelEnd);
	setText(sLine);

	CHARFORMAT2 enc;
	enc.bCharSet = RUSSIAN_CHARSET;
	enc.dwMask = CFM_CHARSET;

	SetSel(0, sLine.length());
	SetSelectionCharFormat(enc);

	// Format TimeStamp
	if(!sTime.empty()) {
		lSelEnd += sTime.size();
		SetSel(lSelBegin, lSelEnd - 1);
		SetSelectionCharFormat(WinUtil::m_TextStyleTimestamp);

		PARAFORMAT2 pf;
		memzero(&pf, sizeof(PARAFORMAT2));
		pf.dwMask = PFM_STARTINDENT; 
		pf.dxStartIndent = 0;
		SetParaFormat(pf);
	}

	// Authors nick
	tstring sAuthor = Text::toT(i.getNick());
	if(!sAuthor.empty()) {
		LONG iLen = (sMsg[0] == _T('*')) ? 1 : 0;
		LONG iAuthorLen = sAuthor.size() + 1;
		sMsg.erase(0, iAuthorLen + iLen);
   		
		lSelBegin = lSelEnd;
		lSelEnd += iAuthorLen + iLen;
		
		if(isMyMessage) {
			SetSel(lSelBegin, lSelBegin + iLen + 1);
			SetSelectionCharFormat(WinUtil::m_ChatTextMyOwn);
			SetSel(lSelBegin + iLen + 1, lSelBegin + iLen + iAuthorLen);
			SetSelectionCharFormat(WinUtil::m_TextStyleMyNick);
		} else {
			bool isFavorite = FavoriteManager::getInstance()->isFavoriteUser(i.getUser());

			if(BOOLSETTING(BOLD_AUTHOR_MESS) || isFavorite || i.isOp()) {
				SetSel(lSelBegin, lSelBegin + iLen + 1);
				SetSelectionCharFormat(cf);
				SetSel(lSelBegin + iLen + 1, lSelEnd);
				if(isFavorite){
					SetSelectionCharFormat(WinUtil::m_TextStyleFavUsers);
				} else if(i.isOp()) {
					SetSelectionCharFormat(WinUtil::m_TextStyleOPs);
				} else {
					SetSelectionCharFormat(WinUtil::m_TextStyleBold);
				}
			} else {
				SetSel(lSelBegin, lSelEnd);
				SetSelectionCharFormat(cf);
            }
		}
	} else {
		bool thirdPerson = false;
        switch(sMsg[0]) {
			case _T('*'):
				if(sMsg[1] != _T(' ')) break;
				thirdPerson = true;
            case _T('<'):
				tstring::size_type iAuthorLen = sMsg.find(thirdPerson ? _T(' ') : _T('>'), thirdPerson ? 2 : 1);
				if(iAuthorLen != tstring::npos) {
                    bool isOp = false, isFavorite = false;

                    if(client != NULL) {
						tstring nick(sMsg.c_str() + 1);
						nick.erase(iAuthorLen - 1);
						
						const OnlineUserPtr ou = client->findUser(Text::fromT(nick));
						if(ou != NULL) {
							isFavorite = FavoriteManager::getInstance()->isFavoriteUser(ou->getUser());
							isOp = ou->getIdentity().isOp();
						}
                    }
                    
					lSelBegin = lSelEnd;
					lSelEnd += iAuthorLen;
					sMsg.erase(0, iAuthorLen);

        			if(BOOLSETTING(BOLD_AUTHOR_MESS) || isFavorite || isOp) {
        				SetSel(lSelBegin, lSelBegin + 1);
        				SetSelectionCharFormat(cf);
						SetSel(lSelBegin + 1, lSelEnd);
						if(isFavorite){
							SetSelectionCharFormat(WinUtil::m_TextStyleFavUsers);
						} else if(isOp) {
							SetSelectionCharFormat(WinUtil::m_TextStyleOPs);
						} else {
							SetSelectionCharFormat(WinUtil::m_TextStyleBold);
						}
        			} else {
        				SetSel(lSelBegin, lSelEnd);
        				SetSelectionCharFormat(cf);
                    }
				}
        }
	}
				   			
	// Format the message part
	FormatChatLine(sMyNick, sMsg, cf, isMyMessage, sAuthor, lSelEnd, bUseEmo);

	SetSel(lSelBeginSaved, lSelEndSaved);
	if(	isMyMessage || ((si.nPage == 0 || (size_t)si.nPos >= (size_t)si.nMax - si.nPage - 5) &&
		(lSelBeginSaved == lSelEndSaved || !selectedUser.empty() || !selectedIP.empty() || !selectedURL.empty())))
	{
		PostMessage(EM_SCROLL, SB_BOTTOM, 0);
	} else {
		SetScrollPos(&pt);
	}

	// Force window to redraw
	SetRedraw(TRUE);
	InvalidateRect(NULL);
}
예제 #15
0
파일: RichMsgView.cpp 프로젝트: bugou/test
void CRichMsgView::appendMsg(IcqMsg &msg, COLORREF color)
{
	const char *nick = "";

	if (!msg.id) {
		IcqContact *c = icqLink->findContact(msg.qid);
		if (c)
			nick = c->nick.c_str();
	} else {
		IcqGroup *g = icqLink->findGroup(msg.id);
		if (g) {
			GroupMember *m = g->getMemberInfo(msg.qid.uin);
			if (m)
				nick = m->nick.c_str();
		}
	}

	long start, end;
	SetSel(-1, -1);
	GetSel(start, end);

	CHARFORMAT defFormat;
	defFormat.cbSize = sizeof(defFormat);
	defFormat.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_FACE | CFM_SIZE | CFM_COLOR;
	GetDefaultCharFormat(defFormat);

	PARAFORMAT pf;
	pf.cbSize = sizeof(pf);
	pf.dwMask = PFM_STARTINDENT;
	pf.dxStartIndent = 0;
	SetParaFormat(pf);

	CHARFORMAT cf;
	cf.cbSize = sizeof(cf);

	CString text;
	CString strTime = CTime(msg.when).Format("%H:%M:%S");
	text.Format("%s (%s): \r\n",
		(msg.flags & MF_RECEIVED) ? nick : icqLink->myInfo.nick.c_str(),
		(LPCTSTR) strTime);

	ReplaceSel(text);
	SetSel(start, -1);
	cf = defFormat;
	cf.crTextColor = color;
	cf.dwEffects = 0;
	SetSelectionCharFormat(cf);

	SetSel(-1, -1);
	insertMsg(msg);

	pf.dxStartIndent = 200;
	SetParaFormat(pf);

	uint8 mask = (MF_RELAY | MF_RECEIVED);
	if ((msg.flags & mask) == mask) {
		GetSel(start, end);

		text.LoadString(IDS_SERVER_RELAY);
		ReplaceSel("\r\n");
		ReplaceSel(text);
		SetSel(start, -1);

		cf = defFormat;
		cf.crTextColor = color;
		cf.dwEffects = 0;
		SetSelectionCharFormat(cf);
	}

	SetSel(-1, -1);
	ReplaceSel("\r\n");

	scrollToBottom();
}
/*
================
CSyntaxRichEditCtrl::InitFont
================
*/
void CSyntaxRichEditCtrl::InitFont(void)
{
	LOGFONT lf;
	CFont font;
	PARAFORMAT pf;
	int logx, tabSize;

	// set the font
	memset(&lf, 0, sizeof(lf));
	lf.lfHeight = FONT_HEIGHT * 10;
	lf.lfWidth = FONT_WIDTH * 10;
	lf.lfCharSet = ANSI_CHARSET;
	lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
	strcpy(lf.lfFaceName, FONT_NAME);
	font.CreatePointFontIndirect(&lf);

	SetFont(&font);

	// get the tab size in twips
	logx = ::GetDeviceCaps(GetDC()->GetSafeHdc(), LOGPIXELSX);
	tabSize = TAB_SIZE * FONT_WIDTH * 1440 / logx;

	// set the tabs
	memset(&pf, 0, sizeof(PARAFORMAT));
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS;

	for (pf.cTabCount = 0; pf.cTabCount < MAX_TAB_STOPS; pf.cTabCount++) {
		pf.rgxTabs[pf.cTabCount] = pf.cTabCount * tabSize;
	}

	SetParaFormat(pf);

	memset(&defaultCharFormat, 0, sizeof(defaultCharFormat));
	defaultCharFormat.dwMask = CFM_CHARSET | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_COLOR | CFM_PROTECTED | CFM_BACKCOLOR;
	defaultCharFormat.yHeight = FONT_HEIGHT * 20;
	defaultCharFormat.bCharSet = ANSI_CHARSET;
	defaultCharFormat.bPitchAndFamily = FIXED_PITCH | FF_MODERN;
	defaultCharFormat.crTextColor = SRE_COLOR_BLACK;
	defaultCharFormat.crBackColor = DEFAULT_BACK_COLOR;
	defaultCharFormat.dwEffects = CFE_PROTECTED;
	strcpy(defaultCharFormat.szFaceName, FONT_NAME);
	defaultCharFormat.cbSize = sizeof(defaultCharFormat);

	SetDefaultCharFormat(defaultCharFormat);

	defaultColor = SRE_COLOR_BLACK;
	singleLineCommentColor = SRE_COLOR_DARK_GREEN;
	multiLineCommentColor = SRE_COLOR_DARK_GREEN;
	stringColor[0] = stringColor[1] = SRE_COLOR_DARK_CYAN;
	literalColor = SRE_COLOR_GREY;
	braceHighlightColor = SRE_COLOR_RED;

	// get the default tom::ITextFont
	tom::ITextRange *irange;
	tom::ITextFont *ifont;

	m_TextDoc->Range(0, 0, &irange);
	irange->get_Font(&ifont);

	ifont->get_Duplicate(&m_DefaultFont);

	ifont->Release();
	irange->Release();
}
예제 #17
0
void CSMLStatic::InsertDocument()
{
	if(FALSE == ::IsWindow(m_hWnd)) {
		return;
	}

	CSMLDoc::CSMLTextGroup				*group;
	CSMLDoc::CSMLTextGroup::CSMLTextBlock	*blk;
	int			grpCount;
	int			grpIndex;
	int			blkCount;
	int			blkIndex;

	// Make sure we can insert text to the rich edit control
	SetReadOnly(FALSE);
	SetSel(0, -1);
	Clear();

	// If a SML document is not present, set the plain text and return
	if(NULL == m_Document) {
		ReplaceSel(m_Text, FALSE);
		return;
	}

	// Set the background color to the document
	SetBackgroundColor(FALSE, m_Document->GetBkgndColor());

	// Step through all text groups
	grpCount = m_Document->GetGroupCount();
	for(grpIndex = 0; grpIndex < grpCount; grpIndex++) {
		PARAFORMAT	format;
		DWORD		style;
		group = m_Document->GetTextGroup(grpIndex);

		blkCount = group->GetBlockCount();

		// Get the default font information for the group
		format.cbSize = sizeof(format);
		format.dwMask = PFM_ALIGNMENT;
		format.wAlignment = PFA_LEFT;

		// Step through all text blocks for the group and collect the
		// text justification
		for(blkIndex = 0; blkIndex < blkCount; blkIndex++) {
			blk = group->GetBlock(blkIndex);

			// Process the style information
			style = blk->GetStyle() & JUSTIFY_MASK;

			if(0 != style) {
				switch(style) {
				case JUSTIFY_LEFT:
					format.wAlignment =	PFA_LEFT;
					break;
				case JUSTIFY_CENTER:
					format.wAlignment =	PFA_CENTER;
					break;
				case JUSTIFY_RIGHT:
					format.wAlignment =	PFA_RIGHT;
					break;
				default:
					ASSERT(0);
				}
				break;
			}
		}
		
		// Set the paragraph font and style information
		SetParaFormat(format);


		// Step through all text blocks and insert the text
		for(blkIndex = 0; blkIndex < blkCount; blkIndex++) {
			CHARFORMAT	charFmt;
			CString		typeface;

			blk = group->GetBlock(blkIndex);
			

			// Create the text block font formatting information for the
			// rich edit control
			charFmt.cbSize = sizeof(charFmt);
			charFmt.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_SIZE | CFM_COLOR;
			charFmt.dwEffects = 0;
			charFmt.yHeight = blk->GetPointSize() * 20;
			charFmt.crTextColor = blk->GetColor();

			// Add typeface
			typeface = blk->GetTypeface();
			if(0 == typeface.GetLength()) {
				typeface = m_Document->GetTypeface();
			}
			
			if(typeface.GetLength() >= LF_FACESIZE) {
				TRACE1("Typeface %s is too long for CHARFORMAT member\n", typeface.GetBuffer(0));
			} else {
				strcpy(charFmt.szFaceName, typeface);
				charFmt.bPitchAndFamily = FF_DONTCARE;
				charFmt.dwMask |= CFM_FACE;
			}

			// Add style
			style = blk->GetStyle();
			if(style & STYLE_BOLD) {
				charFmt.dwEffects |= CFE_BOLD;
			}

			if(style & STYLE_ITALICS) {
				charFmt.dwEffects |= CFE_ITALIC;
			}

			if(style & STYLE_UNDERLINE) {
				charFmt.dwEffects |= CFE_UNDERLINE;
			}

			SetSelectionCharFormat(charFmt);
			
			ReplaceSel(blk->GetText(), FALSE);
		}

		ReplaceSel("\n", FALSE);
	}


	SetReadOnly(TRUE);
}