home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / tvision / tfldex / tfield.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-24  |  3.7 KB  |  115 lines

  1. /* ------------------------------------------------------------------------*/
  2. /*                                                                         */
  3. /*   TFIELD.H                                                              */
  4. /*                                                                         */
  5. /*   Portions Copyright (c) Borland International 1991                     */
  6. /*   All Rights Reserved.                                                  */
  7. /*                                                                         */
  8. /*   defines the classes TField                                            */
  9. /*                                                                         */
  10. /* ------------------------------------------------------------------------*/
  11.  
  12.  
  13. /* ---------------------------------------------------------------------- */
  14. /*      class TField                                                      */
  15. /*                                                                        */
  16. /*      Palette layout                                                    */
  17. /*        1 = Passive                                                     */
  18. /*        2 = Active                                                      */
  19. /*        3 = Selected                                                    */
  20. /*        4 = Arrows                                                      */
  21. /* ---------------------------------------------------------------------- */
  22.  
  23. #if defined( Uses_TField ) && !defined( __TField )
  24. #define __TField
  25.  
  26. //
  27. // 1/17/92 -- MBB
  28. // Added the following justification control constants
  29. //
  30. const int jLeft = 1; // left justification
  31. const int jRight = 2; // right justification
  32.  
  33.  
  34. class far TRect;
  35. class far TEvent;
  36.  
  37. class TField : public TView
  38. {
  39.  
  40. public:
  41.  
  42.      TField( const TRect& bounds, int aMaxLen );
  43.      ~TField();
  44.  
  45.      virtual ushort dataSize();
  46.      virtual void draw();
  47.      virtual void getData( void *rec );
  48.      virtual TPalette& getPalette() const;
  49.      virtual void handleEvent( TEvent& event );
  50.      void selectAll( Boolean enable );
  51.      virtual void setData( void *rec );
  52.      virtual void setState( ushort aState, Boolean enable );
  53.      virtual void setScroll( Boolean enable );
  54.      virtual void setJustification( int jValue );
  55.  
  56.  
  57.      char* data;
  58.      int maxLen;
  59.      int curPos;
  60.      int firstPos;
  61.      int selStart;
  62.      int selEnd;
  63.      //
  64.      // 1/16/92 -- MBB
  65.      // Extension to TInputLine's data structure to allow user to turn
  66.      // scrolling off.  scrollState should be set to zero to disable scrolling
  67.      // or to any non-zero value to enable scrolling.
  68.      //
  69.      int scrollState;
  70.      //
  71.      // 1/17/92 -- MBB
  72.      // added justification to control whether the field fills from the
  73.      // right (jRight) or from the default left (jLeft)
  74.      //
  75.      int justification;
  76.  
  77. private:
  78.  
  79.      Boolean canScroll( int delta );
  80.      int mouseDelta( TEvent& event );
  81.      int mousePos( TEvent& event );
  82.      void deleteSelect();
  83.  
  84.      static const char near rightArrow;
  85.      static const char near leftArrow;
  86.  
  87.      virtual const char *streamableName() const
  88.           { return name; }
  89.  
  90. protected:
  91.  
  92.      TField( StreamableInit );
  93.      virtual void write( opstream& );
  94.      virtual void *read( ipstream& );
  95.  
  96. public:
  97.  
  98.      static const char * const near name;
  99.      static TStreamable *build();
  100.  
  101. };
  102.  
  103. inline ipstream& operator >> ( ipstream& is, TField& cl )
  104.      { return is >> (TStreamable&)cl; }
  105. inline ipstream& operator >> ( ipstream& is, TField*& cl )
  106.      { return is >> (void *&)cl; }
  107.  
  108. inline opstream& operator << ( opstream& os, TField& cl )
  109.      { return os << (TStreamable&)cl; }
  110. inline opstream& operator << ( opstream& os, TField* cl )
  111.      { return os << (TStreamable *)cl; }
  112.  
  113. #endif  // Uses_TField
  114.  
  115.