Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

charzoom.cpp

Go to the documentation of this file.
00001 #include <QPixmap>
00002 #include <QPaintEvent>
00003 
00004 #include "fonts/scface.h"
00005 #include "charzoom.h"
00006 #include "scpainter.h"
00007 
00008 
00009 CharZoom::CharZoom(QWidget* parent, uint currentChar, ScFace face)
00010 #ifdef Q_WS_MAC
00011     : QDialog( parent, Qt::FramelessWindowHint | Qt::Popup)
00012 #else
00013     : QDialog( parent, Qt::FramelessWindowHint)
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 = QPixmap(size, size);
00024     QImage pix(size, size, QImage::Format_ARGB32);
00025     ScPainter *p = new ScPainter(&pix, size, size);
00026     p->clear();
00027     pixm.fill(Qt::white);
00028     QMatrix chma;
00029     chma.scale(4.8, 4.8);
00030 
00031     uint gl = face.char2CMap(currentChar);
00032     FPointArray gly = face.glyphOutline(gl);
00033     double ww = size - face.glyphWidth(gl, base);
00034     if (gly.size() > 4)
00035     {
00036         gly.map(chma);
00037         p->translate(ww / 2, 1);
00038         p->setBrush(Qt::black);
00039         p->setFillMode(1);
00040         p->setupPolygon(&gly);
00041         p->fillPath();
00042         p->end();
00043     }
00044     delete p;
00045     pixm=QPixmap::fromImage(pix);
00046 
00047     QString tmp;
00048     tmp.sprintf("%04X", currentChar);
00049     valu = "0x"+tmp;
00050 }
00051 
00052 void CharZoom::paintEvent(QPaintEvent *)
00053 {
00054     QPainter p;
00055     p.begin(this);
00056     p.setPen(Qt::black);
00057     p.setBrush(Qt::NoBrush);
00058     p.drawRect(0, 0, width()-1, height()-1);
00059     p.drawPixmap(1, 1, pixm);
00060     p.drawText(5, height()-3, valu);
00061     p.end();
00062 }
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.