-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcharacterwidget.h
66 lines (51 loc) · 1.35 KB
/
characterwidget.h
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
63
64
65
66
#ifndef CHARACTERWIDGET_H
#define CHARACTERWIDGET_H
#include <QFont>
#include <QPoint>
#include <QSize>
#include <QString>
#include <QtWidgets/QFrame>
#include <QVector>
class QMouseEvent;
class QPaintEvent;
class MainWindow;
class CharacterWidget : public QFrame
{
Q_OBJECT
public:
explicit CharacterWidget(QWidget *parent = nullptr);
QSize sizeHint() const;
QFont font();
public slots:
void updateFont(const QFont &font);
void updateCharacterDisplayFont(const QFont &font);
void cursorPosition(int old, int newpos);
void updateSelection(int left,int length);
void updateHasSelection(bool hasSelection);
signals:
void characterSelected(const QString &character);
void characterDoubleClicked(quint32 character);
protected:
void paintEvent(QPaintEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
QTransform transform;
QList<QRect> aRects;
private:
qreal mScreenScale;
QVector<quint32> theString;
bool hasSelection;
QFont displayFont, characterDisplayFont;
int squareWidth, squareHeight;
int selectionLeft, selectionLength;
int topTextMargin;
int bottomTextMargin;
int leftTextMargin;
int rightmargin;
int rectPadding;
int cursor;
bool event(QEvent *event);
int whichGlyph(QPoint pos);
private slots:
void updateText(QString str);
};
#endif