Leaked source code of windows server 2003
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.

163 lines
5.3 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-1998, 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. friend LSERR OlsDrawGlyphs(POLS,PLSRUN,BOOL,BOOL,PCGINDEX,const int*,const int*,PGOFFSET,PGPROP,
  28. PCEXPTYPE,DWORD,LSTFLOW,UINT,const POINT*,PCHEIGHTS,long,long,const RECT*);
  29. private:
  30. RECT _rcView; // View rect (_hdc logical coords)
  31. RECT _rcRender; // Rendered rect (_hdc logical coords)
  32. RECT _rc; // Running clip/erase rect (_hdc logical coords)
  33. LONG _xWidthLine; // Total width of line
  34. LONG _cpAccelerator; // Accelerator cp if any (-1 if none).
  35. COLORREF _crBackground; // Default background color
  36. COLORREF _crForeDisabled; // Foreground color for disabled text
  37. COLORREF _crShadowDisabled; // Shadow color for disabled text
  38. COLORREF _crTextColor; // Default text color
  39. COLORREF _crCurBackground; // Current background color
  40. COLORREF _crCurTextColor; // Current text color
  41. COffScreenDC _osdc; // Manager for off screen DC
  42. HDC _hdc;
  43. union
  44. {
  45. DWORD _dwFlags; // All together now
  46. struct
  47. {
  48. DWORD _fDisabled:1; // Draw text with disabled effects?
  49. DWORD _fErase:1; // Erase background (non transparent)
  50. DWORD _fSelected:1; // Render run with selection colors
  51. DWORD _fLastChunk:1; // Rendering last chunk
  52. DWORD _fSelectToEOL:1; // Whether selection runs to end of line
  53. DWORD _fUseOffScreenDC:1; // Using off screen DC
  54. DWORD _fRenderSelection:1;// Render selection?
  55. DWORD _fBackgroundColor:1;// Some text in the line has non-default
  56. // background color.
  57. DWORD _fEnhancedMetafileDC:1; // Use ExtTextOutA to hack around all
  58. // sort of Win95FE EMF or font problems
  59. DWORD _fFEFontOnNonFEWin9x:1; // have to use ExtTextOutW even for EMF.
  60. DWORD _fSelectedPrev:1; // TRUE if prev run selected
  61. DWORD _fStrikeOut:1; // TRUE if current run is struckout
  62. };
  63. };
  64. LOGPALETTE *_plogpalette;
  65. POINT _ptCur; // Current rendering position on screen
  66. BYTE _bUnderlineType; // Underline type
  67. BYTE _bUnderlineClrIdx; // Underline color index (0 uses text color)
  68. void Init(); // Initialize most members to zero
  69. void UpdatePalette(COleObject *pobj);
  70. void RenderText(const WCHAR* pch, LONG cch);
  71. BOOL SetNewFont();
  72. BOOL RenderChunk(LONG &cchChunk, const WCHAR *pszToRender, LONG cch);
  73. LONG RenderTabs(LONG cchChunk);
  74. BOOL RenderBullet();
  75. public:
  76. CRenderer (const CDisplay * const pdp);
  77. CRenderer (const CDisplay * const pdp, const CRchTxtPtr &rtp);
  78. ~CRenderer (){}
  79. void operator =(const CLine& li) {*(CLine*)this = li;}
  80. void RenderExtTextOut(LONG x, LONG y, UINT fuOptions, RECT *prc, PCWSTR pch, UINT cch, const INT *rgdxp);
  81. void SetSelected(BOOL f) {_fSelected = f;}
  82. BOOL fBackgroundColor() const {return _fBackgroundColor;}
  83. BOOL fUseOffScreenDC() const {return _fUseOffScreenDC;}
  84. COLORREF GetTextColor(const CCharFormat *pCF);
  85. void SetTextColor(COLORREF cr);
  86. void SetCurPoint(const POINT &pt) {_ptCur = pt;}
  87. const POINT& GetCurPoint() const {return _ptCur;}
  88. void SetClipRect(void);
  89. void SetClipLeftRight(LONG xWidth);
  90. BOOL RenderStartLine();
  91. const RECT& GetClipRect() const {return _rc;}
  92. HDC GetDC() const {return _hdc;}
  93. BOOL StartRender(
  94. const RECT &rcView,
  95. const RECT &rcRender,
  96. const LONG yHeightBitmap);
  97. void EndRender();
  98. void EndRenderLine(HDC hdcSave, LONG xAdj, LONG yAdj, LONG x);
  99. void FillRectWithColor(RECT *prc, COLORREF cr);
  100. void NewLine (const CLine &li);
  101. BOOL RenderLine(CLine &li);
  102. void RenderOffScreenBitmap(HDC hdc, LONG yAdj, LONG xAdj);
  103. BOOL RenderOutlineSymbol();
  104. void RenderStrikeOut(LONG xStart, LONG yStart,
  105. LONG xWidth, LONG yThickness);
  106. void RenderUnderline(LONG xStart, LONG yStart,
  107. LONG xWidth, LONG yThickness);
  108. void SetFontAndColor(const CCharFormat *pCF);
  109. HDC SetUpOffScreenDC(LONG& xAdj, LONG& yAdj);
  110. void SetupUnderline(LONG UnderlineType);
  111. CONVERTMODE GetConvertMode();
  112. BOOL fFEFontOnNonFEWin9x() {return _fFEFontOnNonFEWin9x;}
  113. BOOL UseXOR(COLORREF cr)
  114. {
  115. return GetPed()->Get10Mode() || (_crBackground != ::GetSysColor(COLOR_WINDOW) && _crBackground == cr);
  116. }
  117. };
  118. /*
  119. * BottomOfRender (rcView, rcRender)
  120. *
  121. * @mfunc
  122. * Calculate maximum logical unit to render.
  123. *
  124. * @rdesc
  125. * Maximum pixel to render
  126. *
  127. * @devnote
  128. * This function exists to allow the renderer and dispml to be able
  129. * to calculate the maximum pixel for rendering in exactly the same
  130. * way.
  131. */
  132. inline LONG BottomOfRender(const RECT& rcView, const RECT& rcRender)
  133. {
  134. return min(rcView.bottom, rcRender.bottom);
  135. }
  136. #endif