Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

rectangle.h

00001 // $Id: rectangle_8h-source.html,v 1.2 2002/06/20 17:09:51 mkrohn5 Exp $
00002 
00003 // Rectangle Header File
00004 // Written by: Marco Krohn
00005 
00006 // Copyright (C) 1999 - 2001, Marco Krohn, marco.krohn@gmx.de
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 1, or (at your option)
00011 // any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 
00018 #ifndef __RECTANGLE_INCLUDED
00019 #define __RECTANGLE_INCLUDED
00020 
00021 #include <iostream>
00022 
00023 using namespace std;
00024 
00025 class TLine;
00026 class TPoint;
00027 class TRectangle;
00028 
00029 
00030 
00031 
00032 
00033 //----------------------------------------  Misc. Functions  ----------------------------------------
00034 
00042 ostream& operator<<( ostream& Stream, const TRectangle& Rect );
00043 
00044 
00045 
00046 
00047 
00048 //----------------------------------------  class TRectangle  ----------------------------------------
00049 
00062 class TRectangle
00063 {
00064   public:
00073     TRectangle( double x=0, double y=0, double w=0, double h=0 );
00080     TRectangle( const TPoint& TopLeft, const TPoint& Size );
00081 
00082     // default: operator=, copy constructor
00083 
00095     bool Contains( double x, double y, bool proper=false ) const;
00106     bool Contains( const TPoint& Point, bool proper=false ) const;
00111     double GetBottom() const;
00116     TPoint GetCenter() const;
00122     double GetHeight() const;
00127     int GetIntersectionPoints( const TLine& line, TPoint* one, TPoint* two ) const;
00132     double GetLeft() const;
00137     double GetRight() const;
00142     TPoint GetSize() const;
00147     double GetTop() const;
00153     double GetWidth() const;
00157     double GetX() const;
00161     double GetY() const;
00167     bool Intersects( const TRectangle& r ) const;
00172     bool IsValid() const;
00181     void MoveBy( double dx, double dy );
00188     void MoveByX( double dx );
00195     void MoveByY( double dy );
00203     void MoveTo( double x, double y );
00210     void MoveToX( double x );
00217     void MoveToY( double y );
00224     TRectangle Normalize() const;
00231     void SetBottom( double b );
00237     void SetHeight( double h );
00244     void SetLeft( double l );
00249     void SetRect( double x, double y, double w, double h );
00255     void SetRight( double r );
00262     void SetSize( double w, double h );
00269     void SetSize( const TPoint& Size );
00275     void SetTop( double t );
00281     void SetWidth( double w );
00288     void SetX( double x );
00295     void SetY( double y );
00302     ostream& Write( ostream& Stream ) const;
00303 
00304   protected:
00305     double x1;
00306     double y1;
00307     double x2;
00308     double y2;
00309 };
00310 
00311 
00312 
00313 
00314 
00315 #endif        // __RECTANGLE_INCLUDED

Generated on Thu Jun 20 18:13:16 2002 for Stellar Legacy by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001