home *** CD-ROM | disk | FTP | other *** search
- /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 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. %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- */
-
- /*************************************************************************
- *
- * WRect --
- *
- *************************************************************************/
-
- #ifndef _WRECT_HPP_INCLUDED
- #define _WRECT_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- #ifndef _WDEF_HPP_INCLUDED
- # include "wdef.hpp"
- #endif
- #ifndef _WPOINT_HPP_INCLUDED
- # include "wpoint.hpp"
- #endif
- #ifndef _WSIZE_HPP_INCLUDED
- # include "wsize.hpp"
- #endif
-
- #ifdef _WIN16
- #ifndef _WINDEF_
- typedef struct tagRECT
- {
- WInt left;
- WInt top;
- WInt right;
- WInt bottom;
- } RECT, *PRECT;
- typedef const RECT FAR* LPCRECT;
- #endif
- typedef struct _RECTL
- {
- WLong left;
- WLong top;
- WLong right;
- WLong bottom;
- } RECTL, *PRECTL, *LPRECTL;
- typedef const RECTL FAR* LPCRECTL;
- #else
- #ifndef _WINDEF_
- typedef struct tagRECT
- {
- WLong left;
- WLong top;
- WLong right;
- WLong bottom;
- } RECT, *PRECT;
- typedef const RECT FAR* LPCRECT;
-
- typedef struct _RECTL
- {
- WLong left;
- WLong top;
- WLong right;
- WLong bottom;
- } RECTL, *PRECTL, *LPRECTL;
- typedef const RECTL FAR* LPCRECTL;
- #endif
- #endif
-
- class WCMCLASS WRect {
-
- /**********************************************************
- * Data members
- *********************************************************/
-
- public:
-
- WInt x;
- WInt y;
- WInt w;
- WInt h;
-
- public:
-
- /**********************************************************
- * Constructors and Destructors
- *********************************************************/
-
- WRect() { x = y = w = h = 0; }
- WRect( WInt nx, WInt ny, WInt nw, WInt nh )
- { x = nx; y = ny; w = nw; h = nh; }
- WRect( const WRect & o ) { x = o.x; y = o.y; w = o.w; h = o.h; }
- WRect( const RECT & o ); // WCMINLINE
- WRect( const RECTL & 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
- *********************************************************/
-
- // RECT
- //
- // Convert to/from the Windows RECT type.
-
- RECT GetRECT() const;
- void SetRECT( const RECT & r );
-
- // RECTL
- //
- // Convert to/from the Windows RECTL type.
-
- RECTL GetRECTL() const; // WCMINLINE
- void SetRECTL( const RECTL & r ); // WCMINLINE
-
- /**********************************************************
- * Methods
- *********************************************************/
-
- // Contains
- //
- // True if a point is contained within a rectangle.
-
- WBool Contains( const WPoint & point ) const; // WCMINLINE
-
- // Create
- //
- // Initialize the rectangle.
-
- void Create() { x = y = w = h = 0; }
- void Create( WInt nx, WInt ny, WInt nw, WInt nh )
- { x = nx; y = ny; w = nw; h = nh; }
- void Create( const WRect & o )
- { x = o.x; y = o.y; w = o.w; h = o.h; }
- void Create( const RECT & o ); // WCMINLINE
- void Create( const RECTL & o ); // WCMINLINE
-
- // Inflate -- relative grow
-
- WBool Inflate( const WSize & s ); // WCMINLINE
-
- // Normalize
-
- WBool Normalize();
-
- // Translate -- relative move
-
- void Translate( const WPoint & pt ); // WCMINLINE
-
- // UnionWith
-
- void UnionWith( const WRect & rectangle );
-
- // IntersectWith
-
- WBool IntersectWith( const WRect & rectangle );
-
- // Intersects
-
- WBool Intersects( const WRect & rectangle ) const;
-
- /**********************************************************
- * Operators
- *********************************************************/
-
- // == operator
-
- int operator==( const WRect & o ) const; // WCMINLINE
-
- // != operator
-
- int operator!=( const WRect & o ) const; // WCMINLINE
-
- // = operator
-
- WRect & operator=( const WRect & o )
- { x = o.x; y = o.y; w = o.w; h = o.h; return *this; }
- WRect & operator=( const RECT & o ); // WCMINLINE
- WRect & operator=( const RECTL & o ); // WCMINLINE
-
- };
-
- #ifdef WCM_ENABLE_INLINES
- #ifndef WCM_NO_WRECT_INLINES
- #define WCMINLINE inline
- #include "wrect.inl"
- #endif
- #endif
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WRECT_HPP_INCLUDED
-