home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20os2.zip / src / TBackground.cpp < prev    next >
C/C++ Source or Header  |  1998-01-19  |  1KB  |  66 lines

  1. /*
  2.  * TBackground.cc
  3.  *
  4.  * Turbo Vision - Version 2.0
  5.  *
  6.  * Copyright (c) 1994 by Borland International
  7.  * All Rights Reserved.
  8.  *
  9.  * Modified by Sergio Sigala <ssigala@globalnet.it>
  10.  */
  11.  
  12. #define Uses_TBackground
  13. #define Uses_TDrawBuffer
  14. #define Uses_opstream
  15. #define Uses_ipstream
  16. #include <tvision/tv.h>
  17.  
  18. #define cpBackground "\x01"      // background palette
  19.  
  20. TBackground::TBackground( const TRect& bounds, char aPattern ) :
  21.     TView(bounds),
  22.     pattern( aPattern )
  23. {
  24.     growMode = gfGrowHiX | gfGrowHiY;
  25. }
  26.  
  27. void TBackground::draw()
  28. {
  29.     TDrawBuffer b;
  30.  
  31.     b.moveChar( 0, pattern, getColor(0x01), size.x );
  32.     writeLine( 0, 0, size.x, size.y, b );
  33. }
  34.  
  35. TPalette& TBackground::getPalette() const
  36. {
  37.     static TPalette palette( cpBackground, sizeof( cpBackground )-1 );
  38.     return palette;
  39. }
  40.  
  41. #if !defined(NO_STREAMABLE)
  42.  
  43. TBackground::TBackground( StreamableInit ) : TView( streamableInit )
  44. {
  45. }
  46.  
  47. void TBackground::write( opstream& os )
  48. {
  49.     TView::write( os );
  50.     os << pattern;
  51. }
  52.  
  53. void *TBackground::read( ipstream& is )
  54. {
  55.     TView::read( is );
  56.     is >> pattern;
  57.     return this;
  58. }
  59.  
  60. TStreamable *TBackground::build()
  61. {
  62.     return new TBackground( streamableInit );
  63. }
  64.  
  65. #endif
  66.