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