Logo    
KDWinUtils
Helper library for MFC to Qt migration
Loading...
Searching...
No Matches
KPainter Class Reference

The KPainter class is used to paint on a widget. More...

#include <kpainter.h>

Inheritance diagram for KPainter:
[legend]
Collaboration diagram for KPainter:
[legend]

Public Member Functions

void BitBlt (const QRect &rect, const QPixmap &pSrcDC, int xSrc, int ySrc)
 Draws a bitmap at the specified coordinates.
 
void BitBlt (int x, int y, int nWidth, int nHeight, const QPixmap &pSrcDC, int xSrc, int ySrc)
 Draws a bitmap at the specified coordinates.
 
void Chord (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
 
void Ellipse (const KRect &rect)
 Draws an ellipse using the current pen and fills it using the current brush.
 
void Ellipse (int x1, int y1, int x2, int y2)
 Draws an ellipse using the current pen and fills it using the current brush.
 
void FillRect (const KRect &rect, const KBrush &brush)
 Fills a given rectangle by using a specific brush.
 
KSize GetTextExtent (const KString &str) const
 Computes the width and height of a line of text based on the current font.
 
void IntersectClipRect (const KRect &rect)
 Enables clipping, and sets the clip region to the given rectangle.
 
void IntersectClipRect (int x1, int y1, int x2, int y2)
 Enables clipping, and sets the clip region to the given rectangle.
 
template<typename T >
 KPainter (KWidgetBase< T > *widget)
 Construct a new KPainter object based on a KWidget or KDialog.
 
void LineTo (int x, int y)
 Draws a line from the current position up to, but not including, a point.
 
void MoveTo (int x, int y)
 Moves the current position.
 
void Pie (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
 Draws a pie-shaped wedge.
 
void PolyBezier (const KPoint *points, int pointCount)
 Draws one or more Bzier splines. The current position isn't used or updated.
 
void Polygon (const KPoint *points, int pointCount)
 Draws a polygon consisting of two or more points (vertices) connected by lines.
 
void Rectangle (const KRect &rect)
 Draws a rectangle using the current pen and fills it using the current brush.
 
void Rectangle (int x1, int y1, int x2, int y2)
 Draws a rectangle using the current pen and fills it using the current brush.
 
void RoundRect (const KRect &rect, int ellipseWidth, int ellipseHeight)
 Draws a rounded rectangle using the current pen and fills it using the current brush.
 
void RoundRect (int x1, int y1, int x2, int y2, int ellipseWidth, int ellipseHeight)
 Draws a rounded rectangle using the current pen and fills it using the current brush.
 
void SelectClipRgn (QRegion *region)
 Sets the clipping region to be used for drawing.
 
KBrush SelectObject (const KBrush &brush)
 Sets the brush to be used for drawing.
 
KFont SelectObject (const KFont &font)
 Sets the font to be used for drawing.
 
KPen SelectObject (const KPen &pen)
 Sets the pen to be used for drawing.
 
QColor SetBkColor (const QColor &color)
 Sets the background color to be used for drawing (ie the brush color)
 
QColor SetTextColor (const QColor &color)
 Sets the text color to be used for drawing (ie the pen color)
 
void TextOut (int x, int y, const KString &text)
 Writes a character string at a specified location using the currently selected font.
 
void TextOut (int x, int y, const KString &text, int nCount)
 Writes a character string at a specified location using the currently selected font.
 

Detailed Description

The KPainter class is used to paint on a widget.

This class can replace CDC or CPaintDC with the same API, and can be used in the same way as QPainter (it's inheriting QPainter).

See also
https://learn.microsoft.com/en-us/cpp/mfc/reference/cdc-class
https://learn.microsoft.com/en-us/cpp/mfc/reference/cpaintdc-class

Constructor & Destructor Documentation

◆ KPainter()

template<typename T >
KPainter::KPainter ( KWidgetBase< T > * widget)
inline

Construct a new KPainter object based on a KWidget or KDialog.

If the widget has a scroll area (using the VScroll or HScroll flag), the painter will be based on the viewport of the scroll area, not on the widget itself.

Member Function Documentation

◆ BitBlt() [1/2]

void KPainter::BitBlt ( const QRect & rect,
const QPixmap & pSrcDC,
int xSrc,
int ySrc )

Draws a bitmap at the specified coordinates.

◆ BitBlt() [2/2]

void KPainter::BitBlt ( int x,
int y,
int nWidth,
int nHeight,
const QPixmap & pSrcDC,
int xSrc,
int ySrc )

Draws a bitmap at the specified coordinates.

◆ Chord()

void KPainter::Chord ( int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4 )

◆ Ellipse() [1/2]

void KPainter::Ellipse ( const KRect & rect)

Draws an ellipse using the current pen and fills it using the current brush.

◆ Ellipse() [2/2]

void KPainter::Ellipse ( int x1,
int y1,
int x2,
int y2 )

Draws an ellipse using the current pen and fills it using the current brush.

◆ FillRect()

void KPainter::FillRect ( const KRect & rect,
const KBrush & brush )

Fills a given rectangle by using a specific brush.

◆ GetTextExtent()

KSize KPainter::GetTextExtent ( const KString & str) const

Computes the width and height of a line of text based on the current font.

◆ IntersectClipRect() [1/2]

void KPainter::IntersectClipRect ( const KRect & rect)

Enables clipping, and sets the clip region to the given rectangle.

If clipping is already enabled, the new clip region is the intersection of the current clip region and the rectangle.

◆ IntersectClipRect() [2/2]

void KPainter::IntersectClipRect ( int x1,
int y1,
int x2,
int y2 )

Enables clipping, and sets the clip region to the given rectangle.

If clipping is already enabled, the new clip region is the intersection of the current clip region and the rectangle.

◆ LineTo()

void KPainter::LineTo ( int x,
int y )

Draws a line from the current position up to, but not including, a point.

◆ MoveTo()

void KPainter::MoveTo ( int x,
int y )

Moves the current position.

◆ Pie()

void KPainter::Pie ( int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int x4,
int y4 )

Draws a pie-shaped wedge.

◆ PolyBezier()

void KPainter::PolyBezier ( const KPoint * points,
int pointCount )

Draws one or more Bzier splines. The current position isn't used or updated.

◆ Polygon()

void KPainter::Polygon ( const KPoint * points,
int pointCount )

Draws a polygon consisting of two or more points (vertices) connected by lines.

◆ Rectangle() [1/2]

void KPainter::Rectangle ( const KRect & rect)

Draws a rectangle using the current pen and fills it using the current brush.

◆ Rectangle() [2/2]

void KPainter::Rectangle ( int x1,
int y1,
int x2,
int y2 )

Draws a rectangle using the current pen and fills it using the current brush.

◆ RoundRect() [1/2]

void KPainter::RoundRect ( const KRect & rect,
int ellipseWidth,
int ellipseHeight )

Draws a rounded rectangle using the current pen and fills it using the current brush.

◆ RoundRect() [2/2]

void KPainter::RoundRect ( int x1,
int y1,
int x2,
int y2,
int ellipseWidth,
int ellipseHeight )

Draws a rounded rectangle using the current pen and fills it using the current brush.

◆ SelectClipRgn()

void KPainter::SelectClipRgn ( QRegion * region)

Sets the clipping region to be used for drawing.

If the region is null, the clipping is diasabled.

◆ SelectObject() [1/3]

KBrush KPainter::SelectObject ( const KBrush & brush)

Sets the brush to be used for drawing.

Returns
The old brush

◆ SelectObject() [2/3]

KFont KPainter::SelectObject ( const KFont & font)

Sets the font to be used for drawing.

Returns
The old font

◆ SelectObject() [3/3]

KPen KPainter::SelectObject ( const KPen & pen)

Sets the pen to be used for drawing.

Returns
The old pen

◆ SetBkColor()

QColor KPainter::SetBkColor ( const QColor & color)

Sets the background color to be used for drawing (ie the brush color)

Returns
The old background color

◆ SetTextColor()

QColor KPainter::SetTextColor ( const QColor & color)

Sets the text color to be used for drawing (ie the pen color)

Returns
The old text color

◆ TextOut() [1/2]

void KPainter::TextOut ( int x,
int y,
const KString & text )

Writes a character string at a specified location using the currently selected font.

◆ TextOut() [2/2]

void KPainter::TextOut ( int x,
int y,
const KString & text,
int nCount )

Writes a character string at a specified location using the currently selected font.


The documentation for this class was generated from the following file: