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.

157 lines
4.4 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-1998 Microsoft Corporation. All rights reserved.
  13. */
  14. #ifndef _LINE_H
  15. #define _LINE_H
  16. #include "_runptr.h"
  17. class CDisplay;
  18. class CMeasurer;
  19. class CRenderer;
  20. class CDispDim;
  21. // ============================ CLine =====================================
  22. // line - keeps track of a line of text
  23. // All metrics are in rendering device units
  24. class CLine : public CTxtRun
  25. {
  26. public:
  27. LONG _xLeft; // Line left position (line indent + line shift)
  28. LONG _xWidth; // Line width not incl _xLeft, trailing whitespace
  29. SHORT _yHeight; // Line height
  30. SHORT _yDescent; // Distance from baseline to bottom of line
  31. SHORT _xLineOverhang; // Overhang for the line.
  32. WORD _cchWhite; // Count of white chars at end of line
  33. BYTE _cchEOP; // Count of EOP chars; 0 if no EOP this line
  34. BYTE _bFlags; // Flags defined below
  35. BYTE _bNumber; // Abstract paragraph number (0 is unnumbered)
  36. BYTE _nHeading:4; // Heading level (0 if not heading)
  37. BYTE _fCollapsed:1; // TRUE if line is collapsed
  38. BYTE _fNextInTable:1;// TRUE if next line is in table
  39. public:
  40. CLine () {}
  41. // !!!!! CLine should not have any virtual methods !!!!!!
  42. // The "big four" line methods: measure, render, CchFromXpos, XposFromCch
  43. BOOL Measure (CMeasurer& me, LONG cchMax, LONG xWidth,
  44. UINT uiFlags, CLine *pliTarget = NULL);
  45. BOOL Render (CRenderer& re);
  46. LONG CchFromXpos(CMeasurer& me, POINT pt, CDispDim *pdispdim = NULL,
  47. HITTEST *pHit = NULL, LONG *pcpActual = NULL) const;
  48. LONG XposFromCch(CMeasurer& me, LONG cchMax, UINT taMode,
  49. CDispDim *pdispdim = NULL, LONG *pdy = NULL) const;
  50. // Helper functions
  51. LONG GetHeight () const;
  52. void Init () {ZeroMemory(this, sizeof(CLine));}
  53. BOOL IsEqual (CLine& li);
  54. };
  55. // Line flags
  56. #define fliHasEOP 0x0001 // True if ends with CR or LF
  57. #define fliHasSpecialChars 0x0002 // Has special characters (Euro, etc.)
  58. #define fliHasTabs 0x0004 // set if tabs, *not* iff tabs
  59. #define fliHasOle 0x0008
  60. #define fliFirstInPara 0x0010
  61. #define fliUseOffScreenDC 0x0020 // Line needs to be rendered off
  62. // screen to handle change in fonts
  63. #define fliOffScreenOnce 0x0040 // Only render off screen once. Used
  64. // for rendering 1st line of an edit
  65. #define fliHasSurrogates 0x0080 // Has Unicode surrogate chars
  66. // ========================== CLineArray ===================================
  67. // Array of lines
  68. typedef CArray<CLine> CLineArray;
  69. // ========================== CLinePtr ===================================
  70. // Maintains position in a array of lines
  71. class CLinePtr : public CRunPtr<CLine>
  72. {
  73. protected:
  74. CDisplay * _pdp;
  75. CLine * _pLine;
  76. public:
  77. CLinePtr (CDisplay *pdp);
  78. CLinePtr (CLinePtr& rp) : CRunPtr<CLine> (rp) {}
  79. void Init ( CLine & );
  80. void Init ( CLineArray & );
  81. // Alternate initializer
  82. void RpSet(LONG iRun, LONG ich);
  83. // Direct cast to a run index
  84. operator LONG() const {return _iRun;}
  85. // Get the run index (line number)
  86. LONG GetLineIndex(void) {return _iRun;}
  87. LONG GetAdjustedLineLength();
  88. LONG GetIch() const {return _ich;}
  89. LONG GetCchLeft() const;
  90. // Dereferencing
  91. BOOL IsValid();
  92. CLine * operator ->() const;
  93. CLine & operator *() const;
  94. CLine & operator [](LONG dRun);
  95. CLine * GetLine() const;
  96. WORD GetNumber();
  97. WORD GetHeading() {return GetLine()->_nHeading;}
  98. // Pointer arithmetic
  99. BOOL operator --(int);
  100. BOOL operator ++(int);
  101. // Character position control
  102. LONG RpGetIch() const {return _ich;}
  103. BOOL RpAdvanceCp(LONG cch);
  104. BOOL RpSetCp(LONG cp, BOOL fAtEnd);
  105. BOOL OperatorPostDeltaSL(LONG Delta);
  106. BOOL RpAdvanceCpSL(LONG cch);
  107. // Array management
  108. // These should assert, but gotta be here
  109. // Strictly speaking, these members should never be called for the single
  110. // line case. The base class better assert
  111. void Remove (LONG cRun)
  112. {
  113. CRunPtr<CLine>::Remove(cRun);
  114. }
  115. BOOL Replace(LONG cRun, CArrayBase *parRun)
  116. {
  117. return CRunPtr<CLine>::Replace(cRun,parRun);
  118. }
  119. // Assignment from a run index
  120. CRunPtrBase& operator =(LONG iRun) {SetRun(iRun, 0); return *this;}
  121. LONG FindParagraph(BOOL fForward);
  122. };
  123. #endif