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.

202 lines
6.6 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. #include "_layout.h"
  16. class CDisplayML : public CDisplay, public CLayout
  17. {
  18. public:
  19. #ifdef DEBUG
  20. BOOL Invariant(void) const;
  21. #endif
  22. friend class CLayout;
  23. friend class CLinePtr;
  24. friend class CLed;
  25. friend BOOL CTxtEdit::OnDisplayBand(const RECT *prc, BOOL fPrintFromDraw);
  26. friend class CDisplayPrinter;
  27. private:
  28. LONG _cpCalcMax; // last cp for which line breaks have been calc'd + 1
  29. LONG _vpCalcMax; // height of calculated lines
  30. LONG _cpWait; // cp WaitForRecalc() is waiting for (or < 0)
  31. LONG _vpWait; // vp WaitForRecalc() is waiting for (or < 0)
  32. LONG _vpScroll; // vertical scroll position of visible view
  33. LONG _dvpFirstVisible; // offset from top of view to first visible line
  34. LONG _iliFirstVisible; // index of first visible line
  35. LONG _dulTarget; // max width of this display (in log unit)
  36. LONG _dvlTarget; // max height of this display (-1 for infinite)
  37. LONG _dupLineMax; // width of longest calculated line
  38. CDevDesc *_pddTarget; // Target device (if any).
  39. LONG _sPage; // Page # of _iliFirstVisible if PageView
  40. WORD _fInRecalcScrollBars:1; // Are trying to recalc scrollbars
  41. private:
  42. // Helpers
  43. void InitVars();
  44. void RecalcScrollBars();
  45. LONG ConvertScrollToVPos(LONG vPos);
  46. LONG GetMaxVpScroll() const;
  47. BOOL CreateEmptyLine();
  48. LONG CalcScrollHeight(LONG yHeight) const;
  49. void RebindFirstVisible(BOOL fResetCp = FALSE);
  50. void Set_yScroll(LONG cp);
  51. void Sync_yScroll();
  52. // Line/page breaking
  53. BOOL RecalcLines(CRchTxtPtr &rtp, BOOL fWait);
  54. BOOL RecalcLines(CRchTxtPtr &rtp, LONG cchOld, LONG cchNew,
  55. BOOL fBackground, BOOL fWait, CLed *pled);
  56. BOOL RecalcSingleLine(CLed *pled);
  57. LONG CalcDisplayDup();
  58. LONG CalculatePage(LONG iliFirst);
  59. // Rendering
  60. virtual void Render(const RECTUV &rcView, const RECTUV &rcRender);
  61. void DeferUpdateScrollBar();
  62. BOOL DoDeferredUpdateScrollBar();
  63. virtual BOOL UpdateScrollBar(INT nBar, BOOL fUpdateRange = FALSE );
  64. protected:
  65. virtual LONG GetMaxUScroll() const;
  66. public:
  67. virtual BOOL Paginate(LONG iLineFirst, BOOL fRebindFirstVisible = FALSE);
  68. virtual HRESULT GetPage(LONG *piPage, DWORD dwFlags, CHARRANGE *pcrg);
  69. virtual HRESULT SetPage(LONG iPage);
  70. virtual LONG ConvertVPosToScrollPos(LONG vPos);
  71. CDisplayML (CTxtEdit* ped);
  72. virtual CDisplayML::~CDisplayML();
  73. virtual BOOL Init();
  74. virtual BOOL IsNestedLayout() const {return FALSE;}
  75. virtual TFLOW GetTflow() const {return CLayout::GetTflow();}
  76. virtual void SetTflow(TFLOW tflow) {CLayout::SetTflow(tflow);}
  77. // Device context management
  78. virtual BOOL SetMainTargetDC(HDC hdc, LONG dulTarget);
  79. virtual BOOL SetTargetDC(HDC hdc, LONG dxpInch = -1, LONG dypInch = -1);
  80. // Getting properties
  81. virtual void InitLinePtr ( CLinePtr & );
  82. virtual const CDevDesc* GetDdTarget() const {return _pddTarget;}
  83. virtual BOOL IsMain() const {return TRUE;}
  84. BOOL IsInOutlineView() const {return _ped->IsInOutlineView();}
  85. // When wrapping to printer, return the width we are to wrap to (or 0)
  86. virtual LONG GetDulForTargetWrap() const {return _dulTarget;}
  87. // Get width of widest line
  88. virtual LONG GetDupLineMax() const {return _dupLineMax;}
  89. // Height and line count (of all text)
  90. virtual LONG GetHeight() const {return _dvp;}
  91. virtual LONG GetResizeHeight() const;
  92. virtual LONG LineCount() const;
  93. // Visible view properties
  94. virtual LONG GetCliVisible(
  95. LONG *pcpMostVisible = NULL,
  96. BOOL fLastCharOfLastVisible = FALSE) const;
  97. virtual LONG GetFirstVisibleLine() const {return _iliFirstVisible;}
  98. // Line info
  99. virtual LONG GetLineText(LONG ili, TCHAR *pchBuff, LONG cchMost);
  100. virtual LONG CpFromLine(LONG ili, LONG *pdvp = NULL);
  101. virtual LONG LineFromCp(LONG cp, BOOL fAtEnd) ;
  102. // Point <-> cp conversion
  103. virtual LONG CpFromPoint(
  104. POINTUV pt,
  105. const RECTUV *prcClient,
  106. CRchTxtPtr * const ptp,
  107. CLinePtr * const prp,
  108. BOOL fAllowEOL,
  109. HITTEST *pHit = NULL,
  110. CDispDim *pdispdim = NULL,
  111. LONG *pcpActual = NULL,
  112. CLine *pliParent = NULL);
  113. virtual LONG PointFromTp (
  114. const CRchTxtPtr &tp,
  115. const RECTUV *prcClient,
  116. BOOL fAtEnd,
  117. POINTUV &pt,
  118. CLinePtr * const prp,
  119. UINT taMode,
  120. CDispDim *pdispdim = NULL);
  121. // Line break recalc
  122. BOOL StartBackgroundRecalc();
  123. virtual VOID StepBackgroundRecalc();
  124. virtual BOOL RecalcView(BOOL fUpdateScrollBars, RECTUV* prc = NULL);
  125. virtual BOOL WaitForRecalc(LONG cpMax, LONG vpMax);
  126. virtual BOOL WaitForRecalcIli(LONG ili);
  127. virtual BOOL WaitForRecalcView();
  128. virtual void RecalcLine(LONG cp);
  129. // Complete updating (recalc + rendering)
  130. virtual BOOL UpdateView(CRchTxtPtr &rtp, LONG cchOld, LONG cchNew);
  131. // Scrolling
  132. virtual LRESULT VScroll(WORD wCode, LONG uPos);
  133. virtual VOID LineScroll(LONG cli, LONG cch);
  134. virtual VOID FractionalScrollView ( LONG vDelta );
  135. virtual VOID ScrollToLineStart(LONG iDirection);
  136. virtual LONG CalcVLineScrollDelta ( LONG cli, BOOL fFractionalFirst );
  137. virtual BOOL ScrollView(LONG upScroll, LONG vpScroll, BOOL fTracking, BOOL fFractionalScroll);
  138. virtual LONG GetVpScroll() const { return _vpScroll; }
  139. virtual LONG GetScrollRange(INT nBar) const;
  140. virtual LONG AdjustToDisplayLastLine(LONG yBase, LONG vpScroll);
  141. // Selection
  142. virtual BOOL InvertRange(LONG cp, LONG cch, SELDISPLAYACTION selAction);
  143. // Natural size calculation
  144. virtual HRESULT GetNaturalSize(
  145. HDC hdcDraw,
  146. HDC hicTarget,
  147. DWORD dwMode,
  148. LONG *pwidth,
  149. LONG *pheight);
  150. // Misc. methods
  151. void FindParagraph(LONG cpMin, LONG cpMost, LONG *pcpMin, LONG *pcpMost);
  152. virtual LONG GetCurrentPageHeight() const;
  153. virtual CDisplay *Clone() const;
  154. #ifdef DEBUG
  155. void CheckLineArray() const;
  156. void DumpLines(LONG iliFirst, LONG cli);
  157. void CheckView();
  158. BOOL VerifyFirstVisible(LONG *pHeight = NULL);
  159. #endif
  160. };
  161. #endif