home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
COMPILER
/
UILINES
/
PMLINES.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-01
|
11KB
|
196 lines
#ifndef _PMLINES_HPP_INCLUDED_
#define _PMLINES_HPP_INCLUDED_
/*+--------------------------------------------------------------------------+*/
/*| |*/
/*| PROGRAM NAME: PMLINES |*/
/*| ------------- |*/
/*| A Simple OS/2 Presentation Manager Graphics Demonstration Program |*/
/*| |*/
/*| 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. |*/
/*| |*/
/*| REVISION LEVEL: 1.1 |*/
/*| --------------- |*/
/*| |*/
/*+--------------------------------------------------------------------------+*/
/* ----------------------------------------------------------- */
/* This version is a port of the PMLINES program. The original */
/* PMLINES program was coded in C and PM. This port has been */
/* coded in C++. The PM interface is the User Interface Library*/
/* that comes with the compiler. */
/* */
/* The following Library features are demonstrated by this */
/* program. */
/* 1. Window Creation. */
/* 2. Event Handling */
/* 3. Simple multitasking */
/* 4. Use of GPI or native PM API with User Interface Library */
/* Objects */
/* */
/* */
/* Change History: */
/* Rel Programmer Stamp Date Description */
/* --- ----------------- ----- -------- ---------------------- */
/* 1.0 Noel Sales njCs 16/12/92 Creation */
/* 1.1 Bill Sarantakos bjs 09/05/95 Minor fixes */
/* ----------------------------------------------------------- */
/* ----------------------------------------------------------- */
/* Include IBMCLASS headers */
/* ----------------------------------------------------------- */
// include IBMCLASS headers
#include <iframe.hpp> /* IFrameWindow */
#include <icanvas.hpp>
#include <icmdhdr.hpp> /* ICommandHandler */
#include <ipainhdr.hpp> /* IPaintHandler */
#include <ipainevt.hpp> /* IPaintEvent */
#include <isizehdr.hpp> /* Resize event handler */
#include <imenubar.hpp> /* IActionBarMenu */
#include <ithread.hpp> /* Thread utilization */
#include <imchdr.hpp> /* Mouse commands */
#include <iframhdr.hpp> /* frame closed */
/* ----------------------------------------------------------- */
/* Class: MyClientWindow */
/* */
/* Purpose: This is the sample application's Client Window. */
/* It is a subclass of IFrameWindow. It also contains */
/* the member function responsible in 'drawing' the */
/* lines on the screen. It also provides the functions*/
/* needed to set window dimensions, window colors and */
/* to issue events to the parallel thread. */
/* */
/* Change History: */
/* Rel Programmer Stamp Date Description */
/* --- ----------------- ----- -------- ---------------------- */
/* 1.0 Noel Sales njCs 16/12/92 Creation */
/* 1.1 Bill Sarantakos bjs 09/05/95 Minor fixes */
/* ----------------------------------------------------------- */
class MyClientWindow : public ICanvas
{
public:
/* -------------------------------------------------------- */
/* declare the constructor */
/* -------------------------------------------------------- */
MyClientWindow(unsigned long windowId,
IWindow *parentWindow,
IWindow *ownerWindow);
/* -------------------------------------------------------- */
/* DrawLines() is the line drawing function. It runs under */
/* a separate thread. */
/* -------------------------------------------------------- */
void DrawLines( );
/* -------------------------------------------------------- */
/* SetThreadMessage() and GetThreadMessage() are elementary */
/* 'inter thread' communication routines. In the real world */
/* they must be guarded by semaphores. The application is */
/* quite simple however so the use of semaphores was */
/* dispensed with. */
/* -------------------------------------------------------- */
void SetThreadMessage(long Tmsg) {threadMsg= Tmsg; }
long GetThreadMessage() {return threadMsg; }
/* -------------------------------------------------------- */
/* the following functions support the Line Drawing */
/* Function. SetcxClient and SetcyClient respectively set */
/* x and y dimensions of the Client rectangle. */
/* -------------------------------------------------------- */
void SetcxClient(long cx) {cxClient= cx; }
void SetcyClient(long cy) {cyClient= cy; }
/* -------------------------------------------------------- */
/* Set the initial begin and end points of a line */
/* -------------------------------------------------------- */
void SetBeginPoint(IPoint Begin) {ptl1= Begin.asPOINTL() ;}
void SetEndPoint (IPoint End) {ptl2= End.asPOINTL() ;}
/* -------------------------------------------------------- */
/* Increment and obtain the color counter */
/* -------------------------------------------------------- */
void IncColorCount() {fcolourcounter++; }
long GetColorCount() {return fcolourcounter; }
void SetColorCount(long Value) {fcolourcounter= Value; }
/* -------------------------------------------------------- */
/* Set and obtain the background color */
/* -------------------------------------------------------- */
void SetBcolor(long value) {lBcolour= value; }
long GetBcolor() {return lBcolour; }
/* -------------------------------------------------------- */
/* Set and obtain the foreground color */
/* -------------------------------------------------------- */
void SetFcolor(long value) {lFcolour= value; }
long GetFcolor() {return lFcolour; }
protected:
const IWindow *MyParent;
long cxClient, cyClient;
long fcolourcounter, lBcolour, lFcolour;
long threadMsg;
POINTL ptl1, ptl2;
HAB habThread2; /* thread anchor block */
IPresSpaceHandle hps;
RECTL rclClient; /* rectangle for client */
// IMsgQueueHandle qmsgThread2; /* message queue structure */
};
/* ----------------------------------------------------------- */
/* Class: MyWindow */
/* */
/* Purpose: This is the sample application's main window */
/* It is a subclass of IFrameWindow. The frame has */
/* a command menu and needs to handle the WM_PAINT */
/* and MOUSE CLICK events. */
/* */
/* Change History: */
/* Rel Programmer Stamp Date Description */
/* --- ----------------- ----- -------- ---------------------- */
/* 1.0 Noel Sales njCs 16/12/92 Creation */
/* 1.1 Bill Sarantakos bjs 09/05/95 Minor fixes */
/* ----------------------------------------------------------- */
class MyWindow : public IFrameWindow, public ICommandHandler,
public IPaintHandler, public IMouseClickHandler,
public IFrameHandler
{
public:
/* -------------------------------------------------------- */
/* declare the constructor */
/* -------------------------------------------------------- */
MyWindow(unsigned long windowId);
protected:
/* -------------------------------------------------------- */
/* declare the event handlers. These event handlers are all */
/* pure virtual functions in their respective base classes */
/* -------------------------------------------------------- */
Boolean command(ICommandEvent&);
Boolean paintWindow(IPaintEvent &);
Boolean mouseClicked(IMouseClickEvent &);
Boolean closed( IFrameEvent &);
private:
IMenuBar /* create the menu bar */
menubar;
MyClientWindow /* create the client window */
myClient;
IThread /* define an IThread object */
thread;
};
#endif