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