⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cedtviewdraw.cpp

📁 Crimson编辑器的英文版,完成从韩文版变成英文版的移植,并且附带可执行文件和注册表文件,无需原先的安装包,是改写编辑器的最理想选择.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
					if( cType != WT_RETURN && cType != WT_TAB && cType != WT_SPACE ) {
						// set font to italic
						if( m_bItalicizeComment && (bLineComment || bBlockComment || cType2 == WT_LINECOMMENT) ) pDC->SelectObject( & m_fontPrinterIt );

						pDC->TextOut(rect.left+nPosX, -(rect.top+nPosY), (LPCTSTR)rLine + rWord.m_sIndex, rWord.m_sLength);

						if( m_bEmboldenKeywords && ! bLineComment && ! bBlockComment && ! bShadow && ! bQuotation1 && ! bQuotation2 && ! bQuotation3
							&& _IS_BET(WT_KEYWORD0, cType, WT_KEYWORD9) && _CheckRange(bRange1, bRange2, cRange) ) 
							pDC->TextOut(rect.left+nPosX+nAveCharWidth/8, -(rect.top+nPosY), (LPCTSTR)rLine + rWord.m_sIndex, rWord.m_sLength);

						// restore font from italic
						if( m_bItalicizeComment && (bLineComment || bBlockComment || cType2 == WT_LINECOMMENT) ) pDC->SelectObject( & m_fontPrinter );
					}
				}
			}
		} else if( sInfoFlags & LT_HASRANGE || sInfoFlags & LT_HASCOMMENT || sInfoFlags & LT_HASHIGHLIGHT || sInfoFlags & LT_HASQUOTATION ) {
			for(sWordCount = 0; sWordCount < rLine.m_sWordCount; sWordCount++) {
				FORMATEDWORDINFO & rWord = rLine.m_pWordInfo[sWordCount];
				cType = rWord.m_cType; cRange = rWord.m_cRange; 

				if( _IS_BET(WT_RANGE1BEG, cType, WT_RANGE2END) ||
					_IS_BET(WT_LINECOMMENT, cType, WT_COMMENTOFF) ||
					_IS_BET(WT_SHADOWON, cType, WT_HIGHLIGHTOFF) ||
					_IS_BET(WT_QUOTATION1, cType, WT_QUOTATION3) )
					_CheckType(cType, cRange, bQuotation1, bQuotation2, bQuotation3, bLineComment, bBlockComment, bHighlight, bShadow, bRange1, bRange2);
			}
		}

		nLineCount++;
		if( sLineSplitIndex == 0 ) nParaCount++;
	}
}


void CCedtView::DrawActiveLineHighlight()
{
	RECT rect; GetClientRect( & rect );
	INT nCharHeight = GetCharHeight();
	INT nLeftMargin = GetLeftMargin();
	INT nPosY = m_nCaretPosY - m_nScrollPosY;

	if( nPosY >= 0 && nPosY <= rect.bottom ) {
		INT nLineWidth  = rect.right - nLeftMargin;
	//	INT nLineHeight = GetLineHeight();

		m_dcActiveLine.BitBlt(nLeftMargin, nCharHeight+1, nLineWidth, nCharHeight+1, & m_dcScreen, nLeftMargin, nPosY, SRCCOPY);

		m_dcActiveLine.FillSolidRect(nLeftMargin, 0, nLineWidth, nCharHeight, m_crBkgrColor[0]);
		m_dcActiveLine.BitBlt(nLeftMargin, nCharHeight+1, nLineWidth, nCharHeight+1, & m_dcActiveLine, nLeftMargin, 0, SRCINVERT);
		m_dcActiveLine.FillSolidRect(nLeftMargin, 0, nLineWidth, nCharHeight, m_crBkgrColor[2]);
		m_dcActiveLine.BitBlt(nLeftMargin, nCharHeight+1, nLineWidth, nCharHeight+1, & m_dcActiveLine, nLeftMargin, 0, SRCINVERT);

		if( m_bHighlightActiveLine ) {
			for(INT i = nLeftMargin; i < rect.right; i += 2) {
				m_dcActiveLine.SetPixelV(i, nCharHeight+1, m_crTextColor[WT_WORD]);
				m_dcActiveLine.SetPixelV(i, nCharHeight+1+nCharHeight, m_crTextColor[WT_WORD]);
			}
		}

		m_dcActiveLine.BitBlt(nLeftMargin, 0, nLineWidth, nCharHeight+1, & m_dcScreen, nLeftMargin, nPosY, SRCCOPY);
		m_dcScreen.BitBlt(nLeftMargin, nPosY, nLineWidth, nCharHeight+1, & m_dcActiveLine, nLeftMargin, nCharHeight+1, SRCCOPY);

		m_bActiveLineHighlighted = TRUE;
		m_nActiveLineHighlightedPosY = nPosY;
	} else {
		m_bActiveLineHighlighted = FALSE;
		m_nActiveLineHighlightedPosY = 0;
	}
}

