void QwtPicker::PrivateData::PickerWidget::updateMask() { QBitmap bm(width(), height()); bm.fill(Qt::color0); QPainter painter(&bm); if ( d_type == RubberBand ) { QPen pen = d_picker->rubberBandPen(); pen.setColor(Qt::color1); painter.setPen(pen); d_picker->drawRubberBand(&painter); } if ( d_type == Text ) { QPen pen = d_picker->trackerPen(); pen.setColor(Qt::color1); painter.setPen(pen); d_picker->drawTracker(&painter); } painter.end(); #if QT_VERSION < 0x040000 QWidget *w = parentWidget(); const bool doUpdate = w->isUpdatesEnabled(); const Qt::BackgroundMode bgMode = w->backgroundMode(); w->setUpdatesEnabled(false); if ( bgMode != Qt::NoBackground ) w->setBackgroundMode(Qt::NoBackground); #endif const QRegion r(bm); setMask(r); #if QT_VERSION < 0x040000 if ( bgMode != Qt::NoBackground ) w->setBackgroundMode(bgMode); w->setUpdatesEnabled(doUpdate); #endif setShown(!r.isEmpty()); }
void QwtPicker::PickerWidget::updateMask() { QRegion mask; if ( d_type == RubberBand ) { QBitmap bm(width(), height()); bm.fill(Qt::color0); QPainter painter(&bm); QPen pen = d_picker->rubberBandPen(); pen.setColor(Qt::color1); painter.setPen(pen); d_picker->drawRubberBand(&painter); mask = QRegion(bm); } if ( d_type == Text ) { d_hasTextMask = true; #if QT_VERSION >= 0x040300 if ( !parentWidget()->testAttribute(Qt::WA_PaintOnScreen) ) { #if 0 if ( parentWidget()->paintEngine()->type() != QPaintEngine::OpenGL ) #endif { // With Qt >= 4.3 drawing of the tracker can be implemented in an // easier way, using the textRect as mask. d_hasTextMask = false; } } #endif if ( d_hasTextMask ) { const QwtText label = d_picker->trackerText( d_picker->trackerPosition()); if ( label.testPaintAttribute(QwtText::PaintBackground) && label.backgroundBrush().style() != Qt::NoBrush ) { #if QT_VERSION >= 0x040300 if ( label.backgroundBrush().color().alpha() > 0 ) #endif // We don't need a text mask, when we have a background d_hasTextMask = false; } } if ( d_hasTextMask ) { QBitmap bm(width(), height()); bm.fill(Qt::color0); QPainter painter(&bm); painter.setFont(font()); QPen pen = d_picker->trackerPen(); pen.setColor(Qt::color1); painter.setPen(pen); d_picker->drawTracker(&painter); mask = QRegion(bm); } else { mask = d_picker->trackerRect(font()); } } #if QT_VERSION < 0x040000 QWidget *w = parentWidget(); const bool doUpdate = w->isUpdatesEnabled(); const Qt::BackgroundMode bgMode = w->backgroundMode(); w->setUpdatesEnabled(false); if ( bgMode != Qt::NoBackground ) w->setBackgroundMode(Qt::NoBackground); #endif setMask(mask); #if QT_VERSION < 0x040000 if ( bgMode != Qt::NoBackground ) w->setBackgroundMode(bgMode); w->setUpdatesEnabled(doUpdate); #endif setShown(!mask.isEmpty()); }