summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/lecturer/ltr-areas.tex
blob: 9e89d6696edaed094176cc831c45c3f41a77e953 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
% This file is part of the Lecturer package.
% Paul Isambert -- July 2010.
% 
%
% ATTRIBUTES
%
\def\setarea#1#2\par{%
  \ltr@space_loop{\ltr@setarea_do{#2}}{#1 }%
  }
\long\def\ltr@setarea_do#1#2{%
  \ltr@ifattribute {ltr@#2@inner_area}:visible;
    {\setparameter {ltr@#2@inner_area}:}
    {\ltr@setarea_new{#2}}%
    #1\par
  }%
\def\ltr@area_list{}%
\def\ltr@setarea_new#1{%
  \global\eaddright\ltr@area_list{ltr@#1@inner_area,}%
  \passcs{\usecs{newbox}}{ltr@#1@inner_area:box}%
  \restrictparameter ltr@#1@inner_area:
    width height hshift hshift* vshift vshift* left right top bottom
    foreground background topskip baselineskip parindent parskip hpos vpos
    visible frame frame_width frame_color frame_corner frame_dash
    everyposition everyfreeposition font hsize vsize image
    \par
  \ltr@restrictattribute ltr@#1@inner_area:visible; true false step\par
  \ltr@restrictattribute ltr@#1@inner_area:frame_corner; miter round bevel\par
  \ltr@restrictattribute ltr@#1@inner_area:hpos; ff rr fr rf\par
  \defactiveparameter ltr@#1@inner_area {%
    \ltr@delete_empty{##1:background}%
    \ltr@todim_loop{##1}{width height hshift hshift* vshift vshift* left right top bottom hsize vsize
    topskip baselineskip parindent frame_width }%
    \ltr@dimen_set{##1}{hshift*}{hshift}{width}{\pdfpagewidth}%
    \ltr@dimen_set{##1}{vshift*}{vshift}{height}{\pdfpageheight}%
    \ltr@deleteattribute ##1:hshift*;%
    \ltr@deleteattribute ##1:vshift*;%
    \ltr@dimen_set{##1}{right}{left}{hsize}{\ltr@area_width{##1}}%
    \ltr@dimen_set{##1}{bottom}{top}{vsize}{\ltr@area_height{##1}}%
    \ltr@deleteattribute ##1:right;%
    \ltr@deleteattribute ##1:bottom;%
    \ltr@ifattribute##1:frame;
      {\def\ltr@area_name{#1}\ltr@passvalue{\ltr@option_launchloop{area}}##1:frame;}{}%
    \ltr@deleteattribute##1:frame;
    \ltr@todim_loop{##1}{frame_width }%
    \ltr@ifattribute##1:frame_color;{}
      {\ltr@ifattribute##1:background;
         {\ltr@setattribute##1:frame_color; = {\ltr@usevalueor##1:background;{white}} }{}}%
    }%
  \setparameter {ltr@#1@inner_area}:
     visible = true
  }
\def\ltr@area_usepair#1#2{%
  \ltr@setattribute ltr@\ltr@area_name @inner_area:frame_#1;={#2}
  }
%
%
%
\def\ltr@area_hshift#1{%
  \ltr@usevalueor #1:hshift;{0pt}%
  }
\def\ltr@area_vshift#1{%
  \ltr@usevalueor #1:vshift;{0pt}%
  }
\def\ltr@area_width#1{%
  \ltr@usevalueor #1:width;{\dimexpr(\pdfpagewidth-\ltr@area_hshift{#1})}%
  }
\def\ltr@area_height#1{%
  \ltr@usevalueor #1:height;{\dimexpr(\pdfpageheight-\ltr@area_vshift{#1})}%
  }
\def\ltr@area_left#1{%
  \ltr@usevalueor #1:left;{0pt}%
  }
\def\ltr@area_top#1{%
  \ltr@usevalueor #1:top;{0pt}%
  }
\def\ltr@area_hsize#1{%
  \ltr@usevalueor #1:hsize;{\dimexpr(\ltr@area_width{#1}-\ltr@area_left{#1})\relax}%
  }
\def\ltr@area_vsize#1{%
  \ltr@usevalueor #1:vsize;{\dimexpr(\ltr@area_height{#1}-\ltr@area_top{#1})\relax}%
  }
%
% POSITION
% No attributes, except the optional argument,
% which takes the x and y (downward, \'a la TeX)
% shifts. Most of this is box manipulation.
%
\newcount\ltr@temp_count
\newcount\ltr@position_count
\def\position#1{%
  \ifnextnospace[{\ltr@position{#1}}{\ltr@position{#1}[]}%
  }
\newife\ifltr@area_do
\long\def\ltr@position#1[#2]{%
  \ltr@ifattribute ltr@#1@inner_area:visible;
    {\ltr@area_check{#1}%
     \ifltr@area_do
       {\ltr@position_do{#2}{ltr@#1@inner_area}}
       {\gobbleone}}
    {\ltr@error{Area `#1' doesn't exist. Material is discarded}\gobbleone}
  }
\def\ltr@area_check#1{%
  \ltr@area_dotrue
  \ltr@ifattribute ltr@inner_slide:areas*;
    {\ltr@ifvalue ltr@inner_slide:areas*; = all
       {\ltr@area_dofalse}
       {\ltr@storevalue\ltr@temp ltr@inner_slide:areas*;
        \addright\ltr@temp{ }\addleft\ltr@temp{ }%
        \passexpanded{\iffcontains{ #1 }}{\ltr@temp}\ltr@area_dofalse}}
    {}%
  \ltr@ifattribute ltr@inner_slide:areas;
    {\ltr@ifvalue ltr@inner_slide:areas; = all
       {}
       {\ltr@storevalue\ltr@temp ltr@inner_slide:areas;
        \addright\ltr@temp{ }\addleft\ltr@temp{ }%
        \passexpanded{\ifcontains{ #1 }}{\ltr@temp}\ltr@area_dotrue\ltr@area_dofalse}}
    {}%
  }
\newbox\ltr@temp_box
\newdimen\ltr@temp_dimen
\long\def\ltr@position_do#1#2#3{%
  \ifemptystring{#1}
    % Normal position.
    {\setbox\ltr@temp_box=\ltr@position_dobox{#2}{\ltr@usevalue #2:everyposition;#3}}
    % Free position.
    {\setbox\ltr@temp_box=\vbox{%
       \ltr@position_dobox{#2}{\ltr@usevalue #2:everyfreeposition;#3}}%
     \ltr@position_getposition#1
     \setbox\ltr@temp_box=\vbox{%
       \kern\dimexpr(\ltr@position_top+\ltr@usevalueor #2:topskip;\topskip-\ht\ltr@temp_box)\relax
       \moveright\ltr@position_left\box\ltr@temp_box
       }%
     \dp\ltr@temp_box=0pt	\ht\ltr@temp_box=0pt
     }%
  % How to apply topskip?
  % If the box isn't empty, that doesn't mean it shouldn't be used,
  % since the content of the box might be material freely positioned,
  % which doesn't exist, so to speak.
  % We can't measure the box either, because if topskip
  % is 0pt, one-line material without depth will fill the box
  % with height and depth 0pt, as if there were nothing, and
  % topskip will be applied again on the next material.
  % Hence this pseudo-conditional turned to true the first
  % time real material is added.
  \ifemptystring{#1}
    {\begingroup
     \ltr@usevalue #2:font;% So em and ex are right.
     \ifcsname #2:done\endcsname
       \global\ltr@temp_dimen=\dimexpr(%
         \dimexpr(\ltr@usevalueor #2:baselineskip;\baselineskip+\ltr@usevalueor #2:parskip;{0pt})\relax
         -\dimexpr(\ht\ltr@temp_box+\dp\usecs{#2:box}))\relax
       \ifdim\ltr@temp_dimen<\lineskiplimit
         \global\ltr@temp_dimen=\lineskip
       \fi
     \else
       \global\ltr@temp_dimen=\dimexpr(\ltr@usevalueor #2:topskip;\topskip-\ht\ltr@temp_box)\relax%
       \global\letcs{#2:done}\relax
     \fi
     \endgroup}
    {\edef\ltr@position_left{\the\ht\usecs{#2:box}}% I could have used special dimensions
     \edef\ltr@position_top{\the\dp\usecs{#2:box}}}% but it's a time of austerity.
  \global\setbox\usecs{#2:box}=\vbox{%
    \unless\ifvoid\usecs{#2:box}
      \unvcopy\usecs{#2:box}
    \fi
    \ifemptystring{#1}
      {\kern\ltr@temp_dimen}
      {\kern-\dimexpr(\ht\usecs{#2:box}+\dp\usecs{#2:box})\relax}
    \ifx\ltr@step_current\emptycs
      \ifemptystring{#1}\unvbox\box\ltr@temp_box
      \reverse\iffcs{ltr@#2_\the\slideno @inner_area:group}
        {\global\letcs{ltr@#2_\the\slideno @inner_area:group}\emptycs}
    \else
      \global\advance\ltr@position_count1
      \pdfliteral {/OC/ltr@position_\the\ltr@position_count:content BDC}
      \ifemptystring{#1}\unvbox\box\ltr@temp_box
      \pdfliteral {EMC}
      \addproperties{ltr@position_\the\ltr@position_count:content}{\ltr@step_current}
      \reverse\iffcs{#2_\the\slideno:group}
        {\global\letcs{#2_\the\slideno:group}\ltr@step_current
         \addproperties{#2_\the\slideno:background}{\usecs{#2_\the\slideno:group}}}
    \fi
    \reverse\iffemptystring{#1} % Restore the box to its original dimensions.
      {\prevdepth-1000pt \vbox to \ht\usecs{#2:box}{\vfil\hbox{\vrule height0pt width0pt depth\dp\usecs{#2:box}}}}%
    }%
  \ltr@temp_dimen=0pt
  }
\def\ltr@position_getposition#1,#2 {%
  \edef\ltr@position_left{\ifemptystring{#1}{0pt}{\dimexpr(#1)}}%
  \edef\ltr@position_top{\ifemptystring{#2}{0pt}{\dimexpr(#2)}}
  }
\long\def\ltr@position_dobox#1#2{%
  \vtop{%
    \ltr@usevalue #1:font;
    \parindent\ltr@usevalueor #1:parindent;{0pt}\relax
    \hsize=\ltr@area_hsize{#1}\relax
    \ltr@settovalue\baselineskip #1:baselineskip;
    \parskip=\ltr@usevalueor #1:parskip;{0pt}\relax
    \leftskip=0pt \rightskip=0pt plus 1fill\relax
    \ltr@ifcasevalue #1:hpos;
      \val ff \rightskip=0pt
      \val rr \leftskip=0pt plus 1fill\relax
      \val rf \leftskip=0pt plus 1fill \rightskip=0pt
    \endval
    #2}%
  }

\endinput