XTPSyntaxEditPaintManager.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:33k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPSyntaxEditPaintManager.cpp : implementation of the CXTPSyntaxEditPaintManager class.
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME SYNTAX EDIT LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "Resource.h"
  22. // common includes
  23. #include "Common/XTPVC80Helpers.h"
  24. #include "Common/XTPDrawHelpers.h"
  25. #include "Common/XTPResourceManager.h"
  26. #include "Common/XTPColorManager.h"
  27. #include "Common/XTPNotifyConnection.h"
  28. #include "Common/XTPSmartPtrInternalT.h"
  29. #include "Common/XTPVC50Helpers.h"
  30. // syntax editor includes
  31. #include "XTPSyntaxEditDefines.h"
  32. #include "XTPSyntaxEditStruct.h"
  33. #include "XTPSyntaxEditUndoManager.h"
  34. #include "XTPSyntaxEditLineMarksManager.h"
  35. #include "XTPSyntaxEditLexPtrs.h"
  36. #include "XTPSyntaxEditLexClassSubObjT.h"
  37. #include "XTPSyntaxEditTextIterator.h"
  38. #include "XTPSyntaxEditSectionManager.h"
  39. #include "XTPSyntaxEditLexCfgFileReader.h"
  40. #include "XTPSyntaxEditLexClassSubObjDef.h"
  41. #include "XTPSyntaxEditLexClass.h"
  42. #include "XTPSyntaxEditLexParser.h"
  43. #include "XTPSyntaxEditLexColorFileReader.h"
  44. #include "XTPSyntaxEditCtrl.h"
  45. #include "XTPSyntaxEditCtrl.h"
  46. #include "XTPSyntaxEditPaintManager.h"
  47. #include "XTPSyntaxEditBufferManager.h"
  48. #include <math.h>
  49. #ifdef _DEBUG
  50. #undef THIS_FILE
  51. static char THIS_FILE[]=__FILE__;
  52. #define new DEBUG_NEW
  53. #endif
  54. //===========================================================================
  55. // CXTPSyntaxEditPaintManager class
  56. //===========================================================================
  57. IMPLEMENT_DYNAMIC(CXTPSyntaxEditPaintManager, CCmdTarget)
  58. //////////////////////////////////////////////////////////////////////
  59. // Construction/Destruction
  60. //////////////////////////////////////////////////////////////////////
  61. CXTPSyntaxEditPaintManager::CXTPSyntaxEditPaintManager()
  62. {
  63. m_hCurLine = XTPResourceManager()->LoadCursor(XTP_IDC_EDIT_BACKARROW);
  64. m_hCurMove = XTPResourceManager()->LoadCursor(XTP_IDC_EDIT_MOVE);
  65. m_hCurCopy = XTPResourceManager()->LoadCursor(XTP_IDC_EDIT_COPY);
  66. m_hCurIBeam = AfxGetApp()->LoadStandardCursor(IDC_IBEAM);
  67. m_hCurArrow = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
  68. m_hCurNO = AfxGetApp()->LoadStandardCursor(IDC_NO);
  69. // get non-client metrics info.
  70. NONCLIENTMETRICS ncm;
  71. ncm.cbSize = sizeof(NONCLIENTMETRICS);
  72. ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  73. // create the tooltip font.
  74. VERIFY(SetFontToolTip(&ncm.lfStatusFont));
  75. // construct default fonts.
  76. VERIFY(CreateFontIndirect(NULL, FALSE));
  77. // Initialize metrics
  78. RefreshMetrics();
  79. InitBitmaps();
  80. }
  81. CXTPSyntaxEditPaintManager::~CXTPSyntaxEditPaintManager()
  82. {
  83. }
  84. void CXTPSyntaxEditPaintManager::InitBitmaps()
  85. {
  86. // Check for already initialized bitmaps
  87. m_ilBookmark.DeleteImageList();
  88. // Load bookmarks bitmap
  89. CBitmap bmpBookMarks;       // Regular bookmark image
  90. if (XTPResourceManager()->LoadBitmap(& bmpBookMarks, XTP_IDB_EDIT_BOOKMARKS))
  91. {
  92. BITMAP info;
  93. bmpBookMarks.GetBitmap(&info);
  94. if (m_ilBookmark.Create(20, info.bmHeight,
  95. ILC_COLOR24|ILC_MASK, 0, 1))
  96. {
  97. m_ilBookmark.Add(&bmpBookMarks, RGB(0x00,0xff,0x00));
  98. }
  99. }
  100. }
  101. HCURSOR CXTPSyntaxEditPaintManager::SetMoveCursor(HCURSOR hCurMove)
  102. {
  103. HCURSOR hCurMoveOld = m_hCurMove;
  104. m_hCurMove = hCurMove;
  105. return hCurMoveOld;
  106. }
  107. HCURSOR CXTPSyntaxEditPaintManager::SetCopyCursor(HCURSOR hCurCopy)
  108. {
  109. HCURSOR hCurCopyOld = m_hCurCopy;
  110. m_hCurCopy = hCurCopy;
  111. return hCurCopyOld;
  112. }
  113. HCURSOR CXTPSyntaxEditPaintManager::SetLineSelCursor(HCURSOR hCur)
  114. {
  115. HCURSOR hCurOld = m_hCurLine;
  116. m_hCurLine = hCur;
  117. return hCurOld;
  118. }
  119. AFX_STATIC void GetCustomValue(CWinApp* pWinApp, LPCTSTR lpszRegKey, CXTPPaintManagerColor& pmc)
  120. {
  121. COLORREF color = pWinApp->GetProfileInt(XTP_EDIT_REG_SETTINGS,
  122. lpszRegKey, pmc.GetStandardColor());
  123. if (color != pmc.GetStandardColor())
  124. {
  125. pmc = color;
  126. }
  127. }
  128. void CXTPSyntaxEditPaintManager::RefreshMetrics()
  129. {
  130. // Initialize default colors.
  131. m_clrValues.crText.SetStandardValue(::GetSysColor(COLOR_WINDOWTEXT));
  132. m_clrValues.crBack.SetStandardValue(::GetSysColor(COLOR_WINDOW));
  133. m_clrValues.crReadOnlyBack.SetStandardValue(::GetSysColor(COLOR_3DFACE));
  134. m_clrValues.crHiliteText.SetStandardValue(::GetSysColor(COLOR_HIGHLIGHTTEXT));
  135. m_clrValues.crHiliteBack.SetStandardValue(::GetSysColor(COLOR_HIGHLIGHT));
  136. m_clrValues.crInactiveHiliteText.SetStandardValue(::GetSysColor(COLOR_INACTIVECAPTIONTEXT));
  137. m_clrValues.crInactiveHiliteBack.SetStandardValue(::GetSysColor(COLOR_INACTIVECAPTION));
  138. m_clrValues.crLineNumberText.SetStandardValue(RGB(0x00,0x82,0x84));
  139. m_clrValues.crLineNumberBack.SetStandardValue(::GetSysColor(COLOR_WINDOW));
  140. // Restore user settings from registry.
  141. CWinApp* pWinApp = AfxGetApp();
  142. if (pWinApp != NULL)
  143. {
  144. GetCustomValue(pWinApp, XTP_EDIT_REG_TEXTCOLOR, m_clrValues.crText);
  145. GetCustomValue(pWinApp, XTP_EDIT_REG_BACKCOLOR, m_clrValues.crBack);
  146. GetCustomValue(pWinApp, XTP_EDIT_REG_SELTEXTCOLOR, m_clrValues.crHiliteText);
  147. GetCustomValue(pWinApp, XTP_EDIT_REG_SELBACKCOLOR, m_clrValues.crHiliteBack);
  148. GetCustomValue(pWinApp, XTP_EDIT_REG_INSELTEXTCOLOR, m_clrValues.crInactiveHiliteText);
  149. GetCustomValue(pWinApp, XTP_EDIT_REG_INSELBACKCOLOR, m_clrValues.crInactiveHiliteBack);
  150. GetCustomValue(pWinApp, XTP_EDIT_REG_LINENUMTEXTCOLOR, m_clrValues.crLineNumberText);
  151. GetCustomValue(pWinApp, XTP_EDIT_REG_LINENUMBACKCOLOR, m_clrValues.crLineNumberBack);
  152. UINT nSize = 0;
  153. LPBYTE pbtData = 0;
  154. if (pWinApp->GetProfileBinary(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_LOGFONT, &pbtData, &nSize))
  155. {
  156. LOGFONT* pLogFont = reinterpret_cast<LOGFONT*>(pbtData);
  157. CreateFontIndirect(pLogFont);
  158. delete [] pbtData;
  159. }
  160. }
  161. // Initialize gray pen.
  162. if (m_penGray.m_hObject)
  163. m_penGray.DeleteObject();
  164. m_penGray.CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW));
  165. }
  166. //////////////////////////////////////////////////////////////////////////
  167. CFont* CXTPSyntaxEditPaintManager::GetFont()
  168. {
  169. return &m_font;
  170. }
  171. BOOL CXTPSyntaxEditPaintManager::CreateFontIndirect(LPLOGFONT pLogfont, BOOL bUpdateReg/*=FALSE*/)
  172. {
  173. LOGFONT lfDefault;
  174. // construct default fonts.
  175. if (!pLogfont)
  176. {
  177. ::ZeroMemory(&lfDefault, sizeof(LOGFONT));
  178. lfDefault.lfCharSet = DEFAULT_CHARSET;
  179. lfDefault.lfWeight = FW_NORMAL;
  180. lfDefault.lfHeight = -13;
  181. STRCPY_S(lfDefault.lfFaceName, LF_FACESIZE, _T("Courier New"));
  182. pLogfont = &lfDefault;
  183. }
  184. if (!SetFont(pLogfont))
  185. return FALSE;
  186. if (!SetFontText(pLogfont))
  187. return FALSE;
  188. if (!SetFontLineNumber(pLogfont))
  189. return FALSE;
  190. if (bUpdateReg)
  191. {
  192. CWinApp* pWinApp = AfxGetApp();
  193. if (pWinApp != NULL)
  194. {
  195. if (pWinApp->WriteProfileBinary(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_LOGFONT,
  196. reinterpret_cast<LPBYTE>(pLogfont), sizeof(LOGFONT)))
  197. {
  198. return TRUE;
  199. }
  200. }
  201. return FALSE;
  202. }
  203. return TRUE;
  204. }
  205. BOOL CXTPSyntaxEditPaintManager::SetFont(LPLOGFONT pLogfont)
  206. {
  207. if (m_font.m_hObject)
  208. {
  209. m_font.DeleteObject();
  210. }
  211. return m_font.CreateFontIndirect(pLogfont);
  212. }
  213. CFont* CXTPSyntaxEditPaintManager::GetFontText()
  214. {
  215. return &m_fontText;
  216. }
  217. BOOL CXTPSyntaxEditPaintManager::SetFontText(LPLOGFONT pLogfont)
  218. {
  219. if (m_fontText.m_hObject)
  220. {
  221. m_fontText.DeleteObject();
  222. }
  223. return m_fontText.CreateFontIndirect(pLogfont);
  224. }
  225. CFont* CXTPSyntaxEditPaintManager::GetFontLineNumber()
  226. {
  227. return &m_fontLineNumber;
  228. }
  229. BOOL CXTPSyntaxEditPaintManager::SetFontLineNumber(LPLOGFONT pLogfont)
  230. {
  231. if (m_fontLineNumber.m_hObject)
  232. {
  233. m_fontLineNumber.DeleteObject();
  234. }
  235. return m_fontLineNumber.CreateFontIndirect(pLogfont);
  236. }
  237. CFont* CXTPSyntaxEditPaintManager::GetFontToolTip()
  238. {
  239. return &m_fontToolTip;
  240. }
  241. BOOL CXTPSyntaxEditPaintManager::SetFontToolTip(LPLOGFONT pLogfont)
  242. {
  243. if (m_fontToolTip.m_hObject)
  244. {
  245. m_fontToolTip.DeleteObject();
  246. }
  247. return m_fontToolTip.CreateFontIndirect(pLogfont);
  248. }
  249. //////////////////////////////////////////////////////////////////////////
  250. HCURSOR CXTPSyntaxEditPaintManager::GetCurLine()
  251. {
  252. return m_hCurLine;
  253. }
  254. HCURSOR CXTPSyntaxEditPaintManager::GetCurMove()
  255. {
  256. return m_hCurMove;
  257. }
  258. HCURSOR CXTPSyntaxEditPaintManager::GetCurCopy()
  259. {
  260. return m_hCurCopy;
  261. }
  262. HCURSOR CXTPSyntaxEditPaintManager::GetCurNO()
  263. {
  264. return m_hCurNO;
  265. }
  266. HCURSOR CXTPSyntaxEditPaintManager::GetCurIBeam()
  267. {
  268. return m_hCurIBeam;
  269. }
  270. HCURSOR CXTPSyntaxEditPaintManager::GetCurArrow()
  271. {
  272. return m_hCurArrow;
  273. }
  274. BOOL CXTPSyntaxEditPaintManager::SetTextColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  275. {
  276. m_clrValues.crText = color;
  277. if (bUpdateReg)
  278. {
  279. CWinApp* pWinApp = AfxGetApp();
  280. if (pWinApp != NULL)
  281. {
  282. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_TEXTCOLOR, (int)color))
  283. return TRUE;
  284. }
  285. return FALSE;
  286. }
  287. return TRUE;
  288. }
  289. BOOL CXTPSyntaxEditPaintManager::SetBackColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  290. {
  291. m_clrValues.crBack = color;
  292. if (bUpdateReg)
  293. {
  294. CWinApp* pWinApp = AfxGetApp();
  295. if (pWinApp != NULL)
  296. {
  297. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_BACKCOLOR, (int)color))
  298. return TRUE;
  299. }
  300. return FALSE;
  301. }
  302. return TRUE;
  303. }
  304. BOOL CXTPSyntaxEditPaintManager::SetReadOnlyBackColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  305. {
  306. m_clrValues.crReadOnlyBack = color;
  307. if (bUpdateReg)
  308. {
  309. CWinApp* pWinApp = AfxGetApp();
  310. if (pWinApp != NULL)
  311. {
  312. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_READONLYBACKCOLOR, (int)color))
  313. return TRUE;
  314. }
  315. return FALSE;
  316. }
  317. return TRUE;
  318. }
  319. BOOL CXTPSyntaxEditPaintManager::SetHiliteTextColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  320. {
  321. m_clrValues.crHiliteText = color;
  322. if (bUpdateReg)
  323. {
  324. CWinApp* pWinApp = AfxGetApp();
  325. if (pWinApp != NULL)
  326. {
  327. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_SELTEXTCOLOR, (int)color))
  328. return TRUE;
  329. }
  330. return FALSE;
  331. }
  332. return TRUE;
  333. }
  334. BOOL CXTPSyntaxEditPaintManager::SetHiliteBackColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  335. {
  336. m_clrValues.crHiliteBack = color;
  337. if (bUpdateReg)
  338. {
  339. CWinApp* pWinApp = AfxGetApp();
  340. if (pWinApp != NULL)
  341. {
  342. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_SELBACKCOLOR, (int)color))
  343. return TRUE;
  344. }
  345. return FALSE;
  346. }
  347. return TRUE;
  348. }
  349. BOOL CXTPSyntaxEditPaintManager::SetInactiveHiliteTextColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  350. {
  351. m_clrValues.crInactiveHiliteText = color;
  352. if (bUpdateReg)
  353. {
  354. CWinApp* pWinApp = AfxGetApp();
  355. if (pWinApp != NULL)
  356. {
  357. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_INSELTEXTCOLOR, (int)color))
  358. return TRUE;
  359. }
  360. return FALSE;
  361. }
  362. return TRUE;
  363. }
  364. BOOL CXTPSyntaxEditPaintManager::SetInactiveHiliteBackColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  365. {
  366. m_clrValues.crInactiveHiliteBack = color;
  367. if (bUpdateReg)
  368. {
  369. CWinApp* pWinApp = AfxGetApp();
  370. if (pWinApp != NULL)
  371. {
  372. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_INSELBACKCOLOR, (int)color))
  373. return TRUE;
  374. }
  375. return FALSE;
  376. }
  377. return TRUE;
  378. }
  379. BOOL CXTPSyntaxEditPaintManager::SetLineNumberTextColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  380. {
  381. m_clrValues.crLineNumberText = color;
  382. if (bUpdateReg)
  383. {
  384. CWinApp* pWinApp = AfxGetApp();
  385. if (pWinApp != NULL)
  386. {
  387. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_LINENUMTEXTCOLOR, (int)color))
  388. return TRUE;
  389. }
  390. return FALSE;
  391. }
  392. return TRUE;
  393. }
  394. BOOL CXTPSyntaxEditPaintManager::SetLineNumberBackColor(COLORREF color, BOOL bUpdateReg/*=FALSE*/)
  395. {
  396. m_clrValues.crLineNumberBack = color;
  397. if (bUpdateReg)
  398. {
  399. CWinApp* pWinApp = AfxGetApp();
  400. if (pWinApp != NULL)
  401. {
  402. if (pWinApp->WriteProfileInt(XTP_EDIT_REG_SETTINGS, XTP_EDIT_REG_LINENUMBACKCOLOR, (int)color))
  403. return TRUE;
  404. }
  405. return FALSE;
  406. }
  407. return TRUE;
  408. }
  409. //////////////////////////////////////////////////////////////////////////
  410. CImageList* CXTPSyntaxEditPaintManager::GetBookmarks()
  411. {
  412. return &m_ilBookmark;
  413. }
  414. //////////////////////////////////////////////////////////////////////////
  415. BOOL CXTPSyntaxEditPaintManager::UpdateTextFont(CXTPSyntaxEditCtrl* pEditCtrl, const XTP_EDIT_FONTOPTIONS& lf)
  416. {
  417. LOGFONT lfOpt;
  418. m_font.GetLogFont(&lfOpt);
  419. if (pEditCtrl && pEditCtrl->GetSyntaxColor())
  420. {
  421. if (lf.lfItalic != XTP_EDIT_FONTOPTIONS_UNSPEC_OPTION)
  422. {
  423. lfOpt.lfItalic = lf.lfItalic;
  424. }
  425. if (lf.lfWeight != XTP_EDIT_FONTOPTIONS_UNSPEC_OPTION)
  426. {
  427. lfOpt.lfWeight = lf.lfWeight;
  428. }
  429. if (lf.lfUnderline != XTP_EDIT_FONTOPTIONS_UNSPEC_OPTION)
  430. {
  431. lfOpt.lfUnderline = lf.lfUnderline;
  432. }
  433. }
  434. return SetFontText(&lfOpt);
  435. }
  436. void CXTPSyntaxEditPaintManager::DrawLineNumber(CDC *pDC, const CRect& rcRect, int nTextRow, CXTPSyntaxEditCtrl* pEditCtrl)
  437. {
  438. if (!pEditCtrl)
  439. return;
  440. if (nTextRow < 1)
  441. return;
  442. if (!pDC->IsPrinting())
  443. {
  444. COLORREF clrBk = m_clrValues.crLineNumberBack;
  445. if (m_clrValues.crLineNumberBack.IsStandardValue() && pEditCtrl->IsReadOnly())
  446. clrBk = m_clrValues.crReadOnlyBack;
  447. pDC->FillSolidRect(&rcRect, clrBk);
  448. }
  449. CXTPFontDC fontDC(pDC, GetFontLineNumber(), m_clrValues.crLineNumberText);
  450. CRect rcLineNum(rcRect);
  451. rcLineNum.right -= 2;
  452. if (nTextRow <= pEditCtrl->GetRowCount())
  453. {
  454. // Print line number
  455. CString strLineNum;
  456. strLineNum.Format(_T("%d"), nTextRow);
  457. pDC->DrawText(strLineNum, &rcLineNum, DT_VCENTER|DT_RIGHT);
  458. }
  459. if (!pDC->IsPrinting())
  460. DrawLineNumbersBorder(pDC, rcLineNum, m_clrValues.crLineNumberText);
  461. }
  462. void CXTPSyntaxEditPaintManager::DrawLineNumbersBorder(CDC *pDC, const CRect& rcLineNum, const COLORREF clrBorder)
  463. {
  464. int nDotLineX = rcLineNum.right+1;
  465. for (int y = rcLineNum.top; y < rcLineNum.bottom; y++)
  466. {
  467. if (y % 2)
  468. {
  469. pDC->SetPixelV(nDotLineX, y, clrBorder);
  470. }
  471. }
  472. }
  473. void CXTPSyntaxEditPaintManager::DrawLineNodeBackground(CDC *pDC, const CRect& rcNodeFull,
  474. DWORD dwType, int nTextRow, CXTPSyntaxEditCtrl* pEditCtrl)
  475. {
  476. UNREFERENCED_PARAMETER(dwType); UNREFERENCED_PARAMETER(nTextRow);
  477. pDC->FillSolidRect(&rcNodeFull, m_clrValues.GetBackColorEx(pEditCtrl));
  478. }
  479. void CXTPSyntaxEditPaintManager::DrawLineNode(CDC *pDC, const CRect& rcNode, const CRect& rcNodeFull,
  480. DWORD dwType, int nTextRow, CXTPSyntaxEditCtrl* pEditCtrl)
  481. {
  482. if (!pEditCtrl || !pEditCtrl->m_bDrawNodes)
  483. return;
  484. // fill node background
  485. DrawLineNodeBackground(pDC, rcNodeFull, dwType, nTextRow, pEditCtrl);
  486. // draw node picture
  487. if (dwType != XTP_EDIT_ROWNODE_NOTHING)
  488. {
  489. CXTPPenDC penGray(pDC, &m_penGray);
  490. if (dwType & XTP_EDIT_ROWNODE_NODEUP)
  491. {
  492. // draw up line
  493. CPoint ptEnd(rcNode.CenterPoint().x, rcNodeFull.top);
  494. pDC->MoveTo(ptEnd);
  495. ptEnd.y += rcNodeFull.Height() / 2;
  496. pDC->LineTo(ptEnd);
  497. }
  498. if (dwType & XTP_EDIT_ROWNODE_NODEDOWN)
  499. {
  500. // draw down line
  501. CPoint ptEnd(rcNode.CenterPoint().x, rcNodeFull.bottom);
  502. pDC->MoveTo(ptEnd);
  503. ptEnd.y -= rcNodeFull.Height() / 2 + 2;
  504. pDC->LineTo(ptEnd);
  505. }
  506. if (dwType & XTP_EDIT_ROWNODE_ENDMARK)
  507. {
  508. // draw down line
  509. CPoint ptEnd(rcNode.CenterPoint());
  510. pDC->MoveTo(ptEnd);
  511. ptEnd.x += rcNodeFull.Width() / 2;
  512. pDC->LineTo(ptEnd);
  513. }
  514. if (dwType & XTP_EDIT_ROWNODE_COLLAPSED ||
  515. dwType & XTP_EDIT_ROWNODE_EXPANDED)
  516. {
  517. // draw collapsed sign
  518. pDC->Rectangle(&rcNode);
  519. CPoint ptSign(rcNode.CenterPoint());
  520. ptSign.x -= 2;
  521. pDC->MoveTo(ptSign);
  522. ptSign.x += 5;
  523. pDC->LineTo(ptSign);
  524. }
  525. if (dwType & XTP_EDIT_ROWNODE_COLLAPSED)
  526. {
  527. // draw vertical line of the expanded sign
  528. CPoint ptSign(rcNode.CenterPoint());
  529. ptSign.y -= 2;
  530. pDC->MoveTo(ptSign);
  531. ptSign.y += 5;
  532. pDC->LineTo(ptSign);
  533. }
  534. }
  535. }
  536. void CXTPSyntaxEditPaintManager::DrawCollapsedTextMarks(CXTPSyntaxEditCtrl* pEditCtrl, CDC *pDC)
  537. {
  538. COLORREF clrFrame = GetSysColor(COLOR_BTNSHADOW);
  539. COLORREF crText = GetSysColor(COLOR_BTNSHADOW);
  540. CXTPFontDC fontDC(pDC, GetFont());
  541. const XTP_EDIT_COLLAPSEDBLOCK* pCoDrawBlk = NULL;
  542. XTP_EDIT_LMPARAM LMCoParam;
  543. int nActualRow = 0;
  544. for (int i = 0; i < pEditCtrl->m_nCollapsedTextRowsCount; i++)
  545. {
  546. // get next collapsed row
  547. int nRow = pEditCtrl->m_arCollapsedTextRows[i];
  548. if (nRow <= nActualRow)
  549. {
  550. continue;
  551. }
  552. if (!pEditCtrl->HasRowMark(nRow, xtpEditLMT_Collapsed, &LMCoParam))
  553. {
  554. continue;
  555. }
  556. // get count of collapsed rows under this row
  557. int nHiddenRows = 0;
  558. if (!pEditCtrl->GetCollapsedBlockLen(nRow, nHiddenRows))
  559. {
  560. continue;
  561. }
  562. nActualRow = nRow + nHiddenRows;
  563. // get collapsed block pointer
  564. pCoDrawBlk = (XTP_EDIT_COLLAPSEDBLOCK*)LMCoParam.GetPtr();
  565. if (!pCoDrawBlk)
  566. {
  567. ASSERT(FALSE);
  568. continue;
  569. }
  570. CString strText = pCoDrawBlk->collBlock.strCollapsedText; // "[..]"
  571. CRect rcFrame(pCoDrawBlk->rcCollMark);
  572. rcFrame.InflateRect(0, 0, 0, 1);
  573. CRect rcText = pCoDrawBlk->rcCollMark;
  574. rcText.DeflateRect(1, 0, 1, 0);
  575. COLORREF clrBack = pEditCtrl->IsReadOnly() ? (COLORREF)m_clrValues.crReadOnlyBack :
  576.  (COLORREF)m_clrValues.crBack;
  577. pDC->FillSolidRect(&rcText, clrBack);
  578. pDC->SetTextColor(crText);
  579. pDC->SetBkColor(clrBack);
  580. pDC->DrawText(strText, &rcText, 0);
  581. pDC->Draw3dRect(&rcFrame, clrFrame, clrFrame);
  582. }
  583. }
  584. void CXTPSyntaxEditPaintManager::DrawLineCalcSel(const XTP_EDIT_TEXTBLOCK& txtBlk,
  585.   int nSelStartX, int nSelEndX,
  586.   XTP_EDIT_TEXTBLOCK (&arTxtBlk)[4], BOOL (&bUseBlk)[4] )
  587. {
  588. ASSERT(nSelStartX < nSelEndX);
  589. if (txtBlk.nPos < nSelStartX && txtBlk.nNextBlockPos-1 >= nSelStartX &&
  590. txtBlk.nNextBlockPos <= nSelEndX)
  591. {
  592. arTxtBlk[1] = arTxtBlk[2] = txtBlk;
  593. arTxtBlk[1].nNextBlockPos = nSelStartX;
  594. arTxtBlk[2].nPos = nSelStartX;
  595. bUseBlk[1] = bUseBlk[2] = TRUE;
  596. }
  597. else if (txtBlk.nPos >= nSelStartX && txtBlk.nPos < nSelEndX &&
  598. txtBlk.nNextBlockPos > nSelEndX)
  599. {
  600. arTxtBlk[2] = arTxtBlk[3] = txtBlk;
  601. arTxtBlk[2].nNextBlockPos = nSelEndX;
  602. arTxtBlk[3].nPos = nSelEndX;
  603. bUseBlk[2] = bUseBlk[3] = TRUE;
  604. }
  605. else if (txtBlk.nPos >= nSelStartX && txtBlk.nNextBlockPos <= nSelEndX)
  606. {
  607. arTxtBlk[2] = txtBlk;
  608. bUseBlk[2] = TRUE;
  609. }
  610. else if (txtBlk.nPos < nSelStartX && txtBlk.nNextBlockPos > nSelEndX)
  611. {
  612. arTxtBlk[1] = arTxtBlk[2] = arTxtBlk[3] = txtBlk;
  613. arTxtBlk[1].nNextBlockPos = nSelStartX;
  614. arTxtBlk[2].nPos = nSelStartX;
  615. arTxtBlk[2].nNextBlockPos = nSelEndX;
  616. arTxtBlk[3].nPos = nSelEndX;
  617. bUseBlk[1] = bUseBlk[2] = bUseBlk[3] = TRUE;
  618. }
  619. else
  620. {
  621. ASSERT(txtBlk.nPos >= nSelEndX || txtBlk.nNextBlockPos <= nSelStartX);
  622. arTxtBlk[1] = txtBlk;
  623. bUseBlk[1] = TRUE;
  624. }
  625. }
  626. void CXTPSyntaxEditPaintManager::DrawLineMark(CXTPSyntaxEditCtrl* pEditCtrl, XTP_EDIT_SENMBOOKMARK* pBookmark)
  627. {
  628. enum { bookMark, bookMarkSel, breakpoint };
  629. POINT ptStart;
  630. ptStart.x = pBookmark->rcBookmark.left;
  631. ptStart.y = pBookmark->rcBookmark.top;
  632. SIZE szRect;
  633. szRect.cx = pBookmark->rcBookmark.right - pBookmark->rcBookmark.left;
  634. szRect.cy = pBookmark->rcBookmark.bottom - pBookmark->rcBookmark.top;
  635. CDC *pDC = CDC::FromHandle(pBookmark->hDC);
  636. IMAGEINFO bmpInfo;
  637. ZeroMemory(&bmpInfo, sizeof(bmpInfo));
  638. if (pEditCtrl->HasRowMark(pBookmark->nRow, xtpEditLMT_Bookmark))
  639. {
  640. int iImage = (pEditCtrl->GetCurrentDocumentRow() == pBookmark->nRow)? bookMarkSel: bookMark;
  641. if (GetBookmarks()->GetImageInfo(iImage, &bmpInfo))
  642. {
  643. CRect rcBmp(bmpInfo.rcImage);
  644. szRect.cx = min(szRect.cx, rcBmp.Width());
  645. szRect.cy = min(szRect.cy, rcBmp.Height());
  646. }
  647. IMAGELISTDRAWINDIRECT_S(GetBookmarks(), pDC, iImage, ptStart, szRect);
  648. }
  649. if (pEditCtrl->HasRowMark(pBookmark->nRow, xtpEditLMT_Breakpoint))
  650. {
  651. if (GetBookmarks()->GetImageInfo(breakpoint, &bmpInfo))
  652. {
  653. CRect rcBmp(bmpInfo.rcImage);
  654. szRect.cx = min(szRect.cx, rcBmp.Width());
  655. szRect.cy = min(szRect.cy, rcBmp.Height());
  656. }
  657. IMAGELISTDRAWINDIRECT_S(GetBookmarks(), pDC, breakpoint, ptStart, szRect);
  658. pEditCtrl->SetRowBkColor(pBookmark->nRow, RGB(128,0,0));
  659. pEditCtrl->SetRowColor(pBookmark->nRow, RGB(255,255,255));
  660. }
  661. }
  662. void CXTPSyntaxEditPaintManager::DrawLineMarks(CDC *pDC, const CRect& rcRect, int nTextRow, CXTPSyntaxEditCtrl* pEditCtrl)
  663. {
  664. // NMHDR codes
  665. XTP_EDIT_SENMBOOKMARK bookmark;
  666. bookmark.nmhdr.code = XTP_EDIT_NM_DRAWBOOKMARK;
  667. bookmark.nmhdr.hwndFrom = pEditCtrl->GetSafeHwnd();
  668. bookmark.nmhdr.idFrom = 0;
  669. bookmark.hDC = pDC->GetSafeHdc();
  670. bookmark.rcBookmark = rcRect;
  671. bookmark.nRow = nTextRow;
  672. CRect rcLine = bookmark.rcBookmark;
  673. rcLine.left = rcLine.right-1;
  674. pDC->SetBkColor(::GetSysColor(COLOR_WINDOW));
  675. pDC->SetTextColor(::GetSysColor(COLOR_BTNFACE));
  676. pDC->FillRect(&bookmark.rcBookmark, pDC->GetHalftoneBrush());
  677. pDC->FillSolidRect(rcLine, ::GetSysColor(COLOR_3DSHADOW));
  678. BOOL bHandled = FALSE;
  679. CWnd *pParent = pEditCtrl->GetParent();
  680. if (pParent)
  681. {
  682. bHandled = (BOOL)pParent->SendMessage(WM_NOTIFY, 0, (LPARAM)&bookmark);
  683. }
  684. if (!bHandled)
  685. {
  686. DrawLineMark(pEditCtrl, &bookmark);
  687. }
  688. }
  689. int CXTPSyntaxEditPaintManager::DrawLineTextEx(CDC *pDC, const CRect& rcTextLine, int nTextRow,
  690.   int nLine, CXTPSyntaxEditCtrl* pEditCtrl)
  691. {
  692. int nRowHeight = 0;
  693. ASSERT(pDC && pEditCtrl);
  694. if (!pDC || !pEditCtrl)
  695. return nRowHeight;
  696. CXTPSyntaxEditDrawTextProcessor& drawTxtProc = pEditCtrl->GetDrawTextProcessor();
  697. drawTxtProc.ResetRowInfo(nLine);
  698. if (nTextRow <= 0)
  699. return nRowHeight;
  700. const CString& strText = pEditCtrl->GetLineText(nTextRow);
  701. int nTextLenC = (int)_tcsclen(strText);
  702. CString strDispText;
  703. drawTxtProc.ExpandChars(strText, strDispText, 0, pEditCtrl->IsEnabledWhiteSpace());
  704. drawTxtProc.SetRowTabPositions(nLine, strText);
  705. COLORREF crBreakText;
  706. BOOL bBreakText = pEditCtrl->m_mapRowColor.Lookup(nTextRow, crBreakText);
  707. COLORREF crBreakBack;
  708. BOOL bBreakBack  = pEditCtrl->m_mapRowBkColor.Lookup(nTextRow, crBreakBack);
  709. if (!bBreakBack)
  710. crBreakBack = m_clrValues.GetBackColorEx(pEditCtrl);
  711. if (!pDC->IsPrinting())
  712. pDC->FillSolidRect(&rcTextLine, crBreakBack);
  713. if (nTextRow > pEditCtrl->GetRowCount())
  714. return nRowHeight;
  715. pDC->SetBkMode(OPAQUE);
  716. pDC->SetTextColor(m_clrValues.crText);
  717. CXTPSyntaxEditTextBlockList blocks;
  718. pEditCtrl->GetRowColors(nTextRow, 0, -1, m_clrValues, &blocks);
  719. if (blocks.GetCount() == 0)
  720. {
  721. XTP_EDIT_TEXTBLOCK defBlk;
  722. defBlk.nPos = 0;
  723. defBlk.nNextBlockPos = nTextLenC;
  724. defBlk.clrBlock = m_clrValues;
  725. blocks.AddTail(defBlk);
  726. }
  727. // draw text
  728. //=======================================================================
  729. BOOL bCoBlkDrawn = FALSE;
  730. XTP_EDIT_COLLAPSEDBLOCK* pCoDrawBlk = NULL;
  731. XTP_EDIT_LMPARAM LMCoParam;
  732. if (pEditCtrl->HasRowMark(nTextRow, xtpEditLMT_Collapsed, &LMCoParam))
  733. {
  734. pCoDrawBlk = (XTP_EDIT_COLLAPSEDBLOCK*)LMCoParam.GetPtr();
  735. ASSERT(pCoDrawBlk);
  736. }
  737. //---------------------------------------------------------------
  738. BOOL bInfinitSelEnd = FALSE;
  739. int nSelStart = pEditCtrl->m_Selection.GetSelStartForRow_str(nTextRow, nLine);
  740. int nSelEnd = pEditCtrl->m_Selection.GetSelEndForRow_str(nTextRow, nLine, &bInfinitSelEnd);
  741. //---------------------------------------------------------------
  742. POSITION pos = blocks.GetHeadPosition();
  743. while (pos)
  744. {
  745. const XTP_EDIT_TEXTBLOCK& txtBlk = blocks.GetNext(pos);
  746. // draw [...] if needed
  747. if (pCoDrawBlk)
  748. {
  749. CRect rcCoBlk = rcTextLine;
  750. rcCoBlk.left += drawTxtProc.GetRowWidth(nLine) - drawTxtProc.GetScrollXOffset();
  751. rcCoBlk.left = max(rcCoBlk.left, rcTextLine.left);
  752. rcCoBlk.left = min(rcCoBlk.left, rcTextLine.right);
  753. bCoBlkDrawn = pEditCtrl->ProcessCollapsedTextEx(pDC, pCoDrawBlk, txtBlk, rcCoBlk);
  754. if (bCoBlkDrawn)
  755. {
  756. break;
  757. }
  758. }
  759. // define default colors.
  760. COLORREF crBack = m_clrValues.GetBackColorEx(pEditCtrl);
  761. COLORREF crText    = m_clrValues.crText;
  762. COLORREF crHiliteBack = m_clrValues.crHiliteBack;
  763. COLORREF crHiliteText = m_clrValues.crHiliteText;
  764. // if syntax coloring is enabled use defined colors.
  765. //      if (pEditCtrl->GetSyntaxColor())
  766. //      {
  767. crBack    = txtBlk.clrBlock.crBack;
  768. crText    = txtBlk.clrBlock.crText;
  769. crHiliteBack = txtBlk.clrBlock.crHiliteBack;
  770. crHiliteText = txtBlk.clrBlock.crHiliteText;
  771. //      }
  772. if (bBreakBack)
  773. crBack = crBreakBack;
  774. if (bBreakText)
  775. crText = crBreakText;
  776. //--------------------------------------------------------------
  777. if (crBack == (COLORREF)m_clrValues.crBack)
  778. crBack = m_clrValues.GetBackColorEx(pEditCtrl);
  779. //if (crBack == m_clrValues.crBack.GetStandardColor())
  780. //          crBack = m_clrValues.crBack;
  781. //      if (crText == m_clrValues.crText.GetStandardColor())
  782. //          crText = m_clrValues.crText;
  783. //--------------------------------------------------------------
  784. if (!pEditCtrl->IsActive())
  785. {
  786. if (crHiliteBack == m_clrValues.crHiliteBack.GetStandardColor())
  787. crHiliteBack = m_clrValues.crInactiveHiliteBack;
  788. if (crHiliteText == m_clrValues.crHiliteText.GetStandardColor())
  789. crHiliteText = m_clrValues.crInactiveHiliteText;
  790. }
  791. //--------------------------------------------------------------
  792. XTP_EDIT_TEXTBLOCK arTxtBlk[4];
  793. BOOL bUseBlk[4] = {FALSE, FALSE, FALSE, FALSE};
  794. if (pEditCtrl->m_Selection.IsIntersectSel_str(nTextRow, txtBlk.nPos/* + 1*/, txtBlk.nNextBlockPos) &&
  795. !pDC->IsPrinting() && nTextLenC && nSelStart < nSelEnd)
  796. {
  797. DrawLineCalcSel(txtBlk, nSelStart, nSelEnd, arTxtBlk, bUseBlk);
  798. }
  799. else if (nTextLenC)
  800. {
  801. arTxtBlk[1] = txtBlk;
  802. bUseBlk[1] = TRUE;
  803. }
  804. //**************************************************
  805. for (int i = 1; i <= 3; i++)
  806. {
  807. if (!bUseBlk[i])
  808. continue;
  809. pDC->SetTextColor((i%2) ? crText : crHiliteText);
  810. pDC->SetBkColor((i%2) ? crBack : crHiliteBack);
  811. int nOutStrPos = drawTxtProc.StrPosToDispPos(nLine, arTxtBlk[i].nPos);
  812. int nNextOutStrPos = drawTxtProc.StrPosToDispPos(nLine, arTxtBlk[i].nNextBlockPos);
  813. int nOutStrLen = nNextOutStrPos - nOutStrPos;
  814. //LPCTSTR pText = (LPCTSTR)strDispText + nOutStrPos;
  815. LPCTSTR pText = _tcsninc((LPCTSTR)strDispText, nOutStrPos);
  816. UpdateTextFont(pEditCtrl, arTxtBlk[i].lf);
  817. CXTPFontDC fontDC(pDC, GetFontText());
  818. if (!pDC->IsPrinting())
  819. {
  820. drawTxtProc.DrawRowPart(pDC, nLine, pText, nOutStrLen);
  821. }
  822. else
  823. {
  824. int nOffsetY = rcTextLine.top - drawTxtProc.GetTextRect().top;
  825. nRowHeight = drawTxtProc.PrintRowPart(pDC, nTextRow, nOffsetY, 0,
  826.   pText, nOutStrLen, 0);//int *pnPrintedTextLen)
  827. }
  828. }
  829. if (!pDC->IsPrinting())
  830. {
  831. // draw selection for virtual space, after line text end)
  832. if (!pos && ((nSelStart < nSelEnd && nSelEnd > nTextLenC) || bInfinitSelEnd))
  833. {
  834. CRect rcSel = rcTextLine;
  835. rcSel.left += drawTxtProc.GetRowWidth(nLine) - drawTxtProc.GetScrollXOffset();
  836. if (!bInfinitSelEnd || nSelStart > nTextLenC)
  837. {
  838. if (nSelStart > nTextLenC)
  839. rcSel.left += drawTxtProc.GetSpaceWidth() * (nSelStart - nTextLenC);
  840. if (!bInfinitSelEnd)
  841. rcSel.right = rcSel.left + drawTxtProc.GetSpaceWidth() * abs(nSelEnd - max(nTextLenC, nSelStart));
  842. }
  843. rcSel.left = max(min(rcSel.left, rcTextLine.right), rcTextLine.left);
  844. rcSel.right = max(min(rcSel.right, rcTextLine.right), rcTextLine.left);
  845. pDC->FillSolidRect(rcSel, crHiliteBack);
  846. }
  847. }
  848. }
  849. //===========================================================================
  850. // draw [...] if needed and not yet
  851. if (pCoDrawBlk && !bCoBlkDrawn)
  852. {
  853. CRect rcCoBlk = rcTextLine;
  854. rcCoBlk.left += drawTxtProc.GetRowWidth(nLine) - drawTxtProc.GetScrollXOffset();
  855. rcCoBlk.left = max(rcCoBlk.left, rcTextLine.left);
  856. rcCoBlk.left = min(rcCoBlk.left, rcTextLine.right);
  857. pEditCtrl->ProcessCollapsedText(pDC, pCoDrawBlk, rcCoBlk);
  858. }
  859. pDC->SetTextColor(m_clrValues.crText);
  860. return nRowHeight;
  861. }
  862. int CXTPSyntaxEditPaintManager::PrintLineTextEx(CDC *pDC, const CRect& rcTextLine, int nTextRow,
  863. int nLine, CXTPSyntaxEditCtrl* pEditCtrl, int nFlags)
  864. {
  865. ASSERT(pDC && pEditCtrl);
  866. if (!pDC || !pEditCtrl)
  867. return 0;
  868. CXTPSyntaxEditDrawTextProcessor& drawTxtProc = pEditCtrl->GetDrawTextProcessor();
  869. int nRowHeight = drawTxtProc.GetRowHeight();
  870. const CString& strText = pEditCtrl->GetLineText(nTextRow);
  871. int nTextLenC = (int)_tcsclen(strText);
  872. CString strDispText;
  873. drawTxtProc.ExpandChars(strText, strDispText, 0, pEditCtrl->IsEnabledWhiteSpace());
  874. drawTxtProc.ResetRowInfo(nLine);
  875. drawTxtProc.SetRowTabPositions(nLine, strText);
  876. COLORREF crBreakText;
  877. BOOL bBreakText = pEditCtrl->m_mapRowColor.Lookup(nTextRow, crBreakText);
  878. COLORREF crBreakBack;
  879. BOOL bBreakBack  = pEditCtrl->m_mapRowBkColor.Lookup(nTextRow, crBreakBack);
  880. CXTPSyntaxEditLexTextSchema* ptrTxtSch = pEditCtrl->m_pBuffer->GetLexParser()->GetTextSchema();
  881. if (!bBreakBack)
  882. crBreakBack = m_clrValues.crBack;
  883. if (nTextRow > pEditCtrl->GetRowCount())
  884. return 0;
  885. pDC->SetBkMode(OPAQUE);
  886. pDC->SetTextColor(m_clrValues.crText);
  887. CXTPSyntaxEditTextBlockList blocks;
  888. if (ptrTxtSch)
  889. {
  890. CXTPSyntaxEditLexTextBlock* pScreenSchFirstTB = pEditCtrl->GetOnScreenSch(nTextRow);
  891. if (pScreenSchFirstTB)
  892. {
  893. CXTPSyntaxEditTextIterator txtIter(pEditCtrl->GetEditBuffer());
  894. ptrTxtSch->GetRowColors(&txtIter, nTextRow, 0, -1,
  895. m_clrValues, &blocks,
  896. NULL, pScreenSchFirstTB);
  897. }
  898. }
  899. if (blocks.GetCount() == 0)
  900. {
  901. XTP_EDIT_TEXTBLOCK defBlk;
  902. defBlk.nPos = 0;
  903. defBlk.nNextBlockPos = nTextLenC;
  904. defBlk.clrBlock = m_clrValues;
  905. blocks.AddTail(defBlk);
  906. }
  907. // draw text
  908. //=======================================================================
  909. BOOL bCoBlkDrawn = FALSE;
  910. XTP_EDIT_COLLAPSEDBLOCK* pCoDrawBlk = NULL;
  911. XTP_EDIT_LMPARAM LMCoParam;
  912. if (pEditCtrl->HasRowMark(nTextRow, xtpEditLMT_Collapsed, &LMCoParam))
  913. {
  914. pCoDrawBlk = (XTP_EDIT_COLLAPSEDBLOCK*)LMCoParam.GetPtr();
  915. ASSERT(pCoDrawBlk);
  916. }
  917. //---------------------------------------------------------------
  918. POSITION pos = blocks.GetHeadPosition();
  919. while (pos)
  920. {
  921. const XTP_EDIT_TEXTBLOCK& txtBlk = blocks.GetNext(pos);
  922. // draw [...] if needed
  923. if (pCoDrawBlk)
  924. {
  925. CRect rcCoBlk = rcTextLine;
  926. rcCoBlk.left += drawTxtProc.GetRowWidth(nLine) - drawTxtProc.GetScrollXOffset();
  927. rcCoBlk.left = max(rcCoBlk.left, rcTextLine.left);
  928. rcCoBlk.left = min(rcCoBlk.left, rcTextLine.right);
  929. bCoBlkDrawn = pEditCtrl->ProcessCollapsedTextEx(pDC, pCoDrawBlk, txtBlk, rcCoBlk);
  930. if (bCoBlkDrawn)
  931. {
  932. break;
  933. }
  934. }
  935. // define default colors.
  936. COLORREF crBack    = m_clrValues.crBack.GetStandardColor();
  937. COLORREF crText    = m_clrValues.crText.GetStandardColor();
  938. // if syntax coloring is enabled use defined colors.
  939. if (pEditCtrl->GetSyntaxColor())
  940. {
  941. crBack = txtBlk.clrBlock.crBack;
  942. crText = txtBlk.clrBlock.crText;
  943. }
  944. if (bBreakBack)
  945. crBack = crBreakBack;
  946. if (bBreakText)
  947. crText = crBreakText;
  948. //--------------------------------------------------------------
  949. if (crBack == m_clrValues.crBack.GetStandardColor())
  950. crBack = m_clrValues.crBack;
  951. if (crText == m_clrValues.crText.GetStandardColor())
  952. crText = m_clrValues.crText;
  953. //**************************************************
  954. pDC->SetTextColor(crText);
  955. pDC->SetBkColor(crBack);
  956. int nOutStrPos = drawTxtProc.StrPosToDispPos(nLine, txtBlk.nPos);
  957. int nNextOutStrPos = drawTxtProc.StrPosToDispPos(nLine, txtBlk.nNextBlockPos);
  958. int nOutStrLen = nNextOutStrPos - nOutStrPos;
  959. //LPCTSTR pText = (LPCTSTR)strDispText + nOutStrPos;
  960. LPCTSTR pText = _tcsninc((LPCTSTR)strDispText, nOutStrPos);
  961. UpdateTextFont(pEditCtrl, txtBlk.lf);
  962. CXTPFontDC fontDC(pDC, GetFontText());
  963. int nPrintedTextLen = 0;
  964. int nOffsetY = rcTextLine.top - drawTxtProc.GetTextRect().top;
  965. nRowHeight = drawTxtProc.PrintRowPart(pDC, nTextRow, nOffsetY, nFlags,
  966.   pText, nOutStrLen, &nPrintedTextLen);
  967. if (nPrintedTextLen < nOutStrLen)
  968. {
  969. if ((nFlags & DT_SINGLELINE) == 0)
  970. {
  971. nRowHeight = -1;
  972. pDC->FillSolidRect(&rcTextLine, pDC->GetBkColor());
  973. }
  974. break;
  975. }
  976. }
  977. //===========================================================================
  978. // draw [...] if needed and not yet
  979. if (pCoDrawBlk && !bCoBlkDrawn)
  980. {
  981. CRect rcCoBlk = rcTextLine;
  982. rcCoBlk.left += drawTxtProc.GetRowWidth(nLine) - drawTxtProc.GetScrollXOffset();
  983. rcCoBlk.left = max(rcCoBlk.left, rcTextLine.left);
  984. rcCoBlk.left = min(rcCoBlk.left, rcTextLine.right);
  985. pEditCtrl->ProcessCollapsedText(pDC, pCoDrawBlk, rcCoBlk);
  986. }
  987. pDC->SetTextColor(m_clrValues.crText);
  988. return nRowHeight;
  989. }