You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.5 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Turbo Vision - Version 2.0
  3. *
  4. * Copyright (c) 1994 by Borland International
  5. * All Rights Reserved.
  6. *
  7. Modified by Robert H�hne to be used for RHIDE.
  8. Changed classes hierarchy and added new draw buffers by Salvador E. Tropea
  9. (Changes under GPL as usual).
  10. *
  11. *
  12. */
  13. #if defined( Uses_TDrawBuffer ) && !defined( __TDrawBuffer )
  14. #define __TDrawBuffer
  15. class TDrawBufferBase
  16. {
  17. public:
  18. enum Types { codepage=0, unicode16=1 };
  19. int getType();
  20. virtual void *getBuffer() = 0;
  21. protected:
  22. int type;
  23. };
  24. inline int TDrawBufferBase::getType()
  25. {
  26. return type;
  27. }
  28. // Simple TDrawBuffer compatible with original class that handles:
  29. // 8 bit character, 8 bits attribute, ...
  30. class TDrawBuffer : public TDrawBufferBase
  31. {
  32. friend class TView;
  33. public:
  34. TDrawBuffer() { type=codepage; }
  35. void moveChar(unsigned indent, char c, unsigned attr, unsigned count);
  36. void moveStr(unsigned indent, const char *str, unsigned attrs, int maxLen=-1);
  37. void moveCStr(unsigned indent, const char *str, unsigned attrs );
  38. void moveBuf(unsigned indent, const void *source,
  39. unsigned attr, unsigned count );
  40. void putAttribute(unsigned indent, unsigned attr);
  41. void putChar(unsigned indent, unsigned c);
  42. virtual void *getBuffer();
  43. protected:
  44. uint16 data[maxViewWidth];
  45. };
  46. #define loByte(w) (((uchar *)&w)[0])
  47. #define hiByte(w) (((uchar *)&w)[1])
  48. inline void TDrawBuffer::putAttribute( unsigned indent, unsigned attr )
  49. {
  50. hiByte(data[indent])=(uchar)attr;
  51. }
  52. inline void TDrawBuffer::putChar( unsigned indent, unsigned c )
  53. {
  54. loByte(data[indent])=(uchar)c;
  55. }
  56. // This is a more advanced class to handle 16 bits Unicode encodings plus
  57. // 16 bits attributes.
  58. class TDrawBufferU16 : public TDrawBufferBase
  59. {
  60. friend class TView;
  61. public:
  62. TDrawBufferU16() { type=unicode16; }
  63. void moveChar(unsigned indent, unsigned c, unsigned attr, unsigned count);
  64. void moveStr(unsigned indent, const uint16 *str, unsigned attrs, int maxLen=-1);
  65. void moveCStr(unsigned indent, const uint16 *str, uint32 attrs);
  66. void moveBuf(unsigned indent, const void *source,
  67. unsigned attr, unsigned count);
  68. void putAttribute( unsigned indent, unsigned attr );
  69. void putChar( unsigned indent, unsigned c );
  70. virtual void *getBuffer();
  71. protected:
  72. uint16 data[maxViewWidth*2];
  73. };
  74. inline void TDrawBufferU16::putAttribute( unsigned indent, unsigned attr )
  75. {
  76. data[indent*2+1]=(uint16)attr;
  77. }
  78. inline void TDrawBufferU16::putChar( unsigned indent, unsigned c )
  79. {
  80. data[indent*2]=(uint16)c;
  81. }
  82. #endif // Uses_TDrawBuffer