home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tv20cpp.zip / tvision / drawbuf.h < prev    next >
C/C++ Source or Header  |  1998-01-19  |  2KB  |  71 lines

  1. /*
  2.  * drawbuf.h
  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. #if defined( Uses_TDrawBuffer ) && !defined( __TDrawBuffer )
  13. #define __TDrawBuffer
  14.  
  15. class TDrawBuffer
  16. {
  17.  
  18.     friend class TFrame;
  19.     friend class TView;
  20.     friend void genRefs();
  21.  
  22. public:
  23.  
  24.     void moveChar( ushort indent, char c, ushort attr, ushort count );
  25.     void moveStr( ushort indent, const char *str, ushort attrs );
  26.     void moveCStr( ushort indent, const char *str, ushort attrs );
  27.     void moveBuf( ushort indent, const void *source,
  28.                   ushort attr, ushort count );
  29.  
  30.     void putAttribute( ushort indent, ushort attr );
  31.     void putChar( ushort indent, ushort c );
  32.  
  33. protected:
  34.  
  35.     ushort data[maxViewWidth];
  36.  
  37. };
  38.  
  39. /*
  40.  * SS: some non-portable code changed.
  41.  */
  42. #ifdef __FreeBSD__
  43. #include <machine/endian.h>
  44. #else
  45. #include <endian.h>
  46. #endif
  47.  
  48. #if (BYTE_ORDER == LITTLE_ENDIAN)
  49.     #define loByte(w)    (((uchar *)&w)[0])
  50.     #define hiByte(w)    (((uchar *)&w)[1])
  51. #elif (BYTE_ORDER == BIG_ENDIAN)
  52.     #define loByte(w)    (((uchar *)&w)[1])
  53.     #define hiByte(w)    (((uchar *)&w)[0])
  54. #else
  55.     #error architecture not supported by this library
  56. #endif
  57.  
  58. inline void TDrawBuffer::putAttribute( ushort indent, ushort attr )
  59. {
  60.     hiByte(data[indent]) = uchar(attr);
  61. /* data[indent] = (data[indent] & 0x00ff) | ((attr & 0xff) << 8); */
  62. }
  63.  
  64. inline void TDrawBuffer::putChar( ushort indent, ushort c )
  65. {
  66.     loByte(data[indent]) = uchar(c);
  67. /* data[indent] = (data[indent] & 0xff00) | (c & 0xff); */
  68. }
  69.  
  70. #endif  // Uses_TDrawBuffer
  71.