5 * Created by Toshi Nagata on 08/10/25.
6 * Copyright 2008 Toshi Nagata. All rights reserved.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation version 2 of the License.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
18 // For compilers that support precompilation, includes "wx/wx.h".
19 #include "wx/wxprec.h"
29 #if !wxUSE_DOC_VIEW_ARCHITECTURE
30 #error "You should have DocView architecture enabled in your wxWidgets installation."
33 #include "MoleculeView.h"
34 #include "MyCommand.h"
35 #include "MyDocument.h"
37 MyCommand::MyCommand(Molecule *aMolecule, const wxString& name):
40 mol = MoleculeRetain(aMolecule);
41 undoActions = redoActions = NULL;
42 numUndoActions = numRedoActions = 0;
45 MyCommand::~MyCommand()
48 SetUndoActions(NULL, 0);
49 SetRedoActions(NULL, 0);
53 MyCommand::SetUndoActions(MolAction **actions, int count)
56 if (undoActions != NULL) {
57 for (i = 0; i < numUndoActions; i++)
58 MolActionRelease(undoActions[i]);
61 undoActions = actions;
62 numUndoActions = count;
66 MyCommand::SetRedoActions(MolAction **actions, int count)
69 if (redoActions != NULL) {
70 for (i = 0; i < numRedoActions; i++)
71 MolActionRelease(redoActions[i]);
74 redoActions = actions;
75 numRedoActions = count;
81 MyDocument *doc = MyDocumentFromMolecule(mol);
85 if (redoActions != NULL) {
86 doc->SetCurrentCommand(this);
87 for (i = numRedoActions - 1; i >= 0; i--) {
88 if (MolActionPerform(mol, redoActions[i]) != 0) {
93 doc->CleanUndoStack(retval);
103 MyDocument *doc = MyDocumentFromMolecule(mol);
107 if (undoActions != NULL) {
108 doc->SetIsUndoing(true);
109 doc->SetCurrentCommand(this);
110 for (i = numUndoActions - 1; i >= 0; i--) {
111 if (MolActionPerform(mol, undoActions[i]) != 0) {
116 doc->CleanUndoStack(retval);