Remove QWidget dependency in QPainter::initFrom().
parent
ea6c6d711b
commit
862263b0ab
|
|
@ -12506,6 +12506,16 @@ void QWidget::ungrabGesture(Qt::GestureType gesture)
|
|||
\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
|
||||
|
|
|
|||
|
|
@ -702,6 +702,7 @@ protected:
|
|||
virtual void changeEvent(QEvent *);
|
||||
|
||||
int metric(PaintDeviceMetric) const;
|
||||
void init(QPainter *painter) const;
|
||||
|
||||
virtual void inputMethodEvent(QInputMethodEvent *);
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ int QPaintDevice::metric(PaintDeviceMetric) const
|
|||
}
|
||||
#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);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ public:
|
|||
protected:
|
||||
QPaintDevice();
|
||||
virtual int metric(PaintDeviceMetric metric) const;
|
||||
virtual void init(QPainter *painter) const;
|
||||
|
||||
ushort painters; // refcount
|
||||
|
||||
|
|
|
|||
|
|
@ -1556,25 +1556,23 @@ bool QPainter::isActive() const
|
|||
|
||||
/*!
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public:
|
|||
bool end();
|
||||
bool isActive() const;
|
||||
|
||||
void initFrom(const QWidget *widget);
|
||||
void initFrom(const QPaintDevice *device);
|
||||
|
||||
enum CompositionMode {
|
||||
CompositionMode_SourceOver,
|
||||
|
|
@ -470,6 +470,7 @@ private:
|
|||
|
||||
QScopedPointer<QPainterPrivate> d_ptr;
|
||||
|
||||
friend class QWidget;
|
||||
friend class QFontEngine;
|
||||
friend class QFontEngineBox;
|
||||
friend class QFontEngineFT;
|
||||
|
|
|
|||
Loading…
Reference in New Issue