-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvas.cpp
65 lines (53 loc) · 1.99 KB
/
canvas.cpp
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
#include <QWidget>
#include "canvas.h"
#include <QGraphicsSceneMouseEvent>
#include "mouseeventpacket.h"
#include "serversocket.h"
#include <QDebug>
#include "eventdespatcer.h"
#include "keyboardeventpacket.h"
#include <QGraphicsSceneWheelEvent>
using namespace DG;
Canvas::Canvas(QObject *parent):QGraphicsScene(parent){
}
void Canvas::setDespatcher(EventDespatcher* despatcher){
_despatcher = despatcher;
}
void Canvas::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event){
qDebug() << "Canvas::mouseDoubleClickEvent";
MouseEventPacket* packet = new MouseEventPacket(QEvent::MouseButtonDblClick, event);
_despatcher->addMouseEvent(packet);
}
void Canvas::mouseMoveEvent(QGraphicsSceneMouseEvent* event){
qDebug() << "Canvas::mouseMoveEvent";
MouseEventPacket* packet = new MouseEventPacket(QEvent::MouseMove, event);
_despatcher->addMouseEvent(packet);
}
void Canvas::mousePressEvent(QGraphicsSceneMouseEvent* event){
qDebug() << "Canvas::mousePressEvent";
MouseEventPacket* packet = new MouseEventPacket(QEvent::MouseButtonPress, event);
_despatcher->addMouseEvent(packet);
}
void Canvas::mouseReleaseEvent(QGraphicsSceneMouseEvent* event){
qDebug() << "Canvas::mouseReleaseEvent";
MouseEventPacket* packet = new MouseEventPacket(QEvent::MouseButtonRelease, event);
_despatcher->addMouseEvent(packet);
}
void Canvas::wheelEvent(QGraphicsSceneWheelEvent* event){
qDebug() << "Canvas::wheelEvent";
MouseEventPacket* packet = new MouseEventPacket(QEvent::Wheel, event);
_despatcher->addMouseEvent(packet);
}
void Canvas::keyPressEvent(QKeyEvent* keyEvent){
qDebug() << "Canvas::keyPressEvent";
KeyboardEventPacket* packet = new KeyboardEventPacket(QEvent::KeyPress, keyEvent);
_despatcher->addKeyboardEvent(packet);
}
void Canvas::keyReleaseEvent(QKeyEvent* keyEvent){
qDebug() << "Canvas::keyReleaseEvent";
KeyboardEventPacket* packet = new KeyboardEventPacket(QEvent::KeyRelease, keyEvent);
_despatcher->addKeyboardEvent(packet);
}
void Canvas::setSocket(ServerSocket* socket){
_socket = socket;
}