home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / REALSHPE.H < prev    next >
C/C++ Source or Header  |  1997-02-28  |  12KB  |  370 lines

  1. /* @(#)Z 1.11 com/src/imaging/realshps/RealShpe.h, odimaging, od96os2, odos29646d 96/11/15 15:29:18 (96/10/29 09:27:09) */
  2. /*====START_GENERATED_PROLOG======================================
  3.  */
  4. /*
  5.  *   COMPONENT_NAME: odimaging
  6.  *
  7.  *   CLASSES:   RealShape
  8.  *        RegionRef
  9.  *        Region_rep
  10.  *
  11.  *   ORIGINS: 82,27
  12.  *
  13.  *
  14.  *   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  15.  *   All Rights Reserved
  16.  *   Licensed Materials - Property of IBM
  17.  *   US Government Users Restricted Rights - Use, duplication or
  18.  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  19.  *       
  20.  *   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  21.  *   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22.  *   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  23.  *   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  24.  *   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  25.  *   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  26.  *   OR PERFORMANCE OF THIS SOFTWARE.
  27.  */
  28. /*====END_GENERATED_PROLOG========================================
  29.  */
  30.  
  31. /********************************************************************/
  32. /*  Licensed Materials - Property of IBM                            */
  33. /*                                                                  */
  34. /*                                                                  */
  35. /* Copyright (C) International Business Machines Corp., 1994.       */
  36. /* Copyright (C) Apple Computer, Inc., 1994                         */
  37. /*                                                                  */
  38. /*  US Government Users Restricted Rights -                         */
  39. /*  Use, duplication, or disclosure restricted                      */
  40. /*  by GSA ADP Schedule Contract with IBM Corp.                     */
  41. /********************************************************************/
  42. /*  IBM Change History (most recent first):                         */
  43. /*  23332    6/24/96 chb  Added SetDisplay/fDisplay for X Windows   */
  44. /*  133968  08/22/95 aml  Port DR3                                  */
  45. /*  122017   5/11/95 aml  Performance enhancements                  */
  46. /*  120604   4/28/95 ced  Merge with B1C16 Apple code.              */
  47. /*                                                                  */
  48. /********************************************************************/
  49. /*
  50.     File:        RealShpe.h
  51.  
  52.     Contains:    RealShape class, private to ODShape.
  53.  
  54.     Owned by:    Jens Alfke
  55.  
  56.     Copyright:    1993-94 by Apple Computer, Inc., all rights reserved.
  57.  
  58.     Change History (most recent first):
  59.  
  60.          <7>     5/25/95    jpa        Use new GX headers [1241078, 1253324]
  61.          <6>     2/24/95    jpa        Removed local ODNewRgn. [1220810]
  62.          <5>     12/5/94    jpa        Code review cleanup [1203923]
  63.          <4>    10/24/94    jpa        Added ODNewRgn. [1151710]
  64.          <3>      8/8/94    jpa        Added Outset method [1178690]
  65.          <2>      8/2/94    jpa        Added AsPolygonShape.
  66.          <1>     6/15/94    jpa        first checked in
  67.                             --------Moved to SOM project and rearranged-----
  68.          <7>      5/9/94    jpa        Enable polygon clipper and GX support
  69.                                     [1162090]
  70.          <6>     3/15/94    MB        Changes to support SCpp/ASLM builds,
  71.                                     #1150864.
  72.          <5>     2/17/94    JA        Declare XMPPolygon as struct, not class.
  73.          <4>     2/16/94    JA        Include new AltPoint.h.
  74.          <3>     2/10/94    JA        Stop using ptrs to member fns.
  75.          <2>      2/9/94    JA        Renamed from ShapePrv.h --> ShapePvM.h
  76.          <6>      2/7/94    JA        Further tigerings.
  77.          <5>      2/3/94    JA        Tiger Team Makeover!
  78.          <4>     1/31/94    JA        XMPRealShape no longer derives from
  79.                                     XMPAbsShape. Other API improvements.
  80.          <3>    11/24/93    VL        Rolled back changes as ASLM build breaks
  81.                                     the THINK build.
  82.          <2>    11/23/93    VL        Made this work with ASLM.
  83.          <1>    11/23/93    JA        first checked in
  84.          
  85.     In Progress:
  86.         
  87. */
  88.  
  89.  
  90. #ifndef _REALSHPE_
  91. #define _REALSHPE_
  92.  
  93. #ifndef _ODTYPES_
  94. #include "ODTypes.h"
  95. #endif
  96.  
  97. #ifndef _PLFMDEF_
  98. #include "PlfmDef.h"
  99. #endif
  100.  
  101. #ifdef _PLATFORM_MACINTOSH_
  102. #ifndef __GXTYPES__
  103. #include <GXTypes.h>                /* for gxShape type */
  104. #endif
  105. #endif // _PLATFORM_MACINTOSH_
  106.  
  107. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  108. #ifndef _PLATSHAPE_
  109. #include "PlatShpe.h"
  110. #endif
  111. #endif // IBM Platforms
  112.  
  113. #ifndef _POLYCLIP_
  114. #include "PolyClip.h"            /* for ODShapeOp enum*/
  115. #endif
  116.  
  117.  
  118. #ifdef _PLATFORM_MACINTOSH_
  119.  
  120. #ifndef __QUICKDRAW__
  121. #include <QuickDraw.h>            /* for Region type*/
  122. #endif
  123.  
  124. #else
  125.  
  126. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_)
  127. class Region_rep {
  128.    HRGN hrgn;
  129.    int refs;
  130.    Region_rep( HRGN );
  131.    ~Region_rep();
  132.    friend class RegionRef;
  133. };
  134.  
  135. class RegionRef {
  136.    Region_rep *rgn;
  137. public:
  138.    RegionRef &operator =( const RegionRef& );
  139.    RegionRef &operator =( HRGN );
  140.    operator HRGN ();
  141.    RegionRef( RegionRef& );
  142.    RegionRef( HRGN = 0 );
  143.    ~RegionRef();
  144.    void InitRegion( HRGN );
  145.    void Unlink();
  146.    void DisposeRgn();
  147. };
  148. #endif
  149.  
  150. #if defined(_PLATFORM_UNIX_)
  151. class Region_rep {
  152.    Region hrgn;
  153.    int refs;
  154.    Region_rep( Region );
  155.    ~Region_rep();
  156.    friend class RegionRef;
  157. };
  158.  
  159. class RegionRef {
  160.    Region_rep *rgn;
  161. public:
  162.    RegionRef &operator =( const RegionRef& );
  163.    RegionRef &operator =( Region );
  164.    operator Region ();
  165.    RegionRef( RegionRef& );
  166.    RegionRef( Region = 0 );
  167.    ~RegionRef();
  168.    void InitRegion( Region );
  169.    void Unlink();
  170.    void DisposeRgn();
  171. };
  172. #endif // _PLATFORM_UNIX_
  173.  
  174. #endif
  175.  
  176.  
  177.  
  178. //==============================================================================
  179. // Classes used in this interface
  180. //==============================================================================
  181.  
  182. class ODShape;
  183.  
  184. class PolygonShape;
  185.  
  186. //==============================================================================
  187. // QuickDraw Classic/GX Utilities
  188. //==============================================================================
  189.  
  190. #ifdef _PLATFORM_MACINTOSH_
  191. void ClearGXError( );
  192. void ThrowIfGXError( );
  193. void ThrowIfFirstGXError( );
  194. #endif
  195.  
  196.  
  197. //==============================================================================
  198. // RealShape
  199. //==============================================================================
  200.  
  201. class RealShape {
  202.   public:
  203.  
  204.     RealShape( ODGeometryMode );
  205.     virtual ~RealShape( );
  206.  
  207.     ODVMethod ODSize     Purge(ODSize size);
  208.  
  209.     ODMethod void      SetGeometryMode( ODGeometryMode );
  210.     ODMethod ODGeometryMode  GetGeometryMode( );
  211.  
  212.     ODVMethod RealShape*  SetPolygon( const ODPolygon& );
  213.     ODVMethod void      Simplify( );                       // Implemented only by PolygonShape
  214.  
  215.     ODVMethod void       SetPlatformShape( ODGraphicsSystem, ODPlatformShape );
  216.  
  217. //
  218. // IBM Platforms
  219. //
  220. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  221.  
  222.     ODMethod ODPlatformShape GetPlatformShape( Environment*, ODGraphicsSystem );
  223.  
  224.     inline RgnHandle    GetQDRegion( Environment* ev )
  225.             {return (RgnHandle)this->GetPlatformShape( ev, kODQuickDraw);}
  226.  
  227. #else
  228.  
  229.     ODMethod ODPlatformShape GetPlatformShape( ODGraphicsSystem );
  230.  
  231.     inline RgnHandle    GetQDRegion( )
  232.             {return (RgnHandle)this->GetPlatformShape(kODQuickDraw);}
  233.  
  234. #endif //  IBM Platforms 
  235.  
  236.  
  237.     ODVMethod ODBoolean    HasGeometry( );
  238.  
  239.     ODVMethod RealShape*  Clear( );
  240.  
  241.     static RealShape*    NewGeometricShape( ODGeometryMode mode );
  242.  
  243.  
  244.  
  245.   // Abstract stubs (these basically follow the ODShape interface:)
  246.  
  247. // 
  248. // IBM Platforms
  249. //
  250. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  251.  
  252.  
  253.     ODVMethod void       GetBoundingBox( Environment* ev, ODRect *bounds ) = 0;
  254.     ODVMethod void GetPesimisticBoundingBox(Environment *ev, ODRect *bounds);  // AL
  255.     ODVMethod RealShape*   SetRectangle( const ODRect *rect ) = 0;
  256.     ODVMethod void       CopyPolygon( Environment*, ODPolygon& ) = 0;
  257.     ODVMethod ODBoolean    IsSameAs( Environment*, RealShape * compareShape) = 0;
  258.     ODVMethod ODBoolean    IsEmpty( Environment* ) = 0;
  259.     ODVMethod ODBoolean    IsObviousEmpty(Environment*);  // AL
  260.     ODVMethod ODBoolean    ContainsPoint( Environment*, ODPoint point ) = 0;
  261.     ODVMethod ODBoolean    IsRectangular( Environment* ) = 0;
  262.     ODVMethod ODBoolean    IsObviousRectangular(Environment*);  // AL
  263.     ODVMethod RealShape*  Transform(Environment*, ODTransform* transform) = 0;
  264.     ODVMethod RealShape*  Copy( Environment* ) = 0;
  265.     ODVMethod RealShape*  Outset(Environment*, ODCoordinate distance) = 0;
  266.     ODVMethod RealShape*  Subtract( Environment*, RealShape * diffShape ) = 0;
  267.     ODVMethod RealShape*  Intersect(Environment*, RealShape * sectShape) = 0;
  268.     ODVMethod RealShape*  Union( Environment*, RealShape * unionShape ) = 0;
  269.  
  270.     ODVMethod RealShape*  Combine( Environment*, ODShapeOp, RealShape * );
  271.  
  272. #else
  273.  
  274.     ODVMethod void       GetBoundingBox( ODRect *bounds ) = 0;
  275.     ODVMethod RealShape*   SetRectangle( const ODRect *rect ) = 0;
  276.     ODVMethod void       CopyPolygon( ODPolygon& ) = 0;
  277.     ODVMethod ODBoolean    IsSameAs( RealShape* compareShape) = 0;
  278.     ODVMethod ODBoolean    IsEmpty( ) = 0;
  279.     ODVMethod ODBoolean    ContainsPoint( ODPoint point ) = 0;
  280.     ODVMethod ODBoolean    IsRectangular( ) = 0;
  281.     ODVMethod RealShape*  Copy( ) = 0;
  282.     ODVMethod RealShape*  Transform(Environment*, ODTransform* transform) = 0;
  283.     ODVMethod RealShape*  Outset(ODCoordinate distance) = 0;
  284.     ODVMethod RealShape*  Subtract( RealShape* diffShape ) = 0;
  285.     ODVMethod RealShape*  Intersect(RealShape* sectShape) = 0;
  286.     ODVMethod RealShape*  Union( RealShape* unionShape ) = 0;
  287.  
  288.     ODVMethod RealShape*  Combine( ODShapeOp, RealShape* );
  289.  
  290. #endif // IBM Platforms
  291.  
  292.  
  293. #if ODDebug
  294.     char                    GetType( ) const        {return fType;}
  295. #endif
  296.  
  297. #if _PLATFORM_UNIX_
  298.     static void SetDisplay(Environment*, Display *display);
  299.     static int  GetRegionRects( ODRgnHandle rgn, XRectangle** rectangles );
  300. #endif // _PLATFORM_UNIX_
  301.  
  302.   protected:
  303.  
  304. // 
  305. // IBM Platforms
  306. //
  307. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  308.  
  309.     ODVMethod RealShape*  ReplaceWith( Environment*, RealShape* );   // Delete me & return copy of shape
  310.     ODMethod RealShape*    Promote( Environment*, 
  311.                                     ODShapeOp =kShapeNoOp,
  312.                                     RealShape*  = NULL );            // Convert & perform op
  313.     ODVMethod RealShape*  AsPolygonShape( Environment* );            // Return equivalent polygon/GX shape
  314.     ODVMethod void      InitQDRegion( Environment* ) = 0;            // Called when fQDRegion needs to be set
  315.  
  316. #else
  317.  
  318.     ODVMethod RealShape*  ReplaceWith( RealShape* );                 // Delete me & return copy of shape
  319.     ODMethod RealShape*    Promote( ODShapeOp =kShapeNoOp,
  320.                                     RealShape*  = NULL);             // Convert & perform op
  321.     ODVMethod RealShape*  AsPolygonShape( );                         // Return equivalent polygon/GX shape
  322.     ODVMethod gxShape    CopyGXShape( ) = 0;                         // Return a GX shape
  323.     ODVMethod void      InitQDRegion( ) = 0;                         // Called when fQDRegion needs to be set
  324.  
  325. #endif // IBM Platforms 
  326.  
  327.  
  328. #if ODDebug
  329.     char          fType;          // Number identifying class type:
  330.                                   /* 0=Rect, 1=Rgn, 2=Poly, 3=GX*/
  331. #endif
  332.  
  333.     ODGeometryMode      fMode;          // Geometry mode
  334.  
  335. // 
  336. // IBM Platforms
  337. //
  338. #if defined(_PLATFORM_OS2_) || defined(_PLATFORM_WIN32_) || defined(_PLATFORM_UNIX_)
  339.  
  340.     RegionRef        fQDRegion;
  341.  
  342. #ifdef _PLATFORM_UNIX_
  343.     //    static Display *fDisplay;
  344.     //    static ODBoolean fShapeExtensionOK;
  345.     //    static ODBoolean fShapeExtensionOK_Known;
  346. #endif // _PLATFORM_UNIX_
  347.  
  348. #else
  349.  
  350.     RgnHandle        fQDRegion;        // Cached QuickDraw region
  351.  
  352. #endif  // IBM Platforms 
  353.  
  354. };
  355.  
  356.  
  357. #ifdef _PLATFORM_MACINTOSH_
  358. extern ODBoolean gGX;        // Is GX installed?
  359. #endif  // _PLATFORM_MACINTOSH_
  360.  
  361. #endif /*_REALSHPE_*/
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.