<class name="QStylePainter" doc="/** <p>The <a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a> class is a convenience class for drawing <a href="QStyle.html"><tt>QStyle</tt></a> elements inside a widget.</p> <p><a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a> extends <a href="QPainter.html#QPainter(com.trolltech.qt.gui.QPaintDeviceInterface)"><tt>QPainter</tt></a> with a set of high-level <tt>draw...()</tt> functions implemented on top of <a href="QStyle.html"><tt>QStyle</tt></a>'s API. The advantage of using <a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a> is that the parameter lists get considerably shorter. Whereas a <a href="QStyle.html"><tt>QStyle</tt></a> object must be able to draw on any widget using any painter (because the application normally has one <a href="QStyle.html"><tt>QStyle</tt></a> object shared by all widget), a <a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a> is initialized with a widget, eliminating the need to specify the <a href="QWidget.html"><tt>QWidget</tt></a>, the <a href="QPainter.html#QPainter(com.trolltech.qt.gui.QPaintDeviceInterface)"><tt>QPainter</tt></a>, and the <a href="QStyle.html"><tt>QStyle</tt></a> for every function call.</p> <p>Example using <a href="QStyle.html"><tt>QStyle</tt></a> directly:</p> <pre> void MyWidget::paintEvent(QPaintEvent * <span class="comment">/* event *&#47;</span>) { QPainter painter(this); QStyleOptionFocusRect option; option.initFrom(this); option.backgroundColor = palette().color(QPalette::Background); style()-&gt;drawPrimitive(QStyle::PE_FrameFocusRect, &amp;option, &amp;painter, this); }</pre> <p>Example using <a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a>:</p> <pre> void MyWidget::paintEvent(QPaintEvent * <span class="comment">/* event *&#47;</span>) { QStylePainter painter(this); QStyleOptionFocusRect option; option.initFrom(this); option.backgroundColor = palette().color(QPalette::Background); painter.drawPrimitive(QStyle::PE_FrameFocusRect, option); }</pre> @see <a href="QStyle.html"><tt>QStyle</tt></a> @see <a href="QStyleOption.html"><tt>QStyleOption</tt></a> */"> <method name="public QStylePainter()" doc="/** <p>Constructs a <a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a>.</p> */"/> <method name="public QStylePainter(com.trolltech.qt.gui.QWidget w)" doc="/** <p>Construct a <a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a> using widget <tt>w</tt> for its paint device.</p> */"/> <method name="public QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface pd, com.trolltech.qt.gui.QWidget w)" doc="/** <p>Construct a <a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a> using <tt>pd</tt> for its paint device, and attributes from <tt>w</tt>.</p> */"/> <method name="public final boolean begin(com.trolltech.qt.gui.QWidget w)" doc="/** <p>Begin painting operations on the specified <tt>w</tt>. Returns true if the painter is ready to use; otherwise returns false.</p> <p>This is automatically called by the constructor that takes a <a href="QWidget.html"><tt>QWidget</tt></a>.</p> */"/> <method name="public final boolean begin(com.trolltech.qt.gui.QPaintDeviceInterface pd, com.trolltech.qt.gui.QWidget w)" doc="/** <p>Begin painting operations on paint device <tt>pd</tt> as if it was <tt>w</tt>.</p> <p>This is automatically called by the constructor that takes a <a href="QPaintDevice.html"><tt>QPaintDevice</tt></a> and a <a href="QWidget.html"><tt>QWidget</tt></a>.</p> */"/> <method name="public final void drawComplexControl(com.trolltech.qt.gui.QStyle.ComplexControl cc, com.trolltech.qt.gui.QStyleOptionComplex opt)" doc="/** <p>Use the widget's style to draw a complex control <tt>cc</tt> specified by the <a href="QStyleOptionComplex.html"><tt>QStyleOptionComplex</tt></a> <tt>opt</tt>.</p> @see <tt>QStyle::drawComplexControl</tt> */"/> <method name="public final void drawControl(com.trolltech.qt.gui.QStyle.ControlElement ce, com.trolltech.qt.gui.QStyleOption opt)" doc="/** <p>Use the widget's style to draw a control element <tt>ce</tt> specified by <a href="QStyleOption.html"><tt>QStyleOption</tt></a> <tt>opt</tt>.</p> @see <tt>QStyle::drawControl</tt> */"/> <method name="public final void drawItemPixmap(com.trolltech.qt.core.QRect r, int flags, com.trolltech.qt.gui.QPixmap pixmap)" doc="/** <p>Draws the <tt>pixmap</tt> in rectangle <tt>r</tt>. The pixmap is aligned according to <tt>flags</tt>.</p> @see <tt>QStyle::drawItemPixmap</tt> @see Qt::Alignment</tt> */"/> <method name="public final void drawItemText(com.trolltech.qt.core.QRect r, int flags, com.trolltech.qt.gui.QPalette pal, boolean enabled, java.lang.String text, com.trolltech.qt.gui.QPalette.ColorRole textRole)" doc="/** <p>Draws the <tt>text</tt> in rectangle <tt>r</tt> and palette <tt>pal</tt>. The text is aligned and wrapped according to <tt>flags</tt>.</p> <p>The pen color is specified with <tt>textRole</tt>. The <tt>enabled</tt> bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.</p> @see <tt>QStyle::drawItemText</tt> @see Qt::Alignment</tt> */"/> <method name="public final void drawItemText(com.trolltech.qt.core.QRect r, int flags, com.trolltech.qt.gui.QPalette pal, boolean enabled, java.lang.String text)" doc="/** <p>Equivalent to <a href="QStylePainter.html#drawItemText(com.trolltech.qt.core.QRect, int, com.trolltech.qt.gui.QPalette, boolean, java.lang.String, com.trolltech.qt.gui.QPalette.ColorRole)"><tt>drawItemText</tt></a>(<tt>r</tt>, <tt>flags</tt>, <tt>pal</tt>, <tt>enabled</tt>, <tt>text</tt>, QPalette::NoRole). */"/> <method name="public final void drawPrimitive(com.trolltech.qt.gui.QStyle.PrimitiveElement pe, com.trolltech.qt.gui.QStyleOption opt)" doc="/** <p>Use the widget's style to draw a primitive element <tt>pe</tt> specified by <a href="QStyleOption.html"><tt>QStyleOption</tt></a> <tt>opt</tt>.</p> @see <tt>QStyle::drawPrimitive</tt> */"/> <method name="public final com.trolltech.qt.gui.QStyle style()" doc="/** <p>Return the current style used by the <a href="QStylePainter.html#QStylePainter(com.trolltech.qt.gui.QPaintDeviceInterface, com.trolltech.qt.gui.QWidget)"><tt>QStylePainter</tt></a>.</p> */"/> </class>