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
noconv
participates in overload resolution only if thestring
parameter matches without implicit conversion.Write the string
string
starting from position (x, y) using foreground colorfg
and background colorbg
without attributes.Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
When using the overloads using
std::string
orchar*
the string has to be passed in utf-8 form. When using the overload usingchar16_t
the 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
noconv
participates in overload resolution only if thestring
parameter matches without implicit conversion.Write the string
string
starting from position (x, y) using foreground colorfg
and background colorbg
with 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::string
orchar*
the string has to be passed in utf-8 form. When using the overload usingchar16_t
the 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
fg
and background colorbg
with attributesattr
.The
WithChar
variant usesfillChar
to paint cells inside the clip region unlessfillChar
is 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
,y
with widthwidth
and heightheight
using foreground colorfg
and background colorbg
with attributesattr
.Actual changes are subject to the current clipping region and positioning to the current coordiante transform.
The
WithChar
variant usesfillChar
to paint cells inside the rectangle unlessfillChar
is 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)¶
Draws the rectangle starting at
sourceX
,sourceY
with widthwidth
and heightheight
of the image given assourceImage
. Ifwidth
is -1 then the maximal width still inside the source image is used. Ifheight
is -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.
-
void setForeground(int x, int y, Tui::ZColor fg)¶
Set the foreground of the cell at (x, y) to the color
fg
without 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
fg
without 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::ZTextMetrics
instance matching the painter.