Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
7.4 KiB

  1. /*
  2. * _RENDER.H
  3. *
  4. * Purpose:
  5. * CRenderer class
  6. *
  7. * Authors:
  8. * RichEdit 1.0 code: David R. Fulmer
  9. * Christian Fortini (initial conversion to C++)
  10. * Murray Sargent
  11. *
  12. * Copyright (c) 1995-2000, Microsoft Corporation. All rights reserved.
  13. */
  14. #ifndef _RENDER_H
  15. #define _RENDER_H
  16. #include "_measure.h"
  17. #include "_rtext.h"
  18. #include "_osdc.h"
  19. BOOL IsTooSimilar(COLORREF cr1, COLORREF cr2);
  20. class CDisplay;
  21. // ========================== CRenderer ==================================
  22. // CRenderer - specialized text pointer used for rendering text
  23. class CRenderer : public CMeasurer
  24. {
  25. friend struct COls;
  26. friend struct CLsrun;
  27. #ifndef NOLINESERVICES
  28. friend LSERR OlsDrawGlyphs(POLS,PLSRUN,BOOL,BOOL,PCGINDEX,const int*,const int*,PGOFFSET,PGPROP,
  29. PCEXPTYPE,DWORD,LSTFLOW,UINT,const POINT*,PCHEIGHTS,long,long,const RECT*);
  30. friend LSERR WINAPI OlsOleDisplay(PDOBJ pdobj, PCDISPIN pcdispin);
  31. friend LSERR WINAPI OlsDrawTextRun(POLS, PLSRUN, BOOL, BOOL, const POINT *,LPCWSTR, const int *,DWORD,LSTFLOW,
  32. UINT, const POINT *, PCHEIGHTS, long, long, const RECT *);
  33. #endif
  34. private:
  35. RECTUV _rcView; // View rect (_hdc logical coords)
  36. RECTUV _rcRender; // Rendered rect (_hdc logical coords)
  37. RECTUV _rc; // Running clip/erase rect (_hdc logical coords)
  38. RECTUV _rcErase; // Rectangle to use for erasing iff _fEraseOnFirstDraw
  39. LONG _dupLine; // Total width of line REVIEW (keithcu) still needed
  40. LONG _cpAccelerator; // Accelerator cp if any (-1 if none).
  41. COLORREF _crBackground; // Default background color
  42. COLORREF _crForeDisabled; // Foreground color for disabled text
  43. COLORREF _crShadowDisabled; // Shadow color for disabled text
  44. COLORREF _crTextColor; // Default text color
  45. COLORREF _crCurBackground; // Current background color
  46. COLORREF _crCurTextColor; // Current text color
  47. COffscreenDC _osdc; // Manager for offscreen DC
  48. HDC _hdc; // Current hdc
  49. HDC _hdcBitmap; // Memory hdc for background BitBlts
  50. HBITMAP _hbitmapSave; // Saved hbitmap when _hdcMem being used
  51. SHORT _dxBitmap; // Background bitmap width
  52. SHORT _dyBitmap; // Background bitmap height
  53. union
  54. {
  55. DWORD _dwFlags; // All together now
  56. struct
  57. {
  58. DWORD _fDisabled:1; // Draw text with disabled effects?
  59. DWORD _fErase:1; // Erase background (non transparent)
  60. DWORD _fSelected:1; // Render run with selection colors
  61. DWORD _fLastChunk:1; // Rendering last chunk
  62. DWORD _fSelectToEOL:1; // Whether selection runs to end of line
  63. DWORD _fRenderSelection:1;// Render selection?
  64. DWORD _fBackgroundColor:1;// Some text in the line has non-default
  65. // background color.
  66. DWORD _fEnhancedMetafileDC:1; // Use ExtTextOutA to hack around all
  67. // sort of Win95FE EMF or font problems
  68. DWORD _fFEFontOnNonFEWin9x:1; // have to use ExtTextOutW even for EMF.
  69. DWORD _fSelectedPrev:1; // TRUE if prev run selected
  70. DWORD _fStrikeOut:1; // TRUE if current run is struckout
  71. DWORD _fEraseOnFirstDraw:1;//Draw opaquely for first run?
  72. DWORD _fDisplayDC:1; // Display dc
  73. };
  74. };
  75. LOGPALETTE *_plogpalette;
  76. POINTUV _ptCur; // Current rendering position on screen
  77. BYTE _bUnderlineType; // Underline type
  78. COLORREF _crUnderlineClr; // Underline color
  79. void Init(); // Initialize most members to zero
  80. void UpdatePalette(COleObject *pobj);
  81. void RenderText(const WCHAR* pch, LONG cch);
  82. BOOL SetNewFont();
  83. BOOL FindDrawEntry(LONG cp);
  84. //Rotation wrappers;
  85. void EraseTextOut(HDC hdc, const RECTUV *prc, BOOL fSimple = FALSE);
  86. BOOL RenderChunk(LONG &cchChunk, const WCHAR *pchRender, LONG cch);
  87. LONG RenderTabs(LONG cchChunk);
  88. BOOL RenderBullet();
  89. public:
  90. CRenderer (const CDisplay * const pdp);
  91. CRenderer (const CDisplay * const pdp, const CRchTxtPtr &rtp);
  92. ~CRenderer ();
  93. void operator =(const CLine& li) {*(CLine*)this = li;}
  94. BOOL IsSimpleBackground() const;
  95. void RenderExtTextOut(POINTUV ptuv, UINT fuOptions, RECT *prc, PCWSTR pch, UINT cch, const INT *rgdxp);
  96. BOOL EraseRect(const RECTUV *prc, COLORREF crBack);
  97. void EraseLine();
  98. COLORREF GetDefaultBackColor() const {return _crBackground;}
  99. COLORREF GetDefaultTextColor() const {return _crTextColor;}
  100. COLORREF GetTextColor(const CCharFormat *pCF);
  101. void SetDefaultBackColor(COLORREF cr);
  102. void SetDefaultTextColor(COLORREF cr);
  103. void SetTextColor(COLORREF cr);
  104. void SetSelected(BOOL f) {_fSelected = f;}
  105. void SetErase(BOOL f) {_fErase = f;}
  106. const POINTUV& GetCurPoint() const {return _ptCur;}
  107. void SetCurPoint(const POINTUV &pt) {_ptCur = pt;}
  108. void SetRcView(const RECTUV *prcView){_rcView = *prcView; _rcRender = *prcView;}
  109. void SetRcViewTop(LONG top) {_rcView.top = top;}
  110. void SetRcBottoms(LONG botv, LONG botr) {_rcView.bottom = botv; _rcRender.bottom = botr;}
  111. const RECTUV& GetRcRender() {return _rcRender;}
  112. const RECTUV& GetRcView() {return _rcView;}
  113. const RECTUV& GetClipRect() const {return _rc;}
  114. void SetClipRect(void);
  115. void SetClipLeftRight(LONG dup);
  116. HDC GetDC() const {return _hdc;}
  117. BOOL StartRender(const RECTUV &rcView, const RECTUV &rcRender);
  118. LONG DrawTableBorders(const CParaFormat *pPF, LONG x, LONG yHeightRow,
  119. LONG iDrawBottomLine, LONG dulRow,
  120. const CParaFormat *pPFAbove);
  121. COLORREF GetColorFromIndex(LONG icr, BOOL fForeColor,
  122. const CParaFormat *pPF) const;
  123. COLORREF GetShadedColorFromIndices(LONG icrf, LONG icrb, LONG iShading, //@parm Shading in .01 percent
  124. const CParaFormat *pPF) const;
  125. void DrawWrappedObjects(CLine *pliFirst, CLine *pliLast, LONG cpFirst, const POINTUV &ptFirst);
  126. void EndRender(CLine *pliFirst, CLine *pliLast, LONG cpFirst, const POINTUV &ptFirst);
  127. void FillRectWithColor(const RECTUV *prc, COLORREF cr);
  128. void NewLine (const CLine &li);
  129. BOOL RenderLine(CLine &li, BOOL fLastLine);
  130. void RenderOffscreenBitmap(HDC hdc, LONG dup, LONG dvp);
  131. BOOL RenderOutlineSymbol();
  132. HDC StartLine(CLine &li, BOOL fLastLine, LONG &cpSelMin, LONG &cpSelMost, LONG &dup, LONG &dvp);
  133. void EraseToBottom();
  134. void EndLine(HDC hdcSave, LONG dup, LONG dvp);
  135. void RenderStrikeOut(LONG upStart, LONG vpStart, LONG dup, LONG dvp);
  136. void RenderUnderline(LONG upStart, LONG vpStart, LONG dup, LONG dvp);
  137. void DrawLine(const POINTUV &ptStart, const POINTUV &ptEnd);
  138. void SetFontAndColor(const CCharFormat *pCF);
  139. HDC SetupOffscreenDC(LONG& dup, LONG& dvp, BOOL fLastLine);
  140. void SetupUnderline(BYTE bULType, BYTE bULColorIdx, COLORREF crULColor = tomAutoColor);
  141. CONVERTMODE GetConvertMode();
  142. BOOL fFEFontOnNonFEWin9x() {return _fFEFontOnNonFEWin9x;}
  143. BOOL UseXOR(COLORREF cr);
  144. BOOL fDisplayDC() { return _fDisplayDC; }
  145. };
  146. /*
  147. * BottomOfRender (rcView, rcRender)
  148. *
  149. * @mfunc
  150. * Calculate maximum logical unit to render.
  151. *
  152. * @rdesc
  153. * Maximum pixel to render
  154. *
  155. * @devnote
  156. * This function exists to allow the renderer and dispml to be able
  157. * to calculate the maximum pixel for rendering in exactly the same
  158. * way.
  159. */
  160. inline LONG BottomOfRender(const RECTUV& rcView, const RECTUV& rcRender)
  161. {
  162. return min(rcView.bottom, rcRender.bottom);
  163. }
  164. class CBrush
  165. {
  166. COLORREF _cr; // Current color
  167. HBRUSH _hbrushOld; // HBRUSH when CBrush is created
  168. HBRUSH _hbrush; // Current HBRUSH
  169. CRenderer * _pre; // Renderer to use (for rotation)
  170. public:
  171. CBrush(CRenderer *pre) {_pre = pre; _hbrush = 0;}
  172. ~CBrush();
  173. void Draw(LONG u1, LONG v1, LONG u2, LONG v2, LONG dxpLine,
  174. COLORREF cr, BOOL fHideGridlines);
  175. };
  176. #endif