4 /* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002
5 Free Software Foundation, Inc.
6 Written by James Clark (jjc@jclark.com)
8 This file is part of groff.
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
15 groff is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License along
21 with groff; see the file COPYING. If not, write to the Free Software
22 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
27 class over_box
: public box
{
33 over_box(int small
, box
*, box
*);
36 int compute_metrics(int);
41 box
*make_over_box(box
*pp
, box
*qq
)
43 return new over_box(0, pp
, qq
);
46 box
*make_small_over_box(box
*pp
, box
*qq
)
48 return new over_box(1, pp
, qq
);
51 over_box::over_box(int is_small
, box
*pp
, box
*qq
)
52 : reduce_size(is_small
), num(pp
), den(qq
)
54 spacing_type
= INNER_TYPE
;
63 int over_box::compute_metrics(int style
)
66 style
= script_style(style
);
67 printf(".nr " SIZE_FORMAT
" \\n[.ps]\n", uid
);
69 printf(".nr " SMALL_SIZE_FORMAT
" \\n[.ps]\n", uid
);
72 int res
= num
->compute_metrics(style
);
75 int r
= den
->compute_metrics(cramped_style(style
));
77 error("multiple marks and lineups");
83 printf(".ps \\n[" SIZE_FORMAT
"]u\n", uid
);
84 printf(".nr " WIDTH_FORMAT
" (\\n[" WIDTH_FORMAT
"]>?\\n[" WIDTH_FORMAT
"]",
85 uid
, num
->uid
, den
->uid
);
86 // allow for \(ru being wider than both the numerator and denominator
88 fputs(">?\\w" DELIMITER_CHAR
"\\(ru" DELIMITER_CHAR
, stdout
);
89 printf(")+%dM\n", null_delimiter_space
*2 + over_hang
*2);
91 printf(".nr " SUP_RAISE_FORMAT
" %dM\n",
92 uid
, (reduce_size
? num2
: num1
));
93 printf(".nr " SUB_LOWER_FORMAT
" %dM\n",
94 uid
, (reduce_size
? denom2
: denom1
));
97 printf(".nr " SUP_RAISE_FORMAT
" +(\\n[" DEPTH_FORMAT
98 "]-\\n[" SUP_RAISE_FORMAT
"]+%dM+(%dM/2)+%dM)>?0\n",
99 uid
, num
->uid
, uid
, axis_height
, default_rule_thickness
,
100 default_rule_thickness
*(reduce_size
? 1 : 3));
101 printf(".nr " SUB_LOWER_FORMAT
" +(\\n[" HEIGHT_FORMAT
102 "]-\\n[" SUB_LOWER_FORMAT
"]-%dM+(%dM/2)+%dM)>?0\n",
103 uid
, den
->uid
, uid
, axis_height
, default_rule_thickness
,
104 default_rule_thickness
*(reduce_size
? 1 : 3));
107 printf(".nr " HEIGHT_FORMAT
" \\n[" SUP_RAISE_FORMAT
"]+\\n["
110 printf(".nr " DEPTH_FORMAT
" \\n[" SUB_LOWER_FORMAT
"]+\\n["
114 printf(".nr " MARK_REG
" +(\\n[" WIDTH_FORMAT
"]-\\n["
115 WIDTH_FORMAT
"]/2)\n", uid
, mark_uid
);
121 void over_box::output()
124 printf("\\s[\\n[" SMALL_SIZE_FORMAT
"]u]", uid
);
126 printf("\\Z" DELIMITER_CHAR
);
128 // move up to the numerator baseline
129 printf("\\v'-\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
130 // move across so that it's centered
131 printf("\\h'\\n[" WIDTH_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u'",
134 // print the numerator
138 printf(DELIMITER_CHAR
);
141 printf("\\h'-\\n[" WIDTH_FORMAT
"]u'", num
->uid
);
142 printf("\\h'-(\\n[" WIDTH_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u)'",
145 printf("\\v'\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
148 printf("\\Z" DELIMITER_CHAR
);
150 // move down to the denominator baseline
151 printf("\\v'\\n[" SUB_LOWER_FORMAT
"]u'", uid
);
153 // move across so that it's centered
154 printf("\\h'\\n[" WIDTH_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u'",
157 // print the the denominator
161 printf(DELIMITER_CHAR
);
164 printf("\\h'-\\n[" WIDTH_FORMAT
"]u'", den
->uid
);
165 printf("\\h'-(\\n[" WIDTH_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u)'",
168 printf("\\v'-\\n[" SUB_LOWER_FORMAT
"]u'", uid
);
171 printf("\\s[\\n[" SIZE_FORMAT
"]u]", uid
);
173 printf("\\h'%dM'", null_delimiter_space
);
174 printf("\\v'-%dM'", axis_height
);
175 fputs(draw_flag
? "\\D'l" : "\\l'", stdout
);
176 printf("\\n[" WIDTH_FORMAT
"]u-%dM",
177 uid
, 2*null_delimiter_space
);
178 fputs(draw_flag
? " 0'" : "\\&\\(ru'", stdout
);
179 printf("\\v'%dM'", axis_height
);
180 printf("\\h'%dM'", null_delimiter_space
);
183 void over_box::debug_print()
185 fprintf(stderr
, "{ ");
188 fprintf(stderr
, " } smallover { ");
190 fprintf(stderr
, " } over { ");
192 fprintf(stderr
, " }");
195 void over_box::check_tabs(int level
)
197 num
->check_tabs(level
+ 1);
198 den
->check_tabs(level
+ 1);