Back to index

scribus-ng  1.3.4.dfsg+svn20071115
charzoom.cpp
Go to the documentation of this file.
00001 #include <qpixmap.h>
00002 #include <qpainter.h>
00003 
00004 #include "charzoom.h"
00005 #include "charzoom.moc"
00006 #include "scpainter.h"
00007 
00008 
00009 CharZoom::CharZoom(QWidget* parent, uint currentChar, ScFace face)
00010 #ifdef QT_MAC
00011        : QDialog( parent, "CharZoom", false, WStyle_Customize | WStyle_NoBorder | WType_Popup)
00012 #else
00013        : QDialog( parent, "CharZoom", false, WStyle_Customize | WStyle_NoBorder)
00014 #endif
00015 {
00016        int base = 48;
00017        int size = base + qRound(-face.descent() * base) + 3;
00018        int sizex = size + 2, sizey = size + 20;
00019        resize(sizex, sizey);
00020        setMinimumSize(sizex, sizey);
00021        setMaximumSize(sizex, sizey);
00022        
00023        pixm.resize(size, size);
00024        ScPainter *p = new ScPainter(&pixm, size, size);
00025        p->clear();
00026        pixm.fill(white);
00027        QWMatrix chma;
00028        chma.scale(4.8, 4.8);
00029 
00030        uint gl = face.char2CMap(currentChar);
00031        FPointArray gly = face.glyphOutline(gl);
00032        double ww = size - face.glyphWidth(gl, base);
00033        if (gly.size() > 4)
00034        {
00035               gly.map(chma);
00036               p->translate(ww / 2, 1);
00037               p->setBrush(black);
00038               p->setFillMode(1);
00039               p->setupPolygon(&gly);
00040               p->fillPath();
00041               p->end();
00042        }
00043        delete p;
00044 
00045        QString tmp;
00046        tmp.sprintf("%04X", currentChar);
00047        valu = "0x"+tmp;
00048 }
00049 
00050 void CharZoom::paintEvent(QPaintEvent *)
00051 {
00052        QPainter p;
00053        p.begin(this);
00054        p.setPen(black);
00055        p.setBrush(NoBrush);
00056        p.drawRect(0, 0, width(), height());
00057        p.drawPixmap(1, 1, pixm);
00058        p.drawText(5, height()-3, valu);
00059        p.end();
00060 }