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

  1. #ifndef _IRECT_
  2. #define _IRECT_
  3. /*******************************************************************************
  4. * FILE NAME: irect.hpp                                                         *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IRectangle                                                               *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18.  
  19. #include <ibase.hpp>
  20. #include <ipoint.hpp>
  21.  
  22. #pragma pack(4)
  23.  
  24. struct _RECTL;
  25. struct tagRECT;
  26.  
  27.  
  28. class IRectangle : public IBase {
  29. typedef IBase
  30.   Inherited;
  31. public:
  32. /*------------------------------ Related Types -------------------------------*/
  33.  typedef IPair::Coord Coord;
  34.  
  35. /*------------------------------- Constructors -------------------------------*/
  36.   IRectangle ( );
  37.  
  38.   IRectangle ( const IPoint& point1,
  39.                const IPoint& point2 );
  40.  
  41.   IRectangle ( const IPoint& point,
  42.                const ISize&  size );
  43.  
  44.   IRectangle ( Coord point1X,
  45.                Coord point1Y,
  46.                Coord point2X,
  47.                Coord point2Y );
  48.  
  49.   IRectangle ( const struct _RECTL& rectl);
  50.   IRectangle ( const struct tagRECT& rect);
  51.  
  52.   IRectangle ( Coord width,
  53.                Coord height      );
  54.   IRectangle ( const IPair& pair );
  55.  
  56. /*-------------------------------- Points ------------------------------------*/
  57. IPoint
  58.   minXMinY        ( ) const,
  59.   minXCenterY     ( ) const,
  60.   minXMaxY        ( ) const,
  61.   centerXMinY     ( ) const,
  62.   centerXCenterY  ( ) const,
  63.   centerXMaxY     ( ) const,
  64.   maxXMinY        ( ) const,
  65.   maxXCenterY     ( ) const,
  66.   maxXMaxY        ( ) const;
  67.  
  68.  
  69. /*-------------------------------- Dimensions --------------------------------*/
  70. ISize
  71.   size   ( ) const;
  72.  
  73. Coord
  74.   area   ( ) const,
  75.   height ( ) const,
  76.   minX   ( ) const,
  77.   minY   ( ) const,
  78.   maxX   ( ) const,
  79.   maxY   ( ) const,
  80.   width  ( ) const;
  81.  
  82. /*-------------------------------- Conversions -------------------------------*/
  83. struct _RECTL
  84.   asRECTL ( ) const;
  85.  
  86. IString
  87.   asString    ( ) const,
  88.   asDebugInfo ( ) const;
  89.  
  90. /*------------------------------- Comparisons --------------------------------*/
  91. Boolean
  92.   operator == ( const IRectangle& rectangle ) const,
  93.   operator != ( const IRectangle& rectangle ) const;
  94.  
  95. /*-------------------------- Manipulation Operators --------------------------*/
  96. IRectangle
  97.   operator &  ( const IRectangle& rectangle ) const,
  98.  &operator &= ( const IRectangle& rectangle ),
  99.   operator |  ( const IRectangle& rectangle ) const,
  100.  &operator |= ( const IRectangle& rectangle );
  101.  
  102. /*------------------------------- Manipulation -------------------------------*/
  103. IRectangle
  104.   ¢erAt   ( const IPoint& point    ),
  105.    centeredAt ( const IPoint& point    ) const,
  106.   &expandBy   ( const IPair&  pair     ),
  107.   &expandBy   ( Coord         coord    ),
  108.    expandedBy ( const IPair&  pair     ) const,
  109.    expandedBy ( Coord         coord    ) const,
  110.   &moveBy     ( const IPair&  pair     ),
  111.    movedBy    ( const IPair&  pair     ) const,
  112.   &moveTo     ( const IPoint& point    ),
  113.    movedTo    ( const IPoint& point    ) const,
  114.   &scaleBy    ( const IPair&  pair     ),
  115.   &scaleBy    ( Coord         coord    ),
  116.   &scaleBy    ( double        factor   ),
  117.   &scaleBy    ( double        xfactor,
  118.                 double        yfactor  ),
  119.    scaledBy   ( const IPair&  pair     ) const,
  120.    scaledBy   ( Coord         coord    ) const,
  121.    scaledBy   ( double        factor   ) const,
  122.    scaledBy   ( double        xfactor,
  123.                 double        yfactor  ) const,
  124.   &shrinkBy   ( const IPair&  pair     ),
  125.   &shrinkBy   ( Coord         coord    ),
  126.    shrunkBy   ( const IPair&  pair     ) const,
  127.    shrunkBy   ( Coord         coord    ) const,
  128.   &sizeTo     ( const IPair&  pair     ),
  129.    sizedTo    ( const IPair&  pair     ) const,
  130.   &sizeBy     ( const IPair&  pair     ),
  131.   &sizeBy     ( Coord         factor   ),
  132.   &sizeBy     ( double        factor   ),
  133.   &sizeBy     ( double        xfactor,
  134.                 double        yfactor  ),
  135.    sizedBy    ( const IPair&  pair     ) const,
  136.    sizedBy    ( Coord         factor   ) const,
  137.    sizedBy    ( double        factor   ) const,
  138.    sizedBy    ( double        xfactor,
  139.                 double        yfactor  ) const;
  140.  
  141. /*--------------------------------- Testing ----------------------------------*/
  142. Boolean
  143.   contains   ( const IPoint&     point     ) const,
  144.   contains   ( const IRectangle& rectangle ) const,
  145.   intersects ( const IRectangle& rectangle ) const;
  146.  
  147. /*--------------------------------- Synonyms ---------------------------------*/
  148. IPoint
  149.   bottomLeft   ( ) const,
  150.   bottomCenter ( ) const,
  151.   bottomRight  ( ) const,
  152.   center       ( ) const,
  153.   leftCenter   ( ) const,
  154.   rightCenter  ( ) const,
  155.   topLeft      ( ) const,
  156.   topCenter    ( ) const,
  157.   topRight     ( ) const;
  158.  
  159. Coord
  160.   bottom ( ) const,
  161.   left   ( ) const,
  162.   right  ( ) const,
  163.   top    ( ) const;
  164.  
  165. /*----------------------------- Stream operators -----------------------------*/
  166. friend ostream
  167.  &operator << ( ostream&          stream,
  168.                 const IRectangle& rectangle );
  169.  
  170. protected:
  171. /*------------------------------ Implementation ------------------------------*/
  172. IRectangle
  173.  &validate ( );
  174.  
  175. private:
  176. /*--------------------------------- Private ----------------------------------*/
  177. IPoint
  178.   origin,
  179.   corner;
  180. }; // class IRectangle
  181.  
  182. #pragma pack()
  183.  
  184.   #include <irect.inl>
  185.  
  186. #endif /* _IRECT_ */
  187.