![]() |
The ZX Ecosystem v5.1.0;_GUI_v3.1.0
|
This module provides the ZX screen behavior.
NOTE:
-These classes are not thread-safe.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Namespaces | |
namespace | zxeco |
The main namespace of the library, that spans across all the zx modules. | |
Classes | |
class | zxeco::At |
Just a shorter renaming of CharCursor. More... | |
class | zxeco::Screen |
The class that provides the main support for managing the ZX screen. More... | |
struct | zxeco::Screen::InputCallbacks |
Callbacks used in input. More... | |
class | zxeco::Screen::ScaledTextPrinter< SW, SH > |
A class for printing with scaled characters. More... | |
class | zxeco::BASICScreen |
This class decorates Screen to get the original BASIC screen model of the ZX. More... | |
struct | zxeco::BASICScreen::ScrollInfo |
Info produced after a scroll or some movements of the text cursor. More... | |
class zxeco::At |
Just a shorter renaming of CharCursor.
< Notice that at construction, it comes first the x (horizontal) coordinate, then y (vertical).
Definition at line 50 of file ZXScreen.h.
Public Member Functions | |
At (const CharCursor &cc) | |
At (CharCursor &&cc) | |
At & | operator= (const CharCursor &cc) |
At & | operator= (CharCursor &&cc) |
![]() | |
Cursor (typename WidthType::type xc, typename HeightType::type yc) | |
Constructor, from the numerical coord types. More... | |
Cursor (WidthType xc, HeightType yc) | |
Constructor from the trait coord types. More... | |
void | newRow (void) noexcept |
Go down one row resetting x (y <- y + 1 & x <- 0). More... | |
void | newCol (void) noexcept |
Go right one column (x <- x + 1). More... | |
void | incRow (void) noexcept |
Go down one row without resetting x. More... | |
bool | zero (void) const noexcept |
Return TRUE if the cursor is placed at (0,0). */. More... | |
bool | before (const Cursor &oth) const noexcept |
< Return TRUE if THIS is placed before OTH in the plane (linearly). More... | |
bool | rightBelow (const Cursor &oth) const noexcept |
< Return TRUE if THIS is placed to the right and below of OTH. More... | |
IntDist | xDiff (const Cursor &oth) const noexcept |
< Return the signed distance in X from OTH to THIS. More... | |
IntDist | yDiff (const Cursor &oth) const noexcept |
< Return the signed distance in Y from OTH to THIS. More... | |
void | addDiff (IntDist xdiff, IntDist ydiff) noexcept |
< Add the given signed distances to both coordinates. More... | |
bool | operator== (const Cursor &oth) const noexcept |
< Return TRUE if both cursors are placed at the same place. More... | |
bool | operator!= (const Cursor &oth) const noexcept |
< Unequality. More... | |
Cursor | operator+ (const Cursor &oth) const |
< Return the sum of both cursors. More... | |
Cursor & | operator+= (const Cursor &oth) |
Make the sum and return the result. More... | |
Cursor | operator- (const Cursor &oth) const |
< Return the cursor THIS relative to OTH, or throw if result is negative. More... | |
Cursor & | operator-= (const Cursor &oth) |
Make the substraction and return the result. More... | |
std::string | to_string (bool withtype=true) const |
< Return a string with the textual information of the area. More... | |
Additional Inherited Members | |
![]() | |
using | WidthType = CharCoordT |
Type used for the width dimension. More... | |
using | HeightType = CharCoordT |
Type used for the height dimension. More... | |
![]() | |
static const Cursor & | theZero (void) noexcept |
< Return a reference to an inmutable zero cursorof this type. More... | |
static Cursor | max (const Cursor &c0, const Cursor &c1) noexcept |
< Return a copy of the one of C0, C1 that is more to the right and below. More... | |
![]() | |
WidthType::type | x |
Coordinate in width (horizontally). More... | |
HeightType::type | y |
Coordinates in height (vertically). More... | |
|
inline |
Definition at line 56 of file ZXScreen.h.
|
inline |
Definition at line 57 of file ZXScreen.h.
|
inline |
Definition at line 58 of file ZXScreen.h.
|
inline |
Definition at line 59 of file ZXScreen.h.
class zxeco::Screen |
The class that provides the main support for managing the ZX screen.
Notice that an object of this class does not open any window; it just holds all the information in memory, without visualization. For displaying, see the ZXEco class.
This class manages the screen in a flat model, i.e., no bottom/top areas, text and plot coordinates have their (0,0) at the top-left corner, growing downwards and linear layout in the bitmap (not as in the original ZX). If you want the original ZX model, where the (0,0) pixel was at the bottom-left, which did not count the input area (this class does not distinguish an input area), and also worked with a non-linear layout in the bitmap, use the BASICScreen decorator class.
In this class, the text cursor may be placed at any location without causing errors, even outside the visible screen. The next printed character will cause scrolls if the current row is outside the screen and/or begin at the next line if the current column is outside the screen.
This class is not thread-safe.
Definition at line 88 of file ZXScreen.h.
Static Public Member Functions | |
-----------— Static methods -----------— | |
static void | fillInitialFontBitmaps (uint8_t *p) |
Fill from the given address the ZX original 32-127 character bitmaps. | |
static void | fillInitialUDGBitmaps (uint8_t *p) |
Fill from the given address the original ZX UDG bitmaps. | |
static std::pair< CharArea, size_t > | printArea (const CharArea &area, const std::string &txt, const ExpandToken &expandtoken=kNudeExpandToken) |
Return the space occupied by TXT if printed at (0,0) within AREA. More... | |
static CharArea | areaForPrint (const std::string &txt, const ExpandToken &expandtoken=kNudeExpandToken) |
Fill from the given address the ZX original 32-127 character bitmaps. More... | |
Public Member Functions | |
-----------— Constructors -----------— | |
Screen (const CharArea &dimensions={SCREENCOLS, SCREENROWS}, const ExpandToken expandtoken=kInvExpandToken) | |
Default constructor with given dimensions (cannot be empty area). More... | |
Screen (uint8_t *bitmap, uint8_t *attrmap, const CharArea &dimensions={SCREENCOLS, SCREENROWS}, const ExpandToken expandtoken=kInvExpandToken) | |
Constructor that does not create the bitmap/attrmap, but uses external. | |
Screen (Screen &oth, const CharRect ®ion, const ExpandToken expandtoken=kInvExpandToken) | |
Constructor of a subscreen covering a (non-empty area) region of anothr. More... | |
Screen (const Screen &)=delete | |
Default constructor with given dimensions (cannot be empty area). More... | |
Screen & | operator= (const Screen &)=delete |
Default constructor with given dimensions (cannot be empty area). More... | |
Screen (Screen &&)=delete | |
Default constructor with given dimensions (cannot be empty area). More... | |
Screen & | operator= (Screen &&)=delete |
Default constructor with given dimensions (cannot be empty area). More... | |
virtual | ~Screen (void) |
Destroy the Screen. | |
-----------— General methods -----------— | |
const DoubleArea & | info (void) const noexcept |
Return a read-only reference to the info of this Screen. More... | |
const ExpandToken & | expandToken (void) const noexcept |
Return a read-only reference to the expand token routine. More... | |
CharArea | entireCharArea (void) const |
Return a CharArea covering the whole screen. More... | |
CharRect | entireCharRect (void) const |
Return a CharRect covering the whole screen. More... | |
const CharRect & | subRegion (void) const noexcept |
Return the region within a containing Screen, or empty if not contained. More... | |
bool | inside (const CharRect &r) const noexcept |
< Return TRUE if the given rectangle is inside the screen entirely. More... | |
void | cls (void) |
Clear the Screen by putting all bitmap to 0 and attrs as current color. More... | |
void | scrollUp (PixelDist howmany=8, PixelCoord upperrow=0) |
Scroll the bitmap HOWMANY pixels up from UPPERROW, & maybe the attrmap. More... | |
void | scrollUpAttrs (CharDist howmany=1, CharCoord upperrow=0) |
Scroll HOWMANY rows of chars in the attrmap starting at UPPERROW. More... | |
-----------------— Colors methods ----------------— | |
void | setBorder (BasicColor c) noexcept |
Change the border color. More... | |
BasicColor | border (void) const noexcept |
Get the current border color. More... | |
Colors & | colors (void) noexcept |
Get reference to the current colors that can be used to write and read. More... | |
---------— Bitmap & attrmap access methods --------------— | |
Recall that this class is not thread-safe, thus other threads may be accessing the same data concurrently. Also, recall that the bitmap is internally stored linearly (flat model), not following the ZX original bitmap layout. | |
DoubleGraphic & | graphic (void) noexcept |
Return a reference to the bitmap + attrmap of this Screen. More... | |
const DoubleGraphic & | graphic (void) const noexcept |
Return a const reference to the bitmap + attrmap of this Screen. More... | |
--------— Font and UDGs bitmap methods ----------------— | |
const uint8_t * | currentFontBitmap (void) const noexcept |
Return the current font bitmap, or nullptr if it is the ZX original one. More... | |
void | changeFontBitmap (const uint8_t *pfont) noexcept |
Change the bitmap for the font used to print characters 32-127. More... | |
void | copyFontBitmap (uint8_t *dest) const |
Copy all the characters from the current font bitmap into DEST. More... | |
const uint8_t * | currentUDGsBitmap (void) const noexcept |
Return the current UDGs bitmap, or nullptr if it is the ZX original one. More... | |
void | changeUDGsBitmap (const uint8_t *pudgs) noexcept |
Set to PUDGS the memory address where UDGs are defined. More... | |
uint8_t | recognizeCharInFont (const Bitmap &charbitmap, uint8_t howmany=CHRFIRSTGB - CHRSPC, bool evenwithinv=true) const |
Return the ASCII code of a char in the current font that has that bitmp. More... | |
uint8_t | recognizeCharInGrBlocks (const Bitmap &charbitmap) const |
The same as recognizeCharInFont() but for a ZX graphic block. More... | |
-— Text printing methods (using flat model coordinates) -— | |
uint8_t | attrForPrints (const CharCursor &pos, const Colors &desired) const |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
uint8_t | attrForPrints (size_t offset, const Colors &desired) const |
Calculate the attr to put at (offset) for getting DESIRED colors there. More... | |
void | setTextCursor (const CharCursor &pos) |
Set the cursor for printing at the given flat model coordinates. More... | |
const CharCursor & | getTextCursor (void) const noexcept |
Get the current cursor position for printing in flat model coordinates. More... | |
void | put (uint8_t c) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
void | putChar (const uint8_t *d) |
Put the 1-char bitmap D (8 bytes) exactly as in put(). More... | |
size_t | print (const std::string &txt, size_t printmax=0) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
size_t | printSize (const std::string &txt, CharCursor &cur, CharArea &area, size_t &nscrlls) const |
Do a fake printing of TXT at position CUR to calculate printing size. More... | |
Screen & | operator<< (const std::string &txt) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
Screen & | operator<< (uint8_t c) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
Screen & | operator<< (const CharCursor &at) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
Screen & | operator<< (Paper p) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
Screen & | operator<< (Ink i) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
Screen & | operator<< (Bright b) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
Screen & | operator<< (Flash f) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
Screen & | operator<< (Inverse i) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
Screen & | operator<< (Over o) |
Calculate the attr to put at POS for getting DESIRED colors there. More... | |
void | printRectangle (const CharRect &rect, char c, const Colors *cmc=nullptr) |
Fill the given rectangle with the given char with given colors. More... | |
-----------------— Text input ---------------------------— | |
bool | flatInput_printItem (const std::string &item) |
Callback needed for doing input in the flat model version. More... | |
void | input (std::string &res, const InputCallbacks &callbacks, const CharCursor &pos, const Colors &c0, const Keyboard &k0, bool withquotes, CharDist maxscrolls, size_t maxlen=0, const Beep &b=Beep{}) |
Do input like the ZX, storing the resulting string into RES. More... | |
-----------------— Drawing methods -----------------------— | |
bool | validPixel (const PixCursor &pos) const noexcept |
< Return TRUE if the given coordinates are inside the bitmap. More... | |
bool | point (const PixCursor &pos) const |
Return TRUE if the given pixel has ink color; otherwise return FALSE. More... | |
void | plot (const PixCursor &pos, const Colors *cmc=nullptr) |
Equivalent to the original Spectrum BASIC plot command. More... | |
const PixCursor & | lastPlot (void) const noexcept |
Return the coordinates of the last plot. More... | |
void | draw (IntDist incx, IntDist incy, const Colors *cmc=nullptr) |
Draw a straight line. More... | |
void | draw (IntDist incx, IntDist incy, double arc, const Colors *cmc=nullptr) |
Draw an arc with current colors and modes. More... | |
void | circle (const PixCursor ¢er, PixelDist r, const Colors *cmc=nullptr) |
Draw a circle. More... | |
void | rectangle (const PixRect &rect, const Colors *cmc=nullptr) |
Draw a 1-pixel thick rectangular contour. More... | |
using | ExpandToken = std::function< std::string(uint8_t c)> |
User's routine that must expand a given token code into the token text. More... | |
static const ExpandToken | kInvExpandToken |
Expand token routine that always generates CHRINVALID as expansion. More... | |
static const ExpandToken | kNudeExpandToken |
Expand token that return token text without trailing/leading spaces. More... | |
static constexpr size_t | kFontSize |
Size in bytes of all bitmaps of a font. More... | |
using zxeco::Screen::ExpandToken = std::function< std::string(uint8_t c)> |
User's routine that must expand a given token code into the token text.
Definition at line 95 of file ZXScreen.h.
zxeco::Screen::Screen | ( | const CharArea & | dimensions = {SCREENCOLS, SCREENROWS} , |
const ExpandToken | expandtoken = kInvExpandToken |
||
) |
Default constructor with given dimensions (cannot be empty area).
Construct a Screen with the given dimensions and do CLS(). The border is initially WHITE and the content is filled with the color definition given by AttrColors{} dflt constructor. The printing cursor is at (0,0) in flat model coordinates (i.e., top-left & towards bottom and right when increasing), and so the last plot coordinates. EXPANDTOKEN will be called in print and input whenever a token code must be transformed into text.
zxeco::Screen::Screen | ( | Screen & | oth, |
const CharRect & | region, | ||
const ExpandToken | expandtoken = kInvExpandToken |
||
) |
Constructor of a subscreen covering a (non-empty area) region of anothr.
DO NOT DO CLS() or any modification of BITMAP/ATTRMAP in this ctor. In this case, the destructor of Screen will not delete the external bitmap/attrmap. The rest of parameters are like in the default constructor. BITMAP and ATTRMAP must have enough room for the bitmap/attrmap; this constructor and the rest of the class does not check that. Also, both memory areas can be modified when the Screen is. DO NOT DO CLS() or any modification of OTH bitmap/attrmap in this ctor. A subscreen refers to a region of another screen (OTH, that must outlive this one) and redirects all its operation to that region. If the region is empty, a region covering the entire OTH is used. If the region does not lies within OTH, throws.
|
delete |
Default constructor with given dimensions (cannot be empty area).
Construct a Screen with the given dimensions and do CLS(). The border is initially WHITE and the content is filled with the color definition given by AttrColors{} dflt constructor. The printing cursor is at (0,0) in flat model coordinates (i.e., top-left & towards bottom and right when increasing), and so the last plot coordinates. EXPANDTOKEN will be called in print and input whenever a token code must be transformed into text.
|
delete |
Default constructor with given dimensions (cannot be empty area).
Construct a Screen with the given dimensions and do CLS(). The border is initially WHITE and the content is filled with the color definition given by AttrColors{} dflt constructor. The printing cursor is at (0,0) in flat model coordinates (i.e., top-left & towards bottom and right when increasing), and so the last plot coordinates. EXPANDTOKEN will be called in print and input whenever a token code must be transformed into text.
|
static |
Return the space occupied by TXT if printed at (0,0) within AREA.
Create a dummy Screen of the same size as AREA and do the printing (the dummy screen does not occupy room in memory). Return an empty area in the first element if TXT is empty, or an area that covers in height the entire used height of the printing and in width the width of AREA. The second element in the pair is the length in printed chars of TXT. TXT may contain any control chars.
|
inlinestatic |
Fill from the given address the ZX original 32-127 character bitmaps.
expandtoken | Calculate the bounding area needed to print TXT. It does a dummy print on a screen of maximum size (considering the types of the char coordinates), through printArea(), which does not consume any memory for that screen. |
Definition at line 259 of file ZXScreen.h.
Default constructor with given dimensions (cannot be empty area).
Construct a Screen with the given dimensions and do CLS(). The border is initially WHITE and the content is filled with the color definition given by AttrColors{} dflt constructor. The printing cursor is at (0,0) in flat model coordinates (i.e., top-left & towards bottom and right when increasing), and so the last plot coordinates. EXPANDTOKEN will be called in print and input whenever a token code must be transformed into text.
Default constructor with given dimensions (cannot be empty area).
Construct a Screen with the given dimensions and do CLS(). The border is initially WHITE and the content is filled with the color definition given by AttrColors{} dflt constructor. The printing cursor is at (0,0) in flat model coordinates (i.e., top-left & towards bottom and right when increasing), and so the last plot coordinates. EXPANDTOKEN will be called in print and input whenever a token code must be transformed into text.
|
inlinenoexcept |
Return a read-only reference to the info of this Screen.
Definition at line 322 of file ZXScreen.h.
|
inlinenoexcept |
Return a read-only reference to the expand token routine.
Definition at line 325 of file ZXScreen.h.
|
inline |
Return a CharArea covering the whole screen.
Definition at line 328 of file ZXScreen.h.
|
inline |
Return a CharRect covering the whole screen.
You can get a PixRect or a CharPixRect from the CharRect using the getPixRect() or getCharPixRect() functions, respectively.
Definition at line 331 of file ZXScreen.h.
|
inlinenoexcept |
Return the region within a containing Screen, or empty if not contained.
Definition at line 336 of file ZXScreen.h.
|
inlinenoexcept |
< Return TRUE if the given rectangle is inside the screen entirely.
Definition at line 339 of file ZXScreen.h.
void zxeco::Screen::cls | ( | void | ) |
Clear the Screen by putting all bitmap to 0 and attrs as current color.
Use current colors and modes, and set the printing cursor to 0,0 and the last plot to 0,0, both in flat model coordinates.
void zxeco::Screen::scrollUp | ( | PixelDist | howmany = 8 , |
PixelCoord | upperrow = 0 |
||
) |
Scroll the bitmap HOWMANY pixels up from UPPERROW, & maybe the attrmap.
If HOWMANY is 0 or >= the height of the bitmap, do nothing. UPPERROW indicates the highest row (i.e., the one with smallest y-coord) that is scrolled up; rows higher than that will not be scrolled, but can be overwritten by lower rows that are scrolled (depending on HOWMANY). If UPPERROW >= the height of the bitmap, no scroll is done.
The new pixel rows appearing below the scroll are filled with 0.
If HOWMANY and UPPERROW are multiple of 8, also scroll up the attrmap accordingly, by calling scrollUpAttrmap() at the end; otherwise, no effect occurs on the attrmap.
No effect will be produced on the current text printing cursor.
Scroll HOWMANY rows of chars in the attrmap starting at UPPERROW.
If HOWMANY is 0 or >= the height of the attrmap, do nothing. UPPERROW indicates the highest row (i.e., the one with smallest y-coord) that is scrolled up; rows higher than that will not be scrolled, but can be overwritten by lower rows that are scrolled (depending on HOWMANY). If UPPERROW >= height of the attrmap, no scroll is done.
The attributes for the cleared rows in the bottom are taken from the current colors and modes applied on the first column of the last row of the screen, i.e., if those colors and modes have no contrast or transparent, they are used directly, but if they have contrast or transparent, the contrast or transparent is turned into a basic color by using it at the last row.
There will be no effect in the bitmap.
|
inlinenoexcept |
Change the border color.
Definition at line 399 of file ZXScreen.h.
|
inlinenoexcept |
Get the current border color.
Definition at line 402 of file ZXScreen.h.
|
inlinenoexcept |
Get reference to the current colors that can be used to write and read.
Definition at line 405 of file ZXScreen.h.
|
inlinenoexcept |
Return a reference to the bitmap + attrmap of this Screen.
Definition at line 421 of file ZXScreen.h.
|
inlinenoexcept |
Return a const reference to the bitmap + attrmap of this Screen.
Definition at line 424 of file ZXScreen.h.
|
inlinenoexcept |
Return the current font bitmap, or nullptr if it is the ZX original one.
Definition at line 433 of file ZXScreen.h.
|
inlinenoexcept |
Change the bitmap for the font used to print characters 32-127.
No copy of the content of PFONT is done inside the screen. PFONT will be used as the bitmap for characters (see the Bitmap constructor). Unlike the CHARS sysvar in ZX BASIC, the PFONT address is not substracted 256; it must point to the bitmap of the space character. If PFONT is nullptr, a default font is used. Otherwise, *PFONT must outlive this object, since no copy of the font is done.
Definition at line 436 of file ZXScreen.h.
void zxeco::Screen::copyFontBitmap | ( | uint8_t * | dest | ) | const |
Copy all the characters from the current font bitmap into DEST.
If the current font is nullptr, the original ZX charset is copied. DEST must have space for kFontSize bytes.
|
inlinenoexcept |
Return the current UDGs bitmap, or nullptr if it is the ZX original one.
Definition at line 454 of file ZXScreen.h.
|
inlinenoexcept |
Set to PUDGS the memory address where UDGs are defined.
A nullptr will produce default UDGs when printing. *PUDGS must outlive this object otherwise, since no copy of the UDGs is done. Notice that this class does not deal with 64KB wrapping in the set of UDG bitmaps.
Definition at line 457 of file ZXScreen.h.
uint8_t zxeco::Screen::recognizeCharInFont | ( | const Bitmap & | charbitmap, |
uint8_t | howmany = CHRFIRSTGB - CHRSPC , |
||
bool | evenwithinv = true |
||
) | const |
Return the ASCII code of a char in the current font that has that bitmp.
Return the ASCII code in the font (from 32 for space to 127 to copyright) of the character with coinciding bitmap, or return 0 value if none is recognized. If EVENWITHINV and the recognized char is in inverse form, set the most significant bit of the result to 1.
charbitmap | must be a 1x8 graphic with the bitmap of the char. |
howmany | indicates how many chars to consider in the font. It must be <= CHRFIRSTGB - CHRSPC (96). |
evenwithinv | recognizes the given char in its inverse form if it is true; otherwise it does only recognizes it in its normal form. |
uint8_t zxeco::Screen::recognizeCharInGrBlocks | ( | const Bitmap & | charbitmap | ) | const |
The same as recognizeCharInFont() but for a ZX graphic block.
Graphic blocks are the ones in the numbered keys of the ZX keyboard. This method returns the ASCII code of the graphic block recognized, or 0 if not recognized.
uint8_t zxeco::Screen::attrForPrints | ( | const CharCursor & | pos, |
const Colors & | desired | ||
) | const |
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
uint8_t zxeco::Screen::attrForPrints | ( | size_t | offset, |
const Colors & | desired | ||
) | const |
Calculate the attr to put at (offset) for getting DESIRED colors there.
The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
|
inline |
Set the cursor for printing at the given flat model coordinates.
Do not raise an exception if outside the screen; if the y coordinate is outside the screen, the next print will produce as many scrolls as needed to disclose the affected area, and if the x coordinate is outside the screen the next printed char will be at the next line to the left.
Definition at line 507 of file ZXScreen.h.
|
inlinenoexcept |
Get the current cursor position for printing in flat model coordinates.
Definition at line 516 of file ZXScreen.h.
|
inline |
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
c | Put C at current position with current attrs without updating cursor. The current cursor MUST be within screen; otherwise, an exception is raised. Characters before space or tokens are printed as '?'. The rest are correctly printed. |
Definition at line 519 of file ZXScreen.h.
|
inline |
Put the 1-char bitmap D (8 bytes) exactly as in put().
Definition at line 528 of file ZXScreen.h.
|
inline |
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
printmax | Print TXT using the flat model coordinates, doing scrolls if needed. Print the given text in the current cursor position with the current colors, and move the cursor appropriately. Do scroll if necessary. TXT can contain control ascii codes (see zxString() function). Return the number of one-row scrolls done during printing. If PRINTMAX > 0, only print up to PRINTMAX characters (not counting any control code, but counting all characters or tokens when deployed). |
Definition at line 531 of file ZXScreen.h.
size_t zxeco::Screen::printSize | ( | const std::string & | txt, |
CharCursor & | cur, | ||
CharArea & | area, | ||
size_t & | nscrlls | ||
) | const |
Do a fake printing of TXT at position CUR to calculate printing size.
CUR will be modified as in an actual printing, ending with its position after printing TXT. The number of scrolls (not actually done) will be in NSCRLLS. AREA will be filled with the bounding box of the printing, after doing the scrolls (not counted in the area or in the cursor) and the linear length in chars of the printing will be returned (not counting scrolls).
|
inline |
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 572 of file ZXScreen.h.
|
inline |
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 574 of file ZXScreen.h.
|
inline |
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 576 of file ZXScreen.h.
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 578 of file ZXScreen.h.
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 580 of file ZXScreen.h.
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 582 of file ZXScreen.h.
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 584 of file ZXScreen.h.
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 586 of file ZXScreen.h.
Calculate the attr to put at POS for getting DESIRED colors there.
Return the attr that must be put at the character corresponding to the cell POS if the desired colors and modes are DESIRED, i.e., taking into account transparencies and contrasts. POS must be within screen; otherwise, an exception is raised. Use the flat model coordinates. The procedure to calculate the attribute is explained in the adjustByExisting() method of the AttrColors class.
Definition at line 588 of file ZXScreen.h.
Fill the given rectangle with the given char with given colors.
If CMC == nullptr, uses current colors. If the rectangle goes out of the screen, prints what it can. The current text cursor is not modified.
bool zxeco::Screen::flatInput_printItem | ( | const std::string & | item | ) |
Callback needed for doing input in the flat model version.
For using it in the input() method, wrap it with your Screen obj:
void zxeco::Screen::input | ( | std::string & | res, |
const InputCallbacks & | callbacks, | ||
const CharCursor & | pos, | ||
const Colors & | c0, | ||
const Keyboard & | k0, | ||
bool | withquotes, | ||
CharDist | maxscrolls, | ||
size_t | maxlen = 0 , |
||
const Beep & | b = Beep{} |
||
) |
Do input like the ZX, storing the resulting string into RES.
This method performs the main loop for doing an input, but it needs a number of helper routines to manage sound, keyboard, etc. See ZXEco::flatInputCallbacks() method to an example of how to define those callbacks.
res | will be filled with the input string. |
callbacks | must contain all the callback routines needed for the input. |
pos | is the initial cursor position for the input. |
c0 | are the initial colors to use for the input. |
k0 | is the initial state of the keyboard. |
withquotes | makes the input to be surrounded by quotes or not. |
maxscrolls | is the maximum number of scrolls to do during input. |
maxlen | sets a maximum length for the input, or none if it is 0. |
b | is the sound to do after each key pressing. |
|
inlinenoexcept |
< Return TRUE if the given coordinates are inside the bitmap.
Definition at line 643 of file ZXScreen.h.
bool zxeco::Screen::point | ( | const PixCursor & | pos | ) | const |
Return TRUE if the given pixel has ink color; otherwise return FALSE.
Raise an exception if POS is outside the screen.
Equivalent to the original Spectrum BASIC plot command.
Plot a single point at POS coordinates according to the CMC colors and modes (inverse, over), that are not set as the current colors and modes (i.e., they are temporary). These colors will affect the entire character cell. All of them will be used (paper, ink, etc.) for the plot. If CMC == nullptr, uses the ink, inverse and over from the current colors, and paper, bright and flash from the plotted cell. Also set the last plotted point to the POS coordinates. Raise an exception if POS are outside the screen.
1) If the command contains embedded color commands, it will use them in all their components (like this method). 2) If it does not, only uses the ink from the global current colors, like the next method (bright, flash and paper will be kept as in the existing attr).
In both cases, inverse and over are taken correctly into accout, either from globals or embedded. The behavior of over and inverse is exactly as in the original ZX:
no over & no inverse -> set the pixel to ink (1) no over & inverse -> set the pixel to paper (0) over & no inverse -> complement the pixel over & inverse -> do not modify the pixel (but colors will have an effect)
|
inlinenoexcept |
Return the coordinates of the last plot.
Definition at line 686 of file ZXScreen.h.
Draw a straight line.
Draw a straight line from the last plot coordinates (not included) up to INCX and INCY increments in pixels (inclusive). Ignore any pixel that goes out of screen, instead of producing an error like the original ZX did. Do clipping like the ZX did. The last pixel drawn becomes the last pìxel coordinates for further draws. The management of colors and modes is like in plot().
Draw an arc with current colors and modes.
As in the ZX, draws an arc for INCX, INCY units, in particular the one corresponding to the circle sector that sustains ARC radians and whose circumference passes through both ending points. ARC can be any number.
Draw a circle.
Draw a circle with the given data, using the colors like in plot().
Draw a 1-pixel thick rectangular contour.
If part of the rectangle falls outside the screen, stops at that point. The plotting cursor is changed while drawing, ending at RECT.CORNER if everything is right.
|
static |
Expand token routine that always generates CHRINVALID as expansion.
Definition at line 98 of file ZXScreen.h.
|
static |
Expand token that return token text without trailing/leading spaces.
Definition at line 101 of file ZXScreen.h.
|
staticconstexpr |
struct zxeco::Screen::InputCallbacks |
Public Types | |
using | PrintItem = std::function< bool(const std::string &) > |
using | GetNewKeyboard = std::function< void(const Keyboard &, Keyboard &, Membrane &, std::string &) > |
using | Play = std::function< void(const Beep &) > |
using | CheckInput = std::function< bool(const std::string &) > |
Public Attributes | |
PrintItem | printItem |
Callback to print items in the screen. More... | |
GetNewKeyboard | getNewKeyboard |
Callback to get changes in keyboard. More... | |
Play | play |
Callback to play keyboard clics. More... | |
CheckInput | checkInput |
Callback to check input validity. More... | |
using zxeco::Screen::InputCallbacks::PrintItem = std::function< bool(const std::string &) > |
Must print an element of the input string at the current cursor. The element will be either an ascii character or a control command, never a token code. Must return TRUE if there is one scroll done.
Definition at line 112 of file ZXScreen.h.
using zxeco::Screen::InputCallbacks::GetNewKeyboard = std::function< void(const Keyboard &, Keyboard &, Membrane &, std::string &) > |
Must wait for a key change in the Keyboard, and then return the new keyboard, the last membrane, and the pressed keys as a string.
Definition at line 118 of file ZXScreen.h.
using zxeco::Screen::InputCallbacks::Play = std::function< void(const Beep &) > |
using zxeco::Screen::InputCallbacks::CheckInput = std::function< bool(const std::string &) > |
Must return TRUE if the given string is a valid input.
Definition at line 131 of file ZXScreen.h.
PrintItem zxeco::Screen::InputCallbacks::printItem |
Callback to print items in the screen.
Definition at line 135 of file ZXScreen.h.
GetNewKeyboard zxeco::Screen::InputCallbacks::getNewKeyboard |
Callback to get changes in keyboard.
Definition at line 136 of file ZXScreen.h.
Play zxeco::Screen::InputCallbacks::play |
Callback to play keyboard clics.
Definition at line 137 of file ZXScreen.h.
CheckInput zxeco::Screen::InputCallbacks::checkInput |
Callback to check input validity.
Definition at line 138 of file ZXScreen.h.
class zxeco::Screen::ScaledTextPrinter |
A class for printing with scaled characters.
This prints bitmap chars of an underlying Screen with scaled width and/or height. Attributes and other features of the underlying Screen -including its current text cursor- are unaffected. The printing done by this class is slower and functionally limited w.r.t. the normal print of Screen.
SW | is the scale in width, measured in normal ZX chars width. If it is 0, indicates to scale down to half-width (4 pixels width), and in that case SH must be 1. |
SH | is the scale in height, measured in normal ZX chars height, i.e., 1 means normal height chars, 2 means twice the height, and so on. It must be > 0. |
Definition at line 157 of file ZXScreen.h.
Public Member Functions | |
ScaledTextPrinter (Screen &scr, bool perfectchars=true) | |
Create a scaled text printer for the given screen; cursor at 0,0. More... | |
ScaledTextPrinter (const ScaledTextPrinter &)=delete | |
ScaledTextPrinter (ScaledTextPrinter &&)=delete | |
ScaledTextPrinter & | operator= (const ScaledTextPrinter &)=delete |
ScaledTextPrinter & | operator= (ScaledTextPrinter &&)=delete |
Return a reference to the underlying Screen. | |
Screen & | underlyingScreen (void) noexcept |
const CharArea & | scaledDimensions (void) const noexcept |
< Return the scaled dimensions of the screen with this printer. More... | |
Colors & | colors (void) noexcept |
Return a reference to the current colors to read and write them. More... | |
void | setCursor (const CharCursor &stc) |
Put the current scaled cursor at STC or throw if out of screen. More... | |
const CharCursor & | getCursor (void) const noexcept |
Return the current scaled cursor. More... | |
PixRect | getCursorRect (void) const noexcept |
Return the pixel rectangle of the cursor. More... | |
void | print (const std::string &txt) |
Print the given text at the current scaled position. More... | |
void | print (const uint8_t *bitmap) |
Print a scaled char with the given bitmap. More... | |
zxeco::Screen::ScaledTextPrinter< SCW, SCH >::ScaledTextPrinter | ( | Screen & | scr, |
bool | perfectchars = true |
||
) |
Create a scaled text printer for the given screen; cursor at 0,0.
SCR must outlive this object. PERFECTCHARS indicate whether to use pre-defined scaled chars that look better than the default automatic scaling in the case of scaling down characters to 4-pixel width. Initially, the colours of this printer are taken from the screen, but they can be modified -only for this printer- aftwerwards. The font for characters is taken from the current one in the screen when each character is about to be printed.
Definition at line 1413 of file ZXScreen.h.
|
inlinenoexcept |
Definition at line 179 of file ZXScreen.h.
|
inlinenoexcept |
< Return the scaled dimensions of the screen with this printer.
Definition at line 181 of file ZXScreen.h.
|
inlinenoexcept |
Return a reference to the current colors to read and write them.
Definition at line 185 of file ZXScreen.h.
void zxeco::Screen::ScaledTextPrinter< SCW, SCH >::setCursor | ( | const CharCursor & | stc | ) |
Put the current scaled cursor at STC or throw if out of screen.
Definition at line 1434 of file ZXScreen.h.
|
inlinenoexcept |
Return the current scaled cursor.
Definition at line 191 of file ZXScreen.h.
|
noexcept |
Return the pixel rectangle of the cursor.
Definition at line 1442 of file ZXScreen.h.
void zxeco::Screen::ScaledTextPrinter< SCW, SCH >::print | ( | const std::string & | txt | ) |
Print the given text at the current scaled position.
Current colours of this printer object are used for the printing without changing the ones in the Screen (the Screen cursor is not changed either). Control chars, tokens, and UDGs are printed as CHRINVALID. Graphic blocks are allowed. Scrolls are not performed (when the end of the screen is reached, the rest of the text is ignored). The scaled cursor is updated after printing.
Definition at line 1462 of file ZXScreen.h.
void zxeco::Screen::ScaledTextPrinter< SCW, SCH >::print | ( | const uint8_t * | bitmap | ) |
Print a scaled char with the given bitmap.
Definition at line 1553 of file ZXScreen.h.
class zxeco::BASICScreen |
This class decorates Screen to get the original BASIC screen model of the ZX.
Internally, the screen data is stored as in the Screen class, i.e., in a flat, linear layout in memory, though the data can be transferred to/from other non-flat layouts using the flat*() and nonFlat*() methods. Those methods, however, will consider a flat layout in both sides -not doing any transformation- if the BASICScreen display has dimensions different from the ones in the original ZX.
On a higher abstraction level, instead of the flat coordinate model, this class provides channels 'K' and 'S', specialized inputs in 'K', and the same coordinate axes as in the original ZX.
The text cursor coordinates can be outside the corresponding channel area. Only when an attempt of printing a char at those places occurs is when this class adjusts the cursor by moving to the next line and/or doing necessary scrolls.
The underlying Screen can be manipulated outside this class, but the flat state in that Screen is not guaranteed to be synchronized with the state here at any moment (i.e., cursor positions, current colors, etc.)
Behaviour of channels S and K in the original ZX:
(https://faqwiki.zxnet.co.uk/wiki/Channels_and_streams)
Valid streams are from 0 to 15.
#0 is the input/output stream, associated to channel "K", in the lower screen, rows 22-23 inclusive at the start. #1 is also associated to "K". #2 is output-only stream, associated to channel "S", in the upper screen, rows 0-21 inclusive at the start. #3 is output-only printing stream, associated to channel "P", i.e., it is the one used implicitly by LPRINT, etc.
CLS is the command that clears "K" and "S", filling the former with the border color as paper and contrast color as ink and the latter as the user has established in the global colors.
System messages are always printed at the bottom line of the screen, within the "K" channel, at column 0.
Printing/inputting at channel "K" starts at line 23 (not 22) and may scroll upwards consuming space from channel "S" (scrolling up the content of channel "S" ONLY IF THE GROWING OF "K" reaches the current row to print in "S"; otherwise "K" overwrites the bottom part of "S" without scrolling it). Scroll of the "K" channel cannot go beyond the size of the screen (it produces out of screen error).
The original 2-rows size of "K" is restored by CLS, by starting the execution of INPUT and also by the system printing any message.
Printing at channel "S" at a row that is currently occupied by channel "K", with AT, produces an out of screen error. If the printing is not explicit, but reaches that limit by accumulating other printings, a scroll message is shown (as always, in line 23, where all messages are shown) and, when the user press to scroll (any key but space), the clearing of the message produces a reset of the "K" space to its original 2-rows size before doing the scroll, and then, the pending printing at "S" is done at line 21, the last one of the restored "S" space (having cleared a number of lines in "S" previously occupied by "K").
Definition at line 911 of file ZXScreen.h.
Static Public Member Functions | |
static void | checkChannel (char c, const std::string &place="") |
Public Member Functions | |
BASICScreen (Screen &scr, const KeyWait &keywait=[](void) -> Keyboard { return(Keyboard{});}) | |
Constructor: decorates an existing Screen object. More... | |
BASICScreen (const BASICScreen &)=delete | |
Constructor: decorates an existing Screen object. More... | |
BASICScreen (BASICScreen &&)=delete | |
Constructor: decorates an existing Screen object. More... | |
BASICScreen & | operator= (const BASICScreen &)=delete |
Constructor: decorates an existing Screen object. More... | |
BASICScreen & | operator= (BASICScreen &&)=delete |
Constructor: decorates an existing Screen object. More... | |
virtual | ~BASICScreen (void)=default |
Constructor: decorates an existing Screen object. More... | |
size_t | flatBitmap (size_t offset) const |
Return a bitmap offset in the flat model given the non-flat one. More... | |
size_t | flatAttrmap (size_t offset) const |
Return an attrmap offset in the flat model given the non-flat one. More... | |
CharCursor | flatTextCoords (char channel, const CharCursor &pos) const |
Return a version of POS (that corresponds to CHANNEL) in the flat model. More... | |
PixCursor | flatPixelCoords (const PixCursor &pos) const |
Return a version of POS in the flat model. More... | |
size_t | nonflatBitmap (size_t offset) const |
Return a bitmap offset in the non-flat model given the flat one. More... | |
size_t | nonflatAttrmap (size_t offset) const |
Return an attrmap offset in the non-flat model given the flat one. More... | |
CharCursor | nonflatTextCoords (char channel, const CharCursor &pos) const |
Return POS transformed from flat model to the given channel. More... | |
PixCursor | nonflatPixelCoords (const PixCursor &pos) const |
Return POS transformed from flat into non-flat coords. More... | |
Screen & | flat (void) const |
Return a reference to the underlying flat screen. */. More... | |
void | reset (void) |
Set the K and S channels to their initial cursors and sizes, as in CLS. More... | |
void | resetChannelK (void) |
Reset cursors, size and contents of channel K to its initial values. More... | |
CharDist | scrollCnt (void) const noexcept |
Return how many scrolls will be done (+1) before asking. More... | |
void | setScrollCnt (CharDist newcnt) |
Change to NEWCNT the current count of scrolls to do wihout asking. More... | |
void | fillKColors (BasicColor b, Colors &colors) const |
Fill COLORS with colors for K channel calculated from border color B. More... | |
void | changeGlobalColors (char channel, const Colors &newcols) |
Change the global colors in the given channel to NEWCOLS. | |
void | getGlobalColors (char channel, Colors &colors) const |
Fill COLS with a copy of the global colors in the given channel. More... | |
void | restoreGlobalColors (char channel) |
Set the current, local colors in the channel to the global ones. | |
void | changeChannel (char c) |
Set current channel to C (either 'K' or 'S') without changing cursor. More... | |
char | getChannel (void) const |
Return the current channel. More... | |
void | setTextCursor (char channel, const CharCursor &pos) |
Set the channel to CHANNEL and put the cursor where requested. More... | |
CharCursor | getTextCursor (char ch=0x00) const |
Return the non-flat text cursor of the given channel ('S' or 'K'). More... | |
bool | columnAtLeft (void) const |
TRUE if the current non-flat column at the current channel is at left. More... | |
ScrollInfo | print (const std::string &txt) |
Print a string, possibly containing ctrl chars, in the current channel. More... | |
void | moveNewLine (void) |
Move text cursor to a new line without printing CHRENTER. More... | |
void | plot (const PixCursor &pos, const Colors *cmc=nullptr) |
Plot the given point using original, non-flat ZX plot coordinates. More... | |
void | draw (IntDist incx, IntDist incy, const Colors *cmc=nullptr) |
Draw the given line using original, non-flat ZX plot increments. More... | |
void | draw (IntDist incx, IntDist incy, double arc, const Colors *cmc=nullptr) |
Draw the given arc using original, non-flat ZX plot increments. More... | |
void | circle (const PixCursor ¢er, PixelDist r, const Colors *cmc=nullptr) |
Draw the given circle using original, non-flat ZX plot coordinates. More... | |
bool | point (const PixCursor &pos) const |
< Return TRUE if the given point is on or FALSE if it is off. More... | |
bool | originalInput_printItem (const std::string &txt) |
Callback routine for using in Screen::input() that respects this model. More... | |
std::string | input (bool withquotes, const Keyboard &k0, const Screen::InputCallbacks::GetNewKeyboard &cbk, const Screen::InputCallbacks::Play &cbp, const Screen::InputCallbacks::CheckInput &cnci) |
Do input in the original mode. More... | |
std::string | to_string (void) const |
Return a text with info about the current state of the decorator. More... | |
using | KeyWait = std::function< Keyboard(void) > |
Routine that waits for a key press and return the resulting keyboard. More... | |
static const CharDist | kInitialRowsK = 2 |
Number of character rows initially in the K channel. More... | |
static const PixelDist | kInitialHeightK = charDistToPixelDist(kInitialRowsK) |
Number of pixel rows initially in the K channel. More... | |
using zxeco::BASICScreen::KeyWait = std::function < Keyboard (void) > |
Routine that waits for a key press and return the resulting keyboard.
Definition at line 918 of file ZXScreen.h.
zxeco::BASICScreen::BASICScreen | ( | Screen & | scr, |
const KeyWait & | keywait = [](void) -> Keyboard { return(Keyboard{});} |
||
) |
Constructor: decorates an existing Screen object.
This method also initiates the channels.
scr | is the underlying Screen that is decorated. It must outlive this object. |
keywait | is a routine that must wait for no-key, then must wait for key, then must wait for no-key, and finally return the last keyboard state in order to read the last key pressed. See for instance the method ZXEco::waitOneKey(). The default one does no waitings; just returns a new keyboard. This routine is used for waiting for a key when a scroll message is printed; if the routine return no-pressing, as in the default one, there will be an exception at calling it. |
|
delete |
Constructor: decorates an existing Screen object.
This method also initiates the channels.
scr | is the underlying Screen that is decorated. It must outlive this object. |
keywait | is a routine that must wait for no-key, then must wait for key, then must wait for no-key, and finally return the last keyboard state in order to read the last key pressed. See for instance the method ZXEco::waitOneKey(). The default one does no waitings; just returns a new keyboard. This routine is used for waiting for a key when a scroll message is printed; if the routine return no-pressing, as in the default one, there will be an exception at calling it. |
|
delete |
Constructor: decorates an existing Screen object.
This method also initiates the channels.
scr | is the underlying Screen that is decorated. It must outlive this object. |
keywait | is a routine that must wait for no-key, then must wait for key, then must wait for no-key, and finally return the last keyboard state in order to read the last key pressed. See for instance the method ZXEco::waitOneKey(). The default one does no waitings; just returns a new keyboard. This routine is used for waiting for a key when a scroll message is printed; if the routine return no-pressing, as in the default one, there will be an exception at calling it. |
|
virtualdefault |
Constructor: decorates an existing Screen object.
This method also initiates the channels.
scr | is the underlying Screen that is decorated. It must outlive this object. |
keywait | is a routine that must wait for no-key, then must wait for key, then must wait for no-key, and finally return the last keyboard state in order to read the last key pressed. See for instance the method ZXEco::waitOneKey(). The default one does no waitings; just returns a new keyboard. This routine is used for waiting for a key when a scroll message is printed; if the routine return no-pressing, as in the default one, there will be an exception at calling it. |
|
inlinestatic |
place | Check validity of the channel and throws if invalid. Include PLACE as a text in the error. |
Definition at line 960 of file ZXScreen.h.
|
delete |
Constructor: decorates an existing Screen object.
This method also initiates the channels.
scr | is the underlying Screen that is decorated. It must outlive this object. |
keywait | is a routine that must wait for no-key, then must wait for key, then must wait for no-key, and finally return the last keyboard state in order to read the last key pressed. See for instance the method ZXEco::waitOneKey(). The default one does no waitings; just returns a new keyboard. This routine is used for waiting for a key when a scroll message is printed; if the routine return no-pressing, as in the default one, there will be an exception at calling it. |
|
delete |
Constructor: decorates an existing Screen object.
This method also initiates the channels.
scr | is the underlying Screen that is decorated. It must outlive this object. |
keywait | is a routine that must wait for no-key, then must wait for key, then must wait for no-key, and finally return the last keyboard state in order to read the last key pressed. See for instance the method ZXEco::waitOneKey(). The default one does no waitings; just returns a new keyboard. This routine is used for waiting for a key when a scroll message is printed; if the routine return no-pressing, as in the default one, there will be an exception at calling it. |
size_t zxeco::BASICScreen::flatBitmap | ( | size_t | offset | ) | const |
Return a bitmap offset in the flat model given the non-flat one.
The returned offset is in [0,bitmap.size-1]. This method does not affect the content of the screen in any way; it only reads its dimensions. Throw if the offset is out of range.
offset | must be in [0,bitmap.size-1]. |
|
inline |
Return an attrmap offset in the flat model given the non-flat one.
The returned offset is in [0,attrmap.size-1]. This method does not affect the content of the screen in any way; it only reads its dimensions. Throw if the offset is out of range.
offset | must be in [0,attrmap.size-1]. |
Definition at line 1010 of file ZXScreen.h.
CharCursor zxeco::BASICScreen::flatTextCoords | ( | char | channel, |
const CharCursor & | pos | ||
) | const |
Return a version of POS (that corresponds to CHANNEL) in the flat model.
In the 'K' channel, Y == 0 indicates the current top line of that bottom area. Throw if the channel is invalid. This method does not throws any error if coords are out of the channel area.
Return a version of POS in the flat model.
Throw if the coords are out of the screen.
size_t zxeco::BASICScreen::nonflatBitmap | ( | size_t | offset | ) | const |
Return a bitmap offset in the non-flat model given the flat one.
The returned offset is in [0,bitmap.size-1]. This method does not affect the content of the screen in any way; it only reads its dimensions. Throw if the offset is out of range.
offset | must be in [0,bitmap.size-1]. |
|
inline |
Return an attrmap offset in the non-flat model given the flat one.
The returned offset is in [0,attrmap.size-1]. This method does not affect the content of the screen in any way; it only reads its dimensions. Throw if the offset is out of range.
offset | must be in [0,attrmap.size-1]. |
Definition at line 1039 of file ZXScreen.h.
CharCursor zxeco::BASICScreen::nonflatTextCoords | ( | char | channel, |
const CharCursor & | pos | ||
) | const |
Return POS transformed from flat model to the given channel.
In the 'K' channel, Y == 0 indicates the current top line of that bottom area. Throw if the channel is invalid.
Return POS transformed from flat into non-flat coords.
Throw if the coords are out of screen.
|
inline |
Return a reference to the underlying flat screen. */.
Definition at line 1060 of file ZXScreen.h.
void zxeco::BASICScreen::reset | ( | void | ) |
Set the K and S channels to their initial cursors and sizes, as in CLS.
The colors used are the global ones, thus you must change them before. This method clears the screen as in CLS; actually, it should be called anytime you want a CLS, CLEAR or RUN. This method does not change the current channel.
|
inline |
Reset cursors, size and contents of channel K to its initial values.
Use the global colors for K, that are not reset. This method does not change the current channel.
Definition at line 1070 of file ZXScreen.h.
|
inlinenoexcept |
Return how many scrolls will be done (+1) before asking.
This is the analogous to the SCRCNT system variable in the original ZX.
Definition at line 1074 of file ZXScreen.h.
|
inline |
Change to NEWCNT the current count of scrolls to do wihout asking.
Definition at line 1078 of file ZXScreen.h.
void zxeco::BASICScreen::fillKColors | ( | BasicColor | b, |
Colors & | colors | ||
) | const |
Fill COLORS with colors for K channel calculated from border color B.
void zxeco::BASICScreen::getGlobalColors | ( | char | channel, |
Colors & | colors | ||
) | const |
Fill COLS with a copy of the global colors in the given channel.
This must be called anytime a BORDER, INK, PAPER, etc. statement is to be mimicked (not a substatement within a PRINT or INPUT, but a standalone statement).
void zxeco::BASICScreen::changeChannel | ( | char | c | ) |
Set current channel to C (either 'K' or 'S') without changing cursor.
It also sets the current colors for the channel to the global ones. Therefore, this method MUST BE CALLED at the beginning of any PRINT or INPUT being mimicked even when that statement does not sets the channel (implicitly, it does set the channel), and also every time a channel substatement ("#...") is to be mimicked, since that substatement restores the global colors in the original ZX. This method does not clear or change channel cursors or sizes.
|
inline |
Return the current channel.
Definition at line 1119 of file ZXScreen.h.
void zxeco::BASICScreen::setTextCursor | ( | char | channel, |
const CharCursor & | pos | ||
) |
Set the channel to CHANNEL and put the cursor where requested.
POS contains non-flat coordinates. Putting the cursor outside the screen is dealt with as in the flat Screen class: the next print will adjust it to the next line.
CharCursor zxeco::BASICScreen::getTextCursor | ( | char | ch = 0x00 | ) | const |
Return the non-flat text cursor of the given channel ('S' or 'K').
If CH is 0x00, return the cursor of the current channel.
|
inline |
TRUE if the current non-flat column at the current channel is at left.
Definition at line 1132 of file ZXScreen.h.
ScrollInfo zxeco::BASICScreen::print | ( | const std::string & | txt | ) |
Print a string, possibly containing ctrl chars, in the current channel.
Do the necessary scrolls, asking the user for continuing scrolling if it is the case (using the key waiting routine passed in the constructor). It also updates non-flat cursor.
|
inline |
Move text cursor to a new line without printing CHRENTER.
The difference with printing CHRENTER is that the latter will do scroll if necessary before doing the newline cursor updating. This method does not any scroll, just update the cursor.
Definition at line 1155 of file ZXScreen.h.
Plot the given point using original, non-flat ZX plot coordinates.
Uses global S colors if CMC == nullptr.
Draw the given line using original, non-flat ZX plot increments.
Uses global S colors if CMC == nullptr.
void zxeco::BASICScreen::draw | ( | IntDist | incx, |
IntDist | incy, | ||
double | arc, | ||
const Colors * | cmc = nullptr |
||
) |
Draw the given arc using original, non-flat ZX plot increments.
Uses global S colors if CMC == nullptr.
void zxeco::BASICScreen::circle | ( | const PixCursor & | center, |
PixelDist | r, | ||
const Colors * | cmc = nullptr |
||
) |
Draw the given circle using original, non-flat ZX plot coordinates.
Uses global S colors if CMC == nullptr.
|
inline |
< Return TRUE if the given point is on or FALSE if it is off.
< Uses original, non-flat ZX plot coordinates.
Definition at line 1184 of file ZXScreen.h.
bool zxeco::BASICScreen::originalInput_printItem | ( | const std::string & | txt | ) |
Callback routine for using in Screen::input() that respects this model.
For using it in the Screen::input() method, wrap it with the BASICScreen object:
\code [& your_BASICscreen_obj](const std::string & item) -> bool { return(your_BASICscreen_obj.originalInput_printItem(item)); } \endcode
std::string zxeco::BASICScreen::input | ( | bool | withquotes, |
const Keyboard & | k0, | ||
const Screen::InputCallbacks::GetNewKeyboard & | cbk, | ||
const Screen::InputCallbacks::Play & | cbp, | ||
const Screen::InputCallbacks::CheckInput & | cnci | ||
) |
Do input in the original mode.
Current channel must be 'K'. This method calls the input() method of the underlying flat screen.
withquotes | is true for printing surrounding quotes in the input. |
k0 | is the initial state of the keyboard. |
cbk,cbp,cnci | are the callback routines needed for the input. |
std::string zxeco::BASICScreen::to_string | ( | void | ) | const |
Return a text with info about the current state of the decorator.
The text is multiline.
|
static |
Number of character rows initially in the K channel.
Definition at line 948 of file ZXScreen.h.
|
static |
Number of pixel rows initially in the K channel.
Definition at line 951 of file ZXScreen.h.
struct zxeco::BASICScreen::ScrollInfo |
Info produced after a scroll or some movements of the text cursor.
Definition at line 922 of file ZXScreen.h.
Public Attributes | |
bool | acceptedScroll |
size_t | howmanyScrolls |
How many one-text-line scrolls were done. More... | |
bool | newlineDone |
TRUE if there has been any newline movement. More... | |
Public Member Functions | |
bool | add (const ScrollInfo &si1) noexcept |
< Add the info of SI1 to this, returning the breaking of scrolls. More... | |
std::string | to_string (void) const |
< Return a string with the info about this object. More... | |
|
inline |
Definition at line 929 of file ZXScreen.h.
|
inlinenoexcept |
< Add the info of SI1 to this, returning the breaking of scrolls.
Definition at line 933 of file ZXScreen.h.
|
inline |
< Return a string with the info about this object.
Definition at line 940 of file ZXScreen.h.
bool zxeco::BASICScreen::ScrollInfo::acceptedScroll |
FALSE if there has been an scroll and the user rejected.
Definition at line 924 of file ZXScreen.h.
size_t zxeco::BASICScreen::ScrollInfo::howmanyScrolls |
How many one-text-line scrolls were done.
Definition at line 926 of file ZXScreen.h.
bool zxeco::BASICScreen::ScrollInfo::newlineDone |
TRUE if there has been any newline movement.
Definition at line 927 of file ZXScreen.h.