region.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:6k
- /*
- * region.h
- *
- * Arbitrarily shaped region.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: region.h,v $
- * Revision 1.14 1999/03/10 03:49:53 robertj
- * More documentation adjustments.
- *
- * Revision 1.13 1999/03/09 08:01:49 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.12 1999/02/16 08:08:46 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.11 1998/09/23 06:28:48 robertj
- * Added open source copyright license.
- *
- * Revision 1.10 1995/03/14 12:42:25 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.9 1995/01/14 06:19:30 robertj
- * Documentation
- *
- * Revision 1.8 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.7 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.6 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.5 1993/12/06 22:06:45 robertj
- * Destructor should be virtual for classes with virtual member functions.
- *
- * Revision 1.4 1993/10/16 20:33:20 robertj
- * Added function to determine if a rectangle and region overlap.
- *
- * Revision 1.3 1993/08/21 01:50:33 robertj
- * Made Clone() function optional, default will assert if called.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PREGION
- #ifdef __GNUC__
- #pragma interface
- #endif
- /**A class representing a region of the graphics system drawing plane. This
- is an arbitrary enclosed shape. It is often made up from a collection of
- rectangles.
- */
- class PRegion : public PObject
- {
- PCLASSINFO(PRegion, PObject);
- public:
- /**Create new region object. The first, parameterless, constructor creates
- an empty region. The second creates a region that initially encloses
- the specified rectangle.
- */
- PRegion();
- PRegion(
- const PRect & rect /// Rectangle for initial region.
- );
- /** Create a copy of the specified region. */
- PRegion(
- const PRegion & rgn /// Region to copy.
- );
- /** Assign one region to another. */
- PRegion & operator=(
- const PRegion & rgn /// Region to assign to the current region.
- );
- /** Destroy the region. */
- virtual ~PRegion();
- /**@name Overrides from class PObject */
- /**Determine if the two regions are identical.
- @return
- #EqualTo# if the regions enclose the identical part of the
- drawing plane, otherwise #GreaterThan# is returned.
- */
- virtual Comparison Compare(
- const PObject & obj /// Region to compare against.
- ) const;
- /**@name New functions for class */
- /**Add the specified area of the drawing plane to the region. The region
- will include the area specified into its enclosed space.
- */
- void Add(
- const PRect & rect /// Rectangle to add to teh region.
- );
- void Add(
- const PRegion & rgn /// Another region to add to region.
- );
- /**Determine if the point is contined within the regions space.
-
- @return
- TRUE if point is in region.
- */
- BOOL ContainsPoint(
- const PPoint & pt /// Point to determine if is inside region.
- ) const;
- /**Determine if the rectangle is wholly contiained within the region.
- @return
- TRUE if rectangle is in region.
- */
- BOOL ContainsRect(const PRect & rect) const;
- /**Determine if any part of the rectangle overlapps any part of the region.
-
- @return
- TRUE if rectangle intersect region.
- */
- BOOL OverlapsRect(const PRect & rect) const;
- /**Determine if the region is empty.
- @return
- TRUE if region encloses no space.
- */
- BOOL IsEmpty() const;
- /**Move the region the specified delta amount. The shape of the region does
- not change, only its origin.
- */
- void Offset(
- PORDINATE dx, /// Amount to move region horizontally.
- PORDINATE dy /// Amount ot move region vertically.
- );
- /**Calculate the smallest enclosing bounding box around the region.
- @return
- rectangle that encloses the region.
- */
- PRect GetBounds() const;
- /**Calculate the region that is the intersection of the object and the
- specified region.
-
- @return
- region that is inside both regions.
- */
- PRegion Intersection(const PRegion & rgn) const;
- /**Calcaulte the region that is the union of the object and the specified
- region.
-
- @return
- region that is inside either region.
- */
- PRegion Union(const PRegion & rgn) const;
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////