| 1 |
lars |
1 |
% $Header: /cvsroot/html2ps/postscript/box.list-item.ps,v 1.1 2005/12/18 07:21:37 Konstantin Exp $
|
|
|
2 |
|
|
|
3 |
/box-list-item-height-koeff 0.7 def
|
|
|
4 |
/box-list-item-bullet-size-koeff 0.15 def
|
|
|
5 |
|
|
|
6 |
/box-list-item-create {
|
|
|
7 |
box-block-create
|
|
|
8 |
|
|
|
9 |
dup /MarkerImage /null put
|
|
|
10 |
dup /MarkerString ( ) put
|
|
|
11 |
|
|
|
12 |
dup box-list-item-setup-methods
|
|
|
13 |
dup /box-list-item add-type
|
|
|
14 |
} def
|
|
|
15 |
|
|
|
16 |
/box-list-item-get-marker-box-width { % => ListItem
|
|
|
17 |
dup /list-style get-css-value
|
|
|
18 |
/type get { % => ListItem Type
|
|
|
19 |
dup /none eq { pop 0 exit } if
|
|
|
20 |
|
|
|
21 |
dup /disc eq
|
|
|
22 |
1 index /circle eq or
|
|
|
23 |
1 index /square eq or { pop dup /font-size get-css-value exit } if
|
|
|
24 |
|
|
|
25 |
pop
|
|
|
26 |
|
|
|
27 |
dup /font-family get-css-value
|
|
|
28 |
1 index /font-size get-css-value
|
|
|
29 |
scalefont
|
|
|
30 |
setfont
|
|
|
31 |
|
|
|
32 |
dup box-list-item-get-string
|
|
|
33 |
stringwidth pop % => ListItem Width
|
|
|
34 |
} loop % => ListItem Width
|
|
|
35 |
exch pop % => Width
|
|
|
36 |
} def
|
|
|
37 |
|
|
|
38 |
/box-list-item-get-marker-image {
|
|
|
39 |
/MarkerImage get
|
|
|
40 |
} def
|
|
|
41 |
|
|
|
42 |
/box-list-item-get-string {
|
|
|
43 |
/MarkerString get
|
|
|
44 |
} def
|
|
|
45 |
|
|
|
46 |
/box-list-item-put-marker-image { % => Image This
|
|
|
47 |
exch /MarkerImage exch put
|
|
|
48 |
} def
|
|
|
49 |
|
|
|
50 |
/box-list-item-put-string {
|
|
|
51 |
exch /MarkerString exch put
|
|
|
52 |
} def
|
|
|
53 |
|
|
|
54 |
/box-list-item-reflow { % => Context Parent Box
|
|
|
55 |
% If list-style-position is inside, we'll need to move marker box inside the
|
|
|
56 |
% list-item box and offset all content by its size;
|
|
|
57 |
dup /list-style get-css-value /position get
|
|
|
58 |
/inside eq {
|
|
|
59 |
% Add marker box width to text-indent value
|
|
|
60 |
dup box-list-item-get-marker-box-width
|
|
|
61 |
1 index put-additional-text-indent
|
|
|
62 |
} if
|
|
|
63 |
|
|
|
64 |
3 copy box-block-reflow
|
|
|
65 |
pop pop pop
|
|
|
66 |
} def
|
|
|
67 |
|
|
|
68 |
/box-list-item-show { % => Viewport This
|
|
|
69 |
% Draw generic block box
|
|
|
70 |
2 copy box-container-show
|
|
|
71 |
|
|
|
72 |
% Draw marker
|
|
|
73 |
% Determine the marker box base X coordinate
|
|
|
74 |
dup get-left % => Viewport This MX
|
|
|
75 |
|
|
|
76 |
% Determine the base Y coordinate of marker box
|
|
|
77 |
1 index box-container-get-first-data
|
|
|
78 |
dup /null ne { % => Viewport This MX Element
|
|
|
79 |
dup get-top
|
|
|
80 |
1 index get-default-baseline sub
|
|
|
81 |
exch pop
|
|
|
82 |
} { % => Viewport This MX /null
|
|
|
83 |
pop
|
|
|
84 |
1 index get-top
|
|
|
85 |
} ifelse % => Viewport This MX MY
|
|
|
86 |
|
|
|
87 |
% If list-style-position is inside, we'll need to move marker box inside the
|
|
|
88 |
% list-item box and offset all content by its size;
|
|
|
89 |
2 index /list-style get-css-value /position get
|
|
|
90 |
/inside eq {
|
|
|
91 |
2 index box-list-item-get-marker-box-width
|
|
|
92 |
2 index add % => Viewport This MX MY MX'
|
|
|
93 |
3 2 roll pop
|
|
|
94 |
exch
|
|
|
95 |
} if
|
|
|
96 |
|
|
|
97 |
2 index box-list-item-get-marker-image
|
|
|
98 |
/null ne { % => Viewport This MX MY
|
|
|
99 |
exch 3 index 3 index
|
|
|
100 |
box-list-item-show-image
|
|
|
101 |
} { % => Viewport This MX MY
|
|
|
102 |
exch
|
|
|
103 |
3 index 3 index % => Viewport This MY MX Viewport This
|
|
|
104 |
dup /list-style get-css-value /type get
|
|
|
105 |
{
|
|
|
106 |
dup /none eq { pop pop pop pop pop exit } if
|
|
|
107 |
dup /disc eq { pop box-list-item-show-disc exit } if
|
|
|
108 |
dup /circle eq { pop box-list-item-show-circle exit } if
|
|
|
109 |
dup /square eq { pop box-list-item-show-square exit } if
|
|
|
110 |
pop box-list-item-show-string exit
|
|
|
111 |
} loop
|
|
|
112 |
} ifelse % => Viewport This
|
|
|
113 |
|
|
|
114 |
pop pop
|
|
|
115 |
} def
|
|
|
116 |
|
|
|
117 |
/box-list-item-setup-methods { % => Box
|
|
|
118 |
dup /Methods get
|
|
|
119 |
dup /reflow {box-list-item-reflow} put
|
|
|
120 |
dup /show {box-list-item-show} put
|
|
|
121 |
pop pop
|
|
|
122 |
} def
|
|
|
123 |
|
|
|
124 |
/box-list-item-show-circle { % => MY MX Viewport This
|
|
|
125 |
dup /color get-css-value
|
|
|
126 |
color-apply
|
|
|
127 |
|
|
|
128 |
0.1 setlinewidth
|
|
|
129 |
|
|
|
130 |
dup /font-size get-css-value
|
|
|
131 |
2 div neg
|
|
|
132 |
3 index add % => MY MX Viewport This X
|
|
|
133 |
|
|
|
134 |
1 index /font-size get-css-value
|
|
|
135 |
0.4 mul
|
|
|
136 |
box-list-item-height-koeff mul
|
|
|
137 |
5 index add % => MY MX Viewport This X Y
|
|
|
138 |
|
|
|
139 |
2 copy newpath moveto
|
|
|
140 |
|
|
|
141 |
2 index /font-size get-css-value
|
|
|
142 |
box-list-item-bullet-size-koeff mul
|
|
|
143 |
% => MY MX Viewport This X Y R
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
pop pop pop pop
|
|
|
148 |
} def
|
|
|
149 |
|
|
|
150 |
/box-list-item-show-disc { % => MY MX Viewport This
|
|
|
151 |
dup /color get-css-value
|
|
|
152 |
color-apply
|
|
|
153 |
|
|
|
154 |
dup /font-size get-css-value
|
|
|
155 |
2 div neg
|
|
|
156 |
3 index add % => MY MX Viewport This X
|
|
|
157 |
|
|
|
158 |
1 index /font-size get-css-value
|
|
|
159 |
0.4 mul
|
|
|
160 |
box-list-item-height-koeff mul
|
|
|
161 |
5 index add % => MY MX Viewport This X Y
|
|
|
162 |
|
|
|
163 |
2 copy newpath moveto
|
|
|
164 |
|
|
|
165 |
2 index /font-size get-css-value
|
|
|
166 |
box-list-item-bullet-size-koeff mul
|
|
|
167 |
% => MY MX Viewport This X Y R
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
pop pop pop pop
|
|
|
172 |
} def
|
|
|
173 |
|
|
|
174 |
/box-list-item-show-image { % => MY MX Viewport This
|
|
|
175 |
dup box-list-item-get-marker-image
|
|
|
176 |
% => MY MX Viewport This Image
|
|
|
177 |
3 index
|
|
|
178 |
5 index moveto % => MY MX Viewport This Image
|
|
|
179 |
|
|
|
180 |
dup /SX get px
|
|
|
181 |
1 index /SY get px
|
|
|
182 |
2 index
|
|
|
183 |
image-show % => MY MX Viewport This Image
|
|
|
184 |
|
|
|
185 |
pop pop pop pop pop
|
|
|
186 |
} def
|
|
|
187 |
|
|
|
188 |
/box-list-item-show-square { % => MY MX Viewport This
|
|
|
189 |
dup /color get-css-value
|
|
|
190 |
color-apply
|
|
|
191 |
|
|
|
192 |
2 index
|
|
|
193 |
1 index /font-size get-css-value
|
|
|
194 |
0.512 mul sub
|
|
|
195 |
|
|
|
196 |
4 index
|
|
|
197 |
2 index /font-size get-css-value
|
|
|
198 |
0.3 mul
|
|
|
199 |
box-list-item-height-koeff mul add
|
|
|
200 |
|
|
|
201 |
2 index /font-size get-css-value 0.25 mul
|
|
|
202 |
3 index /font-size get-css-value 0.25 mul
|
|
|
203 |
|
|
|
204 |
rectfill
|
|
|
205 |
|
|
|
206 |
pop pop pop pop
|
|
|
207 |
} def
|
|
|
208 |
|
|
|
209 |
/box-list-item-show-string { % => MY MX Viewport This
|
|
|
210 |
box-text-create % => MY MX Viewport This TextBox
|
|
|
211 |
|
|
|
212 |
1 index box-list-item-get-string % => MY MX Viewport This TextBox String
|
|
|
213 |
1 index put-text % => MY MX Viewport This TextBox
|
|
|
214 |
|
|
|
215 |
1 index
|
|
|
216 |
/font-family get-css-value % => MY MX Viewport This TextBox Font
|
|
|
217 |
1 index exch
|
|
|
218 |
/font-family exch put-css-value % => MY MX Viewport This TextBox
|
|
|
219 |
|
|
|
220 |
1 index
|
|
|
221 |
/font-size get-css-value % => MY MX Viewport This TextBox FontSize
|
|
|
222 |
1 index exch
|
|
|
223 |
/font-size exch put-css-value % => MY MX Viewport This TextBox
|
|
|
224 |
|
|
|
225 |
1 index
|
|
|
226 |
/color get-css-value % => MY MX Viewport This TextBox Color
|
|
|
227 |
1 index exch
|
|
|
228 |
/color exch put-css-value % => MY MX Viewport This TextBox
|
|
|
229 |
|
|
|
230 |
dup box-text-setup % => MY MX Viewport This TextBox
|
|
|
231 |
|
|
|
232 |
dup get-default-baseline
|
|
|
233 |
1 index put-baseline
|
|
|
234 |
|
|
|
235 |
4 index
|
|
|
236 |
1 index get-baseline add
|
|
|
237 |
4 index
|
|
|
238 |
2 index get-full-width sub % => MY MX Viewport This TextBox MY MX
|
|
|
239 |
2 index
|
|
|
240 |
box-generic-move-to % => MY MX Viewport This TextBox
|
|
|
241 |
|
|
|
242 |
2 index exch
|
|
|
243 |
box-text-show
|
|
|
244 |
|
|
|
245 |
pop pop pop pop
|
|
|
246 |
} def
|