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

objects.h

Go to the documentation of this file.
00001 /*
00002  * objects.h
00003  *
00004  * Turbo Vision - Version 2.0
00005  *
00006  * Copyright (c) 1994 by Borland International
00007  * All Rights Reserved.
00008  *
00009  * Modified by Sergio Sigala <sergio@sigala.it>
00010  */
00011 
00012 #if defined( Uses_TPoint ) && !defined( __TPoint )
00013 #define __TPoint
00014 
00028 class TPoint
00029 {
00030 public:
00035     TPoint& operator+=( const TPoint& adder );
00040     TPoint& operator-=( const TPoint& subber );
00045     friend TPoint operator - ( const TPoint& one, const TPoint& two);
00050     friend TPoint operator +( const TPoint& one, const TPoint& two );
00055     friend int operator == ( const TPoint& one, const TPoint& two);
00060     friend int operator != ( const TPoint& one, const TPoint& two);
00064     int x;
00068     int y;
00069 };
00070 
00071 inline TPoint& TPoint::operator += ( const TPoint& adder )
00072 {
00073     x += adder.x;
00074     y += adder.y;
00075     return *this;
00076 }
00077 
00078 inline TPoint& TPoint::operator -= ( const TPoint& subber )
00079 {
00080     x -= subber.x;
00081     y -= subber.y;
00082     return *this;
00083 }
00084 
00088 inline ipstream& operator >> ( ipstream& is, TPoint& p )
00089     { return is >> p.x >> p.y; }
00093 inline ipstream& operator >> ( ipstream& is, TPoint*& p )
00094     { return is >> p->x >> p->y; }
00095 
00099 inline opstream& operator << ( opstream& os, TPoint& p )
00100     { return os << p.x << p.y; }
00104 inline opstream& operator << ( opstream& os, TPoint* p )
00105     { return os << p->x << p->y; }
00106 
00107 #endif  // Uses_TPoint
00108 
00109 #if defined( Uses_TRect ) && !defined( __TRect )
00110 #define __TRect
00111 
00128 class TRect
00129 {
00130 public:
00137     TRect( int ax, int ay, int bx, int by );
00144     TRect( TPoint p1, TPoint p2 );
00151     TRect();
00158     void move( int aDX, int aDY );
00171     void grow( int aDX, int aDY );
00179     void intersect( const TRect& r );
00187     void Union( const TRect& r );
00193     Boolean contains( const TPoint& p ) const;
00198     Boolean operator == ( const TRect& r ) const;
00203     Boolean operator != ( const TRect& r ) const;
00210     Boolean isEmpty();
00214     TPoint a;
00219     TPoint b;
00220 };
00221 
00222 inline TRect::TRect( int ax, int ay, int bx, int by)
00223 {
00224     a.x = ax;
00225     a.y = ay;
00226     b.x = bx;
00227     b.y = by;
00228 }
00229 
00230 inline TRect::TRect( TPoint p1, TPoint p2 )
00231 {
00232     a = p1;
00233     b = p2;
00234 }
00235 
00236 inline TRect::TRect()
00237 {
00238 }
00239 
00240 inline void TRect::move( int aDX, int aDY )
00241 {
00242     a.x += aDX;
00243     a.y += aDY;
00244     b.x += aDX;
00245     b.y += aDY;
00246 }
00247 
00248 inline void TRect::grow( int aDX, int aDY )
00249 {
00250     a.x -= aDX;
00251     a.y -= aDY;
00252     b.x += aDX;
00253     b.y += aDY;
00254 }
00255 
00256 inline void TRect::intersect( const TRect& r )
00257 {
00258     a.x = max( a.x, r.a.x );
00259     a.y = max( a.y, r.a.y );
00260     b.x = min( b.x, r.b.x );
00261     b.y = min( b.y, r.b.y );
00262 }
00263 
00264 inline void TRect::Union( const TRect& r )
00265 {
00266     a.x = min( a.x, r.a.x );
00267     a.y = min( a.y, r.a.y );
00268     b.x = max( b.x, r.b.x );
00269     b.y = max( b.y, r.b.y );
00270 }
00271 
00272 inline Boolean TRect::contains( const TPoint& p ) const
00273 {
00274     return Boolean(
00275         p.x >= a.x && p.x < b.x && p.y >= a.y && p.y < b.y
00276         );
00277 }
00278 
00279 inline Boolean TRect::operator == ( const TRect& r) const
00280 {
00281     return Boolean( a == r.a && b == r.b );
00282 }
00283 
00284 inline Boolean TRect::operator != ( const TRect& r ) const
00285 {
00286     return Boolean( !(*this == r) );
00287 }
00288 
00289 inline Boolean TRect::isEmpty()
00290 {
00291     return Boolean( a.x >= b.x || a.y >= b.y );
00292 }
00293 
00297 inline ipstream& operator >> ( ipstream& is, TRect& r )
00298     { return is >> r.a >> r.b; }
00302 inline ipstream& operator >> ( ipstream& is, TRect*& r )
00303     { return is >> r->a >> r->b; }
00304 
00308 inline opstream& operator << ( opstream& os, TRect& r )
00309     { return os << r.a << r.b; }
00313 inline opstream& operator << ( opstream& os, TRect* r )
00314     { return os << r->a << r->b; }
00315 
00316 #endif  // Uses_TRect
00317 
00318 #if defined( Uses_TCollection ) && !defined( __TCollection )
00319 #define __TCollection
00320 
00349 class TCollection : public virtual TNSCollection, public TStreamable
00350 {
00351 public:
00365     TCollection( ccIndex aLimit, ccIndex aDelta )
00366         { delta = aDelta; setLimit( aLimit ); }
00367 private:
00368     virtual const char *streamableName() const
00369         { return name; }
00377     virtual void *readItem( ipstream& ) = 0;
00385     virtual void writeItem( void *, opstream& ) = 0;
00386 protected:
00395     TCollection( StreamableInit );
00400     virtual void *read( ipstream& is);
00404     virtual void write( opstream& os );
00405 public:
00410     static const char * const name;
00411 };
00412 
00416 inline ipstream& operator >> ( ipstream& is, TCollection& cl )
00417     { return is >> (TStreamable&)cl; }
00421 inline ipstream& operator >> ( ipstream& is, TCollection*& cl )
00422     { return is >> (void *&)cl; }
00423 
00427 inline opstream& operator << ( opstream& os, TCollection& cl )
00428     { return os << (TStreamable&)cl; }
00432 inline opstream& operator << ( opstream& os, TCollection* cl )
00433     { return os << (TStreamable *)cl; }
00434 
00435 #endif  // Uses_TCollection
00436 
00437 #if defined( Uses_TSortedCollection ) && !defined( __TSortedCollection )
00438 #define __TSortedCollection
00439 
00449 class TSortedCollection : public TNSSortedCollection, public TCollection
00450 {
00451 public:
00461     TSortedCollection( ccIndex aLimit, ccIndex aDelta) :
00462         TCollection( aLimit, aDelta ) {}
00463 private:
00468     virtual int compare( void *key1, void *key2 ) = 0;
00469     virtual const char *streamableName() const
00470         { return name; }
00477     virtual void *readItem( ipstream& is ) = 0;
00484     virtual void writeItem( void *, opstream& os ) = 0;
00485 protected:
00492     TSortedCollection( StreamableInit );
00496     virtual void *read( ipstream& is );
00501     virtual void write( opstream& os );
00502 public:
00506     static const char * const name;
00507 };
00508 
00512 inline ipstream& operator >> ( ipstream& is, TSortedCollection& cl )
00513     { return is >> (TStreamable&)cl; }
00517 inline ipstream& operator >> ( ipstream& is, TSortedCollection*& cl )
00518     { return is >> (void *&)cl; }
00519 
00523 inline opstream& operator << ( opstream& os, TSortedCollection& cl )
00524     { return os << (TStreamable&)cl; }
00528 inline opstream& operator << ( opstream& os, TSortedCollection* cl )
00529     { return os << (TStreamable *)cl; }
00530 
00531 #endif  // Uses_TSortedCollection

Generated at Sat Sep 22 20:19:10 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001