Output text (form different data type sources) on screen in graphic mode (similar to TextStream)
More...
#include <graphicsstream.h>
|
| GraphicsStream (Graphics &graphics, const Point &start, unsigned width, unsigned height, Font *font=nullptr) |
| Constructor.
|
|
void | setPos (int x, int y) |
| Set the cursor position.
|
|
void | getPos (int &x, int &y) const |
| Read the current cursor position.
|
|
void | print (char *str, int length, const Color &color=LIGHT_GREY) |
| Display multiple characters in the window starting at the current cursor position.
|
|
void | reset (char character=' ', const Color &color=LIGHT_GREY) |
| Clear window and reset cursor.
|
|
void | show (int x, int y, char character, const Color &color=LIGHT_GREY) |
| Basic output of a (colored) character at a certain position on the screen.
|
|
void | draw () |
| Draw using the Graphics device.
|
|
| OutputStream () |
| Default constructor. Initial number system is decimal.
|
|
virtual | ~OutputStream () |
| Destructor.
|
|
virtual void | flush ()=0 |
| Clears the buffer.
|
|
OutputStream & | operator<< (char c) |
| Print a single character.
|
|
OutputStream & | operator<< (unsigned char c) |
| Print a single character.
|
|
OutputStream & | operator<< (const char *string) |
| Printing a null-terminated string.
|
|
OutputStream & | operator<< (bool b) |
| Print a boolean value.
|
|
OutputStream & | operator<< (short ival) |
| Print an integral number in radix base.
|
|
OutputStream & | operator<< (unsigned short ival) |
| Print an integral number in radix base.
|
|
OutputStream & | operator<< (int ival) |
| Print an integral number in radix base.
|
|
OutputStream & | operator<< (unsigned int ival) |
| Print an integral number in radix base.
|
|
OutputStream & | operator<< (long ival) |
| Print an integral number in radix base.
|
|
OutputStream & | operator<< (unsigned long ival) |
| Print an integral number in radix base.
|
|
OutputStream & | operator<< (long long ival) |
| Print an integral number in radix base.
|
|
OutputStream & | operator<< (unsigned long long ival) |
| Print an integral number in radix base.
|
|
OutputStream & | operator<< (const void *ptr) |
| Print a pointer as hexadecimal number.
|
|
OutputStream & | operator<< (OutputStream &(*f)(OutputStream &)) |
| Calls one of the manipulator functions.
|
|
virtual | ~Stringbuffer () |
| Destructor (nothing to do here)
|
|
|
Font *const | FONT |
| Default font.
|
|
const Point | START |
| Upper left corner of the window.
|
|
const unsigned | ROWS |
| Number of rows in the window.
|
|
const unsigned | COLUMNS |
| Number of columns in the window.
|
|
int | base |
| Number system used for printing integral numbers (one of 2, 8, 10, or 16)
|
|
|
static const Color | BLACK |
| CGA color palette.
|
|
|
void | flush () |
| Output the buffer contents of the base class Stringbuffer.
|
|
| Stringbuffer () |
| Constructor; Marks the buffer as empty.
|
|
void | put (char c) |
| Inserts a character into the buffer.
|
|
virtual void | flush ()=0 |
| Flush the buffer contents.
|
|
|
char | buffer [80+1] |
|
long unsigned | pos |
| current position in the buffer
|
|
Output text (form different data type sources) on screen in graphic mode (similar to TextStream)
Enables output of different data types using a monospaced font on a predefined area of the screen with activated graphics mode.
◆ GraphicsStream()
GraphicsStream::GraphicsStream |
( |
Graphics & |
graphics, |
|
|
const Point & |
start, |
|
|
unsigned |
width, |
|
|
unsigned |
height, |
|
|
Font * |
font = nullptr |
|
) |
| |
Constructor.
Creates a window (= area on the screen) for text output. Within the window text uses a virtual (invisible) cursor to offer a very similar behavior to TextStream – including automatic scrolling and column/row based positioning.
- Parameters
-
graphics | Graphics device for output |
start | Coordinate of the upper left corner for the output window |
width | Width of the output window |
height | Height of the output window |
font | Font used for output text (or nullptr for default font) |
◆ flush()
void GraphicsStream::flush |
( |
| ) |
|
|
protectedvirtual |
Output the buffer contents of the base class Stringbuffer.
The method is automatically called when the buffer is full, but can also be called explicitly to force output of the current buffer.
Implements OutputStream.
◆ getPos()
void GraphicsStream::getPos |
( |
int & |
x, |
|
|
int & |
y |
|
) |
| const |
Read the current cursor position.
- Parameters
-
x | Column in window |
y | Row in window |
◆ print()
void GraphicsStream::print |
( |
char * |
str, |
|
|
int |
length, |
|
|
const Color & |
color = LIGHT_GREY |
|
) |
| |
Display multiple characters in the window starting at the current cursor position.
This method can be used to output a string, starting at the current cursor position. Since the string does not need to contain a '\0' termination (as it is usually the case in C), the parameter length
is required to specify the number of characters in the string. When the output is complete, the cursor will be positioned after the last character printed. The entire text uniformly has the color color
If there is not enough space left at the end of the line, the output will be continued on the following line. As soon as the last window line is filled, the entire window area will be moved up one line. The first line disappears and the last line is blank, continuing output there.
A line break will also occurs wherever the character \\n
is inserted in the text to be output.
- Parameters
-
str | String to output |
length | length of string |
color | Foreground color of string |
◆ reset()
void GraphicsStream::reset |
( |
char |
character = ' ' , |
|
|
const Color & |
color = LIGHT_GREY |
|
) |
| |
Clear window and reset cursor.
- Parameters
-
character | Filling character |
color | Foreground color |
◆ setPos()
void GraphicsStream::setPos |
( |
int |
x, |
|
|
int |
y |
|
) |
| |
Set the cursor position.
- Parameters
-
x | Column in window |
y | Row in window |
◆ show()
void GraphicsStream::show |
( |
int |
x, |
|
|
int |
y, |
|
|
char |
character, |
|
|
const Color & |
color = LIGHT_GREY |
|
) |
| |
Basic output of a (colored) character at a certain position on the screen.
Outputs character
at the absolute position (x
, y
) with the specified color: x
specifies the column and y
the row of the desired position, with 0 ≤ x < COLUMNS and 0 ≤ y
< ROWS. The position (0,0) indicates the upper left corner of the window (at the coordinates START).
- Parameters
-
x | Column for output of the character |
y | Row for output of the character |
character | Character to be output |
color | Foreground color |
The documentation for this class was generated from the following files: