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

  1. /******************************************************************************/
  2. /* HELLO WORLD SAMPLE PROGRAM - Version 5: AEarthWindow Class (AEARTHW5.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 "aearthw5.hpp"                 //Include our class header
  29.  
  30. //**************************************************************************
  31. // AEarthWindow :: AEarthWindow - Constructor for "earth" window           *
  32. //**************************************************************************
  33. AEarthWindow :: AEarthWindow(unsigned long windowId,
  34.                              IWindow * parowWindow,
  35.                              const IRectangle& rect) :
  36.                 IStaticText(windowId, parowWindow, parowWindow, rect)
  37. {
  38.   handleEventsFor(this);                //Set self as event handler
  39.   show();
  40. } /* end AEarthWindow :: AEarthWindow(...) */
  41.  
  42. //**************************************************************************
  43. // AEarthWindow :: paintWindow - paint an view of "earth" from space       *
  44. //**************************************************************************
  45. Boolean AEarthWindow :: paintWindow(IPaintEvent & paintEvent)
  46. {
  47.   POINTL pt0, pt1, pt2 ;
  48.   POINTL ptlist[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} ;
  49.   LONG   delta ;
  50.   IPresSpaceHandle hps ;                //Presentation Space Handle
  51.  
  52.   hps = paintEvent.presSpaceHandle() ;  //Get the presentation space handle
  53.   pt0.x = 0 ;                           //Setup point 0 with origin of window
  54.   pt0.y = 0 ;
  55.   GpiMove (hps, &pt0) ;                 //Set point to origin of window
  56.   GpiSetColor (hps, CLR_BLACK) ;        //Set color to black
  57.   pt1.x = size().width() ;              //Setup point 1 with top-right corner
  58.   pt1.y = size().height() ;
  59.   GpiBox (hps, DRO_OUTLINEFILL, &pt1, 0, 0) ; //Draw Box in entire window
  60.  
  61.   pt2.x = (pt1.x-pt0.x)/2 ;             //Compute half of the window size
  62.   pt2.y = (pt1.y-pt0.y)/2 ;
  63.   delta = pt2.x/8 ;                     //Set delta from edge
  64.   ptlist[0].x = pt0.x + delta ;         //Set point from a little from origin
  65.   ptlist[0].y = pt0.y ;
  66.   ptlist[1].x = pt0.x + pt2.x ;         //Set middle point of arc for "glow"
  67.   ptlist[1].y = pt0.y + pt2.y ;
  68.   ptlist[2].x = pt1.x - delta ;         //Set last point of arc in from edge
  69.   ptlist[2].y = pt0.y ;
  70.   GpiSetColor (hps, CLR_BLUE);          //Set "glow" color to Blue
  71.   GpiBeginPath (hps, 1L) ;              //Begin GPI Path to create "glow"
  72.   GpiMove (hps, &ptlist[0]) ;           //Move to first point
  73.   GpiPointArc (hps, &ptlist[1]);        //"Draw" 3 point arc in path
  74.   GpiLine (hps, &ptlist[0]);            //Connect lines to starting point
  75.   GpiEndPath (hps) ;                    //Close path
  76.   GpiFillPath(hps, 1L, FPATH_ALTERNATE);//Fill Path to create "glow"
  77.  
  78.   ptlist[0].x = ptlist[0].x + 30 ;      //Setup starting point for "earth"
  79.   ptlist[1].y = ptlist[1].y - 10 ;      //Setup middle point for "earth"
  80.   ptlist[2].x = ptlist[2].x - 30 ;      //Setup last point for "earth"
  81.   GpiSetColor (hps, CLR_CYAN) ;         //Set "earth" color to cyan
  82.   GpiBeginPath (hps, 1L) ;              //Begin path for "earth"
  83.   GpiMove (hps, &ptlist[0]) ;           //Move to first point
  84.   GpiPointArc (hps, &ptlist[1]) ;       //"Draw" 3 point arc in path
  85.   GpiLine (hps, &ptlist[0]) ;           //Connect to starting point
  86.   GpiEndPath (hps) ;                    //Close path
  87.   GpiFillPath(hps, 1L, FPATH_ALTERNATE);//Fill Path to create "earth"
  88.  
  89.   ptlist[0].x = ptlist[0].x - delta ;   //Create "star" points
  90.   ptlist[1].x = ptlist[1].x - delta ;
  91.   ptlist[2].x = ptlist[2].x + delta ;
  92.   ptlist[3].x = ptlist[0].x + (delta*3);
  93.   ptlist[4].x = ptlist[1].x + delta ;
  94.   ptlist[5].x = ptlist[2].x - (delta*2);
  95.   delta = pt2.y/3 ;                     //New delta to create "random" stars
  96.   ptlist[0].y = pt1.y - delta ;
  97.   ptlist[1].y = ptlist[1].y + delta ;
  98.   ptlist[2].y = ptlist[2].y + delta ;
  99.   ptlist[3].y = pt1.y - (delta*2) ;
  100.   ptlist[4].y = ptlist[1].y + (delta*2);
  101.   ptlist[5].y = ptlist[2].y + (delta*3);//Done with "star" points
  102.   GpiSetColor (hps, CLR_WHITE) ;        //Set "star" color to white
  103.   GpiSetMarker (hps, MARKSYM_DOT) ;     //Set mark for "stars"
  104.   GpiPolyMarker (hps, 6L, &ptlist[0]) ; //Draw "stars"
  105.   return (true) ;                       //Return
  106.  
  107. } /* end AEarthWindow :: paintEvent(..) */
  108.