home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ICLUI.ZIP / HELLO6 / AEARTHW6.CPP < prev    next >
Text File  |  1993-03-08  |  6KB  |  109 lines

  1. /******************************************************************************/
  2. /* HELLO WORLD SAMPLE PROGRAM - Version 6: AEarthWindow Class (AEARTHW6.CPP)  */
  3. /*                                                                            */
  4. /* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1993. */
  5. /*                                                                            */
  6. /* DISCLAIMER OF WARRANTIES:                                                  */
  7. /*   The following [enclosed] code is sample code created by IBM              */
  8. /*   Corporation.  This sample code is not part of any standard IBM product   */
  9. /*   and is provided to you solely for the purpose of assisting you in the    */
  10. /*   development of your applications.  The code is provided "AS IS",         */
  11. /*   without warranty of any kind.  IBM shall not be liable for any damages   */
  12. /*   arising out of your use of the sample code, even if they have been       */
  13. /*   advised of the possibility of such damages.                              */
  14. /******************************************************************************/
  15.  
  16. //**************************************************************************
  17. // The entire file was created at version 5                                *
  18. //**************************************************************************
  19.  
  20. #include <irect.hpp>                    //IRectangle Class Header
  21. #include <ipainevt.hpp>                 //IPaintEvent Class Header
  22. #include <ihandle.hpp>                  //IHandle Class Header
  23.  
  24. #define INCL_GPIPRIMITIVES              //Set to include GPI Primitives
  25. #define INCL_GPIPATHS                   //Set to include GPI Paths
  26. #include <os2.h>
  27.  
  28. #include "aearthw6.hpp"                 //Include our class header
  29.  
  30. //*************************************************************************
  31. //**************************************************************************
  32. // AEarthWindow :: AEarthWindow - Constructor for "earth" window           *
  33. //**************************************************************************
  34. AEarthWindow :: AEarthWindow(unsigned long windowId,
  35.                              IWindow * parowWindow,
  36.                              const IRectangle& rect) :
  37.                 IStaticText(windowId, parowWindow, parowWindow, rect)
  38. {
  39.   handleEventsFor(this);                //Set self as event handler
  40.   show () ;
  41. } /* end AEarthWindow :: AEarthWindow(...) */
  42.  
  43. //**************************************************************************
  44. // AEarthWindow :: paintWindow - paint an view of "earth" from space       *
  45. //**************************************************************************
  46. Boolean AEarthWindow :: paintWindow(IPaintEvent & paintEvent)
  47. {
  48.   POINTL pt0, pt1, pt2 ;
  49.   POINTL ptlist[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} ;
  50.   LONG   delta ;
  51.   IPresSpaceHandle hps ;                //Presentation Space Handle
  52.  
  53.   hps = paintEvent.presSpaceHandle() ;  //Get the presentation space handle
  54.   pt0.x = 0 ;                           //Setup point 0 with origin of window
  55.   pt0.y = 0 ;
  56.   GpiMove (hps, &pt0) ;                 //Set point to origin of window
  57.   GpiSetColor (hps, CLR_BLACK) ;        //Set color to black
  58.   pt1.x = size().width() ;              //Setup point 1 with top-right corner
  59.   pt1.y = size().height() ;
  60.   GpiBox (hps, DRO_OUTLINEFILL, &pt1, 0, 0) ; //Draw Box in entire window
  61.  
  62.   pt2.x = (pt1.x-pt0.x)/2 ;             //Compute half of the window size
  63.   pt2.y = (pt1.y-pt0.y)/2 ;
  64.   delta = pt2.x/8 ;                     //Set delta from edge
  65.   ptlist[0].x = pt0.x + delta ;         //Set point from a little from origin
  66.   ptlist[0].y = pt0.y ;
  67.   ptlist[1].x = pt0.x + pt2.x ;         //Set middle point of arc for "glow"
  68.   ptlist[1].y = pt0.y + pt2.y ;
  69.   ptlist[2].x = pt1.x - delta ;         //Set last point of arc in from edge
  70.   ptlist[2].y = pt0.y ;
  71.   GpiSetColor (hps, CLR_BLUE);          //Set "glow" color to Blue
  72.   GpiBeginPath (hps, 1L) ;              //Begin GPI Path to create "glow"
  73.   GpiMove (hps, &ptlist[0]) ;           //Move to first point
  74.   GpiPointArc (hps, &ptlist[1]);        //"Draw" 3 point arc in path
  75.   GpiLine (hps, &ptlist[0]);            //Connect lines to starting point
  76.   GpiEndPath (hps) ;                    //Close path
  77.   GpiFillPath(hps, 1L, FPATH_ALTERNATE);//Fill Path to create "glow"
  78.  
  79.   ptlist[0].x = ptlist[0].x + 30 ;      //Setup starting point for "earth"
  80.   ptlist[1].y = ptlist[1].y - 10 ;      //Setup middle point for "earth"
  81.   ptlist[2].x = ptlist[2].x - 30 ;      //Setup last point for "earth"
  82.   GpiSetColor (hps, CLR_CYAN) ;         //Set "earth" color to cyan
  83.   GpiBeginPath (hps, 1L) ;              //Begin path for "earth"
  84.   GpiMove (hps, &ptlist[0]) ;           //Move to first point
  85.   GpiPointArc (hps, &ptlist[1]) ;       //"Draw" 3 point arc in path
  86.   GpiLine (hps, &ptlist[0]) ;           //Connect to starting point
  87.   GpiEndPath (hps) ;                    //Close path
  88.   GpiFillPath(hps, 1L, FPATH_ALTERNATE);//Fill Path to create "earth"
  89.  
  90.   ptlist[0].x = ptlist[0].x - delta ;   //Create "star" points
  91.   ptlist[1].x = ptlist[1].x - delta ;
  92.   ptlist[2].x = ptlist[2].x + delta ;
  93.   ptlist[3].x = ptlist[0].x + (delta*3);
  94.   ptlist[4].x = ptlist[1].x + delta ;
  95.   ptlist[5].x = ptlist[2].x - (delta*2);
  96.   delta = pt2.y/3 ;                     //New delta to create "random" stars
  97.   ptlist[0].y = pt1.y - delta ;
  98.   ptlist[1].y = ptlist[1].y + delta ;
  99.   ptlist[2].y = ptlist[2].y + delta ;
  100.   ptlist[3].y = pt1.y - (delta*2) ;
  101.   ptlist[4].y = ptlist[1].y + (delta*2);
  102.   ptlist[5].y = ptlist[2].y + (delta*3);//Done with "star" points
  103.   GpiSetColor (hps, CLR_WHITE) ;        //Set "star" color to white
  104.   GpiSetMarker (hps, MARKSYM_DOT) ;     //Set mark for "stars"
  105.   GpiPolyMarker (hps, 6L, &ptlist[0]) ; //Draw "stars"
  106.   return (true) ;                       //Return
  107.  
  108. } /* end AEarthWindow :: paintEvent(..) */
  109.