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
|
%D \module
%D [ file=page-grd, % moved from page-ini
%D version=2011.12.07, % 2000.10.20,
%D title=\CONTEXT\ Page Macros,
%D subtitle=Grids,
%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.
\writestatus{loading}{ConTeXt Page Macros / Grids}
\unprotect
\definepalet
[layout]
[grid=red,
page=green]
\newconstant\c_page_grids_location
\newconstant\c_page_grids_line_mode
\newconstant\c_page_grids_lineno_mode
\unexpanded\def\showgrid
{\dosingleempty\page_grids_show}
\def\page_grids_show[#1]%
{\c_page_grids_location \plusone % downward compatible default
\c_page_grids_line_mode \plusone
\c_page_grids_lineno_mode\plusone
\processallactionsinset
[#1]%
[ \v!reset=>\c_page_grids_location \zerocount,
\v!bottom=>\c_page_grids_location \plusone,
\v!top=>\c_page_grids_location \plustwo,
\v!none=>\c_page_grids_line_mode \zerocount,
\v!all=>\c_page_grids_line_mode \plusone,
\v!lines=>\c_page_grids_line_mode \plustwo,
\v!frame=>\c_page_grids_line_mode \plusthree,
\v!nonumber=>\c_page_grids_lineno_mode\zerocount,
\v!right=>\c_page_grids_lineno_mode\plusone,
\v!left=>\c_page_grids_lineno_mode\plustwo,
\v!outer=>\c_page_grids_lineno_mode\plusthree]%
\ifcase\c_page_grids_location
\let\page_grids_add_to_box\gobbleoneargument
\else % 1=bottom 2=top
\let\page_grids_add_to_box\page_grids_add_to_box_indeed
\fi}
% if really needed for speed we can cache the grid
\let\page_grids_add_to_box\gobbleoneargument
\def\page_grids_add_to_box_indeed#1% to be checked for color and layer ..... use mp
{\startcolor[layout:grid]%
\gridboxlinemode \c_page_grids_line_mode
\gridboxlinenomode\c_page_grids_lineno_mode
\setgridbox\scratchbox\makeupwidth\textheight % todo: check color
\global\setbox#1\hbox % global ?
{\ifcase\c_page_grids_location\or\or\box#1\hskip-\makeupwidth\fi
\begingroup % color
\ifcase\layoutcolumns\else
\gray
\setlayoutcomponentattribute{\v!grid:\v!columns}%
\hbox \layoutcomponentboxattribute to \makeupwidth
{\dorecurse\layoutcolumns
{\hskip\layoutcolumnwidth
\ifnum\recurselevel<\layoutcolumns
\vrule
\s!height\ht\scratchbox
\s!depth \dp\scratchbox
\s!width \layoutcolumndistance
\fi}}%
\hskip-\makeupwidth
\fi
\setlayoutcomponentattribute{\v!grid:\v!lines}%
\hbox \layoutcomponentboxattribute{\box\scratchbox}%
\endgroup
\ifcase\c_page_grids_location\or\hskip-\makeupwidth\box#1\fi}%
\stopcolor}
\protect \endinput
|