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

  1. /*------------------------------------------------------------*/
  2. /* filename - tindictr.cpp                                    */
  3. /*                                                            */
  4. /* function(s)                                                */
  5. /*            TIndicator 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_TIndicator
  19. #define Uses_TDrawBuffer
  20. #define Uses_TEvent
  21. #define Uses_TView
  22. #define Uses_opstream
  23. #define Uses_ipstream
  24. #include <tv.h>
  25.  
  26. #if !defined( __STRSTREA_H )
  27. #include <strstrea.h>
  28. #endif    // __STRSTREA_H
  29.  
  30. #define cpIndicator "\x02\x03"
  31.  
  32. TIndicator::TIndicator( const TRect& bounds ) :
  33.     TView( bounds )
  34. {
  35.     growMode = gfGrowLoY | gfGrowHiY;
  36. }
  37.  
  38. void TIndicator::draw()
  39. {
  40.     uchar color, frame;
  41.     TDrawBuffer b;
  42.     char s[15];
  43.  
  44.     if( (state & sfDragging) == 0 )
  45.         {
  46.         color = getColor(1);
  47.         frame = dragFrame;
  48.         }
  49.     else
  50.         {
  51.         color = getColor(2);
  52.         frame = normalFrame;
  53.         }
  54.  
  55.     b.moveChar( 0, frame, color, size.x );
  56.     if( modified )
  57.         b.putChar( 0, 15 );
  58.     ostrstream os( s, 15 );
  59.  
  60.     os << ' ' << (location.y+1)
  61.        << ':' << (location.x+1) << ' ' << ends;
  62.  
  63.     b.moveCStr( 8-int(strchr(s, ':')-s), s, color);
  64.     writeBuf(0, 0, size.x, 1, b);
  65. }
  66.  
  67. TPalette& TIndicator::getPalette() const
  68. {
  69.     static TPalette palette( cpIndicator, sizeof( cpIndicator )-1 );
  70.     return palette;
  71. }
  72.  
  73. void TIndicator::setState( ushort aState, Boolean enable )
  74. {
  75.     TView::setState(aState, enable);
  76.     if( aState == sfDragging )
  77.         drawView();
  78. }
  79.  
  80. void TIndicator::setValue( const TPoint& aLocation, Boolean aModified )
  81. {
  82.     if( (location !=  aLocation) || (modified != aModified) )
  83.         {
  84.         location = aLocation;
  85.         modified = aModified;
  86.         drawView();
  87.         }
  88. }
  89.  
  90. TStreamable *TIndicator::build()
  91. {
  92.     return new TIndicator( streamableInit );
  93. }
  94.  
  95. TIndicator::TIndicator( StreamableInit ) : TView( streamableInit )
  96. {
  97. }
  98.  
  99.