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.

191 lines
6.4 KiB

  1. /*
  2. * _DISPML.H
  3. *
  4. * Purpose:
  5. * CDisplayML class. Multi-line display.
  6. *
  7. * Authors:
  8. * Original RichEdit code: David R. Fulmer
  9. * Christian Fortini
  10. * Murray Sargent
  11. */
  12. #ifndef _DISPML_H
  13. #define _DISPML_H
  14. #include "_disp.h"
  15. class CDisplayML : public CDisplay, public CLineArray
  16. {
  17. public:
  18. #ifdef DEBUG
  19. BOOL Invariant(void) const;
  20. #endif
  21. friend class CLinePtr;
  22. friend class CLed;
  23. friend BOOL CTxtEdit::OnDisplayBand(const RECT *prc, BOOL fPrintFromDraw);
  24. friend class CDisplayPrinter;
  25. private:
  26. LONG _cpCalcMax; // last cp for which line breaks have been calc'd + 1
  27. LONG _yCalcMax; // height of calculated lines
  28. LONG _cpWait; // cp WaitForRecalc() is waiting for (or < 0)
  29. LONG _yWait; // y WaitForRecalc() is waiting for (or < 0)
  30. LONG _yScroll; // vertical scroll position of visible view
  31. LONG _dyFirstVisible; // offset from top of view to first visible line
  32. LONG _iliFirstVisible; // index of first visible line
  33. LONG _xWidthMax; // max width of this display (in log unit)
  34. LONG _yHeightMax; // max height of this display (-1 for infinite)
  35. LONG _xWidth; // width of longest calculated line
  36. LONG _yHeight; // sum of heights of calculated lines
  37. LONG _cpMin; // first character in display
  38. CDevDesc *_pddTarget; // target device (if any).
  39. unsigned long _fInRecalcScrollBars:1; // we're trying to recalc scroll
  40. // bars
  41. private:
  42. // Helpers
  43. void InitVars();
  44. void RecalcScrollBars();
  45. LONG ConvertScrollToYPos(LONG yPos);
  46. LONG GetMaxYScroll() const;
  47. BOOL CreateEmptyLine();
  48. LONG CalcScrollHeight(LONG yHeight) const;
  49. void RebindFirstVisible();
  50. // Line breaking
  51. BOOL RecalcLines(BOOL fWait = FALSE);
  52. BOOL RecalcLines(const CRchTxtPtr &tpFirst, LONG cchOld, LONG cchNew,
  53. BOOL fBackground, BOOL fWait, CLed *pled);
  54. BOOL RecalcSingleLine(CLed *pled);
  55. LONG CalcDisplayWidth();
  56. // Rendering
  57. virtual void Render(const RECT &rcView, const RECT &rcRender);
  58. // Scrolling and scroller bars
  59. void DeferUpdateScrollBar();
  60. BOOL DoDeferredUpdateScrollBar();
  61. virtual BOOL UpdateScrollBar(INT nBar, BOOL fUpdateRange = FALSE );
  62. protected:
  63. virtual LONG GetMaxXScroll() const;
  64. public:
  65. virtual LONG ConvertYPosToScrollPos(LONG yPos);
  66. CDisplayML (CTxtEdit* ped);
  67. virtual CDisplayML::~CDisplayML();
  68. virtual BOOL Init();
  69. // Device context management
  70. virtual BOOL SetMainTargetDC(HDC hdc, LONG xWidthMax);
  71. virtual BOOL SetTargetDC(HDC hdc, LONG dxpInch = -1, LONG dypInch = -1);
  72. // Getting properties
  73. virtual void InitLinePtr ( CLinePtr & );
  74. virtual const CDevDesc* GetDdTarget() const {return _pddTarget;}
  75. virtual BOOL IsMain() const {return TRUE;}
  76. BOOL IsInOutlineView() const {return _ped->IsInOutlineView();}
  77. // maximum height and width
  78. virtual LONG GetMaxWidth() const {return _xWidthMax;}
  79. virtual LONG GetMaxHeight() const {return 0;}
  80. virtual LONG GetMaxPixelWidth() const;
  81. // Width, height and line count (of all text)
  82. virtual LONG GetWidth() const {return _xWidth;}
  83. virtual LONG GetHeight() const {return _yHeight;}
  84. virtual LONG GetResizeHeight() const;
  85. virtual LONG LineCount() const;
  86. // Visible view properties
  87. virtual LONG GetCliVisible(
  88. LONG *pcpMostVisible = NULL,
  89. BOOL fLastCharOfLastVisible = FALSE) const;
  90. virtual LONG GetFirstVisibleLine() const {return _iliFirstVisible;}
  91. // Line info
  92. virtual LONG GetLineText(LONG ili, TCHAR *pchBuff, LONG cchMost);
  93. virtual LONG CpFromLine(LONG ili, LONG *pyLine = NULL);
  94. LONG YposFromLine(LONG ili);
  95. virtual LONG LineFromYpos(LONG yPos, LONG *pyLine = NULL, LONG *pcpFirst = NULL);
  96. virtual LONG LineFromCp(LONG cp, BOOL fAtEnd) ;
  97. // Point <-> cp conversion
  98. virtual LONG CpFromPoint(
  99. POINT pt,
  100. const RECT *prcClient,
  101. CRchTxtPtr * const ptp,
  102. CLinePtr * const prp,
  103. BOOL fAllowEOL,
  104. HITTEST *pHit = NULL,
  105. CDispDim *pdispdim = NULL,
  106. LONG *pcpActual = NULL);
  107. virtual LONG PointFromTp (
  108. const CRchTxtPtr &tp,
  109. const RECT *prcClient,
  110. BOOL fAtEnd,
  111. POINT &pt,
  112. CLinePtr * const prp,
  113. UINT taMode,
  114. CDispDim *pdispdim = NULL);
  115. // Line break recalc
  116. BOOL StartBackgroundRecalc();
  117. virtual VOID StepBackgroundRecalc();
  118. virtual BOOL RecalcView(BOOL fUpdateScrollBars, RECT* prc = NULL);
  119. virtual BOOL WaitForRecalc(LONG cpMax, LONG yMax);
  120. virtual BOOL WaitForRecalcIli(LONG ili);
  121. virtual BOOL WaitForRecalcView();
  122. // Complete updating (recalc + rendering)
  123. virtual BOOL UpdateView(const CRchTxtPtr &tpFirst, LONG cchOld, LONG cchNew);
  124. // Scrolling
  125. virtual LRESULT VScroll(WORD wCode, LONG xPos);
  126. virtual VOID LineScroll(LONG cli, LONG cch);
  127. virtual VOID FractionalScrollView ( LONG yDelta );
  128. virtual VOID ScrollToLineStart(LONG iDirection);
  129. virtual LONG CalcYLineScrollDelta ( LONG cli, BOOL fFractionalFirst );
  130. virtual BOOL ScrollView(LONG xScroll, LONG yScroll, BOOL fTracking, BOOL fFractionalScroll);
  131. virtual LONG GetYScroll() const;
  132. virtual LONG GetScrollRange(INT nBar) const;
  133. virtual LONG AdjustToDisplayLastLine(LONG yBase, LONG yScroll);
  134. // Selection
  135. virtual BOOL InvertRange(LONG cp, LONG cch, SELDISPLAYACTION selAction);
  136. // Natural size calculation
  137. virtual HRESULT GetNaturalSize(
  138. HDC hdcDraw,
  139. HDC hicTarget,
  140. DWORD dwMode,
  141. LONG *pwidth,
  142. LONG *pheight);
  143. // Misc. methods
  144. void FindParagraph(LONG cpMin, LONG cpMost, LONG *pcpMin, LONG *pcpMost);
  145. virtual CDisplay *Clone() const;
  146. #ifdef DEBUG
  147. void CheckLineArray() const;
  148. void DumpLines(LONG iliFirst, LONG cli);
  149. void CheckView();
  150. BOOL VerifyFirstVisible(LONG *pHeight = NULL);
  151. #endif
  152. };
  153. #endif