home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / groff / tbl / table.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-30  |  3.5 KB  |  149 lines

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990 Free Software Foundation, Inc.
  3.      Written by James Clark (jjc@jclark.uucp)
  4.  
  5. This file is part of groff.
  6.  
  7. groff is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation; either version 1, or (at your option) any later
  10. version.
  11.  
  12. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15. for more details.
  16.  
  17. You should have received a copy of the GNU General Public License along
  18. with groff; see the file LICENSE.  If not, write to the Free Software
  19. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <assert.h>
  24. #include <ctype.h>
  25. #include <errno.h>
  26.  
  27. #include "cset.h"
  28. #include "cmap.h"
  29. #include "stringclass.h"
  30. #include "errarg.h"
  31. #include "error.h"
  32. #include "lib.h"
  33.  
  34. struct inc_number {
  35.   short inc;
  36.   short val;
  37. };
  38.  
  39. struct entry_modifier {
  40.   inc_number point_size;
  41.   inc_number vertical_spacing;
  42.   string font;
  43.   enum { CENTER, TOP, BOTTOM } vertical_alignment;
  44.   char zero_width;
  45.   char stagger;
  46.  
  47.   entry_modifier();
  48.   ~entry_modifier();
  49. };
  50.  
  51. struct entry_format : entry_modifier {
  52.   enum format_type {
  53.     LEFT, 
  54.     CENTER, 
  55.     RIGHT, 
  56.     NUMERIC,
  57.     ALPHABETIC,
  58.     SPAN, 
  59.     VSPAN,
  60.     HLINE,
  61.     DOUBLE_HLINE,
  62.     }
  63.   type;
  64.  
  65.   entry_format(format_type);
  66.   entry_format();
  67.   void debug_print() const;
  68. };
  69.  
  70. struct table_entry;
  71. struct horizontal_span;
  72. struct stuff;
  73. struct vertical_rule;
  74.  
  75. class table {
  76.   unsigned flags;
  77.   int nrows;
  78.   int ncolumns;
  79.   int linesize;
  80.   char delim[2];
  81.   vertical_rule *vrule_list;
  82.   stuff *stuff_list;
  83.   horizontal_span *span_list;
  84.   table_entry *entry_list;
  85.   table_entry ***entry;
  86.   char **vline;
  87.   char *row_is_all_lines;
  88.   string *minimum_width;
  89.   int *column_separation;
  90.   char *equal;
  91.   int left_separation;
  92.   int right_separation;
  93.   int allocated_rows;
  94.   void build_span_list();
  95.   void do_hspan(int r, int c);
  96.   void do_vspan(int r, int c);
  97.   void allocate(int r);
  98.   void compute_widths();
  99.   void divide_span(int, int);
  100.   void sum_columns(int, int);
  101.   void compute_separation_factor();
  102.   void compute_column_positions();
  103.   void do_row(int);
  104.   void init_output();
  105.   void add_stuff(stuff *);
  106.   void do_top();
  107.   void do_bottom();
  108.   void do_vertical_rules();
  109.   void build_vrule_list();
  110.   void add_vertical_rule(int, int, int, int);
  111.   void define_bottom_macro();
  112.   int vline_spanned(int r, int c);
  113.   int row_begins_section(int);
  114.   int row_ends_section(int);
  115.   void make_columns_equal();
  116.   void compute_vrule_top_adjust(int, int, string &);
  117.   void compute_vrule_bot_adjust(int, int, string &);
  118.   void determine_row_type();
  119. public:
  120.   /* used by flags */
  121.   enum {
  122.     CENTER = 01,
  123.     EXPAND = 02,
  124.     BOX = 04,
  125.     ALLBOX = 010,
  126.     DOUBLEBOX = 020
  127.     };
  128.   table(int nc, unsigned flags, int linesize);
  129.   ~table();
  130.  
  131.   void add_text_line(int r, const string &, const char *, int);
  132.   void add_single_hline(int r);
  133.   void add_double_hline(int r);
  134.   void add_entry(int r, int c, const string &, const entry_format *,
  135.          const char *, int lineno);
  136.   void add_vlines(int r, const char *);
  137.   void check();
  138.   void print();
  139.   void set_minimum_width(int c, const string &w);
  140.   void set_column_separation(int c, int n);
  141.   void set_equal_column(int c);
  142.   void set_delim(char c1, char c2);
  143.   void print_single_hline(int r);
  144.   void print_double_hline(int r);
  145.   int get_nrows();
  146. };
  147.  
  148. void set_troff_location(const char *, int);
  149.