home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
hpp.z
/
WPOINT.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-18
|
5KB
|
183 lines
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (C) 1994, by WATCOM International Inc. All rights %
% reserved. No part of this software may be reproduced or %
% used in any form or by any means - graphic, electronic or %
% mechanical, including photocopying, recording, taping or %
% information storage and retrieval systems - except with the %
% written permission of WATCOM International Inc. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*************************************************************************
*
* WPoint --
*
*************************************************************************/
#ifndef _WPOINT_HPP_INCLUDED
#define _WPOINT_HPP_INCLUDED
#ifndef _WNO_PRAGMA_PUSH
#pragma pack(push,8);
#pragma enum int;
#endif
#ifndef _WDEF_HPP_INCLUDED
# include "wdef.hpp"
#endif
#ifndef _WARRAY_HPP_INCLUDED
# include "warray.hpp"
#endif
#if defined( _WIN16 )
#ifndef _WINDEF_
typedef struct tagPOINT {
WInt x;
WInt y;
} POINT, *PPOINT;
#endif
typedef struct tagPOINTL {
WLong x;
WLong y;
} POINTL, *PPOINTL;
typedef struct tagPOINTS {
WShort x;
WShort y;
} POINTS, *PPOINTS;
#else
#ifndef _WINDEF_
typedef struct tagPOINT {
WLong x;
WLong y;
} POINT, *PPOINT;
typedef struct tagPOINTL {
WLong x;
WLong y;
} POINTL, *PPOINTL;
typedef struct tagPOINTS {
WShort x;
WShort y;
} POINTS, *PPOINTS;
#endif
#endif
class WCMCLASS WPoint {
/**********************************************************
* Data members
*********************************************************/
public:
WInt x;
WInt y;
public:
/**********************************************************
* Constructors and Destructors
*********************************************************/
WPoint() { x = y = 0; }
WPoint( WInt nx, WInt ny ) { x = nx; y = ny; }
WPoint( const WPoint & o ) { x = o.x; y = o.y; }
WPoint( const POINT & o ); // WCMINLINE
WPoint( const POINTL & o ); // WCMINLINE
WPoint( const POINTS & o ); // WCMINLINE
// Note: no destructor is defined and none will be generated
// because the class has simple types as data and no virtual
// functions and does not inherit from anyone.
/**********************************************************
* Properties
*********************************************************/
// POINT
POINT GetPOINT() const;
void SetPOINT( const POINT & p );
// POINTL
POINTL GetPOINTL() const; // WCMINLINE
void SetPOINTL( const POINTL & p ); // WCMINLINE
// POINTS
POINTS GetPOINTS() const;
void SetPOINTS( const POINTS & p );
/**********************************************************
* Methods
*********************************************************/
// CalculateDistance
WDouble WCMRETURNSFLOAT CalculateDistance( const WPoint & pt ) const;
// Create
void Create( WInt nx=0, WInt ny=0 ) { x = nx; y = ny; }
void Create( const WPoint & o ) { x = o.x; y = o.y; }
void Create( const POINT & o ); // WCMINLINE
void Create( const POINTL & o ); // WCMINLINE
void Create( const POINTS & o ); // WCMINLINE
// Offset
void Offset( WInt nx, WInt ny ); // WCMINLINE
void Offset( const WPoint & pt ); // WCMINLINE
/**********************************************************
* Operators
*********************************************************/
// == operator
int operator==( const WPoint & o ) const; // WCMINLINE
// != operator
int operator!=( const WPoint & o ) const; // WCMINLINE
// = operator
WPoint & operator=( const WPoint & o )
{ x = o.x; y = o.y; return *this; }
WPoint & operator=( const POINT & o ); // WCMINLINE
WPoint & operator=( const POINTL & o ); // WCMINLINE
WPoint & operator=( const POINTS & o ); // WCMINLINE
// +, - operator
WPoint operator+( const WPoint & o ); // WCMINLINE
WPoint operator-( const WPoint & o ); // WCMINLINE
// +=, -= operator
WPoint & operator+=( const WPoint & o ); // WCMINLINE
WPoint & operator-=( const WPoint & o ); // WCMINLINE
};
#ifdef WCM_ENABLE_INLINES
#ifndef WCM_NO_WPOINT_INLINES
#define WCMINLINE inline
#include "wpoint.inl"
#endif
#endif
extern template WArrayReference<WPoint>;
extern template WArray<WPoint>;
typedef WArray<WPoint> WPointArray;
#ifndef _WNO_PRAGMA_PUSH
#pragma enum pop;
#pragma pack(pop);
#endif
#endif // _WPOINT_HPP_INCLUDED