-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtr_canvas.h
122 lines (92 loc) · 3.08 KB
/
tr_canvas.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/******************************************************************
*
* @short basic class for Trafalgar drawing area
*
* project: Trafalgar/Gui
*
* modul: tr_canvas.h drawing area
* @version 0.2
*
* system: UNIX/LINUX
* compiler: gcc
*
* @author Schmid Hubert (C)2004-2022
*
* beginning: 08.2004
*
* history:
*/
/******************************************************************/
/* The trafalgar package is free software. You may 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, or (at your
* option) any later version.
*
* The GNU trafalgar package 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 the GNU plotutils package; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef TR_CANVAS_H
#define TR_CANVAS_H
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qmenu.h>
#include "tr_select_box.h"
#define MIN_SELECT 1 // double click range
#include <QtGui/qevent.h>
// from https://wiki.qt.io/How_to_catch_enter_key/de
class KeyEnterReceiver : public QObject
{
Q_OBJECT
public:
KeyEnterReceiver();
bool eventFilter(QObject* obj, QEvent* event);
signals:
void getKey(QKeyEvent* key);
};
class TrCanvas : public QWidget
{
Q_OBJECT
private:
unsigned char flags;
QPoint m_double_click;
QColor m_background;
QFont * m_font;
signals:
void documentChanged(); // TODO, unused?
protected:
SelectBox m_select_box;
int m_count_click;
void mousePressEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void wheelEvent(QWheelEvent *event);
void paintEvent(QPaintEvent *event);
virtual void paint(QPainter * p);
void configureSelect(Qt::MouseButtons button, bool show);
const QRect & getSelectRect() const;
public:
explicit TrCanvas(QWidget *parent = nullptr);
void setFont(QFont * font);
virtual void zoomReset();
virtual void zoomChange(double value, const QPoint pt, int limit);
void setBackgroundColor(QMap<int, QColor> & map);
virtual bool notifyCoor(const QPoint pt, int mode, Qt::MouseButton button);
virtual bool notifyPress(const QPoint pt, Qt::MouseButton button);
virtual bool notifyMove(const QPoint pt, Qt::MouseButton button);
virtual bool notifyRelease(const QPoint pt, Qt::MouseButton button);
virtual bool notifyClick(const QPoint pt, int mode, Qt::MouseButton button);
virtual bool notifyWheel(const QPoint pt, int a, int b);
virtual bool notifyRectSelect(const QRect & r, Qt::MouseButton button);
void notifyKey(const QString & s);
virtual void userMessage(unsigned char type, int value, void * add);
virtual void addMenuEntrys(QMenu * add_to, unsigned char type);
public slots:
void slotKey(QKeyEvent* key);
};
#endif // TR_CANVAS_H