# QwtPainter Class Reference

A collection of QPainter workarounds. More...

`#include <qwt_painter.h>`

List of all members.

## Static Public Member Functions

static bool | deviceClipping ()
static const QRect & | deviceClipRect ()
static void | drawColorBar (QPainter *painter, const QwtColorMap &, const QwtDoubleInterval &, const QwtScaleMap &, Qt::Orientation, const QRect &)
static void | drawEllipse (QPainter *, const QRect &)
static void | drawFocusRect (QPainter *, QWidget *)
static void | drawFocusRect (QPainter *, QWidget *, const QRect &)
static void | drawLine (QPainter *, int x1, int y1, int x2, int y2)
static void | drawLine (QPainter *, const QPoint &p1, const QPoint &p2)
static void | drawPie (QPainter *, const QRect &r, int a, int alen)
static void | drawPoint (QPainter *, int x, int y)
static void | drawPolygon (QPainter *, const QwtPolygon &pa)
static void | drawPolyline (QPainter *, const QwtPolygon &pa)
static void | drawRect (QPainter *, int x, int y, int w, int h)
static void | drawRect (QPainter *, const QRect &rect)
static void | drawRoundFrame (QPainter *, const QRect &, int width, const QPalette &, bool sunken)
static void | drawSimpleRichText (QPainter *, const QRect &, int flags, QTextDocument &)
static void | drawText (QPainter *, int x, int y, int w, int h, int flags, const QString &)
static void | drawText (QPainter *, int x, int y, const QString &)
static void | drawText (QPainter *, const QPoint &, const QString &)
static void | drawText (QPainter *, const QRect &, int flags, const QString &)
static void | fillRect (QPainter *, const QRect &, const QBrush &)
static const QwtMetricsMap & | metricsMap ()
static void | resetMetricsMap ()
static QPen | scaledPen (const QPen &)
static void | setClipRect (QPainter *, const QRect &)
static void | setDeviceClipping (bool)
static void | setMetricsMap (const QwtMetricsMap &)
static void | setMetricsMap (const QPaintDevice *layout, const QPaintDevice *device)

## Detailed Description

A collection of QPainter workarounds.

1) Clipping to coordinate system limits (Qt3 only)

On X11 pixel coordinates are stored in shorts. Qt produces overruns when mapping QCOORDS to shorts.

2) Scaling to device metrics

QPainter scales fonts, line and fill patterns to the metrics of the paint device. Other values like the geometries of rects, points remain device independend. To enable a device independent widget implementation, QwtPainter adds scaling of these geometries. (Unfortunately QPainter::scale scales both types of paintings, so the objects of the first type would be scaled twice).

## Member Function Documentation

bool QwtPainter::deviceClipping | ( |  | ) | `[inline, static]`

Returns whether device clipping is enabled. On X11 the default is enabled, otherwise it is disabled.

See also:
  QwtPainter::setDeviceClipping()

const QRect & QwtPainter::deviceClipRect | ( |  | ) | `[static]`

Returns rect for device clipping

See also:
  QwtPainter::setDeviceClipping()

void QwtPainter::drawEllipse | ( | QPainter * | painter,
|  | const QRect & | rect
| ) |  | `[static]`

Wrapper for QPainter::drawEllipse()

void QwtPainter::drawLine | ( | QPainter * | painter,
|  | int | x1,
|  | int | y1,
|  | int | x2,
|  | int | y2
| ) |  | `[static]`

Wrapper for QPainter::drawLine()

void QwtPainter::drawLine | ( | QPainter * | painter,
|  | const QPoint & | p1,
|  | const QPoint & | p2
| ) |  | `[inline, static]`

Wrapper for QPainter::drawLine()

void QwtPainter::drawPie | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | int | a,
|  | int | alen
| ) |  | `[static]`

Wrapper for QPainter::drawPie()

void QwtPainter::drawPoint | ( | QPainter * | painter,
|  | int | x,
|  | int | y
| ) |  | `[static]`

