home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_GEN / TVCOLR.ZIP / TCOLTXT.H < prev    next >
C/C++ Source or Header  |  1994-02-08  |  2KB  |  57 lines

  1. // File    : TCOLTXT.H
  2. // Author  : Eric Woodruff,  CIS ID: 72134,1150
  3. // Updated : Tue 02/08/94 10:27:50
  4. // Note    : Hereby declared public domain
  5. // Compiler: Borland C++ 3.1/4.0
  6. //
  7. // Header file for the TColorText class.  Demonstrates the use of the
  8. // concepts described in TVCOLR.DOC.
  9. //
  10.  
  11. class far TRect;
  12. class far TStaticText;
  13.  
  14. // Color type offsets used by the call to getColor() in the draw function.
  15. enum eCType { eTxtNormal = 0, eTxtInfo, eTxtNotify, eTxtWarn, eTxtError };
  16.  
  17. class TColorText : public TStaticText
  18. {
  19. private:
  20.     short ColorType;        // Type of TColorText
  21.  
  22. public:
  23.     TColorText::TColorText(const TRect &bounds, const char *aText,
  24.       eCType CTextType) :
  25.         TStaticText(bounds, aText),
  26.         ColorType(CTextType) {}
  27.  
  28.     virtual void draw();
  29.     virtual TPalette& getPalette() const;
  30.  
  31. // This stuff makes it streamable.
  32. private:
  33.     virtual const char *streamableName() const
  34.         { return name; }
  35.  
  36. protected:
  37.     TColorText( StreamableInit ) : TStaticText( streamableInit ) {}
  38.  
  39. public:
  40.     static const char * const near name;
  41.     static TStreamable *build();
  42.  
  43. protected:
  44.     virtual void write( opstream& );
  45.     virtual void *read( ipstream& );
  46. };
  47.  
  48. inline ipstream& operator >> ( ipstream& is, TColorText& cl )
  49.     { return is >> (TStreamable&)cl; }
  50. inline ipstream& operator >> ( ipstream& is, TColorText*& cl )
  51.     { return is >> (void *&)cl; }
  52.  
  53. inline opstream& operator << ( opstream& os, TColorText& cl )
  54.     { return os << (TStreamable&)cl; }
  55. inline opstream& operator << ( opstream& os, TColorText* cl )
  56.     { return os << (TStreamable *)cl; }
  57.