Skip to content

Latest commit

 

History

History
113 lines (87 loc) · 3.67 KB

textrender.h

File metadata and controls

113 lines (87 loc) · 3.67 KB
 
Feb 20, 2013
Feb 20, 2013
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
Copyright 2011-2012 Heikki Holstila <heikki.holstila@gmail.com>
This file is part of FingerTerm.
FingerTerm is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
FingerTerm is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TEXTRENDER_H
#define TEXTRENDER_H
Jul 22, 2013
Jul 22, 2013
23
#include <QQuickPaintedItem>
Feb 20, 2013
Feb 20, 2013
24
25
26
27
28
29
#include <QPainter>
#include "terminal.h"
class Util;
Jul 22, 2013
Jul 22, 2013
30
class TextRender : public QQuickPaintedItem
Feb 20, 2013
Feb 20, 2013
31
32
33
34
35
{
Q_PROPERTY(int fontWidth READ fontWidth NOTIFY fontSizeChanged)
Q_PROPERTY(int fontHeight READ fontHeight NOTIFY fontSizeChanged)
Q_PROPERTY(int fontPointSize READ fontPointSize WRITE setFontPointSize NOTIFY fontSizeChanged)
Q_PROPERTY(bool showBufferScrollIndicator READ showBufferScrollIndicator WRITE setShowBufferScrollIndicator NOTIFY showBufferScrollIndicatorChanged)
Jun 27, 2016
Jun 27, 2016
36
Q_PROPERTY(bool allowGestures READ allowGestures WRITE setAllowGestures NOTIFY allowGesturesChanged)
Feb 20, 2013
Feb 20, 2013
37
38
39
Q_OBJECT
public:
Jul 22, 2013
Jul 22, 2013
40
explicit TextRender(QQuickItem *parent = 0);
Feb 20, 2013
Feb 20, 2013
41
virtual ~TextRender();
Jul 22, 2013
Jul 22, 2013
42
void paint(QPainter*);
Feb 20, 2013
Feb 20, 2013
43
Jun 8, 2016
Jun 8, 2016
44
45
static void setUtil(Util *util);
static void setTerminal(Terminal *terminal);
Feb 20, 2013
Feb 20, 2013
46
47
48
49
50
51
52
53
54
55
56
57
int fontWidth() { return iFontWidth; }
int fontHeight() { return iFontHeight; }
int fontDescent() { return iFontDescent; }
int fontPointSize() { return iFont.pointSize(); }
void setFontPointSize(int psize);
bool showBufferScrollIndicator() { return iShowBufferScrollIndicator; }
void setShowBufferScrollIndicator(bool s) { if(iShowBufferScrollIndicator!=s) { iShowBufferScrollIndicator=s; emit showBufferScrollIndicatorChanged(); } }
Q_INVOKABLE QPoint cursorPixelPos();
Q_INVOKABLE QSize cursorPixelSize();
Jun 27, 2016
Jun 27, 2016
58
59
60
bool allowGestures();
void setAllowGestures(bool allow);
Feb 20, 2013
Feb 20, 2013
61
62
63
signals:
void fontSizeChanged();
void showBufferScrollIndicatorChanged();
Jun 27, 2016
Jun 27, 2016
64
void allowGesturesChanged();
Feb 20, 2013
Feb 20, 2013
65
66
67
68
public slots:
void redraw();
void updateTermSize();
Jun 8, 2016
Jun 8, 2016
69
70
71
void mousePress(float eventX, float eventY);
void mouseMove(float eventX, float eventY);
void mouseRelease(float eventX, float eventY);
Feb 20, 2013
Feb 20, 2013
72
Jun 8, 2016
Jun 8, 2016
73
74
75
private slots:
void handleScrollBack(bool reset);
Feb 20, 2013
Feb 20, 2013
76
77
78
private:
Q_DISABLE_COPY(TextRender)
Jun 8, 2016
Jun 8, 2016
79
80
enum PanGesture { PanNone, PanLeft, PanRight, PanUp, PanDown };
Feb 20, 2013
Feb 20, 2013
81
82
83
84
void paintFromBuffer(QPainter* painter, QList<QList<TermChar> >& buffer, int from, int to, int &y);
void drawBgFragment(QPainter* painter, int x, int y, int width, TermChar style);
void drawTextFragment(QPainter* painter, int x, int y, QString text, TermChar style);
QPoint charsToPixels(QPoint pos);
Jun 8, 2016
Jun 8, 2016
85
86
87
88
89
90
91
92
93
94
95
96
97
98
void selectionHelper(QPointF scenePos, bool selectionOngoing);
/**
* Scroll the back buffer on drag.
*
* @param now The current position
* @param last The last position (or start position)
* @return The new value for last (modified by any consumed offset)
**/
QPointF scrollBackBuffer(QPointF now, QPointF last);
void doGesture(PanGesture gesture);
bool newSelection;
QPointF dragOrigin;
Feb 20, 2013
Feb 20, 2013
99
100
101
102
103
104
QFont iFont;
int iFontWidth;
int iFontHeight;
int iFontDescent;
bool iShowBufferScrollIndicator;
Jun 27, 2016
Jun 27, 2016
105
bool iAllowGestures;
Feb 20, 2013
Feb 20, 2013
106
Jun 8, 2016
Jun 8, 2016
107
108
static Terminal *sTerm;
static Util *sUtil;
Feb 20, 2013
Feb 20, 2013
109
110
111
112
113
QList<QColor> iColorTable;
};
#endif // TEXTRENDER_H