summaryrefslogtreecommitdiff
path: root/tex/context/base/meta-pag.tex
blob: f33fa3ee22195ce88b9680669867374f1ca250db (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
%D \module
%D   [       file=meta-ini,
%D        version=1999.07.10,
%D          title=\METAPOST\ Graphics,
%D       subtitle=Initialization,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%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 These definitions used to be part of the old \type
%D {core-mps} file, later changed into \type {meta-ini}, but
%D keeping them separate is cleaner.

\writestatus{loading}{MetaPost Graphics / Page Data Management}

\unprotect

\appendtoks
  if unknown context_page : input mp-page ; fi ;
\to \MPinitializations

%D The next few macros tell \METAPOST\ how the \CONTEXT\
%D pagebody looks.

\startuseMPgraphic{page data}
  boolean PageStateAvailable, OnRightPage, InPageBody ; 
  PageStateAvailable := OnRightPage := true ;
  InPageBody         := \ifinpagebody true \else false \fi ; 
  def LoadPageState =
    OnRightPage         :=      \MPonrightpage ;
    RealPageNumber      :=  \the\realpageno ;
    PageNumber          :=  \the\pageno ;
    NOfPages            :=      \lastpage ;
    PaperHeight         :=  \the\papierhoogte ;
    PaperWidth          :=  \the\papierbreedte ;
    PrintPaperHeight    :=  \the\printpapierhoogte ;
    PrintPaperWidth     :=  \the\printpapierbreedte ;
    TopSpace            :=  \the\kopwit ;
    BottomSpace         :=  \the\bodemwit ;
    BackSpace           :=  \the\rugwit ;
    CutSpace            :=  \the\snijwit ;
    MakeupHeight        :=  \the\zethoogte ;
    MakeupWidth         :=  \the\zetbreedte ;
    TopHeight           :=  \the\bovenhoogte ;
    TopDistance         := \@the\bovenafstand ;
    HeaderHeight        :=  \the\hoofdhoogte ;
    HeaderDistance      := \@the\hoofdafstand ;
    TextHeight          :=  \the\teksthoogte ;
    FooterDistance      := \@the\voetafstand ;
    FooterHeight        :=  \the\voethoogte ;
    BottomDistance      := \@the\onderafstand ;
    BottomHeight        :=  \the\onderhoogte ;
    LeftEdgeWidth       :=  \the\linkerrandbreedte ;
    LeftEdgeDistance    := \@the\linkerrandafstand ;
    LeftMarginWidth     :=  \the\linkermargebreedte ;
    LeftMarginDistance  := \@the\linkermargeafstand ;
    TextWidth           :=  \the\tekstbreedte ;
    RightMarginDistance := \@the\rechtermargeafstand ;
    RightMarginWidth    :=  \the\rechtermargebreedte ;
    RightEdgeDistance   := \@the\rechterrandafstand ;
    RightEdgeWidth      :=  \the\rechterrandbreedte ;
    PageOffset          :=  \the\pageoffset ;
    PageDepth           :=  \the\pagedepth ;
  enddef ;
\stopuseMPgraphic

\def\MPonrightpage{true}

\def\freezeMPpagelayout%
  {% the \edef\MPonrightpage{....} alternative is slower
   \doifbothsides
     \def\MPonrightpage{true}%
   \orsideone
     \def\MPonrightpage{true}%
   \orsidetwo
     \def\MPonrightpage{false}%
   \od}

\iffixedlayoutdimensions

  \let\freezeMPlayout\relax

\else

  \def\freezeMPlayout% must be done more efficient
    {\freezedimenmacro\bovenafstand
     \freezedimenmacro\hoofdafstand
     \freezedimenmacro\voetafstand
     \freezedimenmacro\onderafstand
     \freezedimenmacro\linkerrandafstand
     \freezedimenmacro\linkermargeafstand
     \freezedimenmacro\rechtermargeafstand
     \freezedimenmacro\rechterrandafstand}

\fi

%D We need to freeze the pagelayout before the backgrounds
%D are build, because the overlay will temporarily become
%D zero (overlay).

\appendtoks
  \freezeMPpagelayout
\to \everybeforepagebody

%D By freezing these value every graphic, we can use layout
%D variables that change halfways a page, whatever use that
%D has.

\prependtoks
  \calculatereducedvsizes % this is really needed
  \freezeMPpagelayout
  \freezeMPlayout % to be used grouped
\to \everyMPgraphic

\appendtoks
  \includeMPgraphic{page data}
\to \MPinitializations

\protect \endinput