home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / HELLO6 / AEARTHW6.HPP < prev    next >
C/C++ Source or Header  |  1995-04-07  |  15KB  |  198 lines

  1. #ifndef _AEARTHW6_
  2. #define _AEARTHW6_
  3. /*****************************************************************************
  4. * HELLO WORLD SAMPLE PROGRAM - Version 6: AEarthWindow Header (aearthw6.hpp) *
  5. *                                                                            *
  6. * COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1995. *
  7. *                                                                            *
  8. * DISCLAIMER OF WARRANTIES:                                                  *
  9. *   The following [enclosed] code is sample code created by IBM              *
  10. *   Corporation.  This sample code is not part of any standard IBM product   *
  11. *   and is provided to you solely for the purpose of assisting you in the    *
  12. *   development of your applications.  The code is provided "AS IS",         *
  13. *   without warranty of any kind.  IBM shall not be liable for any damages   *
  14. *   arising out of your use of the sample code, even if they have been       *
  15. *   advised of the possibility of such damages.                              *
  16. *****************************************************************************/
  17. // NOTE: WE RECOMMEND USING A FIXED-SPACE FONT TO LOOK AT THE SOURCE.
  18. #ifndef _ISTATTXT_                                                          //V5
  19.   #include <istattxt.hpp>                 //IStaticText class Header          V5
  20. #endif                                                                      //V5
  21. #ifndef _IPAINHDR_                                                          //V5
  22.   #include <ipainhdr.hpp>                 //IPaintHandler class Header        V5
  23. #endif                                                                      //V5
  24. #ifndef _ATIMEHDR_                                                          //V6
  25.   #include "atimehdr.hpp"       //Include ATimeHandler class header           V6
  26. #endif                                                                      //V6
  27.  
  28. /**************************************************************************   V5
  29. * Class:   APaintHandler                                                  *   V5
  30. *                                                                         *   V5
  31. * Purpose: New Paint Handler class that handles requests to repaint       *   V5
  32. *          the static text control containing the graphics of Earth.      *   V5
  33. *                                                                         *   V5
  34. **************************************************************************/ //V5
  35. class APaintHandler : public IPaintHandler {                                //V5
  36. public:                                                                     //V5
  37. virtual ~APaintHandler() { }                                                //V5
  38. protected:                                                                  //V5
  39. /*--------------------- Override paintWindow Function --------------------|   V5
  40. | The paintWindow() function is called to handle repainting of            |   V5
  41. | the static text window containing the graphics of Earth.                |   V5
  42. |------------------------------------------------------------------------*/ //V5
  43. virtual Boolean                                                             //V5
  44.   paintWindow(IPaintEvent&) ;                                               //V5
  45. };                                                                          //V5
  46.  
  47. /**************************************************************************   V6
  48. * Class:   ATwinkleTimeHandler                                            *   V6
  49. *                                                                         *   V6
  50. * Purpose: New Time Handler class that processes timer ticks specifically *   V6
  51. *          for AEarthWindow class windows.  It is derived from the        *   V6
  52. *          ATimeHandler class, which is derived from IHandler class.      *   V6
  53. *                                                                         *   V6
  54. **************************************************************************/ //V6
  55. class ATwinkleTimeHandler : public ATimeHandler {                           //V6
  56. public:                                                                     //V6
  57. virtual ~ATwinkleTimeHandler() { }                                          //V6
  58. protected:                                                                  //V6
  59. /*------------------------ Override Tick Function ------------------------|   V6
  60. | The tick function is called each time a timer event occurs.             |   V6
  61. |------------------------------------------------------------------------*/ //V6
  62. virtual Boolean                                                             //V6
  63.   tick(IEvent& evt);                                                        //V6
  64. };                                                                          //V6
  65.  
  66. /**************************************************************************   V5
  67. * Class:   AEarthWindow                                                   *   V5
  68. *                                                                         *   V5
  69. * Purpose: Earth window for the C++ Hello World sample application.       *   V5
  70. *                                                                         *   V5
  71. **************************************************************************/ //V5
  72. class AEarthWindow : public IStaticText                                     //V5
  73. {                                                                           //V5
  74.   public:                                                                   //V5
  75.     AEarthWindow(unsigned long windowId,                                    //V5
  76.                  IWindow * parentownerWindow,                               //V5
  77.                  const IRectangle& rect=IRectangle());                      //V5
  78. virtual ~AEarthWindow();                                                    //V5
  79. /*---------------------- Earth Window Star Intensity ---------------------|   V6
  80. | The following enumeration type is used to specify the intensity of      |   V6
  81. | the stars in the AEarthWindow object.                                   |   V6
  82. -------------------------------------------------------------------------*/ //V6
  83.     enum Intensity                                                          //V6
  84.       {                                                                     //V6
  85.       dim, twinkle, bright                                                  //V6
  86.       };                                                                    //V6
  87. /*------------------ Paint the Earth and Stars Functions -----------------|   V5
  88. | These functions are called to draw the Earth and stars in a static      |   V5
  89. | text window.                                                            |   V5
  90. |   paintWorld - Clear the background, draw the Earth and a variable      |   V5
  91. |           number of atmosphere layers, and call paintStars to draw the  |   V5
  92. |           stars.                                                        |   V5
  93. |   paintStars - Draw the stars.  The number of graphical points used     |   v6
  94. |           depends on the starIntensity and twinkling attributes.        |   V6
  95. |             dim - draw a single point for every star.                   |   V6
  96. |             bright - draw five points for every star.                   |   V6
  97. |             twinkle - randomly for each star draw one or five points.   |   V6
  98. |------------------------------------------------------------------------*/ //V6
  99. Boolean                                                                     //V5
  100.     paintWorld(),                                                           //V5
  101.     paintStars();                                                           //V5
  102. /*------------------ Earth Window Settings Functions ---------------------|   V6
  103. | These functions are used to change the Earth window settings.           |   V6
  104. |   enableBright - Change starIntensity to bright.                        |   V6
  105. |   disableBright - Change starIntensity to dim.                          |   V6
  106. |   setLayers - Change the number of atmosphere layers drawn atop the     |   V6
  107. |           Earth arc.  Valid values are 0, 1, 2, 3.                      |   V6
  108. |   enableTwinkle - Set twinkling to true.                                |   V6
  109. |   disableTwinkle - Set twinkling to false.                              |   V6
  110. |   setEarthColor - Change the color used to draw the Earth arc.          |   V6
  111. |                                                                         |   V6
  112. | These functions are used to query the Earth window settings.            |   V6
  113. |   isTwinkling - Return true if the stars are set to twinkle.            |   V6
  114. |   isBright - Return true if the stars are to be drawn with five points  |   V6
  115. |           when they are not twinkling.                                  |   V6
  116. |   earthColor - Return the current color used to draw the Earth arc.     |   V6
  117. |   layers - Return the number of arcs drawn above the Earth arc.         |   V6
  118. |------------------------------------------------------------------------*/ //V6
  119. virtual AEarthWindow                                                        //V6
  120.     &enableBright(Boolean makingBright=true),                               //V6
  121.     &disableBright(),                                                       //V6
  122.     &setLayers(const unsigned long atmosphereLayers),                       //V6
  123.     &enableTwinkle(Boolean turningOn=true),                                 //V6
  124.     &disableTwinkle(),                                                      //V6
  125.     &setEarthColor(const IColor &hue);                                      //V6
  126. const Boolean                                                               //V6
  127.     isTwinkling(),                                                          //V6
  128.     isBright();                                                             //V6
  129. const IColor                                                                //V6
  130.     &earthColor();                                                          //V6
  131. const unsigned long                                                         //V6
  132.     layers();                                                               //V6
  133.  
  134.   private:                                                                  //V5
  135.     int         atmosphereLayers;                                           //V5
  136.     Intensity   starIntensity;                                              //V6
  137.     Boolean     twinkling;                                                  //V6
  138.     IColor      spaceColor;                                                 //V5
  139.     IColor      globeColor;                                                 //V5
  140.     IColor      starColor;                                                  //V5
  141.     APaintHandler paintHandler;                                             //V5
  142.     ATwinkleTimeHandler twinkleHandler;                                     //V6
  143.  
  144.     AEarthWindow(const AEarthWindow&);  //Default copy constructor            V5
  145. AEarthWindow                                                                //V5
  146.     &operator=(const AEarthWindow&);    //Default assignment operator         V5
  147.  
  148. /**************************************************************************   V6
  149. * Class:   AEarthWindow :: AStar                                          *   V6
  150. *                                                                         *   V6
  151. * Purpose: Nested Earth window class for encapsulating star attributes.   *   V6
  152. *                                                                         *   V6
  153. **************************************************************************/ //V6
  154.         class       AStar                                                   //V6
  155.         {                                                                   //V6
  156.           public:                                                           //V6
  157. /*------------------------------- Constructors -----------------------------  V6
  158. | You can construct instances of this class in the following ways:         |  V6
  159. |    - From the default constructor.  This constructs an unusable dim      |  V6
  160. |      star positioned at (0,0).                                           |  V6
  161. |    - From a pair of coordinates and an intensity.  This constructs a     |  V6
  162. |      usable star that is either explicitly bright or dim, or randomly    |  V6
  163. |      set to bright or dim if twinkle is specified.                       |  V6
  164. |-------------------------------------------------------------------------*///V6
  165.             AStar() : currentIntensity(dim) { } ;                           //V6
  166.             AStar(IPair coordinates, Intensity starGlow);                   //V6
  167.         virtual ~AStar() { }                                                //V6
  168. /*------------------ Query Star Attributes Functions ---------------------|   V6
  169. | These functions are used to query AStar attributes.                     |   V6
  170. |   intensity - Return the intensity of this star.  Even though twinkle   |   V6
  171. |           intensity can be used to construct a star, only dim or bright |   V6
  172. |           will be returned.  twinkle intensity is used on the           |   V6
  173. |           constructor to randomly select dim or bright.                 |   V6
  174. |   point - Returns the graphical point of an AStar where,                |   V6
  175. |           point(0) is the center point of the star,                     |   V6
  176. |           point(1) is point above the center point,                     |   V6
  177. |           point(2) is point to the right of the center point,           |   V6
  178. |           point(3) is point below the center point,                     |   V6
  179. |           point(4) is point to the left of the center point.            |   V6
  180. |   flicker - Randonly returns true or false.  This protected function    |   V6
  181. |           is used to determine the intensity of twinkling stars.        |   V6
  182. |------------------------------------------------------------------------*/ //V6
  183.         Intensity                                                           //V6
  184.             intensity();                                                    //V6
  185.         const IPoint                                                        //V6
  186.             point(const unsigned long);                                     //V6
  187.           protected:                                                        //V6
  188.         IBoolean                                                            //V6
  189.             flicker();                                                      //V6
  190.  
  191.         private:                                                            //V6
  192.             IPoint      starPoint[5];                                       //V6
  193.             Intensity   currentIntensity;                                   //V6
  194.         }; // AEarthWindow::AStar                                             V6
  195. };                                                                          //V5
  196.  
  197. #endif                                                                      //V5
  198.