mp-cont.mpiv /size: 10 Kb    last modification: 2021-10-28 13:50
1%D \module
2%D   [       file=mp-cont.mpiv,
3%D        version=1999.03.10,
4%D          title=\CONTEXT\ \METAPOST\ graphics,
5%D       subtitle=Interfaces,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D This module is rather preliminary and subjected to changes.
15
16if known context_cont : endinput ; fi ;
17
18boolean context_cont ; context_cont := true ;
19
20string CurrentLayout ; CurrentLayout := "default" ;
21
22boolean mfun_swapped ;
23
24def SwapPageState =
25    mfun_swapped := true ; % eventually this will go !
26enddef ;
27
28extra_beginfig := extra_beginfig & "mfun_swapped := false ;" ;
29
30% runscript("mp.PaperHeight()") is much faster than lua.mp.PaperHeight() so we use that now:
31
32vardef PaperHeight          = runscript("mp.PaperHeight()")          enddef ;
33vardef PaperWidth           = runscript("mp.PaperWidth()")           enddef ;
34vardef PrintPaperHeight     = runscript("mp.PrintPaperHeight()")     enddef ;
35vardef PrintPaperWidth      = runscript("mp.PrintPaperWidth()")      enddef ;
36vardef TopSpace             = runscript("mp.TopSpace()")             enddef ;
37vardef BottomSpace          = runscript("mp.BottomSpace()")          enddef ;
38vardef BackSpace            = runscript("mp.BackSpace()")            enddef ;
39vardef CutSpace             = runscript("mp.CutSpace()")             enddef ;
40vardef MakeupHeight         = runscript("mp.MakeupHeight()")         enddef ;
41vardef MakeupWidth          = runscript("mp.MakeupWidth()")          enddef ;
42vardef TopHeight            = runscript("mp.TopHeight()")            enddef ;
43vardef TopDistance          = runscript("mp.TopDistance()")          enddef ;
44vardef HeaderHeight         = runscript("mp.HeaderHeight()")         enddef ;
45vardef HeaderDistance       = runscript("mp.HeaderDistance()")       enddef ;
46vardef TextHeight           = runscript("mp.TextHeight()")           enddef ;
47vardef FooterDistance       = runscript("mp.FooterDistance()")       enddef ;
48vardef FooterHeight         = runscript("mp.FooterHeight()")         enddef ;
49vardef BottomDistance       = runscript("mp.BottomDistance()")       enddef ;
50vardef BottomHeight         = runscript("mp.BottomHeight()")         enddef ;
51vardef LeftEdgeWidth        = runscript("mp.LeftEdgeWidth()")        enddef ;
52vardef LeftEdgeDistance     = runscript("mp.LeftEdgeDistance()")     enddef ;
53vardef LeftMarginWidth      = runscript("mp.LeftMarginWidth()")      enddef ;
54vardef LeftMarginDistance   = runscript("mp.LeftMarginDistance()")   enddef ;
55vardef TextWidth            = runscript("mp.TextWidth()")            enddef ;
56vardef RightMarginDistance  = runscript("mp.RightMarginDistance()")  enddef ;
57vardef RightMarginWidth     = runscript("mp.RightMarginWidth()")     enddef ;
58vardef RightEdgeDistance    = runscript("mp.RightEdgeDistance()")    enddef ;
59vardef RightEdgeWidth       = runscript("mp.RightEdgeWidth()")       enddef ;
60vardef InnerMarginDistance  = runscript("mp.InnerMarginDistance()")  enddef ;
61vardef InnerMarginWidth     = runscript("mp.InnerMarginWidth()")     enddef ;
62vardef OuterMarginDistance  = runscript("mp.OuterMarginDistance()")  enddef ;
63vardef OuterMarginWidth     = runscript("mp.OuterMarginWidth()")     enddef ;
64vardef InnerEdgeDistance    = runscript("mp.InnerEdgeDistance()")    enddef ;
65vardef InnerEdgeWidth       = runscript("mp.InnerEdgeWidth()")       enddef ;
66vardef OuterEdgeDistance    = runscript("mp.OuterEdgeDistance()")    enddef ;
67vardef OuterEdgeWidth       = runscript("mp.OuterEdgeWidth()")       enddef ;
68vardef PageOffset           = runscript("mp.PageOffset()")           enddef ;
69vardef PageDepth            = runscript("mp.PageDepth()")            enddef ;
70vardef LayoutColumns        = runscript("mp.LayoutColumns()")        enddef ;
71vardef LayoutColumnDistance = runscript("mp.LayoutColumnDistance()") enddef ;
72vardef LayoutColumnWidth    = runscript("mp.LayoutColumnWidth()")    enddef ;
73
74vardef OnRightPage          = runscript("mp.OnRightPage()")          enddef ;
75vardef OnOddPage            = runscript("mp.OnOddPage()")            enddef ;
76vardef InPageBody           = runscript("mp.InPageBody()")           enddef ;
77
78vardef RealPageNumber       = runscript("mp.RealPageNumber()")       enddef ;
79vardef LastPageNumber       = runscript("mp.LastPageNumber()")       enddef ; % duplicates
80
81vardef PageNumber           = runscript("mp.PageNumber()")           enddef ;
82vardef NOfPages             = runscript("mp.NOfPages()")             enddef ;
83
84vardef SubPageNumber        = runscript("mp.SubPageNumber()")        enddef ;
85vardef NOfSubPages          = runscript("mp.NOfSubPages()")          enddef ;
86
87vardef CurrentColumn        = runscript("mp.CurrentColumn()")        enddef ;
88vardef NOfColumns           = runscript("mp.NOfColumns()")           enddef ;
89
90vardef BaseLineSkip         = runscript("mp.BaseLineSkip()")         enddef ;
91vardef LineHeight           = runscript("mp.LineHeight()")           enddef ;
92vardef BodyFontSize         = runscript("mp.BodyFontSize()")         enddef ;
93
94vardef TopSkip              = runscript("mp.TopSkip()")              enddef ;
95vardef StrutHeight          = runscript("mp.StrutHeight()")          enddef ;
96vardef StrutDepth           = runscript("mp.StrutDepth()")           enddef ;
97
98vardef CurrentWidth         = runscript("mp.CurrentWidth()")         enddef ;
99vardef CurrentHeight        = runscript("mp.CurrentHeight()")        enddef ;
100
101vardef HSize                = runscript("mp.HSize()")                enddef ; % duplicates
102vardef VSize                = runscript("mp.VSize()")                enddef ; % duplicates
103
104vardef EmWidth              = runscript("mp.EmWidth()")              enddef ;
105vardef ExHeight             = runscript("mp.ExHeight()")             enddef ;
106
107vardef PageFraction         = runscript("mp.PageFraction()")         enddef ;
108
109vardef SpineWidth           = runscript("mp.SpineWidth()")           enddef ;
110vardef PaperBleed           = runscript("mp.PaperBleed()")           enddef ;
111
112%      CurrentLayout        = runscript("mp.CurrentLayout()")    enddef ;
113vardef OverlayWidth         = runscript("mp.OverlayWidth()")     enddef ;
114vardef OverlayHeight        = runscript("mp.OverlayHeight()")    enddef ;
115vardef OverlayDepth         = runscript("mp.OverlayDepth()")     enddef ;
116vardef OverlayLineWidth     = runscript("mp.OverlayLineWidth()") enddef ;
117vardef OverlayOffset        = runscript("mp.OverlayOffset()")    enddef ;
118vardef OverlayRegion        = runscript("mp.OverlayRegion()")    enddef ;
119%      OverlayLineColor     = runscript("mp.OverlayLineColor()") enddef ;
120%      OverlayColor         = runscript("mp.OverlayColor()")     enddef ;
121
122vardef defaultcolormodel    = runscript("mp.defaultcolormodel()") enddef ;
123
124vardef LeftMarginWidth     = if mfun_swapped and not OnRightPage : runscript("mp.RightMarginWidth()")    else : runscript("mp.LeftMarginWidth()")     fi enddef ;
125vardef RightMarginWidth    = if mfun_swapped and not OnRightPage : runscript("mp.LeftMarginWidth()")     else : runscript("mp.RightMarginWidth()")    fi enddef ;
126vardef LeftMarginDistance  = if mfun_swapped and not OnRightPage : runscript("mp.RightMarginDistance()") else : runscript("mp.LeftMarginDistance()")  fi enddef ;
127vardef RightMarginDistance = if mfun_swapped and not OnRightPage : runscript("mp.LeftMarginDistance()")  else : runscript("mp.RightMarginDistance()") fi enddef ;
128
129vardef LeftEdgeWidth       = if mfun_swapped and not OnRightPage : runscript("mp.RightEdgeWidth()")      else : runscript("mp.LeftEdgeWidth()")       fi enddef ;
130vardef RightEdgeWidth      = if mfun_swapped and not OnRightPage : runscript("mp.LeftEdgeWidth()")       else : runscript("mp.RightEdgeWidth()")      fi enddef ;
131vardef LeftEdgeDistance    = if mfun_swapped and not OnRightPage : runscript("mp.RightEdgeDistance()")   else : runscript("mp.LeftEdgeDistance()")    fi enddef ;
132vardef RightEdgeDistance   = if mfun_swapped and not OnRightPage : runscript("mp.LeftEdgeDistance()")    else : runscript("mp.RightEdgeDistance()")   fi enddef ;
133
134vardef BackSpace           = if mfun_swapped and not OnRightPage : PaperWidth - MakeupWidth - fi runscript("mp.BackSpace()") enddef ;
135vardef CutSpace            = if mfun_swapped and not OnRightPage : PaperWidth - MakeupWidth - fi runscript("mp.CutSpace()")  enddef ;
136
137% better use:
138
139vardef OuterMarginWidth    = if not OnRightPage : runscript("mp.LeftMarginWidth()")     else : runscript("mp.RightMarginWidth()")    fi enddef ;
140vardef InnerMarginWidth    = if not OnRightPage : runscript("mp.RightMarginWidth()")    else : runscript("mp.LeftMarginWidth()")     fi enddef ;
141vardef OuterMarginDistance = if not OnRightPage : runscript("mp.LeftMarginDistance()")  else : runscript("mp.RightMarginDistance()") fi enddef ;
142vardef InnerMarginDistance = if not OnRightPage : runscript("mp.RightMarginDistance()") else : runscript("mp.LeftMarginDistance()")  fi enddef ;
143
144vardef OuterEdgeWidth      = if not OnRightPage : runscript("mp.LeftEdgeWidth()")       else : runscript("mp.RightEdgeWidth()")      fi enddef ;
145vardef InnerEdgeWidth      = if not OnRightPage : runscript("mp.RightEdgeWidth()")      else : runscript("mp.LeftEdgeWidth()")       fi enddef ;
146vardef OuterEdgeDistance   = if not OnRightPage : runscript("mp.LeftEdgeDistance()")    else : runscript("mp.RightEdgeDistance()")   fi enddef ;
147vardef InnerEdgeDistance   = if not OnRightPage : runscript("mp.RightEdgeDistance()")   else : runscript("mp.LeftEdgeDistance()")    fi enddef ;
148
149vardef OuterSpaceWidth     = if not OnRightPage : runscript("mp.BackSpace()")           else : runscript("mp.CutSpace()")            fi enddef ;
150vardef InnerSpaceWidth     = if not OnRightPage : runscript("mp.CutSpace()")            else : runscript("mp.BackSpace()")           fi enddef ;
151
152% indices
153
154vardef OuterMargin = if not OnRightPage : LeftMargin  else : RightMargin fi enddef ;
155vardef InnerMargin = if not OnRightPage : RightMargin else : LeftMargin  fi enddef ;
156
157vardef OuterEdge   = if not OnRightPage : LeftEdge    else : RightEdge   fi enddef ;
158vardef InnerEdge   = if not OnRightPage : RightEdge   else : LeftEdge    fi enddef ;
159