home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / hello5 / aearthw5.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  7.3 KB  |  159 lines

  1. /******************************************************************************
  2. * .FILE:         aearthw5.hpp                                                 *
  3. *                                                                             *
  4. * .DESCRIPTION:  Hello World Sample Program Version 5:  AEarthWindow Header   *
  5. *                                                                             *
  6. * .CLASSES:      AEarthWindow                                                 *
  7. *                AEarthWindowResizeHandler                                    *
  8. *                Star                                                         *
  9. *                                                                             *
  10. * .COPYRIGHT:                                                                 *
  11. *    Licensed Material - Program-Property of IBM                              *
  12. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  13. *                                                                             *
  14. * .DISCLAIMER:                                                                *
  15. *   The following [enclosed] code is sample code created by IBM               *
  16. *   Corporation.  This sample code is not part of any standard IBM product    *
  17. *   and is provided to you solely for the purpose of assisting you in the     *
  18. *   development of your applications.  The code is provided 'AS IS',          *
  19. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  20. *   arising out of your use of the sample code, even if they have been        *
  21. *   advised of the possibility of such damages.                               *
  22. *                                                                             *
  23. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  24. *                                                                             *
  25. ******************************************************************************/
  26. #ifndef _AEARTHW5_
  27. #define _AEARTHW5_
  28.  
  29. #include <igline.hpp>
  30. #include <igelipse.hpp>
  31. #include <igrect.hpp>
  32. #include <igbundle.hpp>
  33. #include <idrawcv.hpp>
  34. #include <iglist.hpp>
  35. #include <isizehdr.hpp>
  36.  
  37.  
  38. const int                       //Number of stars in the sky
  39.   stars=13;
  40. const int                       //Number of layers in the atmosphere
  41.   atmosphereLayers=3;
  42.  
  43. class AEarthWindow;
  44.  
  45. /**************************************************************************
  46. * Class Star -- Draws a star at a specified location                      *
  47. **************************************************************************/
  48.  
  49. class Star:public IGLine
  50. {
  51.   public:
  52. /*--------------------------- Constructor --------------------------------|
  53. | Constructs the object with:                                             |
  54. | 1) the point to put the star                                            |
  55. -------------------------------------------------------------------------*/
  56.     Star(const IPoint &pt) ;
  57.  
  58. /*------------------------------------------------------------------------|
  59. |  setPoint -- This function sets a new location to draw the star at      |
  60. -------------------------------------------------------------------------*/
  61.     Star
  62.      &setPoint(const IPoint &pt);
  63. };
  64.  
  65.  
  66. /**************************************************************************
  67. * Class AEarthWindowResizeHandler -- A handler to resize the picture      *
  68. *    according to the new dimensions of the IDrawingCanvas window.        *
  69. **************************************************************************/
  70. class AEarthWindowResizeHandler: public IResizeHandler
  71. {
  72.   public:
  73. /*--------------------------- Constructor --------------------------------|
  74. | Constructs the object with:                                             |
  75. | 1) a pointer to the EarthWindow                                         |
  76. -------------------------------------------------------------------------*/
  77.     AEarthWindowResizeHandler (AEarthWindow *aew);
  78.  
  79. /*--------------------------- Destructor ---------------------------------|
  80. | Destructs the object with:                                              |
  81. | 1) no parameters                                                        |
  82. -------------------------------------------------------------------------*/
  83.     virtual ~AEarthWindowResizeHandler();
  84.  
  85.   protected:
  86. /*-------------------- Override windowResize Function --------------------|
  87. | The windowResize() function is called to handle resizing of             |
  88. | the IDrawingCanvas text window containing the graphics of Earth.        |
  89. |------------------------------------------------------------------------*/
  90.     virtual Boolean
  91.       windowResize(IResizeEvent & evnt);
  92.  
  93.   private:
  94.     AEarthWindow
  95.      *earthWindow;
  96. };
  97.  
  98. /**************************************************************************
  99. * Class AEarthWindow -- Earth window for the C++ Hello World sample       *
  100. *    application.                                                         *
  101. **************************************************************************/
  102. class AEarthWindow : public IDrawingCanvas
  103. {
  104.   public:
  105. /*--------------------------- Constructor --------------------------------|
  106. | Constructs the object with:                                             |
  107. | 1) the window id, the parent window, and the size of the window         |
  108. -------------------------------------------------------------------------*/
  109.     AEarthWindow(unsigned long windowId,
  110.                  IWindow * parentownerWindow,
  111.                  const IRectangle& rect=IRectangle());
  112.  
  113. /*--------------------------- Destructor ---------------------------------|
  114. | Destructs the object with:                                              |
  115. | 1) no parameters                                                        |
  116. -------------------------------------------------------------------------*/
  117.     virtual
  118.      ~AEarthWindow();
  119.  
  120. /*------------------ Paint the Earth and Stars Functions -----------------|
  121. | These functions are called to draw the Earth and stars in a static      |
  122. | text window.                                                            |
  123. |   paintWorld - Clear the background, draw the Earth and a variable      |
  124. |           number of atmosphere layers, and call paintStars to draw the  |
  125. |           stars.                                                        |
  126. |   paintStars - Draw the stars as graphical points.                      |
  127. |------------------------------------------------------------------------*/
  128.     Boolean
  129.       paintWorld(),
  130.       paintStars();
  131.  
  132.   private:
  133.     AEarthWindowResizeHandler
  134.       earthWindowResizeHandler;
  135.     IColor
  136.       spaceColor,
  137.       globeColor,
  138.       starColor;
  139.     Star
  140.      *starlist[stars];
  141.     IGEllipse
  142.      *earthArc[atmosphereLayers+1];
  143.     IGRectangle
  144.       space;
  145.     IGList
  146.       graphList,
  147.       earthGraphicList,
  148.       starGraphicList;
  149.  
  150. /*------------------------------ Operators -------------------------------|
  151. | Operators defined for this class:                                       |
  152. |  =  -- Assignment operator                                              |
  153. -------------------------------------------------------------------------*/
  154.     AEarthWindow
  155.      &operator=(const AEarthWindow&);    //Default assignment operator
  156.  
  157. };
  158. #endif
  159.