home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / groff-1.08 / tbl / table.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-31  |  3.6 KB  |  152 lines

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.      Written by James Clark (jjc@jclark.com)
  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 2, 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 COPYING.  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. enum format_type {
  52.   FORMAT_LEFT, 
  53.   FORMAT_CENTER, 
  54.   FORMAT_RIGHT, 
  55.   FORMAT_NUMERIC,
  56.   FORMAT_ALPHABETIC,
  57.   FORMAT_SPAN, 
  58.   FORMAT_VSPAN,
  59.   FORMAT_HLINE,
  60.   FORMAT_DOUBLE_HLINE
  61. };
  62.  
  63. struct entry_format : entry_modifier {
  64.   format_type type;
  65.  
  66.   entry_format(format_type);
  67.   entry_format();
  68.   void debug_print() const;
  69. };
  70.  
  71. struct table_entry;
  72. struct horizontal_span;
  73. struct stuff;
  74. struct vertical_rule;
  75.  
  76. class table {
  77.   unsigned flags;
  78.   int nrows;
  79.   int ncolumns;
  80.   int linesize;
  81.   char delim[2];
  82.   char decimal_point_char;
  83.   vertical_rule *vrule_list;
  84.   stuff *stuff_list;
  85.   horizontal_span *span_list;
  86.   table_entry *entry_list;
  87.   table_entry ***entry;
  88.   char **vline;
  89.   char *row_is_all_lines;
  90.   string *minimum_width;
  91.   int *column_separation;
  92.   char *equal;
  93.   int left_separation;
  94.   int right_separation;
  95.   int allocated_rows;
  96.   void build_span_list();
  97.   void do_hspan(int r, int c);
  98.   void do_vspan(int r, int c);
  99.   void allocate(int r);
  100.   void compute_widths();
  101.   void divide_span(int, int);
  102.   void sum_columns(int, int);
  103.   void compute_separation_factor();
  104.   void compute_column_positions();
  105.   void do_row(int);
  106.   void init_output();
  107.   void add_stuff(stuff *);
  108.   void do_top();
  109.   void do_bottom();
  110.   void do_vertical_rules();
  111.   void build_vrule_list();
  112.   void add_vertical_rule(int, int, int, int);
  113.   void define_bottom_macro();
  114.   int vline_spanned(int r, int c);
  115.   int row_begins_section(int);
  116.   int row_ends_section(int);
  117.   void make_columns_equal();
  118.   void compute_vrule_top_adjust(int, int, string &);
  119.   void compute_vrule_bot_adjust(int, int, string &);
  120.   void determine_row_type();
  121. public:
  122.   /* used by flags */
  123.   enum {
  124.     CENTER = 01,
  125.     EXPAND = 02,
  126.     BOX = 04,
  127.     ALLBOX = 010,
  128.     DOUBLEBOX = 020,
  129.     NOKEEP = 040
  130.     };
  131.   table(int nc, unsigned flags, int linesize, char decimal_point_char);
  132.   ~table();
  133.  
  134.   void add_text_line(int r, const string &, const char *, int);
  135.   void add_single_hline(int r);
  136.   void add_double_hline(int r);
  137.   void add_entry(int r, int c, const string &, const entry_format *,
  138.          const char *, int lineno);
  139.   void add_vlines(int r, const char *);
  140.   void check();
  141.   void print();
  142.   void set_minimum_width(int c, const string &w);
  143.   void set_column_separation(int c, int n);
  144.   void set_equal_column(int c);
  145.   void set_delim(char c1, char c2);
  146.   void print_single_hline(int r);
  147.   void print_double_hline(int r);
  148.   int get_nrows();
  149. };
  150.  
  151. void set_troff_location(const char *, int);
  152.