Qt Jambi Home

com.trolltech.qt.gui
Class QStylePainter

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.gui.QPainter
              extended by com.trolltech.qt.gui.QStylePainter
All Implemented Interfaces:
QtJambiInterface

public class QStylePainter
extends QPainter

The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.

QStylePainter extends QPainter with a set of high-level draw...() functions implemented on top of QStyle's API. The advantage of using QStylePainter is that the parameter lists get considerably shorter. Whereas a QStyle object must be able to draw on any widget using any painter (because the application normally has one QStyle object shared by all widget), a QStylePainter is initialized with a widget, eliminating the need to specify the QWidget, the QPainter, and the QStyle for every function call.

Example using QStyle directly:

    void MyWidget::paintEvent(QPaintEvent * /* event *<!-- noop -->/)
    {
        QPainter painter(this);

        QStyleOptionFocusRect option;
        option.initFrom(this);
        option.backgroundColor = palette().color(QPalette::Background);

        style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
    }

Example using QStylePainter:

    void MyWidget::paintEvent(QPaintEvent * /* event *<!-- noop -->/)
    {
        QStylePainter painter(this);

        QStyleOptionFocusRect option;
        option.initFrom(this);
        option.backgroundColor = palette().color(QPalette::Background);

        painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
    }

See Also:
QStyle, QStyleOption

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QPainter
QPainter.CompositionMode, QPainter.RenderHint, QPainter.RenderHints
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QStylePainter()
          Constructs a QStylePainter.
QStylePainter(QPaintDeviceInterface pd, QWidget w)
          Construct a QStylePainter using pd for its paint device, and attributes from w.
QStylePainter(QWidget w)
          Construct a QStylePainter using widget w for its paint device.
 
Method Summary
 boolean begin(QPaintDeviceInterface pd, QWidget w)
          Begin painting operations on paint device pd as if it was w.
 boolean begin(QWidget w)
          Begin painting operations on the specified w.
 void drawComplexControl(QStyle.ComplexControl cc, QStyleOptionComplex opt)
          Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex opt.
 void drawControl(QStyle.ControlElement ce, QStyleOption opt)
          Use the widget's style to draw a control element ce specified by QStyleOption opt.
 void drawItemPixmap(QRect r, int flags, QPixmap pixmap)
          Draws the pixmap in rectangle r.
 void drawItemText(QRect r, int flags, QPalette pal, boolean enabled, java.lang.String text)
          Equivalent to drawItemText(r, flags, pal, enabled, text, QPalette::NoRole).
 void drawItemText(QRect r, int flags, QPalette pal, boolean enabled, java.lang.String text, QPalette.ColorRole textRole)
          Draws the text in rectangle r and palette pal.
 void drawPrimitive(QStyle.PrimitiveElement pe, QStyleOption opt)
          Use the widget's style to draw a primitive element pe specified by QStyleOption opt.
static QStylePainter fromNativePointer(QNativePointer nativePointer)
          This function returns the QStylePainter instance pointed to by nativePointer
 QStyle style()
          Return the current style used by the QStylePainter.
 
Methods inherited from class com.trolltech.qt.gui.QPainter
background, backgroundMode, begin, boundingRect, boundingRect, boundingRect, boundingRect, boundingRect, brush, brushOrigin, clipPath, clipRegion, combinedMatrix, combinedTransform, compositionMode, device, deviceMatrix, deviceTransform, drawArc, drawArc, drawArc, drawChord, drawChord, drawChord, drawConvexPolygon, drawConvexPolygon, drawEllipse, drawEllipse, drawEllipse, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawLine, drawLine, drawLine, drawLine, drawLines, drawLinesF, drawLinesFromPoints, drawLinesFromPointsF, drawPath, drawPicture, drawPicture, drawPicture, drawPie, drawPie, drawPie, drawPixmap, drawPixmap, drawPixmap, drawPixmap, drawPixmap, drawPixmap, drawPixmap, drawPixmap, drawPixmap, drawPixmap, drawPixmap, drawPoint, drawPoint, drawPoint, drawPoints, drawPoints, drawPolygon, drawPolygon, drawPolygon, drawPolygon, drawPolyline, drawPolyline, drawRect, drawRect, drawRect, drawRects, drawRectsF, drawRoundRect, drawRoundRect, drawRoundRect, drawRoundRect, drawRoundRect, drawRoundRect, drawRoundRect, drawRoundRect, drawRoundRect, drawText, drawText, drawText, drawText, drawText, drawText, drawText, drawText, drawText, drawText, drawText, drawTextItem, drawTextItem, drawTextItem, drawTiledPixmap, drawTiledPixmap, drawTiledPixmap, drawTiledPixmap, drawTiledPixmap, drawTiledPixmap, drawTiledPixmap, end, eraseRect, eraseRect, eraseRect, fillPath, fillRect, fillRect, fillRect, font, fontInfo, fontMetrics, hasClipping, initFrom, isActive, layoutDirection, opacity, paintEngine, pen, redirected, renderHints, resetMatrix, resetTransform, restore, restoreRedirected, rotate, save, scale, setBackground, setBackgroundMode, setBrush, setBrush, setBrush, setBrush, setBrush, setBrushOrigin, setBrushOrigin, setBrushOrigin, setClipPath, setClipPath, setClipping, setClipRect, setClipRect, setClipRect, setClipRect, setClipRect, setClipRect, setClipRegion, setClipRegion, setCompositionMode, setFont, setLayoutDirection, setOpacity, setPen, setPen, setPen, setRedirected, setRedirected, setRenderHint, setRenderHint, setRenderHints, setRenderHints, setTransform, setTransform, setViewport, setViewport, setViewTransformEnabled, setWindow, setWindow, setWorldMatrix, setWorldMatrix, setWorldMatrixEnabled, setWorldTransform, setWorldTransform, shear, strokePath, testRenderHint, transform, translate, translate, translate, viewport, viewTransformEnabled, window, worldMatrix, worldMatrixEnabled, worldTransform
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QStylePainter

public QStylePainter()

Constructs a QStylePainter.


QStylePainter

public QStylePainter(QWidget w)

Construct a QStylePainter using widget w for its paint device.


QStylePainter

public QStylePainter(QPaintDeviceInterface pd,
                     QWidget w)

Construct a QStylePainter using pd for its paint device, and attributes from w.

Method Detail

begin

public final boolean begin(QPaintDeviceInterface pd,
                           QWidget w)

Begin painting operations on paint device pd as if it was w.

This is automatically called by the constructor that takes a QPaintDevice and a QWidget.


begin

public final boolean begin(QWidget w)

Begin painting operations on the specified w. Returns true if the painter is ready to use; otherwise returns false.

This is automatically called by the constructor that takes a QWidget.

Overrides:
begin in class QPainter

drawComplexControl

public final void drawComplexControl(QStyle.ComplexControl cc,
                                     QStyleOptionComplex opt)

Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex opt.

See Also:
QStyle::drawComplexControl

drawControl

public final void drawControl(QStyle.ControlElement ce,
                              QStyleOption opt)

Use the widget's style to draw a control element ce specified by QStyleOption opt.

See Also:
QStyle::drawControl

drawItemPixmap

public final void drawItemPixmap(QRect r,
                                 int flags,
                                 QPixmap pixmap)

Draws the pixmap in rectangle r. The pixmap is aligned according to flags.

See Also:
QStyle::drawItemPixmap, Qt::Alignment

drawItemText

public final void drawItemText(QRect r,
                               int flags,
                               QPalette pal,
                               boolean enabled,
                               java.lang.String text)

Equivalent to drawItemText(r, flags, pal, enabled, text, QPalette::NoRole).


drawItemText

public final void drawItemText(QRect r,
                               int flags,
                               QPalette pal,
                               boolean enabled,
                               java.lang.String text,
                               QPalette.ColorRole textRole)

Draws the text in rectangle r and palette pal. The text is aligned and wrapped according to flags.

The pen color is specified with textRole. The enabled bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.

See Also:
QStyle::drawItemText, Qt::Alignment

drawPrimitive

public final void drawPrimitive(QStyle.PrimitiveElement pe,
                                QStyleOption opt)

Use the widget's style to draw a primitive element pe specified by QStyleOption opt.

See Also:
QStyle::drawPrimitive

style

public final QStyle style()

Return the current style used by the QStylePainter.


fromNativePointer

public static QStylePainter fromNativePointer(QNativePointer nativePointer)
This function returns the QStylePainter instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home