QPrinter_Win.cpp

Simon Rutishauser simon.rutishauser at web.de
Wed Dec 15 21:06:24 CET 2004


I've implemented quite a part of qprinter_win.cpp. Drawing graphic 
primitives should work now. 

Drawing text is a quite ugly hack in qpainter_win.cpp - maybe someone 
has a better solution for this?
The problem there in short:
You have to access some private methods of QTextEngine (or was ist 
QScriptItem, don't remember) to draw the text from within qprinter_win - 
this is not possible because qprinter_win is no _friend_ of the above 
class. Bad luck.
Drawing on the printer from within qpainter_win (which is a friend of 
the needed class) doesn't work because I haven't got the deivce context 
there.
Current solution: Drawing on a QPixmap and printing just as a normal 
pixmap.

There might be lots of bugs all over. Some code has not yet been _really_ tested, rather 
just implemented (especially the brushes and raster-op part)

I attached the complete qprinter_win.cpp (lots of code by me and I don't 
think anyone has changed anything there in the meanwhile) and a file 
containing the changed QPainter::drawTextItem() function.

Somehow cvs diff (-u) does not seem to produce usable results for me. 
Bad luck.

Simon
-------------- next part --------------
void QPainter::drawTextItem( int x, int y, const QTextItem & ti, int textFlags )
{
    if ( testf( ExtDev ) ) {
        QPDevCmdParam param[ 2 ];
        QPoint p( x, y );
        param[ 0 ].point = &p;
        param[ 1 ].textItem = &ti;
        //bool retval = pdev->cmd( QPaintDevice::PdcDrawTextItem, this, param );

        //Create Pixmap and write there...
        QTextEngine *engine = ti.engine;
        QScriptItem *si = &engine->items[ ti.item ];

        engine->shape( ti.item );
        QFontEngine *fe = si->fontEngine;
        assert( fe != 0 );

        QPixmap pixmap = QPixmap( si->width, fe->tm.w.tmHeight );
        pixmap.fill();

        fe->draw( &QPainter( &pixmap ), si->x, si->y, engine, si, textFlags );
        pixmap.setMask( pixmap.createHeuristicMask() );

        param[ 1 ].pixmap = &pixmap;
        bool retval = pdev->cmd( QPaintDevice::PdcDrawPixmap, this, param );

        if ( !retval || !hdc )
            return ;
    }

    QTextEngine *engine = ti.engine;
    QScriptItem *si = &engine->items[ ti.item ];

    engine->shape( ti.item );
    QFontEngine *fe = si->fontEngine;
    assert( fe != 0 );

    x += si->x;
    y += si->y;

    fe->draw( this, x, y, engine, si, textFlags );
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qprinter_win-20041215-2105.cpp
Type: text/x-c++src
Size: 41804 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-cygwin/attachments/20041215/3eab59e4/qprinter_win-20041215-2105-0001.bin


More information about the kde-cygwin mailing list