\a m is the metric to get.
*/
+void QWidget::init(QPainter *painter) const
+{
+ const QPalette &pal = palette();
+ painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 0);
+ painter->d_func()->state->bgBrush = pal.brush(backgroundRole());
+ QFont f(font(), const_cast<QWidget *>(this));
+ painter->d_func()->state->deviceFont = f;
+ painter->d_func()->state->font = f;
+}
+
/*!
\fn void QWidget::setMask(const QRegion ®ion)
\overload
virtual void changeEvent(QEvent *);
int metric(PaintDeviceMetric) const;
+ void init(QPainter *painter) const;
virtual void inputMethodEvent(QInputMethodEvent *);
public:
}
#endif
+void QPaintDevice::init(QPainter *painter) const
+{
+}
+
Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric)
{
return device->metric(metric);
protected:
QPaintDevice();
virtual int metric(PaintDeviceMetric metric) const;
+ virtual void init(QPainter *painter) const;
ushort painters; // refcount
/*!
Initializes the painters pen, background and font to the same as
- the given \a widget. This function is called automatically when the
- painter is opened on a QWidget.
+ the given \a paint device.
+
+ \obsolete
\sa begin(), {QPainter#Settings}{Settings}
*/
-void QPainter::initFrom(const QWidget *widget)
+void QPainter::initFrom(const QPaintDevice *device)
{
- Q_ASSERT_X(widget, "QPainter::initFrom(const QWidget *widget)", "Widget cannot be 0");
+ Q_ASSERT_X(device, "QPainter::initFrom(const QPaintDevice *device)", "QPaintDevice cannot be 0");
Q_D(QPainter);
if (!d->engine) {
qWarning("QPainter::initFrom: Painter not active, aborted");
return;
}
- const QPalette &pal = widget->palette();
- d->state->pen = QPen(pal.brush(widget->foregroundRole()), 0);
- d->state->bgBrush = pal.brush(widget->backgroundRole());
- d->state->deviceFont = QFont(widget->font(), const_cast<QWidget*> (widget));
- d->state->font = d->state->deviceFont;
+ device->init(this);
+
if (d->extended) {
d->extended->penChanged();
} else if (d->engine) {
bool end();
bool isActive() const;
- void initFrom(const QWidget *widget);
+ void initFrom(const QPaintDevice *device);
enum CompositionMode {
CompositionMode_SourceOver,
QScopedPointer<QPainterPrivate> d_ptr;
+ friend class QWidget;
friend class QFontEngine;
friend class QFontEngineBox;
friend class QFontEngineFT;