QPaintDevice::~QPaintDevice() { if (paintingActive()) qWarning("QPaintDevice: Cannot destroy paint device that is being " "painted"); qt_painter_removePaintDevice(this); }
QPixmap &QPixmap::operator=( const QPixmap &pixmap ) { if ( paintingActive() ) { #if defined(QT_CHECK_STATE) qWarning("QPixmap::operator=: Cannot assign to pixmap during painting"); #endif return *this; } pixmap.data->ref(); // avoid 'x = x' deref(); if ( pixmap.paintingActive() ) { // make a deep copy init( pixmap.width(), pixmap.height(), pixmap.depth(), pixmap.data->bitmap, pixmap.data->optim ); data->uninit = FALSE; if ( !isNull() ) copyBlt( this, 0, 0, &pixmap, 0, 0, pixmap.width(), pixmap.height() ); pixmap.data->deref(); } else { data = pixmap.data; devFlags = pixmap.devFlags; // copy QPaintDevice flags #if defined(Q_WS_WIN) hdc = pixmap.hdc; #elif defined(Q_WS_PM) hps = pixmap.hps; #elif defined(Q_WS_X11) hd = pixmap.hd; // copy QPaintDevice drawable rendhd = pixmap.rendhd; copyX11Data( &pixmap ); // copy x11Data #elif defined(Q_WS_MACX) || defined(Q_OS_MAC9) hd = pixmap.hd; #endif } return *this; }
bool QPicture::save( QIODevice *dev, const char *format ) { if ( paintingActive() ) { #if defined(QT_CHECK_STATE) qWarning( "QPicture::save: still being painted on. " "Call QPainter::end() first" ); #endif return FALSE; } #ifndef QT_NO_SVG if ( qstricmp( format, "svg" ) == 0 ) { QSvgDevice svg; QPainter p( &svg ); if ( !play( &p ) ) return FALSE; svg.setBoundingRect( boundingRect() ); return svg.save( dev ); } #endif if ( format ) { qWarning( "QPicture::save: No such picture format: %s", format ); return FALSE; } dev->writeBlock( d->pictb.buffer().data(), d->pictb.buffer().size() ); return TRUE; }
bool QPicture::save( const QString &fileName, const char *format ) { if ( paintingActive() ) { #if defined(QT_CHECK_STATE) qWarning( "QPicture::save: still being painted on. " "Call QPainter::end() first" ); #endif return FALSE; } #ifndef QT_NO_SVG // identical to QIODevice* code below but the file name // makes a difference when it comes to saving pixmaps if ( qstricmp( format, "svg" ) == 0 ) { QSvgDevice svg; QPainter p( &svg ); if ( !play( &p ) ) return FALSE; svg.setBoundingRect( boundingRect() ); return svg.save( fileName ); } #endif QFile f( fileName ); if ( !f.open(IO_WriteOnly) ) return FALSE; return save( &f, format ); }
QPaintDevice::~QPaintDevice() { if (paintingActive()) qWarning("QPaintDevice: Cannot destroy paint device that is being " "painted. Be sure to QPainter::end() painters!"); qt_painter_removePaintDevice(this); }
/*! \fn bool Q3Picture::save(QIODevice *device, const char *format) Saves the picture in the specified \a format to the given \a device. Returns true if the save is successful. Returns false if, for example, the picture is still being painted, i.e., QPainter::end() has not yet been called. Note that when using the save() function to save SVG files, the format must be specified. For example: \snippet doc/src/snippets/code/src_qt3support_painting_q3picture.cpp 1 \sa load() */ bool Q3Picture::save(QIODevice *dev, const char *format) { if (paintingActive()) { qWarning("Q3Picture::save: still being painted on. " "Call QPainter::end() first"); return false; } if (qstricmp(format, "svg") == 0) { Q3SvgDevice svg; QPainter p(&svg); if (!play(&p)) return false; svg.setBoundingRect(boundingRect()); return svg.save(dev); } return QPicture::save(dev, format); }
/*! \overload Saves the picture in the specified \a format to the file with the given \a fileName. \sa load() */ bool Q3Picture::save(const QString &fileName, const char *format) { if (paintingActive()) { qWarning("Q3Picture::save: still being painted on. " "Call QPainter::end() first"); return false; } // identical to QIODevice* code below but the file name // makes a difference when it comes to saving pixmaps if (qstricmp( format, "svg") == 0) { Q3SvgDevice svg; QPainter p(&svg); if (!play(&p)) return false; svg.setBoundingRect(boundingRect()); return svg.save(fileName); } return QPicture::save(fileName, format); }