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

TRect Class Reference

Screen rectangular area. More...

#include <objects.h>

List of all members.

Public Methods

 TRect (int ax, int ay, int bx, int by)
 TRect (TPoint p1, TPoint p2)
 TRect ()
void move (int aDX, int aDY)
void grow (int aDX, int aDY)
void intersect (const TRect &r)
void Union (const TRect &r)
Boolean contains (const TPoint &p) const
Boolean operator== (const TRect &r) const
Boolean operator!= (const TRect &r) const
Boolean isEmpty ()

Public Attributes

TPoint a
TPoint b


Detailed Description

A screen rectangular area.

TRect is used to hold two coordinates on the screen, which usually specify the upper left corner and the lower right corner of views. Sometimes the second coordinate speficy the size (extension) of the view. The two coordinates are named a and b.

TRect has several inline member functions for manipulating rectangles. The operators == and != are overloaded to provide the comparison of two rectangles in a natural way.

See also:
TPoint , TRect::operator== , TRect::operator!=

Definition at line 128 of file objects.h.


Constructor & Destructor Documentation

TRect::TRect ( int ax,
int ay,
int bx,
int by ) [inline]
 

Constructor.

Initializes the rectangle coordinates using the four integer parameters.

Definition at line 222 of file objects.h.

TRect::TRect ( TPoint p1,
TPoint p2 ) [inline]
 

Constructor.

Initializes the rectangle coordinates using two points.

See also:
TPoint

Definition at line 230 of file objects.h.

TRect::TRect ( ) [inline]
 

Constructor.

Does nothing. The two coordinates are not initialized, so they contain garbage.

Definition at line 236 of file objects.h.


Member Function Documentation

void TRect::Union ( const TRect & r ) [inline]
 

Calculates the union between this rectangle and the `r' parameter rectangle.

The resulting rectangle is the smallest rectangle which contains both this rectangle and the `r' rectangle.

Definition at line 264 of file objects.h.

Boolean TRect::contains ( const TPoint & p ) const [inline]
 

Returns True if the calling rectangle (including its boundary) contains the point `p', returns False otherwise.

See also:
TPoint

Definition at line 272 of file objects.h.

void TRect::grow ( int aDX,
int aDY ) [inline]
 

Enlarges the rectangle by a specified value.

Changes the size of the calling rectangle by subtracting `aDX' from a.x, adding `aDX' to b.x, subtracting `aDY' from a.y, and adding `aDY' to b.y.

The left side is left-moved by `aDX' units and the right side is right-moved by `aDX' units. In a similar way the upper side is upper-moved by `aDY' units and the bottom side is bottom-moved by `aDY' units.

Definition at line 248 of file objects.h.

void TRect::intersect ( const TRect & r ) [inline]
 

Calculates the intersection between this rectangle and the parameter rectangle.

The resulting rectangle is the largest rectangle which contains both part of this rectangle and part of the parameter rectangle.

Definition at line 256 of file objects.h.

Boolean TRect::isEmpty ( ) [inline]
 

Checks if the rectangle is empty, i.e. if the first coordinate is greater than the second one.

Empty means that (a.x >= b.x || a.y >= b.y).

Definition at line 289 of file objects.h.

void TRect::move ( int aDX,
int aDY ) [inline]
 

Moves the rectangle to a new position.

The two parameters are added to the two old coordinates as delta values. Both parameters can be negative or positive.

Definition at line 240 of file objects.h.

Boolean TRect::operator!= ( const TRect & r ) const [inline]
 

Returns True if `r' is not the same as the calling rectangle; otherwise, returns False.

Definition at line 284 of file objects.h.

Boolean TRect::operator== ( const TRect & r ) const [inline]
 

Returns True if `r' is the same as the calling rectangle; otherwise, returns False.

Definition at line 279 of file objects.h.


Member Data Documentation

TPoint TRect::a
 

Is the point defining the top-left corner of a rectangle on the screen.

Definition at line 214 of file objects.h.

TPoint TRect::b
 

Is the point defining the bottom-right corner of a rectangle on the screen.

Definition at line 219 of file objects.h.


The documentation for this class was generated from the following file:
Generated at Sat Sep 22 20:19:32 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001