blob: 794f993d009e52cacef9ee17fd381e8992549237 (
plain) (
blame)
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
|
#ifndef UNDO_H
#define UNDO_H
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <functional>
#include <string>
#include <list>
class MapeditFrame;
class Undoable {
public:
Undoable(std::string title, std::function<void ()> forward, std::function<void ()> backward);
virtual std::string getTitle() const;
virtual void apply();
virtual void undo();
virtual void endChanges() {}
protected:
Undoable() {}
std::string title;
std::function<void ()> forward;
std::function<void ()> backward;
};
class UndoableTextBox : public wxTextCtrl {
public:
UndoableTextBox();
UndoableTextBox(wxWindow* parent, wxWindowID id, wxString startText, std::string undoType, MapeditFrame* realParent, wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize, long style = 0);
private:
class Undo : public Undoable {
public:
Undo(std::string title, wxString origText, UndoableTextBox& parent);
void apply();
void undo();
void endChanges();
wxString origText;
wxString newText;
UndoableTextBox& parent;
};
void Init();
void OnFocus(wxFocusEvent& event);
void OnKillFocus(wxFocusEvent& event);
void OnTextChange(wxCommandEvent& event);
MapeditFrame* realParent;
std::string undoText;
wxString curText;
std::shared_ptr<Undo> undo;
wxDECLARE_EVENT_TABLE();
};
#endif
|