-
Notifications
You must be signed in to change notification settings - Fork 3
/
CDoUndoManage.h
134 lines (118 loc) · 1.88 KB
/
CDoUndoManage.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
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef _CDOUNDOMANAGE_H
#define _CDOUNDOMANAGE_H 1
#include <iostream>
#include <stack>
#include "ortaq.h"
using namespace std;
typedef struct QelipDoUnddo
{
ULONG m_Pos;
wchar_t *esli_Text;
wchar_t *yengi_Text;
}DOUNDO,*LPDOUNDO;
class CDoUndoManage
{
private:
stack<LPDOUNDO> m_UnDO;
stack<LPDOUNDO> m_ReDO;
public:
CDoUndoManage()
{
}
~CDoUndoManage()
{
clear();
}
LPDOUNDO getUndo()
{
LPDOUNDO top=m_UnDO.top();
m_UnDO.pop();
m_ReDO.push(top);
return top;
}
BOOL isUnDoEmpyty()
{
BOOL ret=FALSE;
if(m_UnDO.size()==0)
{
ret=TRUE;
}
return ret;
}
BOOL isReDoEmpyty()
{
BOOL ret=FALSE;
if(m_ReDO.size()==0)
{
ret=TRUE;
}
return ret;
}
LPDOUNDO getRedo()
{
LPDOUNDO top=m_ReDO.top();
m_ReDO.pop();
m_UnDO.push(top);
return top;
}
void clear()
{
LPDOUNDO top;
while(m_UnDO.size()!=0)
{
top=m_UnDO.top();
m_UnDO.pop();
if(top->esli_Text!=NULL)
{
delete[] top->esli_Text;
top->esli_Text=NULL;
}
if(top->yengi_Text!=NULL)
{
delete[] top->yengi_Text;
top->yengi_Text=NULL;
}
delete top;
top=NULL;
}
while(m_ReDO.size()!=0)
{
top=m_ReDO.top();
m_ReDO.pop();
if(top->esli_Text!=NULL)
delete[] top->esli_Text;
if(top->yengi_Text!=NULL)
delete[] top->yengi_Text;
delete top;
}
}
void clearRedo()
{
LPDOUNDO top;
while(m_ReDO.size()!=0)
{
top=m_ReDO.top();
m_ReDO.pop();
if(top->esli_Text!=NULL)
{
delete[] top->esli_Text;
top->esli_Text=NULL;
}
if(top->yengi_Text!=NULL)
{
delete[] top->yengi_Text;
top->yengi_Text=NULL;
}
delete top;
}
}
void Add(LPDOUNDO newDo)
{
if(isReDoEmpyty()==FALSE)
{
clearRedo();
}
m_UnDO.push(newDo);
}
};
#endif