void CCedtView::DrawColumnMarkerHighlight()
{
	RECT rect; GetClientRect( & rect );
	INT nLeftMargin = GetLeftMargin();
	INT nAveCharWidth = GetAveCharWidth();
	INT nPosX, nPosY;

	nPosX = nLeftMargin + m_nColumnMarker1Pos * nAveCharWidth - m_nScrollPosX;
	if( m_bShowColumnMarker1 && (nPosX >= nLeftMargin && nPosX <= rect.right) ) {
		for( nPosY = 0; nPosY < rect.bottom; nPosY += 2 ) m_dcScreen.SetPixelV(nPosX, nPosY, m_crTextColor[WT_WORD]);
	}

	nPosX = nLeftMargin + m_nColumnMarker2Pos * nAveCharWidth - m_nScrollPosX;
	if( m_bShowColumnMarker2 && (nPosX >= nLeftMargin && nPosX <= rect.right) ) {
		for( nPosY = 0; nPosY < rect.bottom; nPosY += 2 ) m_dcScreen.SetPixelV(nPosX, nPosY, m_crTextColor[WT_WORD]);
	}
}

void CCedtView::DrawScreenBookmark(INT nPosX, INT nPosY, INT nWidth, INT nHeight)
{
	POINT points[4];
	points[0].x = nPosX;			points[0].y = nPosY;
	points[1].x = nPosX + nWidth;	points[1].y = nPosY + nHeight / 2;
	points[2].x = nPosX;			points[2].y = nPosY + nHeight;

	CPen * penOld, pen(PS_SOLID, 1, RGB(0, 0, 0));
	CBrush * brushOld, brush(RGB(0, 255, 0));
	penOld = m_dcScreen.SelectObject( & pen );
	brushOld = m_dcScreen.SelectObject( & brush );
	m_dcScreen.FillSolidRect(nPosX, nPosY, nWidth, nHeight, m_crBkgrColor[1]);
	m_dcScreen.Polygon( points, 3 );
	m_dcScreen.SelectObject( penOld );
	m_dcScreen.SelectObject( brushOld );
}

void CCedtView::DrawScreenUnderbar(INT nPosX, INT nPosY, INT nWidth, INT nHeight)
{
	CPen * penOld, pen(PS_SOLID, 1, RGB(255, 0, 0));
	penOld = m_dcScreen.SelectObject( & pen );

	if( nHeight == 0 ) nHeight = 1;
	INT i, nCount = nWidth / nHeight;

	m_dcScreen.MoveTo(nPosX, nPosY);
	for(i = 1; i <= nCount; i++) {
		m_dcScreen.LineTo(nPosX + i * nHeight, (i % 2) ? nPosY - nHeight : nPosY);
	}

	m_dcScreen.SelectObject( penOld );
}

void CCedtView::DrawScreenSpace(INT nPosX, INT nPosY, INT nWidth, INT nHeight)
{
	m_dcScreen.SetPixelV( nPosX + nWidth / 2,     nPosY + nHeight / 2,     RGB(127, 127, 127) );
	m_dcScreen.SetPixelV( nPosX + nWidth / 2,     nPosY + nHeight / 2 - 1, RGB(127, 127, 127) );
	m_dcScreen.SetPixelV( nPosX + nWidth / 2 - 1, nPosY + nHeight / 2 - 1, RGB(127, 127, 127) );
	m_dcScreen.SetPixelV( nPosX + nWidth / 2 - 1, nPosY + nHeight / 2,     RGB(127, 127, 127) );
}

void CCedtView::DrawScreenTabChar(INT nPosX, INT nPosY, INT nWidth, INT nHeight)
{
	if( nWidth < 8 ) nWidth = 8;
	INT nCenY = nPosY + nHeight / 2;
	INT nDelY = 4 * nWidth / 8;

	CPen * penOld, pen(PS_SOLID, 1, RGB(127, 127, 127));
	penOld = m_dcScreen.SelectObject( & pen );

	m_dcScreen.MoveTo(nPosX + 4 * nWidth / 8, nCenY);
	m_dcScreen.LineTo(nPosX + 0 * nWidth / 8, nCenY - nDelY);
	m_dcScreen.MoveTo(nPosX + 4 * nWidth / 8, nCenY);
	m_dcScreen.LineTo(nPosX + 0 * nWidth / 8, nCenY + nDelY);

	m_dcScreen.MoveTo(nPosX + 7 * nWidth / 8, nCenY);
	m_dcScreen.LineTo(nPosX + 3 * nWidth / 8, nCenY - nDelY);
	m_dcScreen.MoveTo(nPosX + 7 * nWidth / 8, nCenY);
	m_dcScreen.LineTo(nPosX + 3 * nWidth / 8, nCenY + nDelY);

	m_dcScreen.SelectObject( penOld );
}

