-
Notifications
You must be signed in to change notification settings - Fork 6
/
tedevent.cpp
69 lines (63 loc) · 1.93 KB
/
tedevent.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
66
67
68
69
#include "tedevent.h"
TEDEvent::TEDEvent(EventType evt) : eventType(EventNone), nextEvent(nullptr), lastEvent(nullptr), charList(NULL)
{
SeteventType(evt);
}
TEDEvent::TEDEvent() : eventType(EventNone), nextEvent(nullptr), lastEvent(nullptr), charList(nullptr)
{
//ctor
}
TEDEvent::~TEDEvent()
{
//dtor
if (this->nextEvent!=nullptr)
delete (nextEvent);
}
void TEDEvent::print()
{
std::string s;
CharChange* p;
switch (eventType)
{
case EventNone : s="NO EVENT";
std::cout << "[TEDEvent::print] " << s << std::endl;
break;
case EventKey : s="KEY";
std::cout << "[TEDEvent::print] " << s <<std::endl;
p=charList;
for (p=charList;p!=nullptr;p=p->Getnext())
{
std::cout << "[TEDEvent::print] old" << p->GetOldChar() <<std::endl;
std::cout << "[TEDEvent::print] new" << p->GetNewChar() <<std::endl;
std::cout << "[TEDEvent::print] x" << p->GetLoc().x <<std::endl;
std::cout << "[TEDEvent::print] y" << p->GetLoc().y <<std::endl;
}
break;
case EventSave : s="SAVE";
std::cout << "[TEDEvent::print] " << s << std::endl;
break;
case EventLanguage : s="LANGUAGE";
std::cout << "[TEDEvent::print] " << s << std::endl;
break;
}
}
void TEDEvent::dump()
{
TEDEvent* p;
EventType evt;
for (p=this;p!=nullptr;p=p->GetlastEvent())
{
std::cout << "[TEDEvent::dump]" << std::endl;
evt=p->GeteventType();
char oc=p->charList->GetOldChar();
char nc=p->charList->GetNewChar();
std::cout << "Event type=" << evt << "char=" << oc << "=>" << nc << std::endl;
}
}
void TEDEvent::SetnextEvent(TEDEvent* val)
{
// Before setting the next event, clear the previous head.
if (nextEvent!=NULL)
delete nextEvent;
nextEvent = val;
}