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 >
Wrap
C/C++ Source or Header
|
1995-04-07
|
15KB
|
198 lines
#ifndef _AEARTHW6_
#define _AEARTHW6_
/*****************************************************************************
* HELLO WORLD SAMPLE PROGRAM - Version 6: AEarthWindow Header (aearthw6.hpp) *
* *
* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1995. *
* *
* 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. *
*****************************************************************************/
// NOTE: WE RECOMMEND USING A FIXED-SPACE FONT TO LOOK AT THE SOURCE.
#ifndef _ISTATTXT_ //V5
#include <istattxt.hpp> //IStaticText class Header V5
#endif //V5
#ifndef _IPAINHDR_ //V5
#include <ipainhdr.hpp> //IPaintHandler class Header V5
#endif //V5
#ifndef _ATIMEHDR_ //V6
#include "atimehdr.hpp" //Include ATimeHandler class header V6
#endif //V6
/************************************************************************** V5
* Class: APaintHandler * V5
* * V5
* Purpose: New Paint Handler class that handles requests to repaint * V5
* the static text control containing the graphics of Earth. * V5
* * V5
**************************************************************************/ //V5
class APaintHandler : public IPaintHandler { //V5
public: //V5
virtual ~APaintHandler() { } //V5
protected: //V5
/*--------------------- Override paintWindow Function --------------------| V5
| The paintWindow() function is called to handle repainting of | V5
| the static text window containing the graphics of Earth. | V5
|------------------------------------------------------------------------*/ //V5
virtual Boolean //V5
paintWindow(IPaintEvent&) ; //V5
}; //V5
/************************************************************************** V6
* Class: ATwinkleTimeHandler * V6
* * V6
* Purpose: New Time Handler class that processes timer ticks specifically * V6
* for AEarthWindow class windows. It is derived from the * V6
* ATimeHandler class, which is derived from IHandler class. * V6
* * V6
**************************************************************************/ //V6
class ATwinkleTimeHandler : public ATimeHandler { //V6
public: //V6
virtual ~ATwinkleTimeHandler() { } //V6
protected: //V6
/*------------------------ Override Tick Function ------------------------| V6
| The tick function is called each time a timer event occurs. | V6
|------------------------------------------------------------------------*/ //V6
virtual Boolean //V6
tick(IEvent& evt); //V6
}; //V6
/************************************************************************** V5
* Class: AEarthWindow * V5
* * V5
* Purpose: Earth window for the C++ Hello World sample application. * V5
* * V5
**************************************************************************/ //V5
class AEarthWindow : public IStaticText //V5
{ //V5
public: //V5
AEarthWindow(unsigned long windowId, //V5
IWindow * parentownerWindow, //V5
const IRectangle& rect=IRectangle()); //V5
virtual ~AEarthWindow(); //V5
/*---------------------- Earth Window Star Intensity ---------------------| V6
| The following enumeration type is used to specify the intensity of | V6
| the stars in the AEarthWindow object. | V6
-------------------------------------------------------------------------*/ //V6
enum Intensity //V6
{ //V6
dim, twinkle, bright //V6
}; //V6
/*------------------ Paint the Earth and Stars Functions -----------------| V5
| These functions are called to draw the Earth and stars in a static | V5
| text window. | V5
| paintWorld - Clear the background, draw the Earth and a variable | V5
| number of atmosphere layers, and call paintStars to draw the | V5
| stars. | V5
| paintStars - Draw the stars. The number of graphical points used | v6
| depends on the starIntensity and twinkling attributes. | V6
| dim - draw a single point for every star. | V6
| bright - draw five points for every star. | V6
| twinkle - randomly for each star draw one or five points. | V6
|------------------------------------------------------------------------*/ //V6
Boolean //V5
paintWorld(), //V5
paintStars(); //V5
/*------------------ Earth Window Settings Functions ---------------------| V6
| These functions are used to change the Earth window settings. | V6
| enableBright - Change starIntensity to bright. | V6
| disableBright - Change starIntensity to dim. | V6
| setLayers - Change the number of atmosphere layers drawn atop the | V6
| Earth arc. Valid values are 0, 1, 2, 3. | V6
| enableTwinkle - Set twinkling to true. | V6
| disableTwinkle - Set twinkling to false. | V6
| setEarthColor - Change the color used to draw the Earth arc. | V6
| | V6
| These functions are used to query the Earth window settings. | V6
| isTwinkling - Return true if the stars are set to twinkle. | V6
| isBright - Return true if the stars are to be drawn with five points | V6
| when they are not twinkling. | V6
| earthColor - Return the current color used to draw the Earth arc. | V6
| layers - Return the number of arcs drawn above the Earth arc. | V6
|------------------------------------------------------------------------*/ //V6
virtual AEarthWindow //V6
&enableBright(Boolean makingBright=true), //V6
&disableBright(), //V6
&setLayers(const unsigned long atmosphereLayers), //V6
&enableTwinkle(Boolean turningOn=true), //V6
&disableTwinkle(), //V6
&setEarthColor(const IColor &hue); //V6
const Boolean //V6
isTwinkling(), //V6
isBright(); //V6
const IColor //V6
&earthColor(); //V6
const unsigned long //V6
layers(); //V6
private: //V5
int atmosphereLayers; //V5
Intensity starIntensity; //V6
Boolean twinkling; //V6
IColor spaceColor; //V5
IColor globeColor; //V5
IColor starColor; //V5
APaintHandler paintHandler; //V5
ATwinkleTimeHandler twinkleHandler; //V6
AEarthWindow(const AEarthWindow&); //Default copy constructor V5
AEarthWindow //V5
&operator=(const AEarthWindow&); //Default assignment operator V5
/************************************************************************** V6
* Class: AEarthWindow :: AStar * V6
* * V6
* Purpose: Nested Earth window class for encapsulating star attributes. * V6
* * V6
**************************************************************************/ //V6
class AStar //V6
{ //V6
public: //V6
/*------------------------------- Constructors ----------------------------- V6
| You can construct instances of this class in the following ways: | V6
| - From the default constructor. This constructs an unusable dim | V6
| star positioned at (0,0). | V6
| - From a pair of coordinates and an intensity. This constructs a | V6
| usable star that is either explicitly bright or dim, or randomly | V6
| set to bright or dim if twinkle is specified. | V6
|-------------------------------------------------------------------------*///V6
AStar() : currentIntensity(dim) { } ; //V6
AStar(IPair coordinates, Intensity starGlow); //V6
virtual ~AStar() { } //V6
/*------------------ Query Star Attributes Functions ---------------------| V6
| These functions are used to query AStar attributes. | V6
| intensity - Return the intensity of this star. Even though twinkle | V6
| intensity can be used to construct a star, only dim or bright | V6
| will be returned. twinkle intensity is used on the | V6
| constructor to randomly select dim or bright. | V6
| point - Returns the graphical point of an AStar where, | V6
| point(0) is the center point of the star, | V6
| point(1) is point above the center point, | V6
| point(2) is point to the right of the center point, | V6
| point(3) is point below the center point, | V6
| point(4) is point to the left of the center point. | V6
| flicker - Randonly returns true or false. This protected function | V6
| is used to determine the intensity of twinkling stars. | V6
|------------------------------------------------------------------------*/ //V6
Intensity //V6
intensity(); //V6
const IPoint //V6
point(const unsigned long); //V6
protected: //V6
IBoolean //V6
flicker(); //V6
private: //V6
IPoint starPoint[5]; //V6
Intensity currentIntensity; //V6
}; // AEarthWindow::AStar V6
}; //V5
#endif //V5