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.

181 lines
6.7 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: CDashes.cpp
  3. *
  4. * This file contains the code to support the functionality test harness
  5. * for GDI+. This includes menu options and calling the appropriate
  6. * functions for execution.
  7. *
  8. * Created: 05-May-2000 - Jeff Vezina [t-jfvez]
  9. *
  10. * Copyright (c) 2000 Microsoft Corporation
  11. *
  12. \**************************************************************************/
  13. #include "CDashes.h"
  14. CDashes::CDashes(BOOL bRegression)
  15. {
  16. strcpy(m_szName,"Lines : Dash, Misc");
  17. m_bRegression=bRegression;
  18. }
  19. CDashes::~CDashes()
  20. {
  21. }
  22. void CDashes::Draw(Graphics *g)
  23. {
  24. /*
  25. REAL width = 4; // Pen width
  26. PointF points[4];
  27. points[0].X = 100;
  28. points[0].Y = 10;
  29. points[1].X = -50;
  30. points[1].Y = 50;
  31. points[2].X = 150;
  32. points[2].Y = 200;
  33. points[3].X = 200;
  34. points[3].Y = 70;
  35. Color yellowColor(128, 255, 255, 0);
  36. SolidBrush yellowBrush(yellowColor);
  37. GraphicsPath* path = new GraphicsPath(FillModeAlternate);
  38. path->AddBeziers(points, 4);
  39. Matrix matrix;
  40. matrix.Scale(1.5, 1.5);
  41. path->Transform(&matrix);
  42. Color blackColor(0, 0, 0);
  43. SolidBrush blackBrush(blackColor);
  44. // Set the pen width in inch.
  45. width = (REAL) 0.2;
  46. Pen pen1(&blackBrush, width, UnitInch);
  47. pen1.SetDashStyle(DashStyleDashDotDot);
  48. pen1.SetDashCap(LineCapRound);
  49. g->DrawPath(&pen1, path);
  50. // Create a multiple segment with a closed segment.
  51. points[0].X = 50;
  52. points[0].Y = 50;
  53. points[1].X = 100;
  54. points[1].Y = 50;
  55. points[2].X = 120;
  56. points[2].Y = 120;
  57. points[3].X = 50;
  58. points[3].Y = 100;
  59. path->Reset();
  60. path->AddLines(points, 4);
  61. path->CloseFigure();
  62. points[0].X = 150;
  63. points[0].Y = 60;
  64. points[1].X = 200;
  65. points[1].Y = 150;
  66. path->AddLines(points, 2);
  67. path->Transform(&matrix);
  68. Color blueColor(128, 0, 0, 255);
  69. SolidBrush blueBrush(blueColor);
  70. width = 5;
  71. Pen pen2(&blueBrush, width);
  72. pen2.SetDashStyle(DashStyleDashDotDot);
  73. g->DrawPath(&pen2, path);
  74. delete path;
  75. */
  76. float factor = 100.0f/g->GetDpiX(); //g->GetDpiX()/100.0f;
  77. // Test GDI punting on pen drawing.
  78. Color col0(0xff,0x80,0x80,0x80);
  79. Color col1(0xff,0x80,0,0);
  80. Color col2(0xff,0,0x80,0);
  81. Color col3(0xff,0,0,0x80);
  82. Pen pen0a(col0, factor*1.0f); // Basic PS_COSMETIC, solid pen
  83. Pen pen0b(col0, 2.0f); // Basic PS_GEOMETRIC, solid pen
  84. // PS_COSMETIC with LINE CAP + MITER JOIN + DASH STYLE
  85. Pen pen1a(col1, factor*1.0f);
  86. pen1a.SetLineCap(LineCapFlat, LineCapFlat, DashCapFlat);
  87. pen1a.SetLineJoin(LineJoinMiter);
  88. pen1a.SetMiterLimit(4.0f);
  89. pen1a.SetDashStyle(DashStyleDot);
  90. // PS_GEOMETRIC with LINE CAP + MITER JOIN + DASH STYLE
  91. Pen pen1b(col1, 2.0f);
  92. pen1b.SetLineCap(LineCapRound, LineCapRound, DashCapRound);
  93. pen1b.SetLineJoin(LineJoinMiter);
  94. pen1b.SetMiterLimit(4.0f);
  95. pen1b.SetDashStyle(DashStyleDashDotDot);
  96. // PS_COSMETIC + LINE CAP + BEVEL JOIN + DASH STYLE
  97. Pen pen2a(col2, factor*1.0f);
  98. pen2a.SetLineCap(LineCapArrowAnchor, LineCapArrowAnchor, DashCapFlat);
  99. pen2a.SetLineJoin(LineJoinBevel);
  100. pen2a.SetDashStyle(DashStyleDash);
  101. // PS_GEOMETRIC + LINE CAP + BEVEL JOIN + DASH STYLE
  102. Pen pen2b(col2, 2.0f);
  103. pen2b.SetLineCap(LineCapSquare, LineCapSquare, DashCapFlat);
  104. pen2b.SetLineJoin(LineJoinRound);
  105. // pen2b.SetDashStyle(DashStyleDot);
  106. pen2b.SetDashStyle(DashStyleDashDot);
  107. // PS_GEOMETRIC + SOLID LINE + FLAT CAP + BEVEL JOIN
  108. Pen pen3(col1, 2.0f);
  109. pen3.SetLineCap(LineCapFlat, LineCapFlat, DashCapFlat);
  110. pen3.SetLineJoin(LineJoinBevel);
  111. // PS_GEOMETRIC + SOLID LINE + SQUARE CAP + MITER JOIN (LIMIT 10 - NON RECTANGLE)
  112. Pen pen3b(col1, 2.0f);
  113. pen3b.SetLineCap(LineCapSquare, LineCapSquare, DashCapFlat);
  114. pen3b.SetLineJoin(LineJoinMiter);
  115. pen3b.SetMiterLimit(4.4f);
  116. // PS_GEOMETRIC + SOLID LINE + ROUND CAP + MITER JOIN (NON RECTANGLE)
  117. Pen pen3c(col1, 2.0f);
  118. pen3c.SetLineCap(LineCapRound, LineCapRound, DashCapRound);
  119. pen3c.SetLineJoin(LineJoinMiter);
  120. pen3c.SetMiterLimit(0.75f);
  121. g->SetPageScale(1.0f);
  122. // Matrix m;
  123. // m.Reset();
  124. // g->SetTransform(&m);
  125. g->DrawRectangle(&pen0a, (int)(100.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT), (int)(100.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT));
  126. g->DrawRectangle(&pen0b, (int)(100.0f/600.0f*TESTAREAWIDTH), (int)(250.0f/600.0f*TESTAREAHEIGHT), (int)(100.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT));
  127. g->DrawRectangle(&pen1a, (int)(250.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT), (int)(100.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT));
  128. g->DrawRectangle(&pen1b, (int)(250.0f/600.0f*TESTAREAWIDTH), (int)(250.0f/600.0f*TESTAREAHEIGHT), (int)(100.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT));
  129. g->DrawRectangle(&pen2a, (int)(400.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT), (int)(100.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT));
  130. g->DrawRectangle(&pen2b, (int)(400.0f/600.0f*TESTAREAWIDTH), (int)(250.0f/600.0f*TESTAREAHEIGHT), (int)(100.0f/600.0f*TESTAREAWIDTH), (int)(100.0f/600.0f*TESTAREAHEIGHT));
  131. // Alter pens, PS_GEOMETRIC + DOT + ROUND CAP + ROUND JOIN
  132. pen2b.SetDashStyle(DashStyleDot);
  133. g->DrawRectangle(&pen2b, (int)(425.0f/600.0f*TESTAREAWIDTH), (int)(275.0f/600.0f*TESTAREAHEIGHT), (int)(50.0f/600.0f*TESTAREAWIDTH), (int)(50.0f/600.0f*TESTAREAHEIGHT));
  134. INT i;
  135. Point newPts[4];
  136. newPts[0].X = (int)(175.0f/600.0f*TESTAREAWIDTH); newPts[0].Y = (int)(400.0f/600.0f*TESTAREAHEIGHT);
  137. newPts[1].X = (int)(250.0f/600.0f*TESTAREAWIDTH); newPts[1].Y = (int)(450.0f/600.0f*TESTAREAHEIGHT);
  138. newPts[2].X = (int)(175.0f/600.0f*TESTAREAWIDTH); newPts[2].Y = (int)(500.0f/600.0f*TESTAREAHEIGHT);
  139. newPts[3].X = (int)(100.0f/600.0f*TESTAREAWIDTH); newPts[3].Y = (int)(450.0f/600.0f*TESTAREAHEIGHT);
  140. g->DrawPolygon(&pen3, &newPts[0], 4);
  141. newPts[0].X = (int)(175.0f/600.0f*TESTAREAWIDTH); newPts[0].Y = (int)(400.0f/600.0f*TESTAREAHEIGHT);
  142. newPts[1].X = (int)(175.0f/600.0f*TESTAREAWIDTH); newPts[1].Y = (int)(500.0f/600.0f*TESTAREAHEIGHT);
  143. newPts[2].X = (int)(100.0f/600.0f*TESTAREAWIDTH); newPts[2].Y = (int)(425.0f/600.0f*TESTAREAHEIGHT);
  144. for (i=0; i<3; i++) newPts[i].X += (int)(150.0f/600.0f*TESTAREAWIDTH);
  145. g->DrawLines(&pen3b, &newPts[0], 3);
  146. for (i=0; i<3; i++) newPts[i].X += (int)(150.0f/600.0f*TESTAREAWIDTH);
  147. g->DrawLines(&pen3c, &newPts[0], 3);
  148. }