-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaintwidget.h
64 lines (54 loc) · 1.53 KB
/
paintwidget.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
#ifndef PAINTWIDGET_H
#define PAINTWIDGET_H
#include <QWidget>
#include <QTimer>
#include "layoutengine.h"
class PaintWidget : public QWidget
{
Q_OBJECT
private:
enum Handle{
TopLeft = 0,
TopRight,
BottomRight,
BottomLeft
};
public:
explicit PaintWidget(QWidget *parent = nullptr);
public Q_SLOTS:
void setFontSize(int size);
void setTextColor(QColor col);
void setFontFile(QString file);
void setAlignment(int align);
void setLineHeight(qreal height);
void setLetterSpacing(qreal spacing);
void setWordSpacing(qreal spacing);
void setTextDirection(bool dir);
protected:
void paintEvent(QPaintEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
private:
void drawHandles(QPainter &gc);
void drawIbar(QPainter &gc, QPointF distanceFromLeft);
void recalliberate();
private Q_SLOTS:
void blinkIBar();
private:
QVector<PropertyHolder> m_props;
qreal m_lineHeight;
int m_align, m_blinkCounter = 0;
QColor m_textColor;
QPoint m_topLeft = QPoint(0,0), m_lastCursorPos;
QRect m_boundingRect;
bool m_moveIt = false, m_handleSelected = false, m_insertMode = false;
QVector<QRect> m_handleRects;
Handle m_handle;
QTimer m_timer;
QString m_totalInput;
QStringList m_input;
LayoutEngine m_layoutEngine;
};
#endif // PAINTWIDGET_H