summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/metauml/util_picture_stack.mp
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/metapost/metauml/util_picture_stack.mp')
-rw-r--r--Master/texmf-dist/metapost/metauml/util_picture_stack.mp62
1 files changed, 32 insertions, 30 deletions
diff --git a/Master/texmf-dist/metapost/metauml/util_picture_stack.mp b/Master/texmf-dist/metapost/metauml/util_picture_stack.mp
index e1a1a51bfba..edade327ef8 100644
--- a/Master/texmf-dist/metapost/metauml/util_picture_stack.mp
+++ b/Master/texmf-dist/metapost/metauml/util_picture_stack.mp
@@ -1,19 +1,5 @@
-% MetaUtil, an easier MetaPost life
-% Copyright (C) 2005 Ovidiu Gheorghies
-%
-% This program 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 2
-% of the License, or (at your option) any later version.
-%
-% This program 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 this program; if not, write to the Free Software
-% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+% Copyright 2005 2015 Ovidiu Gheorghies
+% Licensed under the Apache License, Version 2.0.
if known _util_picture_stack_mp:
expandafter endinput
@@ -44,32 +30,36 @@ inputonce util_log;
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-vardef PictureStackInfo@#(expr pleft, pright, ptop, pbottom)(text pspacing)(text ppictInfo)=
+%% Style for a stack of child pictures with the given margins, spacing between children, and a common child style.
+%% If child style supplier @#childStyleSupplier is set, it takes precedence over the common child style.
+%% The child style supplier must be the name of a macro taking a child index as an argument and returning a child style.
+vardef PictureStackInfo@#(expr marginLeft, marginRight, marginTop, marginBottom)(text _spacing)(text _childStyle)=
attributes(@#);
var(numeric) boxed;
var(color) borderColor;
-
- var(numeric) left, right, top, bottom;
var(numeric) spacing;
+ var(string) childStyleSupplier;
- Margins@#(pleft, pright, ptop, pbottom);
+ Margins@#(marginLeft, marginRight, marginTop, marginBottom);
- @#spacing := pspacing;
+ @#spacing := _spacing;
@#boxed := 0;
@#borderColor := green;
- PictureInfoCopy.@#iPict(ppictInfo);
+ @#childStyleSupplier := "";
+
+ PictureInfoCopy.@#iPict(_childStyle);
enddef;
vardef PictureStackInfoCopy@#(text src)=
PictureStackInfo@#(src.left, src.right, src.top, src.bottom)(src.spacing)(src.iPict);
+ @#childStyleSupplier := src.childStyleSupplier;
@#boxed := src.boxed;
@#borderColor := src.borderColor;
enddef;
-log "*** Creating iStack...";
PictureStackInfo.iStack(2, 2, 2, 2)(2)(iPict);
vardef EPictureStack@#(text pictStackInfo)(text thePictures)(text how)=
@@ -81,14 +71,23 @@ vardef EPictureStack@#(text pictStackInfo)(text thePictures)(text how)=
attributes(@#);
var(numeric) nItems;
var(numeric) minx, miny, maxx, maxy;
- var(string) picturesAsString;
- var(string) joinMethod;
-
- @#joinMethod := how;
+ var(string) picturesAsString;
+ %var(text) joinMethod;
+
+ string @#joinMethod;
+
+ %@#joinMethod := str how;
+ for l=how:
+ @#joinMethod := l;
+ endfor;
@#nItems := 0;
for p=thePictures:
- EPicture.@#pict[@#nItems](@#info.iPict)(p);
+ if (@#info.childStyleSupplier <> ""):
+ EPicture.@#pict[@#nItems](scantokens (@#info.childStyleSupplier)(@#nItems))(p);
+ else:
+ EPicture.@#pict[@#nItems](@#info.iPict)(p);
+ fi;
@#nItems := @#nItems + 1;
endfor;
@@ -105,10 +104,10 @@ vardef PictureStack@#(text thePictures)(text how)=
enddef;
vardef PictureStack_layout@#=
- if @#layedout = 1:
+ if @#laidout = 1:
log "PictureStack " & (str @#) & " has already been layed out";
else:
- @#layedout := 1;
+ @#laidout := 1;
layoutObjects(scantokens @#picturesAsString);
@@ -124,6 +123,9 @@ vardef PictureStack_layout@#=
setObjectJoin(pa.midx=pb.midx; pa.bottom = pb.bottom + @#info.spacing);
elseif @#joinMethod = "vrightbase":
setObjectJoin(pa.right=pb.right; pa.bottom = pb.bottom + @#info.spacing);
+ else:
+ setObjectJoin(pa.c = pb.c); % By default, stack objects on top of each other.
+ scantokens @#joinMethod;
fi;
joinObjects(scantokens @#picturesAsString);