home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
IOC
/
2D-DRAW
/
2D-DRAW.HPP
< prev
next >
Wrap
Text File
|
1995-04-04
|
8KB
|
217 lines
#ifndef TWOD_HPP
#define TWOD_HPP
/******************************************************************************/
/* 2D DRAW SAMPLE PROGRAM - Version 1: Class Header (2D-DRAW.HPP) */
/* */
/* 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. */
/******************************************************************************/
#include <iframe.hpp> //Include IFrameWindow Class Header
#include <isizehdr.hpp>
#include <icmdhdr.hpp>
#include <igrafctx.hpp>
#include <igbundle.hpp>
#include <idrawcv.hpp>
#include <imenubar.hpp>
#include <imndihdr.hpp>
#include <imndievt.hpp>
#include <ireslib.hpp>
#include <imoushdr.hpp>
#include <imousevt.hpp>
#include <iflyhhdr.hpp>
#include <iflytext.hpp>
#include <ifont.hpp>
#include <iinfoa.hpp>
#include <itbar.hpp>
#include <itbarbut.hpp>
#include <igrect.hpp>
#include "2d-draw.h"
//**************************************************************************
// Class: DrawingArea *
// *
// Purpose: Subclass of IDrawingCanvas. Class contains the handlers *
// necessary for interactive drawing of the graphic objects. *
// *
//**************************************************************************
class DrawingArea : public IDrawingCanvas,
public IMouseHandler
{
public:
DrawingArea ( unsigned long windowId,
IWindow* parent,
IWindow* owner,
const IRectangle& intial = IRectangle() );
virtual
~DrawingArea ( );
enum DrawState {
drawing,
waitingForInput,
notDrawing
};
DrawingArea
&setDrawState ( const DrawState newState = drawing );
DrawState
drawState ( ) const { return dState; }
DrawingArea
&setBitmapFileName ( const IString& bitmapFile )
{ currentBitmap = bitmapFile;
return *this; }
IString
bitmapFileName ( ) const
{ return currentBitmap; }
enum DrawObject {
pointer = PALLET_NORM,
line,
freeHand,
rectangle,
ellipse,
polyline,
polygon,
arc,
pie,
chord,
text,
bitmap
};
virtual DrawingArea
&setDrawObject ( const DrawObject drawObject )
{ currentObj = drawObject;
return *this; }
virtual DrawObject
drawObject ( ) const {return currentObj;}
virtual IGraphicBundle
&graphicBundle ( ) { return currentBundle; }
virtual DrawingArea
&setCurrentFont ( const IFont& font );
virtual IFont
currentFont ( ) const;
protected:
virtual Boolean
mouseMoved ( IMouseEvent& event ),
mouseClicked ( IMouseClickEvent& event ),
mousePointerChange ( IMousePointerEvent& event );
virtual DrawingArea
&button1Down ( const IPoint& point ),
&button1Up ( const IPoint& point ),
&button1DoubleClick ( const IPoint& point ),
&button2Down ( const IPoint& point ),
&button2Up ( const IPoint& point );
private:
IGraphicContext gc;
IFont currentfont;
IGraphicBundle currentBundle;
IString currentBitmap;
DrawState dState;
DrawObject currentObj;
IGraphic* iGraphic;
IGraphic* moveGraphic;
IGRectangle moveRect;
IPoint startingPt;
IPoint previousPt;
IPoint tempPt;
unsigned long pointCount;
IPointerHandle ptrLine;
IPointerHandle ptrDraw;
IPointerHandle ptrRectangle;
IPointerHandle ptrEllipse;
IPointerHandle ptrPolyline;
IPointerHandle ptrPolygon;
IPointerHandle ptrArc;
IPointerHandle ptrPie;
IPointerHandle ptrChord;
IPointerHandle ptrText;
IPointerHandle ptrBitmap;
IPointerHandle ptrCurrent;
};
//**************************************************************************
// Class: MainWindow *
// *
// Purpose: Main Window for C++ Hello World sample application *
// It is a subclass of IFrameWindow *
// *
//**************************************************************************
class MainWindow : public IFrameWindow,
public ICommandHandler,
public IMenuDrawItemHandler
{
public: //Define the Public Information
MainWindow(unsigned long windowId); //Constructor for this class
virtual
~MainWindow();
static IColor
penColorFromId ( unsigned long Identifier ),
fillColorFromId ( unsigned long Identifier ),
backColorFromId ( unsigned long Identifier );
static unsigned long
patternFromId ( unsigned long Identifier ),
penWidthFromId ( unsigned long Identifier );
static IGraphicBundle::PenType
penTypeFromId ( unsigned long Identifier );
protected:
virtual Boolean
setSize ( IMenuDrawItemEvent& evt,
ISize& newSize ),
draw ( IMenuDrawItemEvent& evt,
DrawFlag& flag ),
command ( ICommandEvent& event );
private: //Define Private Information
DrawingArea drawingArea; // move back to top of list.
IToolBar toolBar;
IMenuBar menuBar;
IInfoArea infoArea;
IFlyText flyText;
IFlyOverHelpHandler flyOver;
unsigned long lastPenColorId;
unsigned long lastFillColorId;
unsigned long lastPenPatternId;
unsigned long lastFillPatternId;
unsigned long lastPenTypeId;
unsigned long lastPenWidthId;
unsigned long lastBackId;
unsigned long lastDrawOperationId;
IToolBarButton normalButton,
lineButton,
drawButton,
rectangleButton,
ellipseButton,
polylineButton,
polygonButton,
arcButton,
pieButton,
chordButton,
textButton,
bitmapButton;
};
#endif