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.

174 lines
5.0 KiB

  1. /*
  2. * _LINE.H
  3. *
  4. * Purpose:
  5. * CLine class
  6. *
  7. * Authors:
  8. * Original RichEdit code: David R. Fulmer
  9. * Christian Fortini
  10. * Murray Sargent
  11. *
  12. * Copyright (c) 1995-2000 Microsoft Corporation. All rights reserved.
  13. */
  14. #ifndef _LINE_H
  15. #define _LINE_H
  16. #include "_runptr.h"
  17. class CDisplay;
  18. class CDisplayML;
  19. class CMeasurer;
  20. class CRenderer;
  21. class CDispDim;
  22. class CLayout;
  23. class CLinePtr;
  24. // ============================ CLine =====================================
  25. // line - keeps track of a line of text
  26. // All metrics are in rendering device units
  27. class CLine : public CTxtRun
  28. {
  29. friend class CMeasurer;
  30. friend class CRenderer;
  31. friend class CDisplaySL;
  32. friend struct COls;
  33. union
  34. {
  35. struct
  36. {
  37. USHORT _dvpDescent; // Distance from baseline to bottom of line
  38. USHORT _dvpHeight; // Line height
  39. };
  40. CLayout *_plo; // Pointer to nested layout iff _fIsNestedLayout
  41. };
  42. public:
  43. SHORT _upStart; // Line start position (line indent + line shift)
  44. USHORT _dup; // Line width not incl _upStart, trailing whitespace
  45. BYTE _bNumber; // Abstract paragraph number (0 is unnumbered)
  46. BYTE _cObjectWrapLeft:3; // How far back in backing store to look for objects
  47. BYTE _cObjectWrapRight:3;// that we are wrapping around
  48. BYTE _fFirstWrapLeft:1; // TRUE iff the first line of a wrapped object
  49. BYTE _fFirstWrapRight:1; // TRUE iff the first line of a wrapped object
  50. BYTE _ihyph : 5; // Index into hyphenation table (0 is no hyphenation)
  51. BYTE _cchEOP:2; // Count of EOP chars; 0 if no EOP this line
  52. BYTE _fIsNestedLayout:1; // TRUE iff line has a nested layout
  53. BYTE _nHeading:4; // Heading level (0 if not heading)
  54. BYTE _fCollapsed:1; // Line is collapsed
  55. BYTE _fFirstOnPage:1; // Line is first one on page
  56. BYTE _fHasFF:1; // Line ends with FF (FormFeed)
  57. BYTE _fHasEOP:1; // Line ends with CR or LF
  58. BYTE _fHasSpecialChars:1;// Has EURO, tabs, OLE, etc.
  59. BYTE _fFirstInPara:1; // First line in paragraph
  60. BYTE _fPageBreakBefore:1;// PFE_PAGEBREAKBEFORE TRUE
  61. BYTE _fUseOffscreenDC:1; // Line should be rendered offscreen
  62. BYTE _fOffscreenOnce:1; // Only render Offscreen once--after edits
  63. BYTE _fIncludeCell:1; // Include CELL in line after nested table
  64. public:
  65. // !!!!! CLine should not have any virtual methods !!!!!!
  66. // The "big four" line methods: measure, render, CchFromUp, UpFromCch
  67. BOOL Measure (CMeasurer& me, UINT uiFlags, CLine *pliTarget = NULL);
  68. BOOL Render (CRenderer& re, BOOL fLastLine);
  69. LONG CchFromUp(CMeasurer& me, POINTUV pt, CDispDim *pdispdim = NULL,
  70. HITTEST *pHit = NULL, LONG *pcpActual = NULL) const;
  71. LONG UpFromCch(CMeasurer& me, LONG cchMax, UINT taMode,
  72. CDispDim *pdispdim = NULL, LONG *pdy = NULL) const;
  73. CLayout *GetPlo() const {return IsNestedLayout() ? _plo : 0;}
  74. void SetPlo(CLayout *plo) {_plo = plo; _fIsNestedLayout = _plo != 0;}
  75. // Helper functions
  76. BOOL IsNestedLayout(void) const {return _fIsNestedLayout;}
  77. LONG GetHeight () const;
  78. LONG GetDescent() const;
  79. void Init () {ZeroMemory(this, sizeof(CLine));}
  80. BOOL IsEqual (CLine& li);
  81. };
  82. // ========================== CLineArray ===================================
  83. // Array of lines
  84. typedef CArray<CLine> CLineArray;
  85. // ========================== CLinePtr ===================================
  86. // Maintains position in a array of lines
  87. class CLinePtr : public CRunPtr<CLine>
  88. {
  89. protected:
  90. CDisplay * _pdp;
  91. CLine * _pLine;
  92. public:
  93. CLinePtr (CDisplay *pdp);
  94. CLinePtr (CLinePtr& rp) : CRunPtr<CLine> (rp) {}
  95. void Init ( CLine & );
  96. void Init ( CLineArray & );
  97. // Alternate initializer
  98. void Set(LONG iRun, LONG ich, CLineArray *pla = NULL);
  99. // Direct cast to a run index
  100. operator LONG() const {return _iRun;}
  101. // Get the run index (line number)
  102. LONG GetLineIndex(void) const {return _iRun;}
  103. LONG GetAdjustedLineLength();
  104. LONG GetCchLeft() const;
  105. CDisplay *GetPdp() const {return _pdp;}
  106. // Dereferencing
  107. BOOL IsValid() const;
  108. CLine * operator ->() const;
  109. CLine & operator *() const;
  110. CLine & operator [](LONG dRun);
  111. CLine * GetLine() const;
  112. WORD GetNumber();
  113. WORD GetHeading() {return GetLine()->_nHeading;}
  114. // Pointer arithmetic
  115. BOOL operator --(int);
  116. BOOL operator ++(int);
  117. // Character position control
  118. LONG GetIch() const {return _ich;}
  119. BOOL Move(LONG cch);
  120. BOOL SetCp(LONG cp, BOOL fAtEnd, LONG lNest = 0);
  121. BOOL OperatorPostDeltaSL(LONG Delta);
  122. BOOL MoveSL(LONG cch);
  123. // Array management
  124. // These should assert, but gotta be here
  125. // Strictly speaking, these members should never be called for the single
  126. // line case. The base class better assert
  127. void Remove (LONG cRun)
  128. {
  129. CRunPtr<CLine>::Remove(cRun);
  130. }
  131. BOOL Replace(LONG cRun, CArrayBase *parRun)
  132. {
  133. return CRunPtr<CLine>::Replace(cRun, parRun);
  134. }
  135. // Assignment from a run index
  136. CRunPtrBase& operator =(LONG iRun) {SetRun(iRun, 0); return *this;}
  137. LONG FindParagraph(BOOL fForward);
  138. LONG CountPages(LONG &cPage, LONG cchMax, LONG cp, LONG cchText) const;
  139. void FindPage(LONG *pcpMin, LONG *pcpMost, LONG cpMin, LONG cch, LONG cchText);
  140. };
  141. #endif