summaryrefslogtreecommitdiff
path: root/metapost/context/base/mpiv/mp-cont.mpiv
blob: 083286bee44c2d790005b3ae6c2f95511ec3127b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
%D \module
%D   [       file=mp-cont.mpiv,
%D        version=1999.03.10,
%D          title=\CONTEXT\ \METAPOST\ graphics,
%D       subtitle=Interfaces,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D This module is rather preliminary and subjected to changes.

if known context_cont : endinput ; fi ;

boolean context_cont ; context_cont := true ;

string CurrentLayout ; CurrentLayout := "default" ;

boolean mfun_swapped ;

def SwapPageState =
    mfun_swapped := true ; % eventually this will go !
enddef ;

extra_beginfig := extra_beginfig & "mfun_swapped := false ;" ;

% runscript("mp.PaperHeight()") is much faster than lua.mp.PaperHeight() so we use that now:

vardef PaperHeight          = runscript("mp.PaperHeight()")          enddef ;
vardef PaperWidth           = runscript("mp.PaperWidth()")           enddef ;
vardef PrintPaperHeight     = runscript("mp.PrintPaperHeight()")     enddef ;
vardef PrintPaperWidth      = runscript("mp.PrintPaperWidth()")      enddef ;
vardef TopSpace             = runscript("mp.TopSpace()")             enddef ;
vardef BottomSpace          = runscript("mp.BottomSpace()")          enddef ;
vardef BackSpace            = runscript("mp.BackSpace()")            enddef ;
vardef CutSpace             = runscript("mp.CutSpace()")             enddef ;
vardef MakeupHeight         = runscript("mp.MakeupHeight()")         enddef ;
vardef MakeupWidth          = runscript("mp.MakeupWidth()")          enddef ;
vardef TopHeight            = runscript("mp.TopHeight()")            enddef ;
vardef TopDistance          = runscript("mp.TopDistance()")          enddef ;
vardef HeaderHeight         = runscript("mp.HeaderHeight()")         enddef ;
vardef HeaderDistance       = runscript("mp.HeaderDistance()")       enddef ;
vardef TextHeight           = runscript("mp.TextHeight()")           enddef ;
vardef FooterDistance       = runscript("mp.FooterDistance()")       enddef ;
vardef FooterHeight         = runscript("mp.FooterHeight()")         enddef ;
vardef BottomDistance       = runscript("mp.BottomDistance()")       enddef ;
vardef BottomHeight         = runscript("mp.BottomHeight()")         enddef ;
vardef LeftEdgeWidth        = runscript("mp.LeftEdgeWidth()")        enddef ;
vardef LeftEdgeDistance     = runscript("mp.LeftEdgeDistance()")     enddef ;
vardef LeftMarginWidth      = runscript("mp.LeftMarginWidth()")      enddef ;
vardef LeftMarginDistance   = runscript("mp.LeftMarginDistance()")   enddef ;
vardef TextWidth            = runscript("mp.TextWidth()")            enddef ;
vardef RightMarginDistance  = runscript("mp.RightMarginDistance()")  enddef ;
vardef RightMarginWidth     = runscript("mp.RightMarginWidth()")     enddef ;
vardef RightEdgeDistance    = runscript("mp.RightEdgeDistance()")    enddef ;
vardef RightEdgeWidth       = runscript("mp.RightEdgeWidth()")       enddef ;
vardef InnerMarginDistance  = runscript("mp.InnerMarginDistance()")  enddef ;
vardef InnerMarginWidth     = runscript("mp.InnerMarginWidth()")     enddef ;
vardef OuterMarginDistance  = runscript("mp.OuterMarginDistance()")  enddef ;
vardef OuterMarginWidth     = runscript("mp.OuterMarginWidth()")     enddef ;
vardef InnerEdgeDistance    = runscript("mp.InnerEdgeDistance()")    enddef ;
vardef InnerEdgeWidth       = runscript("mp.InnerEdgeWidth()")       enddef ;
vardef OuterEdgeDistance    = runscript("mp.OuterEdgeDistance()")    enddef ;
vardef OuterEdgeWidth       = runscript("mp.OuterEdgeWidth()")       enddef ;
vardef PageOffset           = runscript("mp.PageOffset()")           enddef ;
vardef PageDepth            = runscript("mp.PageDepth()")            enddef ;
vardef LayoutColumns        = runscript("mp.LayoutColumns()")        enddef ;
vardef LayoutColumnDistance = runscript("mp.LayoutColumnDistance()") enddef ;
vardef LayoutColumnWidth    = runscript("mp.LayoutColumnWidth()")    enddef ;

vardef OnRightPage          = runscript("mp.OnRightPage()")          enddef ;
vardef OnOddPage            = runscript("mp.OnOddPage()")            enddef ;
vardef InPageBody           = runscript("mp.InPageBody()")           enddef ;

vardef RealPageNumber       = runscript("mp.RealPageNumber()")       enddef ;
vardef LastPageNumber       = runscript("mp.LastPageNumber()")       enddef ; % duplicates

vardef PageNumber           = runscript("mp.PageNumber()")           enddef ;
vardef NOfPages             = runscript("mp.NOfPages()")             enddef ;

vardef SubPageNumber        = runscript("mp.SubPageNumber()")        enddef ;
vardef NOfSubPages          = runscript("mp.NOfSubPages()")          enddef ;

vardef CurrentColumn        = runscript("mp.CurrentColumn()")        enddef ;
vardef NOfColumns           = runscript("mp.NOfColumns()")           enddef ;

vardef BaseLineSkip         = runscript("mp.BaseLineSkip()")         enddef ;
vardef LineHeight           = runscript("mp.LineHeight()")           enddef ;
vardef BodyFontSize         = runscript("mp.BodyFontSize()")         enddef ;

vardef TopSkip              = runscript("mp.TopSkip()")              enddef ;
vardef StrutHeight          = runscript("mp.StrutHeight()")          enddef ;
vardef StrutDepth           = runscript("mp.StrutDepth()")           enddef ;

vardef CurrentWidth         = runscript("mp.CurrentWidth()")         enddef ;
vardef CurrentHeight        = runscript("mp.CurrentHeight()")        enddef ;

vardef HSize                = runscript("mp.HSize()")                enddef ; % duplicates
vardef VSize                = runscript("mp.VSize()")                enddef ; % duplicates

vardef EmWidth              = runscript("mp.EmWidth()")              enddef ;
vardef ExHeight             = runscript("mp.ExHeight()")             enddef ;

vardef PageFraction         = runscript("mp.PageFraction()")         enddef ;

vardef SpineWidth           = runscript("mp.SpineWidth()")           enddef ;
vardef PaperBleed           = runscript("mp.PaperBleed()")           enddef ;

%      CurrentLayout        = runscript("mp.CurrentLayout()")    enddef ;
vardef OverlayWidth         = runscript("mp.OverlayWidth()")     enddef ;
vardef OverlayHeight        = runscript("mp.OverlayHeight()")    enddef ;
vardef OverlayDepth         = runscript("mp.OverlayDepth()")     enddef ;
vardef OverlayLineWidth     = runscript("mp.OverlayLineWidth()") enddef ;
vardef OverlayOffset        = runscript("mp.OverlayOffset()")    enddef ;
vardef OverlayRegion        = runscript("mp.OverlayRegion()")    enddef ;
%      OverlayLineColor     = runscript("mp.OverlayLineColor()") enddef ;
%      OverlayColor         = runscript("mp.OverlayColor()")     enddef ;

vardef defaultcolormodel    = runscript("mp.defaultcolormodel()") enddef ;

vardef LeftMarginWidth     = if mfun_swapped and not OnRightPage : runscript("mp.RightMarginWidth()")    else : runscript("mp.LeftMarginWidth()")     fi enddef ;
vardef RightMarginWidth    = if mfun_swapped and not OnRightPage : runscript("mp.LeftMarginWidth()")     else : runscript("mp.RightMarginWidth()")    fi enddef ;
vardef LeftMarginDistance  = if mfun_swapped and not OnRightPage : runscript("mp.RightMarginDistance()") else : runscript("mp.LeftMarginDistance()")  fi enddef ;
vardef RightMarginDistance = if mfun_swapped and not OnRightPage : runscript("mp.LeftMarginDistance()")  else : runscript("mp.RightMarginDistance()") fi enddef ;

vardef LeftEdgeWidth       = if mfun_swapped and not OnRightPage : runscript("mp.RightEdgeWidth()")      else : runscript("mp.LeftEdgeWidth()")       fi enddef ;
vardef RightEdgeWidth      = if mfun_swapped and not OnRightPage : runscript("mp.LeftEdgeWidth()")       else : runscript("mp.RightEdgeWidth()")      fi enddef ;
vardef LeftEdgeDistance    = if mfun_swapped and not OnRightPage : runscript("mp.RightEdgeDistance()")   else : runscript("mp.LeftEdgeDistance()")    fi enddef ;
vardef RightEdgeDistance   = if mfun_swapped and not OnRightPage : runscript("mp.LeftEdgeDistance()")    else : runscript("mp.RightEdgeDistance()")   fi enddef ;

vardef BackSpace           = if mfun_swapped and not OnRightPage : PaperWidth - MakeupWidth - fi runscript("mp.BackSpace()") enddef ;
vardef CutSpace            = if mfun_swapped and not OnRightPage : PaperWidth - MakeupWidth - fi runscript("mp.CutSpace()")  enddef ;

% better use:

vardef OuterMarginWidth    = if not OnRightPage : runscript("mp.LeftMarginWidth()")     else : runscript("mp.RightMarginWidth()")    fi enddef ;
vardef InnerMarginWidth    = if not OnRightPage : runscript("mp.RightMarginWidth()")    else : runscript("mp.LeftMarginWidth()")     fi enddef ;
vardef OuterMarginDistance = if not OnRightPage : runscript("mp.LeftMarginDistance()")  else : runscript("mp.RightMarginDistance()") fi enddef ;
vardef InnerMarginDistance = if not OnRightPage : runscript("mp.RightMarginDistance()") else : runscript("mp.LeftMarginDistance()")  fi enddef ;

vardef OuterEdgeWidth      = if not OnRightPage : runscript("mp.LeftEdgeWidth()")       else : runscript("mp.RightEdgeWidth()")      fi enddef ;
vardef InnerEdgeWidth      = if not OnRightPage : runscript("mp.RightEdgeWidth()")      else : runscript("mp.LeftEdgeWidth()")       fi enddef ;
vardef OuterEdgeDistance   = if not OnRightPage : runscript("mp.LeftEdgeDistance()")    else : runscript("mp.RightEdgeDistance()")   fi enddef ;
vardef InnerEdgeDistance   = if not OnRightPage : runscript("mp.RightEdgeDistance()")   else : runscript("mp.LeftEdgeDistance()")    fi enddef ;

vardef OuterSpaceWidth     = if not OnRightPage : runscript("mp.BackSpace()")           else : runscript("mp.CutSpace()")            fi enddef ;
vardef InnerSpaceWidth     = if not OnRightPage : runscript("mp.CutSpace()")            else : runscript("mp.BackSpace()")           fi enddef ;

% indices

vardef OuterMargin = if not OnRightPage : LeftMargin  else : RightMargin fi enddef ;
vardef InnerMargin = if not OnRightPage : RightMargin else : LeftMargin  fi enddef ;

vardef OuterEdge   = if not OnRightPage : LeftEdge    else : RightEdge   fi enddef ;
vardef InnerEdge   = if not OnRightPage : Rightedge   else : LeftEdge    fi enddef ;