groff: update vendor branch to v1.20.1
[dragonfly.git] / contrib / groff / src / preproc / eqn / box.h
CommitLineData
92d0a6a6 1// -*- C++ -*-
4d3e9548 2/* Copyright (C) 1989, 1990, 1991, 1992, 2004, 2005, 2009
465b256c 3 Free Software Foundation, Inc.
92d0a6a6
JR
4 Written by James Clark (jjc@jclark.com)
5
6This file is part of groff.
7
8groff is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
4d3e9548
JL
10Software Foundation, either version 3 of the License, or
11(at your option) any later version.
92d0a6a6
JR
12
13groff is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
4d3e9548
JL
18You should have received a copy of the GNU General Public License
19along with this program. If not, see <http://www.gnu.org/licenses/>. */
92d0a6a6
JR
20
21class list_box;
22
23class box {
24private:
25 static int next_uid;
26public:
27 int spacing_type;
28 const int uid;
29 box();
30 virtual void debug_print() = 0;
31 virtual ~box();
32 void top_level();
33 virtual int compute_metrics(int);
34 virtual void compute_subscript_kern();
35 virtual void compute_skew();
36 virtual void output();
37 void extra_space();
38 virtual list_box *to_list_box();
39 virtual int is_simple();
40 virtual int is_char();
41 virtual int left_is_italic();
42 virtual int right_is_italic();
43 virtual void handle_char_type(int, int);
44 enum { FOUND_NOTHING = 0, FOUND_MARK = 1, FOUND_LINEUP = 2 };
45 void set_spacing_type(char *type);
46 virtual void hint(unsigned);
47 virtual void check_tabs(int);
48};
49
50class box_list {
51private:
52 int maxlen;
53public:
54 box **p;
55 int len;
56
57 box_list(box *);
58 ~box_list();
59 void append(box *);
60 void list_check_tabs(int);
61 void list_debug_print(const char *sep);
62 friend class list_box;
63};
64
465b256c
JR
65// declarations to avoid friend name injection problems
66box *make_script_box(box *, box *, box *);
67box *make_mark_box(box *);
68box *make_lineup_box(box *);
69
92d0a6a6
JR
70class list_box : public box {
71 int is_script;
72 box_list list;
73 int sty;
74public:
75 list_box(box *);
76 void debug_print();
77 int compute_metrics(int);
78 void compute_subscript_kern();
79 void output();
80 void check_tabs(int);
81 void append(box *);
82 list_box *to_list_box();
83 void handle_char_type(int, int);
84 void compute_sublist_width(int n);
85 friend box *make_script_box(box *, box *, box *);
86 friend box *make_mark_box(box *);
87 friend box *make_lineup_box(box *);
88};
89
90enum alignment { LEFT_ALIGN, RIGHT_ALIGN, CENTER_ALIGN };
91
92class column : public box_list {
93 alignment align;
94 int space;
95public:
96 column(box *);
97 void set_alignment(alignment);
98 void set_space(int);
99 void debug_print(const char *);
100
101 friend class matrix_box;
102 friend class pile_box;
103};
104
105class pile_box : public box {
106 column col;
107public:
108 pile_box(box *);
109 int compute_metrics(int);
110 void output();
111 void debug_print();
112 void check_tabs(int);
113 void set_alignment(alignment a) { col.set_alignment(a); }
114 void set_space(int n) { col.set_space(n); }
115 void append(box *p) { col.append(p); }
116};
117
118class matrix_box : public box {
119private:
120 int len;
121 int maxlen;
122 column **p;
123public:
124 matrix_box(column *);
125 ~matrix_box();
126 void append(column *);
127 int compute_metrics(int);
128 void output();
129 void check_tabs(int);
130 void debug_print();
131};
132
133class pointer_box : public box {
134protected:
135 box *p;
136public:
137 pointer_box(box *);
138 ~pointer_box();
139 int compute_metrics(int);
140 void compute_subscript_kern();
141 void compute_skew();
142 void debug_print() = 0;
143 void check_tabs(int);
144};
145
146class vcenter_box : public pointer_box {
147public:
148 vcenter_box(box *);
149 int compute_metrics(int);
150 void output();
151 void debug_print();
152};
153
154class simple_box : public box {
155public:
156 int compute_metrics(int);
157 void compute_subscript_kern();
158 void compute_skew();
159 void output() = 0;
160 void debug_print() = 0;
161 int is_simple();
162};
163
164class quoted_text_box : public simple_box {
165 char *text;
166public:
167 quoted_text_box(char *);
168 ~quoted_text_box();
169 void debug_print();
170 void output();
171};
172
173class half_space_box : public simple_box {
174public:
175 half_space_box();
176 void output();
177 void debug_print();
178};
179
180class space_box : public simple_box {
181public:
182 space_box();
183 void output();
184 void debug_print();
185};
186
187class tab_box : public box {
188 int disabled;
189public:
190 tab_box();
191 void output();
192 void debug_print();
193 void check_tabs(int);
194};
195
196class size_box : public pointer_box {
197private:
198 char *size;
199public:
200 size_box(char *, box *);
201 ~size_box();
202 int compute_metrics(int);
203 void output();
204 void debug_print();
205};
206
207class font_box : public pointer_box {
208private:
209 char *f;
210public:
211 font_box(char *, box *);
212 ~font_box();
213 int compute_metrics(int);
214 void output();
215 void debug_print();
216};
217
218class fat_box : public pointer_box {
219public:
220 fat_box(box *);
221 int compute_metrics(int);
222 void output();
223 void debug_print();
224};
225
226class vmotion_box : public pointer_box {
227private:
228 int n; // up is >= 0
229public:
230 vmotion_box(int, box *);
231 int compute_metrics(int);
232 void output();
233 void debug_print();
234};
235
236class hmotion_box : public pointer_box {
237 int n;
238public:
239 hmotion_box(int, box *);
240 int compute_metrics(int);
241 void output();
242 void debug_print();
243};
244
245box *split_text(char *);
246box *make_delim_box(char *, box *, char *);
247box *make_sqrt_box(box *);
248box *make_prime_box(box *);
249box *make_over_box(box *, box *);
250box *make_small_over_box(box *, box *);
251box *make_limit_box(box *, box *, box *);
252box *make_accent_box(box *, box *);
253box *make_uaccent_box(box *, box *);
254box *make_overline_box(box *);
255box *make_underline_box(box *);
256box *make_special_box(char *, box *);
257
258void set_space(int);
259int set_gsize(const char *);
260void set_gfont(const char *);
261void set_grfont(const char *);
262void set_gbfont(const char *);
263const char *get_gfont();
264const char *get_grfont();
265const char *get_gbfont();
266void start_string();
267void output_string();
268void do_text(const char *);
269void restore_compatibility();
270void set_script_reduction(int n);
271void set_minimum_size(int n);
272void set_param(const char *name, int value);
273
274void set_char_type(const char *type, char *ch);
275
276void init_char_table();
277void init_extensible();
278void define_extensible(const char *name, const char *ext, const char *top = 0,
279 const char *mid = 0, const char *bot = 0);