4 /* Copyright (C) 1989, 1990, 1991, 1992, 2002 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License along
20 with groff; see the file COPYING. If not, write to the Free Software
21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
26 class limit_box
: public box
{
32 limit_box(box
*, box
*, box
*);
34 int compute_metrics(int);
40 box
*make_limit_box(box
*pp
, box
*qq
, box
*rr
)
42 return new limit_box(pp
, qq
, rr
);
45 limit_box::limit_box(box
*pp
, box
*qq
, box
*rr
)
46 : p(pp
), from(qq
), to(rr
)
48 spacing_type
= p
->spacing_type
;
51 limit_box::~limit_box()
58 int limit_box::compute_metrics(int style
)
60 printf(".nr " SIZE_FORMAT
" \\n[.ps]\n", uid
);
61 if (!(style
<= SCRIPT_STYLE
&& one_size_reduction_flag
))
63 printf(".nr " SMALL_SIZE_FORMAT
" \\n[.ps]\n", uid
);
67 res
= from
->compute_metrics(cramped_style(script_style(style
)));
72 int r
= to
->compute_metrics(script_style(style
));
74 error("multiple marks and lineups");
80 printf(".ps \\n[" SIZE_FORMAT
"]u\n", uid
);
81 int r
= p
->compute_metrics(style
);
82 p
->compute_subscript_kern();
84 error("multiple marks and lineups");
89 printf(".nr " LEFT_WIDTH_FORMAT
" "
90 "0\\n[" WIDTH_FORMAT
"]",
93 printf(">?(\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
96 printf(">?(-\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
99 printf(".nr " WIDTH_FORMAT
" "
100 "0\\n[" WIDTH_FORMAT
"]",
103 printf(">?(-\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
106 printf(">?(\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
108 printf("/2+\\n[" LEFT_WIDTH_FORMAT
"]\n", uid
);
109 printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]", uid
, p
->uid
);
111 printf(">?\\n[" WIDTH_FORMAT
"]", to
->uid
);
113 printf(">?\\n[" WIDTH_FORMAT
"]", from
->uid
);
116 printf(".nr " MARK_REG
" +(\\n[" LEFT_WIDTH_FORMAT
"]"
117 "-(\\n[" WIDTH_FORMAT
"]/2))\n",
120 printf(".nr " SUP_RAISE_FORMAT
" %dM+\\n[" DEPTH_FORMAT
121 "]>?%dM+\\n[" HEIGHT_FORMAT
"]\n",
122 uid
, big_op_spacing1
, to
->uid
, big_op_spacing3
, p
->uid
);
123 printf(".nr " HEIGHT_FORMAT
" \\n[" SUP_RAISE_FORMAT
"]+\\n["
124 HEIGHT_FORMAT
"]+%dM\n",
125 uid
, uid
, to
->uid
, big_op_spacing5
);
128 printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
130 printf(".nr " SUB_LOWER_FORMAT
" %dM+\\n[" HEIGHT_FORMAT
131 "]>?%dM+\\n[" DEPTH_FORMAT
"]\n",
132 uid
, big_op_spacing2
, from
->uid
, big_op_spacing4
, p
->uid
);
133 printf(".nr " DEPTH_FORMAT
" \\n[" SUB_LOWER_FORMAT
"]+\\n["
134 DEPTH_FORMAT
"]+%dM\n",
135 uid
, uid
, from
->uid
, big_op_spacing5
);
138 printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
142 void limit_box::output()
144 printf("\\s[\\n[" SMALL_SIZE_FORMAT
"]u]", uid
);
146 printf("\\Z" DELIMITER_CHAR
);
147 printf("\\v'-\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
148 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
149 "+(-\\n[" WIDTH_FORMAT
"]u+\\n[" SUB_KERN_FORMAT
"]u/2u)'",
150 uid
, to
->uid
, p
->uid
);
152 printf(DELIMITER_CHAR
);
155 printf("\\Z" DELIMITER_CHAR
);
156 printf("\\v'\\n[" SUB_LOWER_FORMAT
"]u'", uid
);
157 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
158 "+(-\\n[" SUB_KERN_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u)'",
159 uid
, p
->uid
, from
->uid
);
161 printf(DELIMITER_CHAR
);
163 printf("\\s[\\n[" SIZE_FORMAT
"]u]", uid
);
164 printf("\\Z" DELIMITER_CHAR
);
165 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
166 "-(\\n[" WIDTH_FORMAT
"]u/2u)'",
169 printf(DELIMITER_CHAR
);
170 printf("\\h'\\n[" WIDTH_FORMAT
"]u'", uid
);
173 void limit_box::debug_print()
175 fprintf(stderr
, "{ ");
177 fprintf(stderr
, " }");
179 fprintf(stderr
, " from { ");
181 fprintf(stderr
, " }");
184 fprintf(stderr
, " to { ");
186 fprintf(stderr
, " }");
190 void limit_box::check_tabs(int level
)
193 to
->check_tabs(level
+ 1);
195 from
->check_tabs(level
+ 1);
196 p
->check_tabs(level
+ 1);