home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / ipoint.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  6.7 KB  |  211 lines

  1. #ifndef _IPOINT_
  2. #define _IPOINT_
  3. /*******************************************************************************
  4. * FILE NAME: ipoint.hpp                                                        *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IPair                                                                    *
  9. *     IPoint                                                                   *
  10. *     ISize                                                                    *
  11. *     IRange                                                                   *
  12. *                                                                              *
  13. * COPYRIGHT:                                                                   *
  14. *   IBM Open Class Library                                                     *
  15. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  16. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  17. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  18. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  19. *                                                                              *
  20. *******************************************************************************/
  21. #include <ibase.hpp>
  22.  
  23. #pragma pack(4)
  24.  
  25. struct _POINTL;
  26. struct _RECTL;
  27. struct _SIZEL;
  28. struct tagPOINT;
  29. struct tagSIZE;
  30. class  ISize;
  31. class  IWindowHandle;
  32. typedef struct tagSIZE SIZEL;
  33.  
  34. class IPair : public IBase {
  35. typedef IBase
  36.   Inherited;
  37. public:
  38. /*------------------------------ Related Types -------------------------------*/
  39. typedef long Coord;
  40.  
  41. /*------------------------------ Constructors --------------------------------*/
  42.   IPair ( );
  43.   IPair ( Coord init );
  44.   IPair ( Coord coord1,
  45.           Coord coord2 );
  46.  
  47. /*-------------------------------- Accessors ---------------------------------*/
  48. Coord
  49.   coord1 ( )  const,
  50.   coord2 ( )  const;
  51.  
  52. IPair
  53.  &setCoord1 ( Coord coord1 ),
  54.  &setCoord2 ( Coord coord2 );
  55.  
  56. /*----------------------------- Minimum and Maximum --------------------------*/
  57. IPair
  58.   minimum ( const IPair& aPair ) const,
  59.   maximum ( const IPair& aPair ) const;
  60.  
  61. /*--------------------------------- Negation ---------------------------------*/
  62. IPair
  63.   operator - ( ) const;
  64.  
  65. /*--------------------------- Comparison Operators ---------------------------*/
  66. Boolean
  67.   operator == ( const IPair& aPair ) const,
  68.   operator != ( const IPair& aPair ) const,
  69.   operator <  ( const IPair& aPair ) const,
  70.   operator >  ( const IPair& aPair ) const,
  71.   operator <= ( const IPair& aPair ) const,
  72.   operator >= ( const IPair& aPair ) const;
  73.  
  74. /*-------------------------- Manipulation Operators --------------------------*/
  75. friend IPair
  76.   operator +  ( const IPair& pair1,  const IPair& pair2       ),
  77.   operator *  ( const IPair& pair1,  const IPair& pair2       ),
  78.   operator *  ( const IPair& pair1,  double       multiplier  ),
  79.   operator -  ( const IPair& pair1,  const IPair& pair2       ),
  80.   operator /  ( const IPair& pair1,  const IPair& pair2       ),
  81.   operator /  ( const IPair& pair1,  double       divisor     ),
  82.   operator %  ( const IPair& pair1,  const IPair& pair2       ),
  83.   operator %  ( const IPair& aPair1, long         divisor     );
  84.  
  85. IPair
  86.  &operator += ( const IPair& aPair ),
  87.  &operator -= ( const IPair& aPair ),
  88.  &operator *= ( const IPair& aPair ),
  89.  &operator *= ( double multiplier ),
  90.  &operator /= ( const IPair& aPair ),
  91.  &operator /= ( double divisor ),
  92.  &operator %= ( const IPair& aPair ),
  93.  &operator %= ( long  divisor );
  94.  
  95. /*-------------------------- Manipulation Functions --------------------------*/
  96. IPair
  97.  &scaleBy  ( double xFactor, double yFactor ),
  98.   scaledBy ( double xFactor, double yFactor ) const;
  99.  
  100. /*------------------------------ Miscellaneous -------------------------------*/
  101. double
  102.   distanceFrom ( const IPair& aPair ) const;
  103.  
  104. long
  105.   dotProduct ( const IPair& aPair ) const;
  106.  
  107. IPair
  108.  &transpose ( );
  109.  
  110. friend IPair
  111.   transpose ( const IPair& aPair );
  112.  
  113. /*-------------------------------- Conversions -------------------------------*/
  114. IString
  115.   asString ( ) const,
  116.   asDebugInfo ( ) const;
  117.  
  118. /*-------------------------------- Displaying --------------------------------*/
  119. friend ostream
  120.  &operator << ( ostream&          aStream,
  121.                 const IPair&      aRectangle );
  122.  
  123. private:
  124. /*--------------------------------- Private ----------------------------------*/
  125. Coord
  126.   coordCl1,
  127.   coordCl2;
  128. }; // class IPair
  129.  
  130. class IPoint : public IPair {
  131. typedef IPair
  132.   Inherited;
  133.  
  134. public:
  135. /*------------------------------- Constructors -------------------------------*/
  136.   IPoint ( );
  137.   IPoint ( const IPair& pair );
  138.   IPoint ( Coord x, Coord y );
  139.   IPoint ( const struct _POINTL& ptl );
  140.   IPoint ( const struct tagPOINT& ptl );
  141.  
  142. /*-------------------------------- Accessors ---------------------------------*/
  143. Coord
  144.   x      ( ) const,
  145.   y      ( ) const;
  146.  
  147. IPoint
  148.  &setX ( Coord X ),
  149.  &setY ( Coord Y );
  150.  
  151. /*-------------------------------- Conversions -------------------------------*/
  152. struct _POINTL
  153.   asPOINTL ( ) const;
  154. }; // class IPoint
  155.  
  156. class ISize  : public IPair {
  157. typedef IPair
  158.   Inherited;
  159. public:
  160. /*------------------------------- Constructors -------------------------------*/
  161.   ISize ( );
  162.   ISize ( const IPair& pair );
  163.   ISize ( Coord width, Coord height );
  164.   ISize ( const SIZEL& sizl );
  165.   ISize ( const struct _RECTL& rcl );
  166.  
  167. /*-------------------------------- Accessors ---------------------------------*/
  168. Coord
  169.   width  ( ) const,
  170.   height ( ) const;
  171.  
  172. ISize
  173.  &setWidth  ( Coord cx ),
  174.  &setHeight ( Coord cy );
  175.  
  176. /*-------------------------------- Conversions -------------------------------*/
  177. SIZEL
  178.   asSIZEL ( ) const;
  179. }; // class ISize
  180.  
  181. class IRange : public IPair {
  182. typedef IPair
  183.   Inherited;
  184.  
  185. public:
  186. /*------------------------------- Constructors -------------------------------*/
  187.   IRange ( );
  188.   IRange ( const IPair& aPair );
  189.   IRange ( Coord lower, Coord upper );
  190.  
  191. /*-------------------------------- Accessors ---------------------------------*/
  192. Coord
  193.   lowerBound ( ) const,
  194.   upperBound ( ) const;
  195.  
  196. IRange
  197.  &setUpperBound ( Coord upper ),
  198.  &setLowerBound ( Coord lower );
  199.  
  200. /*--------------------------------- Testing ----------------------------------*/
  201. Boolean
  202.   includes ( Coord aValue ) const;
  203. }; // class IRange
  204.  
  205. #pragma pack()
  206.  
  207. /*----------------------------- Inline Functions -----------------------------*/
  208.   #include <ipoint.inl>
  209.  
  210. #endif /* _IPOINT_ */
  211.