ZPainter¶
ZPainter is responsible for getting characters and colors onto the terminal or memory buffers.
A ZPainter instance can be obtained from a paint() event, an Tui::ZImage or
when not using widgets from a Tui::ZTerminal.
-
class Tui::ZPainter¶
This class is copyable. It does not define comparison operators.
Constructors
(only copy constructor)
Functions
Members¶
-
Tui::ZPainter translateAndClip(int x, int y, int width, int height)¶
Returns a new ZPainter instance with adjusted transform and clip.
The new clipping region is the intersection of the previous clipping region with the rectangle specified as parameter, relative to the current transform.
The new transform is created such, that in the new painter (0, 0) refers to the same global point as (x, y) did with the previous transform.
-
void writeWithColors(int x, int y, const char16_t *string, int size, Tui::ZColor fg, Tui::ZColor bg)¶
-
void writeWithColors(int x, int y, const char *stringUtf8, int utf8CodeUnits, Tui::ZColor fg, Tui::ZColor bg)¶
-
void writeWithColors(int x, int y, std::string_view string, Tui::ZColor fg, Tui::ZColor bg)¶
The overloads marked with
noconvparticipates in overload resolution only if thestringparameter matches without implicit conversion.Write the string
stringstarting from position (x, y) using foreground colorfgand background colorbgwithout attributes.Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
When using the overloads using
std::stringorchar*the string has to be passed in utf-8 form. When using the overload usingchar16_tthe string has to be passed in utf-16 form.
-
void writeWithAttributes(int x, int y, const QString &string, Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr)¶
-
void writeWithAttributes(int x, int y, const QChar *string, int size, Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr)¶
-
void writeWithAttributes(int x, int y, const char16_t *string, int size, Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr)¶
-
void writeWithAttributes(int x, int y, const char *stringUtf8, int utf8CodeUnits, Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr)¶
-
void writeWithAttributes(int x, int y, QStringView string, Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr)¶
-
void writeWithAttributes(int x, int y, std::u16string_view string, Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr)¶
-
void writeWithAttributes(int x, int y, std::string_view string, Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr)¶
The overloads marked with
noconvparticipates in overload resolution only if thestringparameter matches without implicit conversion.Write the string
stringstarting from position (x, y) using foreground colorfgand background colorbgwith the attributes given inattr.Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
When using the overloads using
std::stringorchar*the string has to be passed in utf-8 form. When using the overload usingchar16_tthe string has to be passed in utf-16 form.
-
void clearWithChar(Tui::ZColor fg, Tui::ZColor bg, int fillChar, Tui::ZTextAttributes attr = {})¶
Paints all cells inside the clip region using foreground color
fgand background colorbgwith attributesattr.The
WithCharvariant usesfillCharto paint cells inside the clip region unlessfillCharis 127. Otherwise the cells set to the cleared state.
-
void clearRect(int x, int y, int width, int height, Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr = {})¶
-
void clearRectWithChar(int x, int y, int width, int height, Tui::ZColor fg, Tui::ZColor bg, int fillChar, Tui::ZTextAttributes attr = {})¶
Paints all cells inside the rectangle starting at
x,ywith widthwidthand heightheightusing foreground colorfgand background colorbgwith attributesattr.Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
The
WithCharvariant usesfillCharto paint cells inside the rectangle unlessfillCharis 127. Otherwise the cells set to the cleared state.
-
void setSoftwrapMarker(int x, int y)¶
Sets a softwarp marker at position (x, y).
If the right-most cell of a line of the whole terminal and the left-most cell of the next line of the whole terminal have a softwrap marker, both lines will be send to the terminal as wrapped in supported terminals. This influences for example how hard line breaks are handled in text copied from the terminal.
Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
-
void clearSoftwrapMarker(int x, int y)¶
Removes a softwarp marker at position (x, y).
Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
-
void drawImage(int x, int y, const Tui::ZImage &sourceImage, int sourceX = 0, int sourceY = 0, int width = -1, int height = -1)¶
-
void drawImageWithTiling(int x, int y, const Tui::ZImage &sourceImage, int sourceX, int sourceY, int width, int height, Tui::ZTilingMode tileLeft, Tui::ZTilingMode tileRight)¶
Draws the rectangle starting at
sourceX,sourceYwith widthwidthand heightheightof the image given assourceImage. Ifwidthis -1 then the maximal width still inside the source image is used. Ifheightis -1 then the maximal height still inside the source image is used. The image is drawn starting at the pointx,y.Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
Handling of wide characters on the left or right edge of the source rectangle is selected using
tileLeftandtileRight.Tui::ZTilingMode::NoTilingis used in the variant without these parameters.
-
void setForeground(int x, int y, Tui::ZColor fg)¶
Set the foreground of the cell at (x, y) to the color
fgwithout changing the cell contents or other attributes.Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
-
void setBackground(int x, int y, Tui::ZColor bg)¶
Set the background of the cell at (x, y) to the color
fgwithout changing the cell contents or other attributes.Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
-
void setCursor(int x, int y)¶
Sets the cursor position to (x, y).
This needs the painter to have an associated widget and the cursor position is only changed if that widget has focus (and no keyboard grab of another widget is active)
Positioning is subject to the current coordiante transform.
-
void setWidget(Tui::ZWidget *widget)¶
Used by in the paint event handling in
Tui::ZWidget. It should not be needed to call this from normal application code.Sets the associated widget of the painter.
-
Tui::ZTextMetrics textMetrics() const¶
Returns a
Tui::ZTextMetricsinstance matching the painter.