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.

182 lines
4.6 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1999 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * dppathiterator.hpp
  8. *
  9. * Abstract:
  10. *
  11. * Path iterator API
  12. *
  13. * Revision History:
  14. *
  15. * 11/13/99 ikkof
  16. * Created it
  17. *
  18. \**************************************************************************/
  19. #ifndef _DPPATHITERATOR_HPP
  20. #define _DPPATHITERATOR_HPP
  21. class DpPathTypeIterator
  22. {
  23. private:
  24. // We now use an ObjectTag to determine if the object is valid
  25. // instead of using a BOOL. This is much more robust and helps
  26. // with debugging. It also enables us to version our objects
  27. // more easily with a version number in the ObjectTag.
  28. ObjectTag Tag; // Keep this as the 1st value in the object!
  29. protected:
  30. VOID SetValid(BOOL valid)
  31. {
  32. Tag = valid ? ObjectTagPathIterator : ObjectTagInvalid;
  33. }
  34. public:
  35. DpPathTypeIterator()
  36. {
  37. Initialize();
  38. }
  39. DpPathTypeIterator(const BYTE* types, INT count)
  40. {
  41. Initialize();
  42. SetTypes(types, count);
  43. }
  44. ~DpPathTypeIterator()
  45. {
  46. SetValid(FALSE); // so we don't use a deleted object
  47. }
  48. VOID SetTypes(const BYTE* types, INT count);
  49. virtual INT NextSubpath(INT* startIndex, INT* endIndex, BOOL* isClosed);
  50. INT NextPathType(BYTE* pathType, INT* startIndex, INT* endIndex);
  51. virtual INT NextMarker(INT* startIndex, INT* endIndex);
  52. virtual INT GetCount() {return Count;}
  53. virtual INT GetSubpathCount() {return SubpathCount;}
  54. BOOL IsValid() const
  55. {
  56. #ifdef _X86_
  57. // We have to guarantee that the Tag field doesn't move for
  58. // versioning to work between releases of GDI+.
  59. ASSERT(offsetof(DpPathTypeIterator, Tag) == 4);
  60. #endif
  61. ASSERT((Tag == ObjectTagPathIterator) || (Tag == ObjectTagInvalid));
  62. #if DBG
  63. if (Tag == ObjectTagInvalid)
  64. {
  65. WARNING1("Invalid DpPathTypeIterator");
  66. }
  67. #endif
  68. return (Tag == ObjectTagPathIterator);
  69. }
  70. BOOL HasCurve() {return HasBezier;}
  71. BOOL IsDashMode(INT index);
  72. BOOL IsExtendedPath() {return ExtendedPath;}
  73. VOID Rewind()
  74. {
  75. Index = 0;
  76. SubpathStartIndex = 0;
  77. SubpathEndIndex = -1;
  78. TypeStartIndex = 0;
  79. TypeEndIndex = -1;
  80. MarkerStartIndex = 0;
  81. MarkerEndIndex = -1;
  82. }
  83. VOID RewindSubpath()
  84. {
  85. // Set the start and end index of type to be the starting index of
  86. // the current subpath. NextPathType() will start from the
  87. // beginning of the current subpath.
  88. TypeStartIndex = SubpathStartIndex;
  89. TypeEndIndex = -1; // Indicate that this is the first type
  90. // in the current subpath.
  91. // Set the current index to the start index of the subpath.
  92. Index = SubpathStartIndex;
  93. }
  94. protected:
  95. // DpPathTypeIterator(DpPath* path);
  96. VOID Initialize()
  97. {
  98. Types = NULL;
  99. Count = 0;
  100. SubpathCount = 0;
  101. SetValid(TRUE);
  102. HasBezier = FALSE;
  103. ExtendedPath = FALSE;
  104. Rewind();
  105. }
  106. BOOL CheckValid();
  107. protected:
  108. const BYTE* Types;
  109. INT Count;
  110. INT SubpathCount;
  111. BOOL HasBezier;
  112. BOOL ExtendedPath;
  113. INT Index;
  114. INT SubpathStartIndex;
  115. INT SubpathEndIndex;
  116. INT TypeStartIndex;
  117. INT TypeEndIndex;
  118. INT MarkerStartIndex;
  119. INT MarkerEndIndex;
  120. };
  121. class DpPathIterator : public DpPathTypeIterator
  122. {
  123. public:
  124. DpPathIterator()
  125. {
  126. Points = NULL;
  127. }
  128. DpPathIterator(const GpPointF* points, const BYTE* types, INT count)
  129. {
  130. Points = NULL;
  131. SetData(points, types, count);
  132. }
  133. DpPathIterator(const DpPath* path);
  134. VOID SetData(const GpPointF* points, const BYTE* types, INT count);
  135. VOID SetData(const DpPath* path);
  136. virtual INT NextSubpath(INT* startIndex, INT* endIndex, BOOL* isClosed);
  137. virtual INT NextSubpath(DpPath* path, BOOL* isClosed);
  138. virtual INT NextMarker(INT* startIndex, INT* endIndex);
  139. virtual INT NextMarker(DpPath* path);
  140. INT Enumerate(GpPointF *points, BYTE *types, INT count);
  141. INT CopyData(GpPointF* points, BYTE* types, INT startIndex, INT endIndex);
  142. protected:
  143. VOID Initialize()
  144. {
  145. DpPathTypeIterator::Initialize();
  146. Points = NULL;
  147. }
  148. INT EnumerateWithinSubpath(GpPointF* points, BYTE* types, INT count);
  149. protected:
  150. const GpPointF* Points;
  151. };
  152. #endif