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.

113 lines
3.4 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: CContainer.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 "CContainer.h"
  14. #define ROOT 0
  15. #define LEFT 1
  16. #define RIGHT 2
  17. #define TOP 3
  18. #define BOTTOM 4
  19. CContainer::CContainer(BOOL bRegression)
  20. {
  21. strcpy(m_szName,"Container");
  22. m_circlePath=NULL;
  23. m_circleRect.X=0;
  24. m_circleRect.Y=0;
  25. m_circleRect.Width=(int)(TESTAREAWIDTH/4.0f);
  26. m_circleRect.Height=(int)(TESTAREAHEIGHT/4.0f);
  27. m_bRegression=bRegression;
  28. }
  29. CContainer::~CContainer()
  30. {
  31. }
  32. void CContainer::Draw(Graphics *g)
  33. {
  34. m_circlePath = new GraphicsPath;
  35. m_circlePath->AddEllipse(m_circleRect);
  36. // !!! [agodfrey] Question: If I add the next line, why do I get no output?
  37. // m_circlePath->AddEllipse(m_circleRect);
  38. INT id = g->Save();
  39. g->TranslateTransform((int)(TESTAREAWIDTH/4.0f), (int)(TESTAREAHEIGHT/4.0f));
  40. DrawFractal(g, 245, ROOT, 8);
  41. g->Restore(id);
  42. delete m_circlePath;
  43. }
  44. void CContainer::DrawFractal(Graphics * g, BYTE gray, INT side, INT count)
  45. {
  46. ARGB argb;
  47. switch (count % 3)
  48. {
  49. case 0:
  50. argb = Color::MakeARGB(255, 0, 0, gray);
  51. break;
  52. case 1:
  53. argb = Color::MakeARGB(255, 0, gray, 0);
  54. break;
  55. case 2:
  56. argb = Color::MakeARGB(255, gray, 0, 0);
  57. gray -= 60;
  58. break;
  59. }
  60. Color color(argb);
  61. SolidBrush contBrush(color);
  62. g->SetPageUnit(UnitPixel);
  63. g->FillPath(&contBrush, m_circlePath);
  64. if (--count == 0)
  65. {
  66. return;
  67. }
  68. Rect destRect;
  69. GraphicsContainer cstate;
  70. if (side != LEFT)
  71. {
  72. destRect = Rect((int)(TESTAREAWIDTH/4.0f), (int)(TESTAREAHEIGHT/16.0f), (int)(TESTAREAWIDTH/8.0f), (int)(TESTAREAHEIGHT/8.0f));
  73. cstate = g->BeginContainer(destRect, m_circleRect, UnitPixel);
  74. g->SetSmoothingMode(SmoothingModeAntiAlias);
  75. DrawFractal(g, gray, RIGHT, count);
  76. g->EndContainer(cstate);
  77. }
  78. if (side != TOP)
  79. {
  80. destRect = Rect((int)(TESTAREAWIDTH/16.0f), (int)(TESTAREAHEIGHT/4.0f), (int)(TESTAREAWIDTH/8.0f), (int)(TESTAREAHEIGHT/8.0f));
  81. cstate = g->BeginContainer(destRect, m_circleRect, UnitPixel);
  82. g->SetSmoothingMode(SmoothingModeNone);
  83. DrawFractal(g, gray, BOTTOM, count);
  84. g->EndContainer(cstate);
  85. }
  86. if (side != RIGHT)
  87. {
  88. destRect = Rect(-(int)(TESTAREAWIDTH/8.0f), (int)(TESTAREAHEIGHT/16.0f), (int)(TESTAREAWIDTH/8.0f), (int)(TESTAREAHEIGHT/8.0f));
  89. cstate = g->BeginContainer(destRect, m_circleRect, UnitPixel);
  90. g->SetSmoothingMode(SmoothingModeAntiAlias);
  91. DrawFractal(g, gray, LEFT, count);
  92. g->EndContainer(cstate);
  93. }
  94. if (side != BOTTOM)
  95. {
  96. destRect = Rect((int)(TESTAREAWIDTH/16.0f), -(int)(TESTAREAHEIGHT/8.0f), (int)(TESTAREAWIDTH/8.0f), (int)(TESTAREAHEIGHT/8.0f));
  97. cstate = g->BeginContainer(destRect, m_circleRect, UnitPixel);
  98. g->SetSmoothingMode(SmoothingModeNone);
  99. DrawFractal(g, gray, TOP, count);
  100. g->EndContainer(cstate);
  101. }
  102. }