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

  1. /*
  2.  * TParamText.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_TParamText
  13. #include <tvision/tv.h>
  14.  
  15. #include <stdarg.h>
  16. #include <stdio.h>
  17. #include <string.h>
  18.  
  19. TParamText::TParamText( const TRect& bounds ) :
  20.     TStaticText(bounds, 0 ),
  21.     str( new char [256] )
  22. {
  23.     str[0] = EOS;
  24. }
  25.  
  26. TParamText::~TParamText()
  27. {
  28.     delete str;
  29. }
  30.  
  31. void TParamText::getText( char *s )
  32. {
  33.     if( str != 0 )
  34.         strcpy( s, str );
  35.     else
  36.         *s = EOS;
  37. }
  38.  
  39. int TParamText::getTextLen()
  40. {
  41.     return (str != 0) ? strlen( str ) : 0;
  42. }
  43.  
  44. void TParamText::setText( char *fmt, ... )
  45. {
  46.     va_list ap;
  47.  
  48.     va_start( ap, fmt );
  49.     vsprintf( str, fmt, ap );
  50.     va_end( ap );
  51.  
  52.     drawView();
  53. }
  54.  
  55. #if !defined(NO_STREAMABLE)
  56.  
  57. #ifndef __UNPATCHED
  58. void TParamText::write( opstream& os )
  59. {
  60.     TStaticText::write( os );
  61.     os.writeString(str);
  62. }
  63.  
  64. void *TParamText::read( ipstream& is )
  65. {
  66.     TStaticText::read( is );
  67.     str = new char [256];
  68.     is.readString(str, 256);
  69.     return this;
  70. }
  71. #endif
  72.  
  73. TStreamable *TParamText::build()
  74. {
  75.     return new TParamText( streamableInit );
  76. }
  77.  
  78. TParamText::TParamText( StreamableInit ) : TStaticText( streamableInit )
  79. {
  80. }
  81.  
  82. #endif
  83.