-
Notifications
You must be signed in to change notification settings - Fork 2
/
levelonecommands.h
286 lines (222 loc) · 6.97 KB
/
levelonecommands.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*
* Copyright (C) 2020-2024 Gavin MacGregor
*
* This file is part of QTeletextMaker.
*
* QTeletextMaker 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 3 of the License, or
* (at your option) any later version.
*
* QTeletextMaker 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 QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef LEVELONECOMMANDS_H
#define LEVELONECOMMANDS_H
#include <QByteArrayList>
#include <QUndoCommand>
#include "document.h"
class LevelOneCommand : public QUndoCommand
{
public:
LevelOneCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
protected:
TeletextDocument *m_teletextDocument;
int m_subPageIndex, m_row, m_column;
bool m_firstDo;
};
class StoreOldCharactersCommand : public LevelOneCommand
{
public:
StoreOldCharactersCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
protected:
void storeOldCharacters(int topRow, int leftColumn, int bottomRow, int rightColumn);
void retrieveOldCharacters(int topRow, int leftColumn, int bottomRow, int rightColumn);
QByteArrayList m_oldCharacters;
};
class TypeCharacterCommand : public LevelOneCommand
{
public:
enum { Id = 101 };
TypeCharacterCommand(TeletextDocument *teletextDocument, unsigned char newCharacter, bool insertMode, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return Id; }
private:
unsigned char m_newCharacter, m_oldRowContents[40], m_newRowContents[40];
int m_columnStart, m_columnEnd;
bool m_insertMode;
};
class ToggleMosaicBitCommand : public LevelOneCommand
{
public:
enum { Id = 102 };
ToggleMosaicBitCommand(TeletextDocument *teletextDocument, unsigned char bitToToggle, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return Id; }
private:
unsigned char m_oldCharacter, m_newCharacter;
};
class BackspaceKeyCommand : public LevelOneCommand
{
public:
enum { Id = 103 };
BackspaceKeyCommand(TeletextDocument *teletextDocument, bool insertMode, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return Id; }
private:
unsigned char m_oldRowContents[40], m_newRowContents[40];
int m_columnStart, m_columnEnd;
bool m_insertMode;
};
class DeleteKeyCommand : public LevelOneCommand
{
public:
enum { Id = 104 };
DeleteKeyCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return Id; }
private:
unsigned char m_oldRowContents[40], m_newRowContents[40];
};
class InsertSubPageCommand : public LevelOneCommand
{
public:
InsertSubPageCommand(TeletextDocument *teletextDocument, bool afterCurrentSubPage, bool copySubPage, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
private:
int m_newSubPageIndex;
bool m_copySubPage;
};
class DeleteSubPageCommand : public LevelOneCommand
{
public:
DeleteSubPageCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
};
class InsertRowCommand : public LevelOneCommand
{
public:
InsertRowCommand(TeletextDocument *teletextDocument, bool copyRow, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
private:
bool m_copyRow;
unsigned char m_deletedBottomRow[40];
};
class DeleteRowCommand : public LevelOneCommand
{
public:
DeleteRowCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
private:
unsigned char m_deletedRow[40];
};
#ifndef QT_NO_CLIPBOARD
class CutCommand : public StoreOldCharactersCommand
{
public:
CutCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
private:
int m_selectionTopRow, m_selectionBottomRow, m_selectionLeftColumn, m_selectionRightColumn;
int m_selectionCornerRow, m_selectionCornerColumn;
};
class PasteCommand : public StoreOldCharactersCommand
{
public:
PasteCommand(TeletextDocument *teletextDocument, int pageCharSet, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
private:
QByteArrayList m_pastingCharacters;
int m_pasteTopRow, m_pasteBottomRow, m_pasteLeftColumn, m_pasteRightColumn;
int m_clipboardDataHeight, m_clipboardDataWidth;
int m_selectionCornerRow, m_selectionCornerColumn;
bool m_selectionActive, m_plainText;
};
#endif // !QT_NO_CLIPBOARD
class SetFullScreenColourCommand : public LevelOneCommand
{
public:
enum { Id = 105 };
SetFullScreenColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return Id; }
private:
int m_oldColour, m_newColour;
};
class SetFullRowColourCommand : public LevelOneCommand
{
public:
enum { Id = 106 };
SetFullRowColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return Id; }
private:
int m_oldColour, m_newColour;
};
class SetCLUTRemapCommand : public LevelOneCommand
{
public:
enum { Id = 107 };
SetCLUTRemapCommand(TeletextDocument *teletextDocument, int newMap, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return Id; }
private:
int m_oldMap, m_newMap;
};
class SetBlackBackgroundSubstCommand : public LevelOneCommand
{
public:
enum { Id = 108 };
SetBlackBackgroundSubstCommand(TeletextDocument *teletextDocument, bool newSub, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return Id; }
private:
int m_oldSub, m_newSub;
};
class SetColourCommand : public LevelOneCommand
{
public:
SetColourCommand(TeletextDocument *teletextDocument, int colourIndex, int newColour, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
private:
int m_colourIndex, m_oldColour, m_newColour;
};
class ResetCLUTCommand : public LevelOneCommand
{
public:
ResetCLUTCommand(TeletextDocument *teletextDocument, int colourTable, QUndoCommand *parent = 0);
void redo() override;
void undo() override;
private:
int m_colourTable;
int m_oldColourEntry[8];
};
#endif