Aufgabe 7: Anwendung
Output text (form different data type sources) on screen in graphic mode (similar to TextStream) More...
#include <device/graphicsstream.h>
Public Member Functions | |
GraphicsStream (Graphics &graphics, const Point &start, unsigned width, unsigned height, Font *font=nullptr) | |
Constructor. More... | |
void | setPos (int x, int y) |
Set the cursor position. More... | |
void | getPos (int &x, int &y) const |
Read the current cursor position. More... | |
void | print (char *str, int length, const Color &color=LIGHT_GREY) |
Display multiple characters in the window starting at the current cursor position. More... | |
void | reset (char character=' ', const Color &color=LIGHT_GREY) |
Clear window and reset cursor. More... | |
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. More... | |
void | draw () |
Draw using the Graphics device. | |
Public Member Functions inherited from OutputStream | |
OutputStream () | |
Default constructor. Initial number system is decimal. | |
virtual | ~OutputStream () |
Destructor. | |
OutputStream & | operator<< (char c) |
Print a single character. More... | |
OutputStream & | operator<< (unsigned char c) |
Print a single character. More... | |
OutputStream & | operator<< (const char *string) |
Printing a null-terminated string. More... | |
OutputStream & | operator<< (bool b) |
Print a boolean value. More... | |
OutputStream & | operator<< (short ival) |
Print an integral number in radix base More... | |
OutputStream & | operator<< (unsigned short ival) |
Print an integral number in radix base More... | |
OutputStream & | operator<< (int ival) |
Print an integral number in radix base More... | |
OutputStream & | operator<< (unsigned int ival) |
Print an integral number in radix base More... | |
OutputStream & | operator<< (long ival) |
Print an integral number in radix base More... | |
OutputStream & | operator<< (unsigned long ival) |
Print an integral number in radix base More... | |
OutputStream & | operator<< (long long ival) |
Print an integral number in radix base More... | |
OutputStream & | operator<< (unsigned long long ival) |
Print an integral number in radix base More... | |
OutputStream & | operator<< (const void *ptr) |
Print a pointer as hexadecimal number. More... | |
OutputStream & | operator<< (OutputStream &(*f)(OutputStream &)) |
Calls one of the manipulator functions. More... | |
Public Member Functions inherited from Stringbuffer | |
virtual | ~Stringbuffer () |
Destructor (nothing to do here) | |
Public Attributes | |
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. | |
Public Attributes inherited from OutputStream | |
int | base |
Number system used for printing integral numbers (one of 2, 8, 10, or 16) | |
Static Public Attributes | |
static const Color | BLACK |
CGA color palette. | |
static const Color | BLUE |
static const Color | GREEN |
static const Color | CYAN |
static const Color | RED |
static const Color | MAGENTA |
static const Color | BROWN |
static const Color | LIGHT_GREY |
static const Color | DARK_GREY |
static const Color | LIGHT_BLUE |
static const Color | LIGHT_GREEN |
static const Color | LIGHT_CYAN |
static const Color | LIGHT_RED |
static const Color | LIGHT_MAGENTA |
static const Color | YELLOW |
static const Color | WHITE |
Protected Member Functions | |
void | flush () |
Output the buffer contents of the base class Stringbuffer. More... | |
Protected Member Functions inherited from Stringbuffer | |
Stringbuffer () | |
Constructor; Marks the buffer as empty. | |
void | put (char c) |
Inserts a character into the buffer. More... | |
Additional Inherited Members | |
Protected Attributes inherited from Stringbuffer | |
char | buffer [80] |
buffer containing characters that will be printed upon flush() | |
long unsigned | pos |
current position in the buffer | |
Detailed Description
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.
Constructor & Destructor Documentation
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)
Member Function Documentation
|
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.
void GraphicsStream::setPos | ( | int | x, |
int | y | ||
) |
Set the cursor position.
- Parameters
-
x Column in window y Row in window
void GraphicsStream::getPos | ( | int & | x, |
int & | y | ||
) | const |
Read the current cursor position.
- Parameters
-
x Column in window y Row in window
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
void GraphicsStream::reset | ( | char | character = ' ' , |
const Color & | color = LIGHT_GREY |
||
) |
Clear window and reset cursor.
- Parameters
-
character Filling character color Foreground color
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:
- device/graphicsstream.h
- device/graphicsstream.cc