diff options
Diffstat (limited to 'tools/mapedit/src/undo.cpp')
| -rw-r--r-- | tools/mapedit/src/undo.cpp | 74 |
1 files changed, 73 insertions, 1 deletions
| diff --git a/tools/mapedit/src/undo.cpp b/tools/mapedit/src/undo.cpp index bcf7b92..12cafc9 100644 --- a/tools/mapedit/src/undo.cpp +++ b/tools/mapedit/src/undo.cpp | |||
| @@ -28,7 +28,7 @@ wxBEGIN_EVENT_TABLE(UndoableTextBox, wxTextCtrl) | |||
| 28 | EVT_KILL_FOCUS(UndoableTextBox::OnKillFocus) | 28 | EVT_KILL_FOCUS(UndoableTextBox::OnKillFocus) |
| 29 | wxEND_EVENT_TABLE() | 29 | wxEND_EVENT_TABLE() |
| 30 | 30 | ||
| 31 | UndoableTextBox::UndoableTextBox(wxWindow* parent, wxWindowID id, wxString startText, std::string undoType, MapeditFrame* realParent, wxPoint pos, wxSize size, long style) : wxTextCtrl(parent, id, startText, pos, size, style) | 31 | UndoableTextBox::UndoableTextBox(wxWindow* parent, wxWindowID id, wxString startText, std::string undoType, MapeditFrame* realParent, const wxPoint& pos, const wxSize& size, long style) : wxTextCtrl(parent, id, startText, pos, size, style) |
| 32 | { | 32 | { |
| 33 | this->undoText = undoType; | 33 | this->undoText = undoType; |
| 34 | this->realParent = realParent; | 34 | this->realParent = realParent; |
| @@ -93,3 +93,75 @@ void UndoableTextBox::Undo::endChanges() | |||
| 93 | { | 93 | { |
| 94 | parent.undo.reset(); | 94 | parent.undo.reset(); |
| 95 | } | 95 | } |
| 96 | |||
| 97 | UndoableChoice::UndoableChoice() | ||
| 98 | { | ||
| 99 | Init(); | ||
| 100 | } | ||
| 101 | |||
| 102 | UndoableChoice::UndoableChoice(wxWindow* parent, wxWindowID id, MapeditFrame* realParent, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) : wxChoice(parent, id, pos, size, n, choices, style, validator, name) | ||
| 103 | { | ||
| 104 | this->realParent = realParent; | ||
| 105 | |||
| 106 | Init(); | ||
| 107 | } | ||
| 108 | |||
| 109 | void UndoableChoice::Init() | ||
| 110 | { | ||
| 111 | Bind(wxEVT_CHOICE, &UndoableChoice::OnChoose, this); | ||
| 112 | } | ||
| 113 | |||
| 114 | void UndoableChoice::OnChoose(wxCommandEvent& event) | ||
| 115 | { | ||
| 116 | int new_selection = GetSelection(); | ||
| 117 | GetValidator()->TransferToWindow(); | ||
| 118 | int old_selection = GetSelection(); | ||
| 119 | |||
| 120 | realParent->commitAction(std::make_shared<Undoable>(("Set " + GetName()).ToStdString(), [=] () { | ||
| 121 | SetSelection(new_selection); | ||
| 122 | GetValidator()->TransferFromWindow(); | ||
| 123 | }, [=] () { | ||
| 124 | SetSelection(old_selection); | ||
| 125 | GetValidator()->TransferFromWindow(); | ||
| 126 | })); | ||
| 127 | |||
| 128 | event.Skip(); | ||
| 129 | } | ||
| 130 | |||
| 131 | wxBEGIN_EVENT_TABLE(UndoableSlider, wxSlider) | ||
| 132 | EVT_SCROLL(UndoableSlider::OnSlide) | ||
| 133 | wxEND_EVENT_TABLE() | ||
| 134 | |||
| 135 | UndoableSlider::UndoableSlider() | ||
| 136 | { | ||
| 137 | Init(); | ||
| 138 | } | ||
| 139 | |||
| 140 | UndoableSlider::UndoableSlider(wxWindow* parent, wxWindowID id, MapeditFrame* realParent, int value, int minvalue, int maxvalue, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) : wxSlider(parent, id, value, minvalue, maxvalue, pos, size, style, validator, name) | ||
| 141 | { | ||
| 142 | this->realParent = realParent; | ||
| 143 | |||
| 144 | Init(); | ||
| 145 | } | ||
| 146 | |||
| 147 | void UndoableSlider::Init() | ||
| 148 | { | ||
| 149 | |||
| 150 | } | ||
| 151 | |||
| 152 | void UndoableSlider::OnSlide(wxScrollEvent& event) | ||
| 153 | { | ||
| 154 | int new_value = GetValue(); | ||
| 155 | GetValidator()->TransferToWindow(); | ||
| 156 | int old_value = GetValue(); | ||
| 157 | |||
| 158 | realParent->commitAction(std::make_shared<Undoable>(("Set " + GetName()).ToStdString(), [=] () { | ||
| 159 | SetValue(new_value); | ||
| 160 | GetValidator()->TransferFromWindow(); | ||
| 161 | }, [=] () { | ||
| 162 | SetValue(old_value); | ||
| 163 | GetValidator()->TransferFromWindow(); | ||
| 164 | })); | ||
| 165 | |||
| 166 | event.Skip(); | ||
| 167 | } | ||
