home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 10.ddi / TVSRC.ZIP / TBKGRND.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.0 KB  |  72 lines

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