| Commit | Line | Data |
|---|---|---|
| 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 | ||
| 6 | This file is part of groff. | |
| 7 | ||
| 8 | groff 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 | |
| 4d3e9548 JL |
10 | Software Foundation, either version 3 of the License, or |
| 11 | (at your option) any later version. | |
| 92d0a6a6 JR |
12 | |
| 13 | groff 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. | |
| 17 | ||
| 4d3e9548 JL |
18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
| 92d0a6a6 JR |
20 | |
| 21 | class list_box; | |
| 22 | ||
| 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); | |
| 48 | }; | |
| 49 | ||
| 50 | class box_list { | |
| 51 | private: | |
| 52 | int maxlen; | |
| 53 | public: | |
| 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 |
| 66 | box *make_script_box(box *, box *, box *); | |
| 67 | box *make_mark_box(box *); | |
| 68 | box *make_lineup_box(box *); | |
| 69 | ||
| 92d0a6a6 JR |
70 | class list_box : public box { |
| 71 | int is_script; | |
| 72 | box_list list; | |
| 73 | int sty; | |
| 74 | public: | |
| 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 | ||
| 90 | enum alignment { LEFT_ALIGN, RIGHT_ALIGN, CENTER_ALIGN }; | |
| 91 | ||
| 92 | class column : public box_list { | |
| 93 | alignment align; | |
| 94 | int space; | |
| 95 | public: | |
| 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 | ||
| 105 | class pile_box : public box { | |
| 106 | column col; | |
| 107 | public: | |
| 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 | ||
| 118 | class matrix_box : public box { | |
| 119 | private: | |
| 120 | int len; | |
| 121 | int maxlen; | |
| 122 | column **p; | |
| 123 | public: | |
| 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 | ||
| 133 | class pointer_box : public box { | |
| 134 | protected: | |
| 135 | box *p; | |
| 136 | public: | |
| 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 | ||
| 146 | class vcenter_box : public pointer_box { | |
| 147 | public: | |
| 148 | vcenter_box(box *); | |
| 149 | int compute_metrics(int); | |
| 150 | void output(); | |
| 151 | void debug_print(); | |
| 152 | }; | |
| 153 | ||
| 154 | class simple_box : public box { | |
| 155 | public: | |
| 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 | ||
| 164 | class quoted_text_box : public simple_box { | |
| 165 | char *text; | |
| 166 | public: | |
| 167 | quoted_text_box(char *); | |
| 168 | ~quoted_text_box(); | |
| 169 | void debug_print(); | |
| 170 | void output(); | |
| 171 | }; | |
| 172 | ||
| 173 | class half_space_box : public simple_box { | |
| 174 | public: | |
| 175 | half_space_box(); | |
| 176 | void output(); | |
| 177 | void debug_print(); | |
| 178 | }; | |
| 179 | ||
| 180 | class space_box : public simple_box { | |
| 181 | public: | |
| 182 | space_box(); | |
| 183 | void output(); | |
| 184 | void debug_print(); | |
| 185 | }; | |
| 186 | ||
| 187 | class tab_box : public box { | |
| 188 | int disabled; | |
| 189 | public: | |
| 190 | tab_box(); | |
| 191 | void output(); | |
| 192 | void debug_print(); | |
| 193 | void check_tabs(int); | |
| 194 | }; | |
| 195 | ||
| 196 | class size_box : public pointer_box { | |
| 197 | private: | |
| 198 | char *size; | |
| 199 | public: | |
| 200 | size_box(char *, box *); | |
| 201 | ~size_box(); | |
| 202 | int compute_metrics(int); | |
| 203 | void output(); | |
| 204 | void debug_print(); | |
| 205 | }; | |
| 206 | ||
| 207 | class font_box : public pointer_box { | |
| 208 | private: | |
| 209 | char *f; | |
| 210 | public: | |
| 211 | font_box(char *, box *); | |
| 212 | ~font_box(); | |
| 213 | int compute_metrics(int); | |
| 214 | void output(); | |
| 215 | void debug_print(); | |
| 216 | }; | |
| 217 | ||
| 218 | class fat_box : public pointer_box { | |
| 219 | public: | |
| 220 | fat_box(box *); | |
| 221 | int compute_metrics(int); | |
| 222 | void output(); | |
| 223 | void debug_print(); | |
| 224 | }; | |
| 225 | ||
| 226 | class vmotion_box : public pointer_box { | |
| 227 | private: | |
| 228 | int n; // up is >= 0 | |
| 229 | public: | |
| 230 | vmotion_box(int, box *); | |
| 231 | int compute_metrics(int); | |
| 232 | void output(); | |
| 233 | void debug_print(); | |
| 234 | }; | |
| 235 | ||
| 236 | class hmotion_box : public pointer_box { | |
| 237 | int n; | |
| 238 | public: | |
| 239 | hmotion_box(int, box *); | |
| 240 | int compute_metrics(int); | |
| 241 | void output(); | |
| 242 | void debug_print(); | |
| 243 | }; | |
| 244 | ||
| 245 | box *split_text(char *); | |
| 246 | box *make_delim_box(char *, box *, char *); | |
| 247 | box *make_sqrt_box(box *); | |
| 248 | box *make_prime_box(box *); | |
| 249 | box *make_over_box(box *, box *); | |
| 250 | box *make_small_over_box(box *, box *); | |
| 251 | box *make_limit_box(box *, box *, box *); | |
| 252 | box *make_accent_box(box *, box *); | |
| 253 | box *make_uaccent_box(box *, box *); | |
| 254 | box *make_overline_box(box *); | |
| 255 | box *make_underline_box(box *); | |
| 256 | box *make_special_box(char *, box *); | |
| 257 | ||
| 258 | void set_space(int); | |
| 259 | int set_gsize(const char *); | |
| 260 | void set_gfont(const char *); | |
| 261 | void set_grfont(const char *); | |
| 262 | void set_gbfont(const char *); | |
| 263 | const char *get_gfont(); | |
| 264 | const char *get_grfont(); | |
| 265 | const char *get_gbfont(); | |
| 266 | void start_string(); | |
| 267 | void output_string(); | |
| 268 | void do_text(const char *); | |
| 269 | void restore_compatibility(); | |
| 270 | void set_script_reduction(int n); | |
| 271 | void set_minimum_size(int n); | |
| 272 | void set_param(const char *name, int value); | |
| 273 | ||
| 274 | void set_char_type(const char *type, char *ch); | |
| 275 | ||
| 276 | void init_char_table(); | |
| 277 | void init_extensible(); | |
| 278 | void define_extensible(const char *name, const char *ext, const char *top = 0, | |
| 279 | const char *mid = 0, const char *bot = 0); |