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.

196 lines
4.2 KiB

  1. #ifndef GDIPDRAW_H
  2. #define GDIPDRAW_H
  3. // drawing context information
  4. class TestDrawInterface
  5. {
  6. public:
  7. // manipulate the current shape
  8. virtual VOID AddPoint(HWND hwnd, Point pt) = 0;
  9. virtual BOOL DoneShape(HWND hwnd) = 0;
  10. virtual BOOL EndPoint(HWND hwnd, Point pt) = 0;
  11. virtual BOOL RemovePoint(HWND hwnd) = 0;
  12. // draw all shapes
  13. virtual VOID Draw(HWND hwnd) = 0;
  14. virtual VOID SetClipRegion(HWND hwnd) = 0;
  15. // move around a control point
  16. virtual VOID RememberPoint(Point pt) = 0;
  17. virtual VOID MoveControlPoint(Point pt) = 0;
  18. // status window
  19. virtual VOID UpdateStatus(HWND hwnd = NULL) = 0;
  20. virtual VOID SaveAsFile(HWND hwnd) = 0;
  21. };
  22. class TestDraw : public TestDrawInterface
  23. {
  24. public:
  25. TestDraw() : curBrush(NULL),
  26. curPen(NULL),
  27. curShape(NULL),
  28. clipShapeRegion(NULL),
  29. shapeType(LineType),
  30. redrawAll(FALSE),
  31. keepControlPoints(FALSE),
  32. antiAlias(FALSE),
  33. useClip(FALSE)
  34. {
  35. // !! initialize in sync with menu choices
  36. curBrush = new TestSolidBrush();
  37. curBrush->Initialize();
  38. curPen = new TestPen();
  39. curPen->Initialize();
  40. clipShapeRegion = new TestShapeRegion();
  41. worldMatrix = new Matrix();
  42. hwndStatus = NULL;
  43. // !! infinite default may change??
  44. clipRegion = new Region();
  45. clipRegion->SetInfinite();
  46. }
  47. ~TestDraw()
  48. {
  49. delete curBrush;
  50. delete curPen;
  51. delete curShape;
  52. delete clipShapeRegion;
  53. delete worldMatrix;
  54. delete clipRegion;
  55. }
  56. // manipulate the current shape
  57. virtual VOID AddPoint(HWND hwnd, Point pt);
  58. virtual BOOL DoneShape(HWND hwnd);
  59. virtual BOOL EndPoint(HWND hwnd, Point pt);
  60. virtual BOOL RemovePoint(HWND hwnd);
  61. // draw all shapes
  62. virtual VOID Draw(HWND hwnd);
  63. virtual VOID SetClipRegion(HWND hwnd);
  64. // move around a control point
  65. virtual VOID RememberPoint(Point pt);
  66. virtual VOID MoveControlPoint(Point pt);
  67. // status window
  68. virtual VOID UpdateStatus(HWND hwnd = NULL);
  69. virtual VOID SaveAsFile(HWND hwnd);
  70. VOID ChangeBrush(HWND hwnd, INT type);
  71. VOID ChangePen(HWND hwnd);
  72. VOID ChangeShape(HWND hwnd, INT type);
  73. INT GetBrushType()
  74. {
  75. if (!curBrush)
  76. return SolidColorBrush;
  77. else if (curShape && curShape->GetCount() > 0)
  78. return curShape->GetBrush()->GetType();
  79. else
  80. return curBrush->GetType();
  81. }
  82. INT GetPenType()
  83. {
  84. return 0;
  85. }
  86. INT GetShapeType()
  87. {
  88. if (curShape && curShape->GetCount() > 0)
  89. return curShape->GetType();
  90. else
  91. return shapeType;
  92. }
  93. Matrix* GetWorldMatrix()
  94. {
  95. return worldMatrix;
  96. }
  97. VOID SetWorldMatrix(Matrix* newMatrix)
  98. {
  99. delete worldMatrix;
  100. worldMatrix = newMatrix->Clone();
  101. }
  102. // make public to avoid get/set methods
  103. public:
  104. BOOL redrawAll;
  105. BOOL keepControlPoints;
  106. BOOL antiAlias;
  107. BOOL useClip;
  108. private:
  109. TestBrush *curBrush;
  110. TestPen *curPen;
  111. INT shapeType;
  112. TestShape *curShape;
  113. ShapeStack shapeStack;
  114. Matrix *worldMatrix;
  115. Region *clipRegion;
  116. TestShapeRegion *clipShapeRegion;
  117. Point remPoint;
  118. HWND hwndStatus;
  119. };
  120. class TestGradDraw : public TestDrawInterface,
  121. public TestConfigureInterface
  122. {
  123. public:
  124. TestGradDraw() : gradShape(NULL) {};
  125. ~TestGradDraw()
  126. {
  127. // caller's responsible to delete gradShape
  128. }
  129. // manipulate the current shape
  130. virtual VOID AddPoint(HWND hwnd, Point pt);
  131. virtual BOOL DoneShape(HWND hwnd);
  132. virtual BOOL EndPoint(HWND hwnd, Point pt);
  133. virtual BOOL RemovePoint(HWND hwnd);
  134. // draw all shapes
  135. virtual VOID Draw(HWND hwnd);
  136. virtual VOID SetClipRegion(HWND hwnd);
  137. // move around a control point
  138. virtual VOID RememberPoint(Point pt);
  139. virtual VOID MoveControlPoint(Point pt);
  140. // status window
  141. virtual VOID UpdateStatus(HWND hwnd = NULL);
  142. virtual VOID SaveAsFile(HWND hwnd);
  143. // configuration management interface
  144. // initializes/creates the test draw window
  145. BOOL ChangeSettings(HWND hwnd);
  146. VOID Initialize();
  147. VOID Initialize(TestGradShape *gradShape);
  148. /////////////////////////////////////////////////////////////////
  149. // Optional supported menu items
  150. virtual VOID Reset(HWND hwnd);
  151. virtual VOID Instructions(HWND hwnd);
  152. private:
  153. TestGradShape *gradShape;
  154. Point remPoint;
  155. };
  156. #endif