- /*
- * point.h
- *
- * Coordinate system position.
- *
- * 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: point.h,v $
- * Revision 1.16 1999/03/10 03:49:52 robertj
- * More documentation adjustments.
- *
- * Revision 1.15 1999/03/09 08:01:49 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.14 1999/02/16 08:08:46 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.13 1998/09/23 06:28:17 robertj
- * Added open source copyright license.
- *
- * Revision 1.12 1995/06/04 12:34:35 robertj
- * Added Add component functions.
- *
- * Revision 1.11 1995/03/14 12:42:10 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.10 1995/01/11 09:45:04 robertj
- * Documentation and normalisation.
- *
- * Revision 1.9 1994/10/23 04:53:00 robertj
- * Added multiply and divide operators.
- *
- * 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/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * Revision 1.5 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.4 1993/12/31 06:45:38 robertj
- * Made inlines optional for debugging purposes.
- *
- * Revision 1.3 1993/11/20 17:26:28 robertj
- * Made real point structure private and added operators to get at pointers.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PPOINT
- #ifdef __GNUC__
- #pragma interface
- #endif
- class PRect;
- /**This class represents a coordinate pair used in the drawing environment. It
- represents a specific point in the drawing plane.
- */
- class PPoint : public PObject
- {
- PCLASSINFO(PPoint, PObject);
- public:
- /** Create a point object with the initial x and y values of 0. */
- PPoint();
- /** Create a point object with the initial x and y values. */
- PPoint(
- PORDINATE nx, /// New x value.
- PORDINATE ny /// New y value
- );
- /** Create a point the specified distance from the origin. */
- PPoint(
- const PDim & pt /// Dimensions of distance from origin.
- );
- /** Create a copy of the specified point. */
- PPoint(
- const PPoint & pt /// Point to make a copy of.
- );
- /**@name Overrides from class PObject */
- /**Create a new copy of the specified point. It is the users responsibility
- to delete the returned object.
- @return
- pointer to new copy of point.
- */
- virtual PObject * Clone() const;
- /**Determine the relative rank of the point objects. Points are ranked
- according to the sum of the two ordinates. However they can only be
- equal if the two ordinates are equal, an equal sum is regarded as
- #GreaterThan#.
- @return
- #EqualTo# if the two points are the same,
- #LessThan# and #GreaterThan# according to sum of
- ordinates.
- */
- virtual Comparison Compare(
- const PObject & obj /// Point object to compare against.
- ) const;
- /**@name New function for class */
- /**Get the the X ordinate of the point.
- @return
- x ordinate.
- */
- PORDINATE X() const;
- /**Get the the Y ordinate of the point.
- @return
- y ordinate.
- */
- PORDINATE Y() const;
- /** Set the the X ordinate of the point. */
- void SetX(
- PORDINATE nx /// New x value for point.
- );
- /** Set the the Y ordinate of the point. */
- void SetY(
- PORDINATE ny /// New y value for point.
- );
- /** Add value to the the X ordinate of the point. */
- void AddX(
- PORDINATE dx /// Value to add to point.
- );
- /** Add value to the the Y ordinate of the point. */
- void AddY(
- PORDINATE dy /// Value to add to point.
- );
- /**Calculate the cartesian sum of the points or point and dimensions. The
- sum of a point is the sum of each ordinate independent of the other.
- @return
- new point containing the sum.
- */
- PPoint operator+(
- const PPoint & pt /// Point to add.
- ) const;
- PPoint operator+(
- const PDim & dim /// Dimensions to add.
- ) const;
- /**Calculate the cartesian sum of the points or point and dimensions. The
- sum of a point is the sum of each ordinate independent of the other.
- @return
- reference to the current object instance.
- */
- PPoint & operator+=(
- const PPoint & pt /// Point to add.
- );
- PPoint & operator+=(
- const PDim & dim /// Dimensions to add.
- );
- /**Calculate the cartesian difference of the points or point and
- dimensions. The difference of a point is the difference of each
- ordinate independent of the other.
- @return
- new point containing the difference.
- */
- PPoint operator-(
- const PPoint & pt /// Point to subtract.
- ) const;
- PPoint operator-(
- const PDim & dim /// Dimensions to subtract.
- ) const;
- /**Calculate the cartesian difference of the points or point and
- dimensions. The difference of a point is the difference of each
- ordinate independent of the other.
- @return
- reference to the current object instance.
- */
- PPoint & operator-=(
- const PPoint & pt /// Point to subtract.
- );
- PPoint & operator-=(
- const PDim & dim /// Dimensions to subtract.
- );
- /**Calculate the cartesian product of the points or point and dimensions.
- The product of a point is the product of each ordinate independent of
- the other.
- The #scale# parameter is applied to each ordinate equally.
- @return
- new point containing the product.
- */
- PPoint operator*(
- const PPoint & pt /// Point to multiply.
- ) const;
- PPoint operator*(
- const PDim & dim /// Dimensions to multiply.
- ) const;
- PPoint operator*(
- PORDINATE scale /// Scale factor.
- ) const;
- /**Calculate the cartesian product of the points or point and dimensions.
- The product of a point is the product of each ordinate independent of
- the other.
- The #scale# parameter is applied to each ordinate equally.
- @return
- reference to the current object instance.
- */
- PPoint & operator*=(
- const PPoint & pt /// Point to multiply.
- );
- PPoint & operator*=(
- const PDim & dim /// Dimensions to multiply.
- );
- PPoint & operator*=(
- PORDINATE scale /// Scale factor.
- );
- /**Calculate the cartesian division of the points or point and dimensions.
- The division of a point is the division of each ordinate independent of
- the other.
- The #scale# parameter is applied to each ordinate equally.
- @return
- new point containing the divided point.
- */
- PPoint operator/(
- const PPoint & pt /// Point to divide.
- ) const;
- PPoint operator/(
- const PDim & dim /// Dimensions to divide.
- ) const;
- PPoint operator/(
- PORDINATE scale /// Scale factor.
- ) const;
- /**Calculate the cartesian division of the points or point and dimensions.
- The division of a point is the division of each ordinate independent of
- the other.
- The #scale# parameter is applied to each ordinate equally.
- @return
- reference to the current object instance.
- */
- PPoint & operator/=(
- const PPoint & pt /// Point to divide.
- );
- PPoint & operator/=(
- const PDim & dim /// Dimensions to divide.
- );
- PPoint & operator/=(
- PORDINATE scale /// Scale factor.
- );
- /**Determine if the point is contained within the specified rectangle.
- @return
- TRUE if point is "inside" the rectangle.
- */
- BOOL InRect(
- const PRect & rect /// Rectangle to check for being "inside".
- ) const;
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////