/*
* drawbuf.h
*
* Turbo Vision - Version 2.0
*
* Copyright (c) 1994 by Borland International
* All Rights Reserved.
*
* Modified by Sergio Sigala <ssigala@globalnet.it>
*/
#if defined( Uses_TDrawBuffer ) && !defined( __TDrawBuffer )
#define __TDrawBuffer
/**
* This class implements a video buffer.
*
* Every view uses at least one istance of this class in its draw() method.
* The view draws itself using a TDrawBuffer object. Just before returning
* from draw(), a call to one of the writeXXXX methods will write the video
* buffer on the screen. Each member of the buffer is an attribute & character
* pair. The attribute is a byte which stores informations about foreground
* and background colors.
*
* Note: pay attention to the size of the buffer! It usually stores only a
* line of the picture. Its default size is maxViewWidth = 132 pairs.
* @see TView::draw
* @see TView::writeBuf
* @see TView::writeChar
* @see TView::writeLine
* @see TView::writeStr
* @short A video buffer
*/
class TDrawBuffer
{
friend class TFrame;
friend class TView;
public:
/**
* Fills the buffer or part of the buffer with an uniform pattern.
*
* `indent' is the character position within the buffer where the data is
* to go. `c' is the character to be put into the buffer. If `c' is 0 the
* character is not written and the old character is preserved. `attr' is
* the attribute to be put into the buffer. If `attr' is 0 the attribute
* is not written and the old attribute is preserved. `count' is the
* number of character/attribute pairs to put into the buffer.
*/
void moveChar( ushort indent, char c, ushort attr, ushort count );
/**
* Writes a string in the buffer.
*
* `indent' is the character position within the buffer where the data is
* to go. `str' is a pointer to a 0-terminated string of characters to be
* moved into the buffer. `attr' is the text attribute to be put into the
* buffer with each character in the string. If `attr' is 0 the attribute
* is not written and the old attribute is preserved.
*/
void moveStr( ushort indent, const char *str, ushort attrs );
/**
* Writes a string in the buffer.
*
* `indent' is the character position within the buffer where the data is
* to go. `str' is a pointer to a 0-terminated string of characters to be
* moved into the buffer. `attrs' is a pair of text attributes to be put
* into the buffer with each character in the string. Initially the low
* byte is used, and a `~' in the string toggles between the low byte and
* the high byte.
*/
void moveCStr( ushort indent, const char *str, ushort attrs );
/**
* Writes a text buffer in this video buffer.
*
* `indent' is the character position within the buffer where the data is
* to go. `source' is a pointer to an array of characters. `attr' is the
* attribute to be used for all characters (0 to retain the old attribute).
* `count' is the number of characters to move.
*/
void moveBuf( ushort indent, const void *source, ushort attr, ushort count );
/**
* Writes an attribute.
*
* `ident' is the character position within the buffer where the attribute
* is to go. `attr' is the attribute to write.
*/
void putAttribute( ushort indent, ushort attr );
/**
* Writes a character.
*
* `ident' is the character position within the buffer where the character
* is to go. `c' is the character to write.
*/
void putChar( ushort indent, ushort c );
protected:
ushort data[maxViewWidth];
};
#ifdef __FreeBSD__
#include <machine/endian.h>
#else
#include <endian.h>
#endif
#if (BYTE_ORDER == LITTLE_ENDIAN)
#define loByte(w) (((uchar *)&w)[0])
#define hiByte(w) (((uchar *)&w)[1])
#elif (BYTE_ORDER == BIG_ENDIAN)
#define loByte(w) (((uchar *)&w)[1])
#define hiByte(w) (((uchar *)&w)[0])
#else
#error architecture not supported by this library
#endif
inline void TDrawBuffer::putAttribute( ushort indent, ushort attr )
{
hiByte(data[indent]) = uchar(attr);
}
inline void TDrawBuffer::putChar( ushort indent, ushort c )
{
loByte(data[indent]) = uchar(c);
}
#endif // Uses_TDrawBuffer
Documentation generated by sergio@athena.milk.it on Wed Feb 10 22:11:47 CET 1999