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(QRect transform)
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 QString &string, Tui::ZColor fg, Tui::ZColor bg)
void writeWithColors(int x, int y, const QChar *string, int size, Tui::ZColor fg, Tui::ZColor bg)
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, QStringView string, Tui::ZColor fg, Tui::ZColor bg)
void writeWithColors(int x, int y, std::u16string_view string, 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 the string parameter matches without implicit conversion.

Write the string string starting from position (x, y) using foreground color fg and background color bg 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 or char* the string has to be passed in utf-8 form. When using the overload using char16_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 the string parameter matches without implicit conversion.

Write the string string starting from position (x, y) using foreground color fg and background color bg with the attributes given in attr.

Actual changes are subject to the current clipping region and positioning to the current coordiante transform.

When using the overloads using std::string or char* the string has to be passed in utf-8 form. When using the overload using char16_t the string has to be passed in utf-16 form.

void clear(Tui::ZColor fg, Tui::ZColor bg, Tui::ZTextAttributes attr = {})
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 color bg with attributes attr.

The WithChar variant uses fillChar to paint cells inside the clip region unless fillChar 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 width width and height height using foreground color fg and background color bg with attributes attr.

Actual changes are subject to the current clipping region and positioning to the current coordiante transform.

The WithChar variant uses fillChar to paint cells inside the rectangle unless fillChar 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 width width and height height of the image given as sourceImage. If width is -1 then the maximal width still inside the source image is used. If height is -1 then the maximal height still inside the source image is used. The image is drawn starting at the point x, 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.