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