box.h revision 75584
1// -*- C++ -*-
2/* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3     Written by James Clark (jjc@jclark.com)
4
5This file is part of groff.
6
7groff is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 2, or (at your option) any later
10version.
11
12groff is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License along
18with groff; see the file COPYING.  If not, write to the Free Software
19Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21struct 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
65class list_box : public box {
66  int is_script;
67  box_list list;
68  int sty;
69public:
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 *);
83};
84
85enum alignment { LEFT_ALIGN, RIGHT_ALIGN, CENTER_ALIGN };
86
87class column : public box_list {
88  alignment align;
89  int space;
90public:
91  column(box *);
92  void set_alignment(alignment);
93  void set_space(int);
94  void debug_print(const char *);
95
96  friend class matrix_box;
97  friend class pile_box;
98};
99
100class pile_box : public box {
101  column col;
102public:
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); }
111};
112
113class matrix_box : public box {
114private:
115  int len;
116  int maxlen;
117  column **p;
118public:
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();
126};
127
128class pointer_box : public box {
129protected:
130  box *p;
131public:
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);
139};
140
141class vcenter_box : public pointer_box {
142public:
143  vcenter_box(box *);
144  int compute_metrics(int);
145  void output();
146  void debug_print();
147};
148
149class simple_box : public box {
150public:
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();
157};
158
159class quoted_text_box : public simple_box {
160  char *text;
161public:
162  quoted_text_box(char *);
163  ~quoted_text_box();
164  void debug_print();
165  void output();
166};
167
168class half_space_box : public simple_box {
169public:
170  half_space_box();
171  void output();
172  void debug_print();
173};
174
175class space_box : public simple_box {
176public:
177  space_box();
178  void output();
179  void debug_print();
180};
181
182class tab_box : public box {
183  int disabled;
184public:
185  tab_box();
186  void output();
187  void debug_print();
188  void check_tabs(int);
189};
190
191class size_box : public pointer_box {
192private:
193  char *size;
194public:
195  size_box(char *, box *);
196  ~size_box();
197  int compute_metrics(int);
198  void output();
199  void debug_print();
200};
201
202class font_box : public pointer_box {
203private:
204  char *f;
205public:
206  font_box(char *, box *);
207  ~font_box();
208  int compute_metrics(int);
209  void output();
210  void debug_print();
211};
212
213class fat_box : public pointer_box {
214public:
215  fat_box(box *);
216  int compute_metrics(int);
217  void output();
218  void debug_print();
219};
220
221class vmotion_box : public pointer_box {
222private:
223  int n;			// up is >= 0
224public:
225  vmotion_box(int, box *);
226  int compute_metrics(int);
227  void output();
228  void debug_print();
229};
230
231class hmotion_box : public pointer_box {
232  int n;
233public:
234  hmotion_box(int, box *);
235  int compute_metrics(int);
236  void output();
237  void debug_print();
238};
239
240box *split_text(char *);
241box *make_script_box(box *, box *, box *);
242box *make_mark_box(box *);
243box *make_lineup_box(box *);
244box *make_delim_box(char *, box *, char *);
245box *make_sqrt_box(box *);
246box *make_prime_box(box *);
247box *make_over_box(box *, box *);
248box *make_small_over_box(box *, box *);
249box *make_limit_box(box *, box *, box *);
250box *make_accent_box(box *, box *);
251box *make_uaccent_box(box *, box *);
252box *make_overline_box(box *);
253box *make_underline_box(box *);
254box *make_special_box(char *, box *);
255
256void set_space(int);
257int set_gsize(const char *);
258void set_gfont(const char *);
259void set_grfont(const char *);
260void set_gbfont(const char *);
261const char *get_gfont();
262const char *get_grfont();
263const char *get_gbfont();
264void start_string();
265void output_string();
266void do_text(const char *);
267void restore_compatibility();
268void set_script_reduction(int n);
269void set_minimum_size(int n);
270void set_param(const char *name, int value);
271
272void set_char_type(const char *type, char *ch);
273
274void init_char_table();
275void init_extensible();
276void define_extensible(const char *name, const char *ext, const char *top = 0,
277		       const char *mid = 0, const char *bot = 0);
278