home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tvision / tstrin / tstrinp.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-17  |  3.0 KB  |  111 lines

  1. /*
  2.    TSTRINP.HPP
  3.  
  4.    (C) Copyright 1992 Michael Joseph Newton
  5.    All rights reserved.
  6.  
  7.    Header file for TStringInputLine class.
  8.  
  9.       The TStringInputLine class is derived from Turbo Vision's
  10.    TInputLine class. TStringInputLine is declared in TSTRINP.HPP,
  11.    and defined in TSTRINP.CPP.
  12.  
  13.       This file is hereby released by the author to the public
  14.    domain. Use it as you will.
  15.  
  16.    Author:      Michael Joseph Newton
  17.    Date:        01/17/92
  18.    Address:     17874 Marygold Ave. #32
  19.                 Bloomington, CA 92316
  20.    Phone:       (714) 877-4655
  21.    CompuServe:  70402,531 (as Michael J. Newton)
  22.    RelayNet:    ->ECTECH (as Mick Newton)
  23.  
  24.    All questions or comments will be greatly appreciated!
  25. */
  26.  
  27. #if !defined __TSTRINP_HPP
  28. #define __TSTRINP_HPP
  29.  
  30. #define Uses_TInputLine
  31. #define Uses_TStreamable
  32.  
  33. #include <tv.h>
  34.  
  35. /*
  36.    Define bits 10, 11, and 12 for TView::options word
  37.    Define 'caseField' as 0xC00 (ofUpperCase | ofLowerCase)
  38. */
  39.  
  40. const ushort ofMandInput = 0x400;
  41. const ushort ofUpperCase = 0x800;
  42. const ushort ofLowerCase = 0x1000;
  43. const ushort caseField   = (ofUpperCase | ofLowerCase);
  44.  
  45. /*
  46.    If 'ofMandInput' bit is set, will not accept an empty string.
  47.    If 'ofUpperCase' bit is set, will convert input to uppercase.
  48.    If 'ofLowerCase' bit is set, will convert input to lowercase.
  49.  
  50.    Use "setf(ofMandInput)" to set the ofMandInput bit.
  51.  
  52.    Use "setf(ofUpperCase, caseField)" to clear the ofLowerCase bit and
  53.    set the ofUpperCase bit.
  54.  
  55.    Use "setf(ofLowerCase, caseField)" to clear the ofUpperCase bit and
  56.    set the ofLowerCase bit.
  57. */
  58.  
  59.  
  60. class TStringInputLine : public TInputLine
  61. {
  62.    public:
  63.       TStringInputLine(const TRect&, int aMaxLen);
  64.       ~TStringInputLine();
  65.       virtual ushort dataSize();
  66.       virtual void getData(void *rec);
  67.       virtual void setData(void *rec);
  68.       virtual Boolean valid(ushort command);
  69.       virtual void handleEvent(TEvent& event);
  70.       ushort setf(ushort setBits, ushort aField);
  71.       ushort setf(ushort setBits);
  72.    protected:
  73.       TStringInputLine(StreamableInit) :
  74.          TInputLine(streamableInit){};
  75.       virtual void write(opstream& os);
  76.       virtual void *read(ipstream& is);
  77.    private:
  78.       virtual const char *streamableName() const
  79.                             {
  80.                             return name;
  81.                             };
  82.    public:
  83.       static const char * const name;
  84.       static TStreamable *build();
  85. };
  86.  
  87.  
  88. inline ipstream& operator >> (ipstream& is, TStringInputLine& cl)
  89.    {
  90.    return is >> (TStreamable&) cl;
  91.    };
  92.  
  93. inline ipstream& operator >> (ipstream& is, TStringInputLine*& cl)
  94.    {
  95.    return is >> (void *&) cl;
  96.    };
  97.  
  98. inline opstream& operator << (opstream& os, TStringInputLine& cl)
  99.    {
  100.    return os << (TStreamable&) cl;
  101.    };
  102.  
  103. inline opstream& operator << (opstream& os, TStringInputLine* cl)
  104.    {
  105.    return os << (TStreamable *) cl;
  106.    };
  107.  
  108.  
  109. #endif                            // End of __TSTRINP_HPP
  110.  
  111.