groff before CVS: release 1.06
[s-roff.git] / eqn / box.h
bloba4874a95b8f5d607e68a6ceded5a998cd8d3c427
1 // -*- C++ -*-
2 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
5 This file is part of groff.
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.
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.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 struct list_box;
23 class box {
24 private:
25 static int next_uid;
26 public:
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);
50 class box_list {
51 private:
52 int maxlen;
53 public:
54 box **p;
55 int len;
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;
65 class list_box : public box {
66 int is_script;
67 box_list list;
68 int sty;
69 public:
70 list_box(box *);
71 void debug_print();
72 int compute_metrics(int);
73 void compute_subscript_kern();
74 void output();
75 void check_tabs(int);
76 void append(box *);
77 list_box *to_list_box();
78 void handle_char_type(int, int);
79 void compute_sublist_width(int n);
80 friend box *make_script_box(box *, box *, box *);
81 friend box *make_mark_box(box *);
82 friend box *make_lineup_box(box *);
85 enum alignment { LEFT_ALIGN, RIGHT_ALIGN, CENTER_ALIGN };
87 class column : public box_list {
88 alignment align;
89 int space;
90 public:
91 column(box *);
92 void set_alignment(alignment);
93 void set_space(int);
94 void debug_print(const char *);
96 friend class matrix_box;
97 friend class pile_box;
100 class pile_box : public box {
101 column col;
102 public:
103 pile_box(box *);
104 int compute_metrics(int);
105 void output();
106 void debug_print();
107 void check_tabs(int);
108 void set_alignment(alignment a) { col.set_alignment(a); }
109 void set_space(int n) { col.set_space(n); }
110 void append(box *p) { col.append(p); }
113 class matrix_box : public box {
114 private:
115 int len;
116 int maxlen;
117 column **p;
118 public:
119 matrix_box(column *);
120 ~matrix_box();
121 void append(column *);
122 int compute_metrics(int);
123 void output();
124 void check_tabs(int);
125 void debug_print();
128 class pointer_box : public box {
129 protected:
130 box *p;
131 public:
132 pointer_box(box *);
133 ~pointer_box();
134 int compute_metrics(int);
135 void compute_subscript_kern();
136 void compute_skew();
137 void debug_print() = 0;
138 void check_tabs(int);
141 class vcenter_box : public pointer_box {
142 public:
143 vcenter_box(box *);
144 int compute_metrics(int);
145 void output();
146 void debug_print();
149 class simple_box : public box {
150 public:
151 int compute_metrics(int);
152 void compute_subscript_kern();
153 void compute_skew();
154 void output() = 0;
155 void debug_print() = 0;
156 int is_simple();
159 class quoted_text_box : public simple_box {
160 char *text;
161 public:
162 quoted_text_box(char *);
163 ~quoted_text_box();
164 void debug_print();
165 void output();
168 class half_space_box : public simple_box {
169 public:
170 half_space_box();
171 void output();
172 void debug_print();
175 class space_box : public simple_box {
176 public:
177 space_box();
178 void output();
179 void debug_print();
182 class tab_box : public box {
183 int disabled;
184 public:
185 tab_box();
186 void output();
187 void debug_print();
188 void check_tabs(int);
191 class size_box : public pointer_box {
192 private:
193 char *size;
194 public:
195 size_box(char *, box *);
196 ~size_box();
197 int compute_metrics(int);
198 void output();
199 void debug_print();
202 class font_box : public pointer_box {
203 private:
204 char *f;
205 public:
206 font_box(char *, box *);
207 ~font_box();
208 int compute_metrics(int);
209 void output();
210 void debug_print();
213 class fat_box : public pointer_box {
214 public:
215 fat_box(box *);
216 int compute_metrics(int);
217 void output();
218 void debug_print();
221 class vmotion_box : public pointer_box {
222 private:
223 int n; // up is >= 0
224 public:
225 vmotion_box(int, box *);
226 int compute_metrics(int);
227 void output();
228 void debug_print();
231 class hmotion_box : public pointer_box {
232 int n;
233 public:
234 hmotion_box(int, box *);
235 int compute_metrics(int);
236 void output();
237 void debug_print();
240 box *split_text(char *);
241 box *make_script_box(box *, box *, box *);
242 box *make_mark_box(box *);
243 box *make_lineup_box(box *);
244 box *make_delim_box(char *, box *, char *);
245 box *make_sqrt_box(box *);
246 box *make_prime_box(box *);
247 box *make_over_box(box *, box *);
248 box *make_small_over_box(box *, box *);
249 box *make_limit_box(box *, box *, box *);
250 box *make_accent_box(box *, box *);
251 box *make_uaccent_box(box *, box *);
252 box *make_overline_box(box *);
253 box *make_underline_box(box *);
254 box *make_special_box(char *, box *);
256 void set_space(int);
257 void set_gsize(const char *);
258 void set_gfont(const char *);
259 void set_grfont(const char *);
260 void set_gbfont(const char *);
261 const char *get_gfont();
262 const char *get_grfont();
263 const char *get_gbfont();
264 void start_string();
265 void output_string();
266 void do_text(const char *);
267 void restore_compatibility();
268 void set_script_reduction(int n);
269 void set_minimum_size(int n);
270 void set_param(const char *name, int value);
272 void set_char_type(const char *type, char *ch);
274 void init_char_table();
275 void init_extensible();
276 void define_extensible(const char *name, const char *ext, const char *top = 0,
277 const char *mid = 0, const char *bot = 0);