@ -30,85 +30,46 @@
# undef Qt
# undef Qt
/*!
/*!
\ class TDEQt4PaintDevice ntqpicture . h
\ class TDEQt4PaintDevice tdeqt4painter . h
\ brief The TDEQt4PaintDevice class is a paint device that record s and
\ brief The TDEQt4PaintDevice class is a paint device that t ranslat es
replays TQPainter commands .
Qt paint events to a TQt painter .
\ ingroup graphics
\ ingroup graphics
\ ingroup images
\ ingroup shared
\ ingroup shared
A picture serializes painter commands to an IO device in a
platform - independent format . For example , a picture created under
Windows can be read on a Sun SPARC .
Pictures are called meta - files on some platforms .
TQt pictures use a proprietary binary format . Unlike native picture
( meta - file ) formats on many window systems , TQt pictures have no
limitations regarding their contents . Everything that can be
painted can also be stored in a picture , e . g . fonts , pixmaps ,
regions , transformed graphics , etc .
TDEQt4PaintDevice is an \ link shclass . html implicitly shared \ endlink class .
Example of how to record a picture :
\ code
TDEQt4PaintDevice pic ;
TQPainter p ;
p . begin ( & pic ) ; // paint in picture
p . drawEllipse ( 10 , 20 , 80 , 70 ) ; // draw an ellipse
p . end ( ) ; // painting done
pic . save ( " drawing.pic " ) ; // save picture
\ endcode
Example of how to replay a picture :
\ code
TDEQt4PaintDevice pic ;
pic . load ( " drawing.pic " ) ; // load picture
TQPainter p ;
p . begin ( & myWidget ) ; // paint in myWidget
p . drawPicture ( pic ) ; // draw the picture
p . end ( ) ; // painting done
\ endcode
Pictures can also be drawn using play ( ) . Some basic data about a
picture is available , for example , size ( ) , isNull ( ) and
boundingRect ( ) .
*/
*/
inline int qt4PainterRectSubtraction ( QPainter * pd ) {
QPen pen = pd - > pen ( ) ;
return pen . style ( ) ! = Qt : : NoPen & & pen . width ( ) = = 0 ? 1 : 0 ;
}
/*!
inline QRect qt4PainterAdjustedRectangle ( const QRect & r , QPainter * pd )
Constructs an empty picture .
{
QRect rect = r . normalized ( ) ;
The \ a formatVersion parameter may be used to \ e create a TDEQt4PaintDevice
int subtract = qt4PainterRectSubtraction ( pd ) ;
that can be read by applications that are compiled with earlier
if ( subtract ! = 0 ) {
versions of TQt .
rect . setSize ( QSize ( rect . width ( ) - subtract , rect . height ( ) - subtract ) ) ;
\ list
}
\ i \ a formatVersion = = 1 is binary compatible with TQt 1. x and later .
return rect ;
\ i \ a formatVersion = = 2 is binary compatible with TQt 2.0 . x and later .
}
\ i \ a formatVersion = = 3 is binary compatible with TQt 2.1 . x and later .
\ i \ a formatVersion = = 4 is binary compatible with TQt 3.0 . x and later .
\ i \ a formatVersion = = 5 is binary compatible with TQt 3.1 .
\ endlist
Note that the default formatVersion is - 1 which signifies the
current release , i . e . for TQt 3.1 a formatVersion of 5 is the same
as the default formatVersion of - 1.
Reading pictures generated by earlier versions of TQt is supported
/*!
and needs no special coding ; the format is automatically detected .
Constructs TDEQt4PaintDevice on an existing QPainter
*/
*/
TDEQt4PaintDevice : : TDEQt4PaintDevice ( QPainter * qt4painter )
TDEQt4PaintDevice : : TDEQt4PaintDevice ( QPainter * qt4painter )
: TQPaintDevice ( TQInternal : : Picture | TQInternal : : ExternalDevice )
: TQPaintDevice ( TQInternal : : Picture | TQInternal : : ExternalDevice )
{
{
m_qt4painter = qt4painter ;
m_qt4painter = qt4painter ;
m_qt4OrigClipping = m_qt4painter - > hasClipping ( ) ;
m_qt4OrigClipRegion = m_qt4painter - > clipRegion ( ) ;
m_qt4OrigWorldTransformEnabled = m_qt4painter - > worldMatrixEnabled ( ) ;
m_qt4OrigWorldTransform = m_qt4painter - > worldTransform ( ) ;
}
}
/*!
/*!
Destroys the picture .
Destroys the TDEQt4PaintDevice .
*/
*/
TDEQt4PaintDevice : : ~ TDEQt4PaintDevice ( )
TDEQt4PaintDevice : : ~ TDEQt4PaintDevice ( )
{
{
@ -153,24 +114,27 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
TQRect r = rects [ ( int ) i ] ;
TQRect r = rects [ ( int ) i ] ;
qt4region = qt4region . united ( QRegion ( QRect ( r . x ( ) , r . y ( ) , r . width ( ) , r . height ( ) ) ) ) ;
qt4region = qt4region . united ( QRegion ( QRect ( r . x ( ) , r . y ( ) , r . width ( ) , r . height ( ) ) ) ) ;
}
}
{
# else
# else
// SLOW
// SLOW
TQRect tqt3br = p [ 0 ] . rgn - > boundingRect ( ) ;
TQRect tqt3br = p [ 0 ] . rgn - > boundingRect ( ) ;
TQBitmap regionMask ( tqt3br . x ( ) + tqt3br . width ( ) , tqt3br . y ( ) + tqt3br . height ( ) ) ;
if ( ! tqt3br . isNull ( ) ) {
regionMask . fill ( TQt : : color0 ) ;
TQBitmap regionMask ( tqt3br . x ( ) + tqt3br . width ( ) , tqt3br . y ( ) + tqt3br . height ( ) ) ;
TQPainter tqt3brpainter ( & regionMask ) ;
regionMask . fill ( TQt : : color0 ) ;
tqt3brpainter . setClipRegion ( * p [ 0 ] . rgn ) ;
TQPainter tqt3brpainter ( & regionMask ) ;
tqt3brpainter . fillRect ( 0 , 0 , regionMask . width ( ) , regionMask . height ( ) , TQt : : color1 ) ;
tqt3brpainter . setClipRegion ( * p [ 0 ] . rgn ) ;
tqt3brpainter . end ( ) ;
tqt3brpainter . fillRect ( 0 , 0 , regionMask . width ( ) , regionMask . height ( ) , TQt : : color1 ) ;
QBitmap qt4RegionMask = QPixmap : : fromX11Pixmap ( regionMask . handle ( ) , QPixmap : : ImplicitlyShared ) ;
tqt3brpainter . end ( ) ;
qt4region = QRegion ( qt4RegionMask ) ;
QBitmap qt4RegionMask = QPixmap : : fromX11Pixmap ( regionMask . handle ( ) , QPixmap : : ImplicitlyShared ) ;
qt4region = QRegion ( qt4RegionMask ) ;
# endif
# endif
TQPainter : : CoordinateMode tqt3coordmode = ( TQPainter : : CoordinateMode ) p [ 1 ] . ival ;
TQPainter : : CoordinateMode tqt3coordmode = ( TQPainter : : CoordinateMode ) p [ 1 ] . ival ;
if ( tqt3coordmode = = TQPainter : : CoordDevice ) {
if ( tqt3coordmode = = TQPainter : : CoordDevice ) {
qt4region = qt4region ;
qt4region = qt4region ;
}
}
else {
else {
qt4region = m_qt4painter - > transform ( ) . map ( qt4region ) ;
qt4region = m_qt4painter - > transform ( ) . map ( qt4region ) ;
}
}
}
}
}
if ( c = = PdcSetWMatrix ) {
if ( c = = PdcSetWMatrix ) {
@ -487,11 +451,67 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
}
}
}
}
if ( c = = PdcSetFont ) {
if ( c = = PdcSetFont ) {
// FIXME
printf ( " [WARNING] QFont conversion is NOT COMPLETE \n \r " ) ; fflush ( stdout ) ;
TQFont qt3font = * p [ 0 ] . font ;
TQFont qt3font = * p [ 0 ] . font ;
qt4font = QFont ( QString : : fromUtf8 ( qt3font . family ( ) . utf8 ( ) . data ( ) ) , qt3font . pointSize ( ) , qt3font . weight ( ) , qt3font . italic ( ) ) ;
qt4font = QFont ( QString : : fromUtf8 ( qt3font . family ( ) . utf8 ( ) . data ( ) ) , qt3font . pointSize ( ) , qt3font . weight ( ) , qt3font . italic ( ) ) ;
qt4font . setBold ( qt3font . bold ( ) ) ;
// qt4font.setCapitalization ( Capitalization caps )
qt4font . setFamily ( QString : : fromUtf8 ( qt3font . family ( ) . utf8 ( ) . data ( ) ) ) ;
qt4font . setFixedPitch ( qt3font . fixedPitch ( ) ) ;
qt4font . setItalic ( qt3font . italic ( ) ) ;
// qt4font.setKerning ( bool enable )
// qt4font.setLetterSpacing ( SpacingType type, qreal spacing )
qt4font . setOverline ( qt3font . overline ( ) ) ;
int pixelSize = qt3font . pixelSize ( ) ;
if ( pixelSize < 0 ) {
float pointSizeFloat = qt3font . pointSizeFloat ( ) ;
if ( pointSizeFloat < 0 ) {
qt4font . setPointSize ( qt3font . pointSize ( ) ) ;
}
else {
qt4font . setPointSizeF ( pointSizeFloat ) ;
}
}
else {
qt4font . setPixelSize ( pixelSize ) ;
}
// qt4font.setRawMode ( bool enable )
// qt4font.setRawName(QString::fromUtf8(qt3font.rawName().utf8().data()));
qt4font . setStretch ( qt3font . stretch ( ) ) ;
qt4font . setStrikeOut ( qt3font . strikeOut ( ) ) ;
// qt4font.setStyle ( Style style )
TQFont : : StyleHint qt3fontstylehint = qt3font . styleHint ( ) ;
QFont : : StyleHint qt4fontstylehint = QFont : : AnyStyle ;
if ( qt3fontstylehint = = TQFont : : Helvetica ) qt4fontstylehint = QFont : : Helvetica ;
else if ( qt3fontstylehint = = TQFont : : SansSerif ) qt4fontstylehint = QFont : : SansSerif ;
else if ( qt3fontstylehint = = TQFont : : Times ) qt4fontstylehint = QFont : : Times ;
else if ( qt3fontstylehint = = TQFont : : Serif ) qt4fontstylehint = QFont : : Serif ;
else if ( qt3fontstylehint = = TQFont : : Courier ) qt4fontstylehint = QFont : : Courier ;
else if ( qt3fontstylehint = = TQFont : : TypeWriter ) qt4fontstylehint = QFont : : TypeWriter ;
else if ( qt3fontstylehint = = TQFont : : OldEnglish ) qt4fontstylehint = QFont : : OldEnglish ;
else if ( qt3fontstylehint = = TQFont : : Decorative ) qt4fontstylehint = QFont : : Decorative ;
else if ( qt3fontstylehint = = TQFont : : System ) qt4fontstylehint = QFont : : System ;
else if ( qt3fontstylehint = = TQFont : : AnyStyle ) qt4fontstylehint = QFont : : AnyStyle ;
TQFont : : StyleStrategy qt3fontstrategy = qt3font . styleStrategy ( ) ;
QFont : : StyleStrategy qt4fontstrategy = ( QFont : : StyleStrategy ) 0 ;
if ( qt3fontstrategy & TQFont : : PreferDefault ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : PreferDefault ) ;
if ( qt3fontstrategy & TQFont : : PreferBitmap ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : PreferBitmap ) ;
if ( qt3fontstrategy & TQFont : : PreferDevice ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : PreferDevice ) ;
if ( qt3fontstrategy & TQFont : : PreferOutline ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : PreferOutline ) ;
if ( qt3fontstrategy & TQFont : : ForceOutline ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : ForceOutline ) ;
if ( qt3fontstrategy & TQFont : : PreferMatch ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : PreferMatch ) ;
if ( qt3fontstrategy & TQFont : : PreferQuality ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : PreferQuality ) ;
if ( qt3fontstrategy & TQFont : : PreferAntialias ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : PreferAntialias ) ;
if ( qt3fontstrategy & TQFont : : NoAntialias ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : NoAntialias ) ;
if ( qt3fontstrategy & TQFont : : OpenGLCompatible ) qt4fontstrategy = ( QFont : : StyleStrategy ) ( qt4fontstrategy | QFont : : OpenGLCompatible ) ;
qt4font . setStyleHint ( qt4fontstylehint , qt4fontstrategy ) ;
// qt4font.setStyleStrategy ( StyleStrategy s )
qt4font . setUnderline ( qt3font . underline ( ) ) ;
qt4font . setWeight ( qt3font . weight ( ) ) ;
// qt4font.setWordSpacing ( qreal spacing )
}
}
if ( c = = PdcDrawPixmap ) {
if ( c = = PdcDrawPixmap ) {
qt4rect = QRect ( p [ 0 ] . rect - > x ( ) , p [ 0 ] . rect - > y ( ) , p [ 0 ] . rect - > width ( ) , p [ 0 ] . rect - > height ( ) ) ;
qt4rect = QRect ( p [ 0 ] . rect - > x ( ) , p [ 0 ] . rect - > y ( ) , p [ 0 ] . rect - > width ( ) , p [ 0 ] . rect - > height ( ) ) ;
@ -527,22 +547,22 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
m_qt4painter - > drawLine ( qt4point1 , qt4point2 ) ;
m_qt4painter - > drawLine ( qt4point1 , qt4point2 ) ;
break ;
break ;
case PdcDrawRect :
case PdcDrawRect :
m_qt4painter - > drawRect ( qt4 rect ) ;
m_qt4painter - > drawRect ( qt4 PainterAdjustedRectangle( qt4 rect, m_qt4painter ) ) ;
break ;
break ;
case PdcDrawRoundRect :
case PdcDrawRoundRect :
m_qt4painter - > drawRoundedRect ( qt4 rect, p [ 1 ] . ival , p [ 2 ] . ival ) ;
m_qt4painter - > drawRoundedRect ( qt4 PainterAdjustedRectangle( qt4 rect, m_qt4painter ) , p [ 1 ] . ival , p [ 2 ] . ival ) ;
break ;
break ;
case PdcDrawEllipse :
case PdcDrawEllipse :
m_qt4painter - > drawEllipse ( qt4 rect ) ;
m_qt4painter - > drawEllipse ( qt4 PainterAdjustedRectangle( qt4 rect, m_qt4painter ) ) ;
break ;
break ;
case PdcDrawArc :
case PdcDrawArc :
m_qt4painter - > drawArc ( qt4 rect, p [ 1 ] . ival , p [ 2 ] . ival ) ;
m_qt4painter - > drawArc ( qt4 PainterAdjustedRectangle( qt4 rect, m_qt4painter ) , p [ 1 ] . ival , p [ 2 ] . ival ) ;
break ;
break ;
case PdcDrawPie :
case PdcDrawPie :
m_qt4painter - > drawPie ( qt4 rect, p [ 1 ] . ival , p [ 2 ] . ival ) ;
m_qt4painter - > drawPie ( qt4 PainterAdjustedRectangle( qt4 rect, m_qt4painter ) , p [ 1 ] . ival , p [ 2 ] . ival ) ;
break ;
break ;
case PdcDrawChord :
case PdcDrawChord :
m_qt4painter - > drawChord ( qt4 rect, p [ 1 ] . ival , p [ 2 ] . ival ) ;
m_qt4painter - > drawChord ( qt4 PainterAdjustedRectangle( qt4 rect, m_qt4painter ) , p [ 1 ] . ival , p [ 2 ] . ival ) ;
break ;
break ;
case PdcDrawLineSegments :
case PdcDrawLineSegments :
index = 0 ;
index = 0 ;
@ -674,7 +694,7 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
break ;
break ;
# endif
# endif
case PdcSetWXform :
case PdcSetWXform :
m_qt4painter - > setWorldMatrixEnabled ( p [ 0 ] . ival ) ;
m_qt4painter - > setWorldMatrixEnabled ( ( m_qt4OrigWorldTransformEnabled ) ? true : p [ 0 ] . ival ) ;
break ;
break ;
case PdcSetWMatrix :
case PdcSetWMatrix :
m_qt4painter - > setWorldMatrix ( qt4matrix , p [ 1 ] . ival ) ;
m_qt4painter - > setWorldMatrix ( qt4matrix , p [ 1 ] . ival ) ;
@ -690,10 +710,10 @@ bool TDEQt4PaintDevice::cmd( int c, TQPainter *pt, TQPDevCmdParam *p )
# endif
# endif
# endif
# endif
case PdcSetClip :
case PdcSetClip :
m_qt4painter - > setClipping ( p [ 0 ] . ival ) ;
m_qt4painter - > setClipping ( ( m_qt4OrigClipping ) ? true : p [ 0 ] . ival ) ;
break ;
break ;
case PdcSetClipRegion :
case PdcSetClipRegion :
m_qt4painter - > setClipRegion ( qt4region , Qt : : ReplaceClip ) ;
m_qt4painter - > setClipRegion ( qt4region .intersected ( m_qt4OrigClipRegion ) , Qt : : ReplaceClip ) ;
break ;
break ;
default :
default :
# if defined(QT_CHECK_RANGE)
# if defined(QT_CHECK_RANGE)