Subversion Repositories Scribus

Rev

Rev 14408 | Rev 22603 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9627 subik 1
#include <QPixmap>
8501 cbradney 2
#include <QPaintEvent>
7022 subik 3
 
9627 subik 4
#include "fonts/scface.h"
7022 subik 5
#include "charzoom.h"
7024 subik 6
#include "scpainter.h"
7022 subik 7
 
8
 
7024 subik 9
CharZoom::CharZoom(QWidget* parent, uint currentChar, ScFace face)
18204 fschmid 10
#ifdef Q_OS_MAC
10469 cbradney 11
        : QDialog( parent, Qt::FramelessWindowHint | Qt::Popup)
7022 subik 12
#else
10469 cbradney 13
        : QDialog( parent, Qt::FramelessWindowHint)
7022 subik 14
#endif
15
{
7024 subik 16
        int base = 48;
17
        int size = base + qRound(-face.descent() * base) + 3;
18
        int sizex = size + 2, sizey = size + 20;
19
        resize(sizex, sizey);
20
        setMinimumSize(sizex, sizey);
21
        setMaximumSize(sizex, sizey);
22
 
10469 cbradney 23
        pixm = QPixmap(size, size);
14408 fschmid 24
        QImage pix(size, size, QImage::Format_ARGB32_Premultiplied);
9319 fschmid 25
        ScPainter *p = new ScPainter(&pix, size, size);
7024 subik 26
        p->clear();
8522 cbradney 27
        pixm.fill(Qt::white);
13951 fschmid 28
        QTransform chma;
7024 subik 29
        chma.scale(4.8, 4.8);
30
 
31
        uint gl = face.char2CMap(currentChar);
32
        FPointArray gly = face.glyphOutline(gl);
33
        double ww = size - face.glyphWidth(gl, base);
34
        if (gly.size() > 4)
35
        {
36
                gly.map(chma);
37
                p->translate(ww / 2, 1);
8522 cbradney 38
                p->setBrush(Qt::black);
7024 subik 39
                p->setFillMode(1);
40
                p->setupPolygon(&gly);
41
                p->fillPath();
42
                p->end();
43
        }
44
        delete p;
10401 cbradney 45
        pixm=QPixmap::fromImage(pix);
7024 subik 46
 
7022 subik 47
        QString tmp;
7024 subik 48
        tmp.sprintf("%04X", currentChar);
7022 subik 49
        valu = "0x"+tmp;
50
}
51
 
52
void CharZoom::paintEvent(QPaintEvent *)
53
{
54
        QPainter p;
55
        p.begin(this);
8522 cbradney 56
        p.setPen(Qt::black);
57
        p.setBrush(Qt::NoBrush);
9383 fschmid 58
        p.drawRect(0, 0, width()-1, height()-1);
7022 subik 59
        p.drawPixmap(1, 1, pixm);
60
        p.drawText(5, height()-3, valu);
61
        p.end();
62
}