void CCedtView::DrawScreenLineBreak(INT nPosX, INT nPosY, INT nWidth, INT nHeight)
{
	if( nWidth < 8 ) nWidth = 8;

	CPen * penOld, pen(PS_SOLID, 1, RGB(127, 127, 127));
	penOld = m_dcScreen.SelectObject( & pen );

	m_dcScreen.Arc(nPosX +  1 * nWidth / 8, nPosY + 2 * nHeight / 10,
				   nPosX +  9 * nWidth / 8, nPosY + 6 * nHeight / 10,
				   nPosX +  6 * nWidth / 8, nPosY + 2 * nHeight / 10,
				   nPosX +  7 * nWidth / 8, nPosY + 6 * nHeight / 10);

	m_dcScreen.MoveTo(nPosX +  6 * nWidth / 8, nPosY + 2 * nHeight / 10);
	m_dcScreen.LineTo(nPosX +  6 * nWidth / 8, nPosY + 8 * nHeight / 10);
	m_dcScreen.MoveTo(nPosX +  8 * nWidth / 8, nPosY + 2 * nHeight / 10);
	m_dcScreen.LineTo(nPosX +  8 * nWidth / 8, nPosY + 8 * nHeight / 10);

	m_dcScreen.MoveTo(nPosX +  9 * nWidth / 8, nPosY + 2 * nHeight / 10);
	m_dcScreen.LineTo(nPosX +  6 * nWidth / 8, nPosY + 2 * nHeight / 10); 
	m_dcScreen.MoveTo(nPosX +  9 * nWidth / 8, nPosY + 8 * nHeight / 10);
	m_dcScreen.LineTo(nPosX +  3 * nWidth / 8, nPosY + 8 * nHeight / 10); 

	m_dcScreen.SelectObject( penOld );
}


void CCedtView::ParsePageHeaderAndFooter(INT nCurPage, INT nMaxPage)
{
	CString szPathName, szFileName, szPageNumber, szTotalPage, szCurrTime, szCurrDate;
	CCedtDoc * pDoc = (CCedtDoc *)GetDocument();

	szPathName = pDoc->GetTitle();
	szFileName = GetFileName( szPathName );

	szPageNumber.Format("%d", nCurPage );
	szTotalPage.Format("%d", nMaxPage );
	szCurrDate = GetCurrentDate();
	szCurrTime = GetCurrentTime();

	for(INT i = 0; i < 3; i++) {
		m_szHeaderString[i] = m_szHeaderFormat[i];
		m_szFooterString[i] = m_szFooterFormat[i];

		ParsePageHeaderAndFooter(m_szHeaderString[i], szPathName, szFileName, szPageNumber, szTotalPage, szCurrDate, szCurrTime);
		ParsePageHeaderAndFooter(m_szFooterString[i], szPathName, szFileName, szPageNumber, szTotalPage, szCurrDate, szCurrTime);
	}
}

void CCedtView::ParsePageHeaderAndFooter(CString & szArgument, LPCTSTR lpszFilePath, LPCTSTR lpszFileName, 
										 LPCTSTR lpszPageNumber, LPCTSTR lpszTotalPage, LPCTSTR lpszCurrDate, LPCTSTR lpszCurrTime)
{
	INT nFound;
	while( (nFound = szArgument.Find("$(FilePath)"  )) >= 0 ) szArgument = szArgument.Left(nFound) + lpszFilePath   + szArgument.Mid(nFound + 11);
	while( (nFound = szArgument.Find("$(FileName)"  )) >= 0 ) szArgument = szArgument.Left(nFound) + lpszFileName   + szArgument.Mid(nFound + 11);
	while( (nFound = szArgument.Find("$(PageNumber)")) >= 0 ) szArgument = szArgument.Left(nFound) + lpszPageNumber + szArgument.Mid(nFound + 13);
	while( (nFound = szArgument.Find("$(TotalPage)" )) >= 0 ) szArgument = szArgument.Left(nFound) + lpszTotalPage  + szArgument.Mid(nFound + 12);
	while( (nFound = szArgument.Find("$(CurrDate)"  )) >= 0 ) szArgument = szArgument.Left(nFound) + lpszCurrDate   + szArgument.Mid(nFound + 11);
	while( (nFound = szArgument.Find("$(CurrTime)"  )) >= 0 ) szArgument = szArgument.Left(nFound) + lpszCurrTime   + szArgument.Mid(nFound + 11);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -