home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ICLUI.ZIP
/
HELLO6
/
AEARTHW6.CPP
< prev
next >
Wrap
Text File
|
1993-03-08
|
6KB
|
109 lines
/******************************************************************************/
/* HELLO WORLD SAMPLE PROGRAM - Version 6: AEarthWindow Class (AEARTHW6.CPP) */
/* */
/* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1993. */
/* */
/* DISCLAIMER OF WARRANTIES: */
/* The following [enclosed] code is sample code created by IBM */
/* Corporation. This sample code is not part of any standard IBM product */
/* and is provided to you solely for the purpose of assisting you in the */
/* development of your applications. The code is provided "AS IS", */
/* without warranty of any kind. IBM shall not be liable for any damages */
/* arising out of your use of the sample code, even if they have been */
/* advised of the possibility of such damages. */
/******************************************************************************/
//**************************************************************************
// The entire file was created at version 5 *
//**************************************************************************
#include <irect.hpp> //IRectangle Class Header
#include <ipainevt.hpp> //IPaintEvent Class Header
#include <ihandle.hpp> //IHandle Class Header
#define INCL_GPIPRIMITIVES //Set to include GPI Primitives
#define INCL_GPIPATHS //Set to include GPI Paths
#include <os2.h>
#include "aearthw6.hpp" //Include our class header
//*************************************************************************
//**************************************************************************
// AEarthWindow :: AEarthWindow - Constructor for "earth" window *
//**************************************************************************
AEarthWindow :: AEarthWindow(unsigned long windowId,
IWindow * parowWindow,
const IRectangle& rect) :
IStaticText(windowId, parowWindow, parowWindow, rect)
{
handleEventsFor(this); //Set self as event handler
show () ;
} /* end AEarthWindow :: AEarthWindow(...) */
//**************************************************************************
// AEarthWindow :: paintWindow - paint an view of "earth" from space *
//**************************************************************************
Boolean AEarthWindow :: paintWindow(IPaintEvent & paintEvent)
{
POINTL pt0, pt1, pt2 ;
POINTL ptlist[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} ;
LONG delta ;
IPresSpaceHandle hps ; //Presentation Space Handle
hps = paintEvent.presSpaceHandle() ; //Get the presentation space handle
pt0.x = 0 ; //Setup point 0 with origin of window
pt0.y = 0 ;
GpiMove (hps, &pt0) ; //Set point to origin of window
GpiSetColor (hps, CLR_BLACK) ; //Set color to black
pt1.x = size().width() ; //Setup point 1 with top-right corner
pt1.y = size().height() ;
GpiBox (hps, DRO_OUTLINEFILL, &pt1, 0, 0) ; //Draw Box in entire window
pt2.x = (pt1.x-pt0.x)/2 ; //Compute half of the window size
pt2.y = (pt1.y-pt0.y)/2 ;
delta = pt2.x/8 ; //Set delta from edge
ptlist[0].x = pt0.x + delta ; //Set point from a little from origin
ptlist[0].y = pt0.y ;
ptlist[1].x = pt0.x + pt2.x ; //Set middle point of arc for "glow"
ptlist[1].y = pt0.y + pt2.y ;
ptlist[2].x = pt1.x - delta ; //Set last point of arc in from edge
ptlist[2].y = pt0.y ;
GpiSetColor (hps, CLR_BLUE); //Set "glow" color to Blue
GpiBeginPath (hps, 1L) ; //Begin GPI Path to create "glow"
GpiMove (hps, &ptlist[0]) ; //Move to first point
GpiPointArc (hps, &ptlist[1]); //"Draw" 3 point arc in path
GpiLine (hps, &ptlist[0]); //Connect lines to starting point
GpiEndPath (hps) ; //Close path
GpiFillPath(hps, 1L, FPATH_ALTERNATE);//Fill Path to create "glow"
ptlist[0].x = ptlist[0].x + 30 ; //Setup starting point for "earth"
ptlist[1].y = ptlist[1].y - 10 ; //Setup middle point for "earth"
ptlist[2].x = ptlist[2].x - 30 ; //Setup last point for "earth"
GpiSetColor (hps, CLR_CYAN) ; //Set "earth" color to cyan
GpiBeginPath (hps, 1L) ; //Begin path for "earth"
GpiMove (hps, &ptlist[0]) ; //Move to first point
GpiPointArc (hps, &ptlist[1]) ; //"Draw" 3 point arc in path
GpiLine (hps, &ptlist[0]) ; //Connect to starting point
GpiEndPath (hps) ; //Close path
GpiFillPath(hps, 1L, FPATH_ALTERNATE);//Fill Path to create "earth"
ptlist[0].x = ptlist[0].x - delta ; //Create "star" points
ptlist[1].x = ptlist[1].x - delta ;
ptlist[2].x = ptlist[2].x + delta ;
ptlist[3].x = ptlist[0].x + (delta*3);
ptlist[4].x = ptlist[1].x + delta ;
ptlist[5].x = ptlist[2].x - (delta*2);
delta = pt2.y/3 ; //New delta to create "random" stars
ptlist[0].y = pt1.y - delta ;
ptlist[1].y = ptlist[1].y + delta ;
ptlist[2].y = ptlist[2].y + delta ;
ptlist[3].y = pt1.y - (delta*2) ;
ptlist[4].y = ptlist[1].y + (delta*2);
ptlist[5].y = ptlist[2].y + (delta*3);//Done with "star" points
GpiSetColor (hps, CLR_WHITE) ; //Set "star" color to white
GpiSetMarker (hps, MARKSYM_DOT) ; //Set mark for "stars"
GpiPolyMarker (hps, 6L, &ptlist[0]) ; //Draw "stars"
return (true) ; //Return
} /* end AEarthWindow :: paintEvent(..) */