home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WREGION.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  5KB  |  157 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. #ifndef _WREGION_HPP_INCLUDED
  12. #define _WREGION_HPP_INCLUDED
  13.  
  14. #ifndef _WNO_PRAGMA_PUSH
  15. #pragma pack(push,8);
  16. #pragma enum int;
  17. #endif
  18.  
  19. #ifndef _WOBJECT_HPP_INCLUDED
  20. #  include "wobject.hpp"
  21. #endif
  22. #ifndef _WRECT_HPP_INCLUDED
  23. #  include "wrect.hpp"
  24. #endif
  25. #ifndef _WPOINT_HPP_INCLUDED
  26. #  include "wpoint.hpp"
  27. #endif
  28. #ifndef _WARRAY_HPP_INCLUDED
  29. #  include "warray.hpp"
  30. #endif
  31.  
  32. enum WRegionHandle { NULLHREGION = 0, LASTHREGION = LAST_16TO32BIT };
  33.  
  34. enum WPolygonFillMode {
  35.     WPFMAlternate               = 1,
  36.     WPFMWinding                 = 2,
  37.     WPFMLast                    = 2,
  38. };
  39.  
  40. enum WRegionCombineMode {
  41.     WRCMMin                     = 1,
  42.     WRCMAnd                     = 1,
  43.     WRCMOr                      = 2,
  44.     WRCMXor                     = 3,
  45.     WRCMDiff                    = 4,
  46.     WRCMCopy                    = 5,
  47.     WRCMMax                     = 5,
  48. };
  49.  
  50. typedef WArray< WPoint >        WPointArray;
  51.  
  52. typedef WArray< WInt >          WIntArray;
  53.  
  54. class WCMCLASS WRegion : public WObject {
  55.     WDeclareSubclass( WRegion, WObject );
  56.  
  57.     public:
  58.  
  59.         /************************************************************
  60.          * Constructors and Destructors
  61.          ************************************************************/
  62.  
  63.         WRegion();
  64.         WRegion( const WRect & rect, WBool createAsEllipse=FALSE );
  65.         WRegion( const WRect & rect, WInt ellipseWidth, WInt ellipseHeight );
  66.         WRegion( const WPointArray & pointArray,
  67.                  WPolygonFillMode mode=WPFMWinding );
  68.         WRegion( const WPointArray & pointArray,
  69.                  const WIntArray & vertexCountArray,
  70.                  WPolygonFillMode mode=WPFMWinding );
  71.  
  72.         ~WRegion();
  73.  
  74.         /************************************************************
  75.          * Properties
  76.          ************************************************************/
  77.  
  78.         // BoundingRectangle
  79.  
  80.         WRect GetBoundingRectangle( WBool * isComplex=NULL );
  81.  
  82.         // Handle
  83.  
  84.         WRegionHandle GetHandle() const;
  85.  
  86.         /************************************************************
  87.          * Methods
  88.          ************************************************************/
  89.  
  90.         // Combine
  91.  
  92.         WBool Combine( const WRegion & region1, const WRegion & region2,
  93.                        WRegionCombineMode mode );
  94.  
  95.         // Create
  96.         //
  97.         //     Create a new region.
  98.  
  99.         WBool Create( const WRect & rect, WBool createAsEllipse=FALSE );
  100.         WBool Create( const WRect & rect, WInt ellipseWidth,
  101.                       WInt ellipseHeight );
  102.         WBool Create( const WPointArray & pointArray,
  103.                       WPolygonFillMode mode=WPFMWinding );
  104.         WBool Create( const WPointArray & pointArray,
  105.                       const WIntArray & vertexCountArray,
  106.                       WPolygonFillMode mode=WPFMWinding );
  107.  
  108.         // Offset
  109.  
  110.         WBool Offset( const WPoint & offset, WBool * isComplex=NULL );
  111.  
  112.         // Intersects
  113.  
  114.         WBool Intersects( const WRect & rect );
  115.         WBool Intersects( const WPoint & point );
  116.  
  117.         /***********************************************************
  118.          * Static Methods
  119.          ***********************************************************/
  120.  
  121.         // IsValidHandle
  122.         //
  123.         //     Returns TRUE if the given handle is valid.  Can
  124.         //     optionally specify whether or not a null handle
  125.         //     is "valid".
  126.  
  127.         static WBool IsValidHandle( WRegionHandle handle,
  128.                                     WBool nullValid=FALSE );
  129.  
  130.         /***********************************************************
  131.          * Others
  132.          ***********************************************************/
  133.  
  134.         WBool operator==( const WRegion & region ) const;
  135.  
  136.         /***********************************************************
  137.          * Data members
  138.          ***********************************************************/
  139.  
  140.     private:
  141.  
  142.         WRegionHandle           _handle;
  143. };
  144.  
  145. #ifdef _DEBUG
  146. #define W_ISREGIONHANDLE(h) CHECKGDI(WRegion::IsValidHandle((WRegionHandle)h))
  147. #else
  148. #define W_ISREGIONHANDLE(h)
  149. #endif
  150.  
  151. #ifndef _WNO_PRAGMA_PUSH
  152. #pragma enum pop;
  153. #pragma pack(pop);
  154. #endif
  155.  
  156. #endif // _WREGION_HPP_INCLUDED
  157.