Sync-to-go: update copyright for 2015
[s-roff.git] / src / pre-eqn / box.h
bloba87096991a0e3c55c510cdb6cb2ab1c461b10768
1 /*@
2 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992, 2004, 2005
5 * Free Software Foundation, Inc.
6 * Written by James Clark (jjc@jclark.com)
8 * This is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any later
11 * version.
13 * This is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with groff; see the file COPYING. If not, write to the Free Software
20 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef _BOX_H
23 #define _BOX_H
25 #include "config.h"
26 #include "eqn-config.h"
28 class list_box;
30 class box
32 static int next_uid;
34 public:
35 int spacing_type;
36 const int uid;
37 box();
38 virtual void debug_print() = 0;
39 virtual ~box();
40 void top_level();
41 virtual int compute_metrics(int);
42 virtual void compute_subscript_kern();
43 virtual void compute_skew();
44 virtual void output();
45 void extra_space();
46 virtual list_box *to_list_box();
47 virtual int is_simple();
48 virtual int is_char();
49 virtual int left_is_italic();
50 virtual int right_is_italic();
51 virtual void handle_char_type(int, int);
52 enum { FOUND_NOTHING = 0, FOUND_MARK = 1, FOUND_LINEUP = 2 };
53 void set_spacing_type(char *type);
54 virtual void hint(unsigned);
55 virtual void check_tabs(int);
58 class box_list
60 int maxlen;
62 public:
63 box **p;
64 int len;
66 box_list(box *);
67 ~box_list();
68 void append(box *);
69 void list_check_tabs(int);
70 void list_debug_print(const char *sep);
71 friend class list_box;
74 // declarations to avoid friend name injection problems
75 box *make_script_box(box *, box *, box *);
76 box *make_mark_box(box *);
77 box *make_lineup_box(box *);
79 class list_box
80 : public box
82 int is_script;
83 box_list list;
84 int sty;
86 public:
87 list_box(box *);
88 void debug_print();
89 int compute_metrics(int);
90 void compute_subscript_kern();
91 void output();
92 void check_tabs(int);
93 void append(box *);
94 list_box *to_list_box();
95 void handle_char_type(int, int);
96 void compute_sublist_width(int n);
97 friend box *make_script_box(box *, box *, box *);
98 friend box *make_mark_box(box *);
99 friend box *make_lineup_box(box *);
102 enum alignment { LEFT_ALIGN, RIGHT_ALIGN, CENTER_ALIGN };
104 class column
105 : public box_list
107 alignment align;
108 int space;
110 public:
111 column(box *);
112 void set_alignment(alignment);
113 void set_space(int);
114 void debug_print(const char *);
116 friend class matrix_box;
117 friend class pile_box;
120 class pile_box
121 : public box
123 column col;
125 public:
126 pile_box(box *);
127 int compute_metrics(int);
128 void output();
129 void debug_print();
130 void check_tabs(int);
131 void set_alignment(alignment a) { col.set_alignment(a); }
132 void set_space(int n) { col.set_space(n); }
133 void append(box *p) { col.append(p); }
136 class matrix_box
137 : public box
139 int len;
140 int maxlen;
141 column **p;
143 public:
144 matrix_box(column *);
145 ~matrix_box();
146 void append(column *);
147 int compute_metrics(int);
148 void output();
149 void check_tabs(int);
150 void debug_print();
153 class pointer_box
154 : public box
156 protected:
157 box *p;
159 public:
160 pointer_box(box *);
161 ~pointer_box();
162 int compute_metrics(int);
163 void compute_subscript_kern();
164 void compute_skew();
165 void debug_print() = 0;
166 void check_tabs(int);
169 class vcenter_box
170 : public pointer_box
172 public:
173 vcenter_box(box *);
174 int compute_metrics(int);
175 void output();
176 void debug_print();
179 class simple_box
180 : public box
182 public:
183 int compute_metrics(int);
184 void compute_subscript_kern();
185 void compute_skew();
186 void output() = 0;
187 void debug_print() = 0;
188 int is_simple();
191 class quoted_text_box
192 : public simple_box
194 char *text;
196 public:
197 quoted_text_box(char *);
198 ~quoted_text_box();
199 void debug_print();
200 void output();
203 class half_space_box
204 : public simple_box
206 public:
207 half_space_box();
208 void output();
209 void debug_print();
212 class space_box
213 : public simple_box
215 public:
216 space_box();
217 void output();
218 void debug_print();
221 class tab_box
222 : public box
224 int disabled;
226 public:
227 tab_box();
228 void output();
229 void debug_print();
230 void check_tabs(int);
233 class size_box
234 : public pointer_box
236 char *size;
238 public:
239 size_box(char *, box *);
240 ~size_box();
241 int compute_metrics(int);
242 void output();
243 void debug_print();
246 class font_box
247 : public pointer_box
249 char *f;
251 public:
252 font_box(char *, box *);
253 ~font_box();
254 int compute_metrics(int);
255 void output();
256 void debug_print();
259 class fat_box
260 : public pointer_box
262 public:
263 fat_box(box *);
264 int compute_metrics(int);
265 void output();
266 void debug_print();
269 class vmotion_box
270 : public pointer_box
272 int n; // up is >= 0
274 public:
275 vmotion_box(int, box *);
276 int compute_metrics(int);
277 void output();
278 void debug_print();
281 class hmotion_box
282 : public pointer_box
284 int n;
286 public:
287 hmotion_box(int, box *);
288 int compute_metrics(int);
289 void output();
290 void debug_print();
293 box *split_text(char *);
294 box *make_delim_box(char *, box *, char *);
295 box *make_sqrt_box(box *);
296 box *make_prime_box(box *);
297 box *make_over_box(box *, box *);
298 box *make_small_over_box(box *, box *);
299 box *make_limit_box(box *, box *, box *);
300 box *make_accent_box(box *, box *);
301 box *make_uaccent_box(box *, box *);
302 box *make_overline_box(box *);
303 box *make_underline_box(box *);
304 box *make_special_box(char *, box *);
306 void set_space(int);
307 int set_gsize(const char *);
308 void set_gfont(const char *);
309 void set_grfont(const char *);
310 void set_gbfont(const char *);
311 const char *get_gfont();
312 const char *get_grfont();
313 const char *get_gbfont();
314 void start_string();
315 void output_string();
316 void do_text(const char *);
317 void restore_compatibility();
318 void set_script_reduction(int n);
319 void set_minimum_size(int n);
320 void set_param(const char *name, int value);
322 void set_char_type(const char *type, char *ch);
324 void init_char_table();
325 void init_extensible();
326 void define_extensible(const char *name, const char *ext, const char *top = 0,
327 const char *mid = 0, const char *bot = 0);
329 #endif // _BOX_H
330 // s-it2-mode