Wrapper for QPainter::drawPoint()

void QwtPainter::drawPolygon | ( | QPainter * | painter,
|  | const QwtPolygon & | pa
| ) |  | `[static]`

Wrapper for QPainter::drawPolygon()

void QwtPainter::drawPolyline | ( | QPainter * | painter,
|  | const QwtPolygon & | pa
| ) |  | `[static]`

Wrapper for QPainter::drawPolyline()

void QwtPainter::drawRect | ( | QPainter * | painter,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h
| ) |  | `[static]`

Wrapper for QPainter::drawRect()

void QwtPainter::drawRect | ( | QPainter * | painter,
|  | const QRect & | rect
| ) |  | `[static]`

Wrapper for QPainter::drawRect()

void QwtPainter::drawRoundFrame | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | int | width,
|  | const QPalette & | palette,
|  | bool | sunken
| ) |  | `[static]`

Draw a round frame.

void QwtPainter::drawSimpleRichText | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | int | flags,
|  | QTextDocument & | text
| ) |  | `[static]`

Wrapper for QSimpleRichText::draw()

void QwtPainter::drawText | ( | QPainter * | painter,
|  | int | x,
|  | int | y,
|  | int | w,
|  | int | h,
|  | int | flags,
|  | const QString & | text
| ) |  | `[static]`

Wrapper for QPainter::drawText()

void QwtPainter::drawText | ( | QPainter * | painter,
|  | int | x,
|  | int | y,
|  | const QString & | text
| ) |  | `[static]`

Wrapper for QPainter::drawText()

void QwtPainter::drawText | ( | QPainter * | painter,
|  | const QPoint & | pos,
|  | const QString & | text
| ) |  | `[static]`

Wrapper for QPainter::drawText()

void QwtPainter::drawText | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | int | flags,
|  | const QString & | text
| ) |  | `[static]`

Wrapper for QPainter::drawText()

void QwtPainter::fillRect | ( | QPainter * | painter,
|  | const QRect & | rect,
|  | const QBrush & | brush
| ) |  | `[static]`

Wrapper for QPainter::fillRect()

const QwtMetricsMap & QwtPainter::metricsMap | ( |  | ) | `[static]`

Returns:
  Metrics map

void QwtPainter::resetMetricsMap | ( |  | ) | `[static]`

Reset the metrics map to the ratio 1:1

See also:
  QwtPainter::setMetricsMap(), QwtPainter::resetMetricsMap()

QPen QwtPainter::scaledPen | ( | const QPen & | pen | ) | `[static]`

Scale a pen according to the layout metrics.

The width of non cosmetic pens is scaled from screen to layout metrics, so that they look similar on paint devices with different resolutions.

Parameters:

  pen | Unscaled pen

Returns:
  Scaled pen

void QwtPainter::setClipRect | ( | QPainter * | painter,
|  | const QRect & | rect
| ) |  | `[static]`

Wrapper for QPainter::setClipRect()

void QwtPainter::setDeviceClipping | ( | bool | enable | ) | `[static]`

En/Disable device clipping.

On X11 the default for device clipping is enabled, otherwise it is disabled.

See also:
  QwtPainter::deviceClipping()

void QwtPainter::setMetricsMap | ( | const QwtMetricsMap & | map | ) | `[static]`

Change the metrics map

See also:
  QwtPainter::resetMetricsMap(), QwtPainter::metricsMap()

void QwtPainter::setMetricsMap | ( | const QPaintDevice * | layout,
|  | const QPaintDevice * | device
| ) |  | `[static]`

Scale all QwtPainter drawing operations using the ratio QwtPaintMetrics(from).logicalDpiX() / QwtPaintMetrics(to).logicalDpiX() and QwtPaintMetrics(from).logicalDpiY() / QwtPaintMetrics(to).logicalDpiY()

See also:
  QwtPainter::resetScaleMetrics(), QwtPainter::scaleMetricsX(), QwtPainter::scaleMetricsY()