home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / hpp.z / WPOINT.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-07  |  4.7 KB  |  165 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WPoint --
  14.  *
  15.  *************************************************************************/
  16.  
  17. #ifndef _WPOINT_HPP_INCLUDED
  18. #define _WPOINT_HPP_INCLUDED
  19.  
  20. #ifndef _WNO_PRAGMA_PUSH
  21. #pragma pack(push,4);
  22. #pragma enum int;
  23. #endif
  24.  
  25. #ifndef _WDEF_HPP_INCLUDED
  26. #  include "wdef.hpp"
  27. #endif
  28. #ifndef _WARRAY_HPP_INCLUDED
  29. #  include "warray.hpp"
  30. #endif
  31.  
  32. #ifndef _WINDEF_
  33. typedef struct tagPOINT {
  34.     WLong x;
  35.     WLong y;
  36. } POINT, *PPOINT;
  37.  
  38. typedef struct tagPOINTL {
  39.     WLong x;
  40.     WLong y;
  41. } POINTL, *PPOINTL;
  42.  
  43. typedef struct tagPOINTS {
  44.     WShort x;
  45.     WShort y;
  46. } POINTS, *PPOINTS;
  47. #endif
  48.  
  49. class WCMCLASS WPoint {
  50.  
  51.         /**********************************************************
  52.          * Data members
  53.          *********************************************************/
  54.  
  55.     public:
  56.     
  57.         WLong x;
  58.         WLong y;
  59.  
  60.     public:
  61.  
  62.         /**********************************************************
  63.          * Constructors and Destructors
  64.          *********************************************************/
  65.  
  66.         WPoint() { x = y = 0; }
  67.         WPoint( WLong nx, WLong ny ) { x = nx; y = ny; }
  68.         WPoint( const WPoint & o ) { x = o.x; y = o.y; }
  69.         WPoint( const POINT & o ); // WCMINLINE
  70.         WPoint( const POINTL & o ); // WCMINLINE
  71.         WPoint( const POINTS & o ); // WCMINLINE
  72.  
  73.         // Note: no destructor is defined and none will be generated
  74.         // because the class has simple types as data and no virtual
  75.         // functions and does not inherit from anyone.
  76.  
  77.         /**********************************************************
  78.          * Properties
  79.          *********************************************************/
  80.  
  81.         // POINT
  82.  
  83.         POINT GetPOINT() const;
  84.         void  SetPOINT( const POINT & p );
  85.  
  86.         // POINTL
  87.  
  88.         POINTL GetPOINTL() const; // WCMINLINE
  89.         void   SetPOINTL( const POINTL & p ); // WCMINLINE
  90.  
  91.         // POINTS
  92.  
  93.         POINTS GetPOINTS() const;
  94.         void   SetPOINTS( const POINTS & p );
  95.  
  96.         /**********************************************************
  97.          * Methods
  98.          *********************************************************/
  99.  
  100.         // CalculateDistance
  101.  
  102.         WDouble WCMRETURNSFLOAT CalculateDistance( const WPoint & pt ) const;
  103.  
  104.         // Create
  105.  
  106.         void Create( WLong nx=0, WLong ny=0 ) { x = nx; y = ny; }
  107.         void Create( const WPoint & o ) { x = o.x; y = o.y; }
  108.         void Create( const POINT & o ); // WCMINLINE
  109.         void Create( const POINTL & o ); // WCMINLINE
  110.         void Create( const POINTS & o ); // WCMINLINE
  111.  
  112.         // Offset
  113.  
  114.         void Offset( WLong nx, WLong ny ); // WCMINLINE
  115.         void Offset( const WPoint & pt ); // WCMINLINE
  116.  
  117.         /**********************************************************
  118.          * Operators
  119.          *********************************************************/
  120.  
  121.         // == operator
  122.  
  123.         int operator==( const WPoint & o ) const; // WCMINLINE
  124.  
  125.         // != operator
  126.  
  127.         int operator!=( const WPoint & o ) const; // WCMINLINE
  128.     
  129.         // = operator
  130.  
  131.         WPoint & operator=( const WPoint & o )
  132.             { x = o.x; y = o.y; return *this; }
  133.         WPoint & operator=( const POINT & o ); // WCMINLINE
  134.         WPoint & operator=( const POINTL & o ); // WCMINLINE
  135.         WPoint & operator=( const POINTS & o ); // WCMINLINE
  136.  
  137.         // +, - operator
  138.  
  139.         WPoint operator+( const WPoint & o ); // WCMINLINE
  140.         WPoint operator-( const WPoint & o ); // WCMINLINE
  141.  
  142.         // +=, -= operator
  143.  
  144.         WPoint & operator+=( const WPoint & o ); // WCMINLINE
  145.         WPoint & operator-=( const WPoint & o ); // WCMINLINE
  146. };
  147.  
  148. #ifdef WCM_ENABLE_INLINES
  149.   #ifndef WCM_NO_WPOINT_INLINES
  150.     #define WCMINLINE inline
  151.     #include "wpoint.inl"
  152.   #endif
  153. #endif
  154.  
  155. extern template WArrayReference<WPoint>;
  156. extern template WArray<WPoint>;
  157. typedef WArray<WPoint>                  WPointArray;
  158.  
  159. #ifndef _WNO_PRAGMA_PUSH
  160. #pragma enum pop;
  161. #pragma pack(pop);
  162. #endif
  163.  
  164. #endif // _WPOINT_HPP_INCLUDED
  165.