add pull/push by one structure commands
Brought to you by:
johnston
|
From: <ivt...@li...> - 2000-01-15 12:27:33
|
Patch: ivtools-000115-jgautier-001
For: ivtools-0.7.10
Author: jga...@us...
This is an intermediate patch to ivtools-0.7.10. To apply, cd to the
top-level directory of the ivtools source tree (the directory with src
and config subdirs), and apply like this:
patch -s <ThisFile
Summary of Changes:
This patch adds Pull/Push By One Commands to the Structure menu in drawtool,
also making them available to any OverlayUnidraw based program.
The Back and Front Commands are Executed by being Interpreted first by the
selected Components which add themselves to the Command's Clipboard in
GraphicComp::Interpret (grcomp.c); then their Execute methods get the
Editor's Component to Interpret the Command if the Clipboard is not empty,
and that composite Component modifies the position in the comp tree
(GraphicComps::Interpret).
To implement the Pull/Push By One Commands in OverlayUnidraw we subclass them
from Back and Front Commands respectively. The Execute/Unexecute methods are
identical and thus inherited from their respective base classes (the proto-
typical methods for a Command that is Interpreted by the selected Component
and by the top level Editor's Component.) The subclassed IsA/GetId methods
enable the "add self to clipboard" behavior of Front/Back in GraphicComp::
Interpret; the actual Pull/Push are interpreted in OverlaysComp::Interpret,
carefully placed before the Front/Back so that the more specific one takes
effect. Checking for the end of the list with !Done(j) avoids segfault.
Index: OverlayUnidraw/ovclasses.h
diff -c OverlayUnidraw/ovclasses.h:1.1 OverlayUnidraw/ovclasses.h:1.2
*** OverlayUnidraw/ovclasses.h:1.1 Fri Jan 14 00:17:26 2000
--- src/OverlayUnidraw/ovclasses.h Sat Jan 15 03:53:09 2000
***************
*** 91,96 ****
--- 91,98 ----
#define OVPRECISEROTATE_CMD 2058
#define OVPRECISEPAGE_CMD 2059
#define OVPRECISEBRUSH_CMD 2060
+ #define PUSH_CMD 2061
+ #define PULL_CMD 2062
#define OVERLAY_COMP 2150
#define OVERLAYS_COMP 2151
Index: OverlayUnidraw/ovcmds.c
diff -c OverlayUnidraw/ovcmds.c:1.1 OverlayUnidraw/ovcmds.c:1.2
*** OverlayUnidraw/ovcmds.c:1.1 Fri Jan 14 00:17:26 2000
--- src/OverlayUnidraw/ovcmds.c Sat Jan 15 03:53:10 2000
***************
*** 1507,1509 ****
--- 1507,1537 ----
}
}
}
+
+ /*****************************************************************************/
+
+ ClassId PushCmd::GetClassId () { return PUSH_CMD; }
+ boolean PushCmd::IsA (ClassId id) { return PUSH_CMD==id || BackCmd::IsA(id);}
+
+ PushCmd::PushCmd (ControlInfo* c) : BackCmd(c) { }
+ PushCmd::PushCmd (Editor* ed) : BackCmd(ed) { }
+
+ Command* PushCmd::Copy () {
+ Command* copy = new PushCmd(CopyControlInfo());
+ InitCopy(copy);
+ return copy;
+ }
+
+ /*****************************************************************************/
+
+ ClassId PullCmd::GetClassId () { return PULL_CMD; }
+ boolean PullCmd::IsA (ClassId id) { return PULL_CMD==id || FrontCmd::IsA(id);}
+
+ PullCmd::PullCmd (ControlInfo* c) : FrontCmd(c) { }
+ PullCmd::PullCmd (Editor* ed) : FrontCmd(ed) { }
+
+ Command* PullCmd::Copy () {
+ Command* copy = new PullCmd(CopyControlInfo());
+ InitCopy(copy);
+ return copy;
+ }
Index: OverlayUnidraw/ovcmds.h
diff -c OverlayUnidraw/ovcmds.h:1.1 OverlayUnidraw/ovcmds.h:1.2
*** OverlayUnidraw/ovcmds.h:1.1 Fri Jan 14 00:17:26 2000
--- src/OverlayUnidraw/ovcmds.h Sat Jan 15 03:53:10 2000
***************
*** 401,404 ****
--- 401,426 ----
int& ni, int*& ix, int*& iy);
};
+ //: command to push down one level in the graphical structure
+ class PushCmd : public BackCmd {
+ public:
+ PushCmd(ControlInfo*);
+ PushCmd(Editor* = nil);
+
+ virtual Command* Copy();
+ virtual ClassId GetClassId();
+ virtual boolean IsA(ClassId);
+ };
+
+ //: command to pull up one level in the graphical structure
+ class PullCmd : public FrontCmd {
+ public:
+ PullCmd(ControlInfo*);
+ PullCmd(Editor* = nil);
+
+ virtual Command* Copy();
+ virtual ClassId GetClassId();
+ virtual boolean IsA(ClassId);
+ };
+
#endif
Index: OverlayUnidraw/ovcomps.c
diff -c OverlayUnidraw/ovcomps.c:1.1 OverlayUnidraw/ovcomps.c:1.2
*** OverlayUnidraw/ovcomps.c:1.1 Fri Jan 14 00:17:26 2000
--- src/OverlayUnidraw/ovcomps.c Sat Jan 15 03:53:10 2000
***************
*** 604,609 ****
--- 604,649 ----
cmd->GetClipboard()->Append(this);
}
+ } else if (cmd->IsA(PUSH_CMD) || cmd->IsA(PULL_CMD)) {
+ Component* edComp = cmd->GetEditor()->GetComponent();
+
+ if (edComp == (Component*) this) {
+ Clipboard* cb = cmd->GetClipboard();
+ Iterator i;
+
+ if (cmd->IsA(PULL_CMD)) {
+ for (cb->First(i); !cb->Done(i); cb->Next(i)) {
+ OverlayComp* comp = (OverlayComp*)cb->GetComp(i);
+ Iterator j;
+ SetComp(comp, j);
+ Next(j);
+ StorePosition(comp, cmd);
+ if (!Done(j)) {
+ Remove(comp);
+ InsertAfter(j, comp);
+ }
+ }
+
+ } else {
+ for (cb->Last(i); !cb->Done(i); cb->Prev(i)) {
+ OverlayComp* comp = (OverlayComp*) cb->GetComp(i);
+ Iterator j;
+ SetComp(comp, j);
+ Prev(j);
+ StorePosition(comp, cmd);
+ if (!Done(j)) {
+ Remove(comp);
+ InsertBefore(j, comp);
+ }
+ }
+ }
+ Notify();
+ unidraw->Update();
+
+ } else {
+ OverlayComp::Interpret(cmd);
+ }
+
} else if (cmd->IsA(FRONT_CMD) || cmd->IsA(BACK_CMD)) {
Component* edComp = cmd->GetEditor()->GetComponent();
Index: OverlayUnidraw/ovcreator.c
diff -c OverlayUnidraw/ovcreator.c:1.1 OverlayUnidraw/ovcreator.c:1.2
*** OverlayUnidraw/ovcreator.c:1.1 Fri Jan 14 00:17:26 2000
--- src/OverlayUnidraw/ovcreator.c Sat Jan 15 03:53:10 2000
***************
*** 62,67 ****
--- 62,69 ----
ClassId id, istream& in, ObjectMap* objmap, int objid
) {
switch (id) {
+ case PUSH_CMD: CREATE(PushCmd, in, objmap, objid);
+ case PULL_CMD: CREATE(PullCmd, in, objmap, objid);
default: return IdrawCreator::Create(id, in,objmap,objid);
}
}
Index: OverlayUnidraw/ovkit.c
diff -c OverlayUnidraw/ovkit.c:1.1 OverlayUnidraw/ovkit.c:1.2
*** OverlayUnidraw/ovkit.c:1.1 Fri Jan 14 00:17:26 2000
--- src/OverlayUnidraw/ovkit.c Sat Jan 15 03:53:10 2000
***************
*** 877,882 ****
--- 877,888 ----
MakeMenu(mbi, new BackCmd(new ControlInfo("Send to Back",
KLBL_BACK, CODE_BACK)),
"Send to Back ");
+ MakeMenu(mbi, new PullCmd(new ControlInfo("Pull Up One"
+ )),
+ "Pull Up One ");
+ MakeMenu(mbi, new PushCmd(new ControlInfo("Push Down One"
+ )),
+ "Push Down One ");
return mbi;
}
|