1 // -*- C++ -*-
2 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
4
5 This file is part of groff.
6
7 groff is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with groff; see the file COPYING. If not, write to the Free Software
19 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
20
21 #include "eqn.h"
22 #include "pbox.h"
23
24 class mark_box : public pointer_box {
25 public:
26 mark_box(box *);
27 int compute_metrics(int);
28 void output();
29 void debug_print();
30 };
31
32 // we push down marks so that they don't interfere with spacing
33
make_mark_box(box * p)34 box *make_mark_box(box *p)
35 {
36 list_box *b = p->to_list_box();
37 if (b != 0) {
38 b->list.p[0] = make_mark_box(b->list.p[0]);
39 return b;
40 }
41 else
42 return new mark_box(p);
43 }
44
mark_box(box * pp)45 mark_box::mark_box(box *pp) : pointer_box(pp)
46 {
47 }
48
output()49 void mark_box::output()
50 {
51 p->output();
52 }
53
compute_metrics(int style)54 int mark_box::compute_metrics(int style)
55 {
56 int res = p->compute_metrics(style);
57 if (res)
58 error("multiple marks and lineups");
59 printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
60 printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
61 printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
62 printf(".nr " MARK_REG " 0\n");
63 return FOUND_MARK;
64 }
65
debug_print()66 void mark_box::debug_print()
67 {
68 fprintf(stderr, "mark { ");
69 p->debug_print();
70 fprintf(stderr, " }");
71 }
72
73
74 class lineup_box : public pointer_box {
75 public:
76 lineup_box(box *);
77 void output();
78 int compute_metrics(int style);
79 void debug_print();
80 };
81
82 // we push down lineups so that they don't interfere with spacing
83
make_lineup_box(box * p)84 box *make_lineup_box(box *p)
85 {
86 list_box *b = p->to_list_box();
87 if (b != 0) {
88 b->list.p[0] = make_lineup_box(b->list.p[0]);
89 return b;
90 }
91 else
92 return new lineup_box(p);
93 }
94
lineup_box(box * pp)95 lineup_box::lineup_box(box *pp) : pointer_box(pp)
96 {
97 }
98
output()99 void lineup_box::output()
100 {
101 p->output();
102 }
103
compute_metrics(int style)104 int lineup_box::compute_metrics(int style)
105 {
106 int res = p->compute_metrics(style);
107 if (res)
108 error("multiple marks and lineups");
109 printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
110 printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
111 printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
112 printf(".nr " MARK_REG " 0\n");
113 return FOUND_LINEUP;
114 }
115
debug_print()116 void lineup_box::debug_print()
117 {
118 fprintf(stderr, "lineup { ");
119 p->debug_print();
120 fprintf(stderr, " }");
121 }
122