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