Class CGA_Screen
Placement in the overall structure
- Module
- machine
- Base classes
- None
- Derived classes
- CGA_Stream
- Time of creation
- Task 1
- Files
cgascr.h cgascr.cc
Description
Since a pure text display is sufficient for error messages and simple applications of OOStuBS, all output should be done via the CGA mode of the graphics card.
Public methods
void CGA_Screen::show (int x, int y, char c, unsigned char attrib)
- This method displays the character c at the position (x,y) with the specified color attribute attrib. Here x specifies the column and y the row of the desired position, where: 0<=x<=79 and 0<=y<=24. The position (0,0) designates the upper left corner of the screen. attrib can be used to specify features such as background color, foreground color and blinking.
void CGA_Screen::setpos (int x, int y)
- This method sets the cursor to the specified position.
void CGA_Screen::getpos (int &x, int &y)
- This can be used to get the current position of the cursor from the graphics card. x and y are references and serve as output parameters.
void CGA_Screen::print (char* text, int length, unsigned char attrib)
- This method can be used to output a string text,
starting at the current position of the cursor. Since the string
does not need to contain a zero terminator, as is usually the case
with C, the length parameter is required, which must
specify of how many characters text consists. After the
output is finished, the cursor should be placed behind the last
printed character. The whole text should be displayed
uniformly with the colors chosen by attrib.
If there is not enough space left until the end of the line, the output should be continued on the following line. As soon as the last screen line is filled, the entire screen area should be moved up by one line. This makes the first line disappear. Now, the last line can be deleted and the output can be continued there.
A line break must also be made whenever the character
'\n'
is contained in the text.