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

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