home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WPOINT.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  5KB  |  183 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,8);
  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. #if defined( _WIN16 )
  33. #ifndef _WINDEF_
  34. typedef struct tagPOINT {
  35.     WInt x;
  36.     WInt y;
  37. } POINT, *PPOINT;
  38. #endif
  39. typedef struct tagPOINTL {
  40.     WLong x;
  41.     WLong y;
  42. } POINTL, *PPOINTL;
  43.  
  44. typedef struct tagPOINTS {
  45.     WShort x;
  46.     WShort y;
  47. } POINTS, *PPOINTS;
  48. #else
  49. #ifndef _WINDEF_
  50. typedef struct tagPOINT {
  51.     WLong x;
  52.     WLong y;
  53. } POINT, *PPOINT;
  54.  
  55. typedef struct tagPOINTL {
  56.     WLong x;
  57.     WLong y;
  58. } POINTL, *PPOINTL;
  59.  
  60. typedef struct tagPOINTS {
  61.     WShort x;
  62.     WShort y;
  63. } POINTS, *PPOINTS;
  64. #endif
  65. #endif
  66.  
  67. class WCMCLASS WPoint {
  68.  
  69.         /**********************************************************
  70.          * Data members
  71.          *********************************************************/
  72.  
  73.     public:
  74.     
  75.         WInt x;
  76.         WInt y;
  77.  
  78.     public:
  79.  
  80.         /**********************************************************
  81.          * Constructors and Destructors
  82.          *********************************************************/
  83.  
  84.         WPoint() { x = y = 0; }
  85.         WPoint( WInt nx, WInt ny ) { x = nx; y = ny; }
  86.         WPoint( const WPoint & o ) { x = o.x; y = o.y; }
  87.         WPoint( const POINT & o ); // WCMINLINE
  88.         WPoint( const POINTL & o ); // WCMINLINE
  89.         WPoint( const POINTS & o ); // WCMINLINE
  90.  
  91.         // Note: no destructor is defined and none will be generated
  92.         // because the class has simple types as data and no virtual
  93.         // functions and does not inherit from anyone.
  94.  
  95.         /**********************************************************
  96.          * Properties
  97.          *********************************************************/
  98.  
  99.         // POINT
  100.  
  101.         POINT GetPOINT() const;
  102.         void  SetPOINT( const POINT & p );
  103.  
  104.         // POINTL
  105.  
  106.         POINTL GetPOINTL() const; // WCMINLINE
  107.         void   SetPOINTL( const POINTL & p ); // WCMINLINE
  108.  
  109.         // POINTS
  110.  
  111.         POINTS GetPOINTS() const;
  112.         void   SetPOINTS( const POINTS & p );
  113.  
  114.         /**********************************************************
  115.          * Methods
  116.          *********************************************************/
  117.  
  118.         // CalculateDistance
  119.  
  120.         WDouble WCMRETURNSFLOAT CalculateDistance( const WPoint & pt ) const;
  121.  
  122.         // Create
  123.  
  124.         void Create( WInt nx=0, WInt ny=0 ) { x = nx; y = ny; }
  125.         void Create( const WPoint & o ) { x = o.x; y = o.y; }
  126.         void Create( const POINT & o ); // WCMINLINE
  127.         void Create( const POINTL & o ); // WCMINLINE
  128.         void Create( const POINTS & o ); // WCMINLINE
  129.  
  130.         // Offset
  131.  
  132.         void Offset( WInt nx, WInt ny ); // WCMINLINE
  133.         void Offset( const WPoint & pt ); // WCMINLINE
  134.  
  135.         /**********************************************************
  136.          * Operators
  137.          *********************************************************/
  138.  
  139.         // == operator
  140.  
  141.         int operator==( const WPoint & o ) const; // WCMINLINE
  142.  
  143.         // != operator
  144.  
  145.         int operator!=( const WPoint & o ) const; // WCMINLINE
  146.     
  147.         // = operator
  148.  
  149.         WPoint & operator=( const WPoint & o )
  150.             { x = o.x; y = o.y; return *this; }
  151.         WPoint & operator=( const POINT & o ); // WCMINLINE
  152.         WPoint & operator=( const POINTL & o ); // WCMINLINE
  153.         WPoint & operator=( const POINTS & o ); // WCMINLINE
  154.  
  155.         // +, - operator
  156.  
  157.         WPoint operator+( const WPoint & o ); // WCMINLINE
  158.         WPoint operator-( const WPoint & o ); // WCMINLINE
  159.  
  160.         // +=, -= operator
  161.  
  162.         WPoint & operator+=( const WPoint & o ); // WCMINLINE
  163.         WPoint & operator-=( const WPoint & o ); // WCMINLINE
  164. };
  165.  
  166. #ifdef WCM_ENABLE_INLINES
  167.   #ifndef WCM_NO_WPOINT_INLINES
  168.     #define WCMINLINE inline
  169.     #include "wpoint.inl"
  170.   #endif
  171. #endif
  172.  
  173. extern template WArrayReference<WPoint>;
  174. extern template WArray<WPoint>;
  175. typedef WArray<WPoint>                  WPointArray;
  176.  
  177. #ifndef _WNO_PRAGMA_PUSH
  178. #pragma enum pop;
  179. #pragma pack(pop);
  180. #endif
  181.  
  182. #endif // _WPOINT_HPP_INCLUDED
  183.