home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / VCW411.ZIP / CIRCLE.CPP next >
Encoding:
C/C++ Source or Header  |  1995-11-29  |  2.7 KB  |  150 lines

  1. // -[Keep_Heading]-
  2.  
  3.  
  4. // -[Copyright_Mesg]-
  5. // --------------------------------------------------------------- //
  6. // (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights reserved.
  7. // Class Name  : Circle
  8. // Designer    : Example Writer
  9. // Filename    : CIRCLE.cpp
  10. // Description : 
  11. // Circle objects are objects in the system that are shown on the screen
  12. // as a circle at a location X,Y with a size specified by Radius. Their
  13. // colour is determined by the protected Colour member in their base
  14. // class Shape.
  15. // --------------------------------------------------------------- //
  16.  
  17.  
  18. // ==================================================
  19. // = LIBRARY
  20. // Step 3 Graphics Example
  21. // = FILENAME
  22. // CIRCLE.cpp
  23. // = RCSID
  24. // $Id$
  25. // = AUTHOR
  26. // Example Writer
  27. // = COPYRIGHT
  28. // (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights reserved.
  29. // ==================================================
  30.  
  31. #include "CIRCLE.h"
  32.  
  33.  
  34. // -[Keep_cpp_Extras]-
  35.  
  36.  
  37. // -[Module_Function_Decs]-
  38.  
  39.  
  40. // -[Module_Data_Decs_Def]-
  41.  
  42.  
  43. // -[Global_Data_Defs]-
  44.  
  45.  
  46. // -[Static_Member_Data_Defs]-
  47.  
  48.  
  49. // -[Function_Defs]-
  50.  
  51. void
  52. Circle::write(Ropstream os)
  53. {
  54.   // Call to base class write functions
  55.   Shape::write(os);
  56.   os << Radius;
  57. }
  58.  
  59. Pvoid
  60. Circle::read(Ripstream is)
  61. {
  62.   // Call to base class read functions
  63.   Shape::read(is);
  64.   is >> Radius;
  65.   return this;
  66. }
  67.  
  68. // Constructs the object before a stream input operation
  69. Circle::Circle(StreamableInit s)
  70.     : Shape(s)
  71.  
  72. {
  73. }
  74.  
  75. // Unique class ID
  76. classType
  77. Circle::isA() const
  78. {
  79.   return CircleClass;
  80. }
  81.  
  82. // Output Class Info
  83. void
  84. Circle::printOn(Rostream outputStream) const
  85. {
  86. }
  87.  
  88. // Class Name
  89. char *
  90. Circle::nameOf() const
  91. {
  92.   return "Circle";
  93. }
  94.  
  95. // Returns a hash value
  96. hashValueType
  97. Circle::hashValue() const
  98. {
  99.   return 0;
  100. }
  101.  
  102. // Tests Equality
  103. int
  104. Circle::isEqual(const Object& testObject) const
  105. {
  106.   return FALSE;
  107. }
  108.  
  109. // Constructs a circle object with the given parameters.
  110. Circle::Circle(int InitX, int InitY, int InitRadius)
  111. : Shape(InitX, InitY)
  112. {
  113.      Radius = InitRadius;
  114.     Width = Radius * 2;
  115.     Height = Radius * 2;
  116.     Colour = RGB(255, 0, 0);
  117. }
  118.  
  119. // Draws the circle.
  120. void
  121. Circle::Show(HDC hDC)
  122. {
  123.     HBRUSH hBrush = CreateSolidBrush(Colour);
  124.     HBRUSH hOldBrush;
  125.  
  126.     hOldBrush = SelectObject(hDC, hBrush);
  127.  
  128.     // Draw the circle
  129.     Ellipse(hDC, X, Y, X + Radius * 2, Y + Radius * 2);
  130.  
  131.     SelectObject(hDC, hOldBrush);
  132.     DeleteObject(hBrush);
  133. }
  134.  
  135.  
  136. // -[Persistent]-
  137. // OWL 1.0 streamability
  138. PTStreamable Circle::build()
  139. {
  140.   return new Circle(streamableInit);
  141. }
  142.  
  143. const Pchar Circle::streamableName() const
  144. {
  145.   return "Circle";
  146. }
  147.  
  148. TStreamableClass RegCircle("Circle", Circle::build,
  149.   __DELTA(Circle));
  150.