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
4.8 KiB

  1. /*
  2. * @doc INTERNAL
  3. *
  4. * @module _FRUNPTR.H -- CFormatRunPtr class declaration |
  5. *
  6. * Original Authors: <nl>
  7. * Original RichEdit code: David R. Fulmer <nl>
  8. * Christian Fortini <nl>
  9. * Murray Sargent <nl>
  10. *
  11. * History: <nl>
  12. * 06-25-95 alexgo cleanup and commenting
  13. *
  14. * Copyright (c) 1995-1997, Microsoft Corporation. All rights reserved.
  15. */
  16. #ifndef _FRUNPTR_H
  17. #define _FRUNPTR_H
  18. #include "_array.h"
  19. #include "_text.h"
  20. #include "_runptr.h"
  21. #include "_format.h"
  22. #define CharFormat 0
  23. #define ParaFormat 1
  24. typedef enum {
  25. IGNORE_CURRENT_FONT = 0,
  26. MATCH_CURRENT_CHARSET = 1,
  27. MATCH_FONT_SIG = 2,
  28. MATCH_ASCII = 4
  29. } FONT_MATCHING;
  30. /*
  31. * CFormatRunPtr
  32. *
  33. * @class A Run pointer over an array of CFormatRun structures.
  34. * This pointer understands how to add remove character/paragraph
  35. * formatting
  36. *
  37. * @base public | CRunPtr<lt>CFormatRun<gt>
  38. *
  39. * @devnote The format run pointer has one extra interesting state
  40. * transistion beyond the normal CRunPtrBase transistions.
  41. *
  42. * If this run pointer is in the NULL state, then InitRuns may
  43. * be used to create or fetch the correct run array for the
  44. * run pointer. Note that if a run array is already allocated
  45. * it will be simply be fetched and used. This allows us to
  46. * treat unitialized run pointers the same as run pointers to
  47. * an uninitialized document.
  48. * @xref See also <mf CFormatRunPtr::InitRuns>
  49. */
  50. class CFormatRunPtr : public CRunPtr<CFormatRun>
  51. {
  52. friend class CRchTxtPtr;
  53. friend class CTxtRange;
  54. friend class CReplaceFormattingAE;
  55. friend class CUniscribe;
  56. //@access Public Methods
  57. public:
  58. #ifdef DEBUG
  59. BOOL Invariant(void) const; //@cmember Invariant tests
  60. #endif
  61. CFormatRunPtr(const CFormatRunPtr &rp) //@cmember Copy Constructor
  62. : CRunPtr<CFormatRun>((CRunPtrBase&)rp) {}
  63. CFormatRunPtr(CFormatRuns *pfr) //@cmember Constructor
  64. : CRunPtr<CFormatRun>((CRunArray *)pfr) {}
  65. short GetFormat() const; //@cmember Get current format index
  66. void SetLevel (CBiDiLevel& level); //@cmember Set run's embedding level
  67. BYTE GetLevel (CBiDiLevel* pLevel = NULL);//@cmember Get run's embedding level
  68. BOOL SameLevel (CFormatRunPtr* prp)
  69. {
  70. return !(IsValid() && GetRun(0)->_level._value != prp->GetRun(0)->_level._value);
  71. }
  72. BOOL SameLevel (BYTE bLevel)
  73. {
  74. return !(IsValid() && GetRun(0)->_level._value != bLevel);
  75. }
  76. //@access Private Methods
  77. private:
  78. //@cmember Format Run Array management
  79. BOOL InitRuns(LONG ich, LONG cch, CFormatRuns **ppfrs);
  80. //@cmember Formatting replacement
  81. void Delete(LONG cch, IFormatCache *pf, LONG cchMove);
  82. //@cmember Formatting insertion
  83. LONG InsertFormat(LONG cch, LONG iformat, IFormatCache *pf);
  84. //@cmember Merge two adjacent formatting runs
  85. void MergeRuns(LONG iRun, IFormatCache *pf);
  86. //@cmember Split run
  87. void SplitFormat(IFormatCache *pf);
  88. //@cmember Sets the format for the current run
  89. LONG SetFormat(LONG ifmt, LONG cch, IFormatCache *pf, CBiDiLevel* pLevel = NULL);
  90. //@cmember Extends formatting from previous run
  91. void AdjustFormatting(LONG cch, IFormatCache *pf);
  92. //@cmember Remove <p cRun>
  93. void Remove (LONG cRun, IFormatCache *pf);
  94. };
  95. enum MASKOP
  96. {
  97. MO_OR = 0,
  98. MO_AND,
  99. MO_EXACT
  100. };
  101. class CTxtEdit;
  102. class CCFRunPtr : public CFormatRunPtr
  103. {
  104. friend class CRchTxtPtr;
  105. friend class CTxtRange;
  106. public:
  107. CTxtEdit *_ped;
  108. CCFRunPtr(const CRchTxtPtr &rtp); //@cmember Copy Constructor
  109. CCFRunPtr(const CFormatRunPtr &rp, CTxtEdit *ped);
  110. BOOL IsHidden() {return IsMask(CFE_HIDDEN);}
  111. BOOL IsMask(DWORD dwMask, MASKOP mo = MO_OR);
  112. BOOL IsInHidden(); //@cmember True if in hidden text
  113. LONG FindUnhidden(); //@cmember Find nearest unhidden CF
  114. LONG FindUnhiddenBackward();//@cmember Find previous unhidden CF
  115. LONG FindUnhiddenForward();//@cmember Find previous unhidden CF
  116. int MatchFormatSignature(const CCharFormat* pCF, int iScript, int fMatchCurrent, DWORD* pdwFontSig = NULL);
  117. //@member Get font info for code page
  118. bool GetPreferredFontInfo(
  119. int cpg,
  120. BYTE& bCharSet,
  121. SHORT& iFont,
  122. SHORT& yHeight,
  123. BYTE& bPitchAndFamily,
  124. int iFormat,
  125. int iMatchCurrent = MATCH_FONT_SIG
  126. );
  127. };
  128. class CPFRunPtr : public CFormatRunPtr
  129. {
  130. friend class CRchTxtPtr;
  131. friend class CTxtRange;
  132. public:
  133. CTxtEdit *_ped;
  134. CPFRunPtr(const CRchTxtPtr &rtp); //@cmember Copy Constructor
  135. //@cmember Find Heading before cpMost
  136. LONG FindHeading(LONG cch, LONG& lHeading);
  137. BOOL InTable(); //@cmember True if paraformat is in table
  138. BOOL IsCollapsed(); //@cmember True if paraformat is collapsed
  139. LONG FindExpanded(); //@cmember Find nearest expanded PF
  140. LONG FindExpandedBackward();//@cmember Find previous expanded PF
  141. LONG FindExpandedForward();//@cmember Find next expanded PF
  142. LONG GetOutlineLevel(); //@cmember Get outline level
  143. LONG GetStyle(); //@cmember Get style
  144. };
  145. #endif