html-table.h revision 104862
1104862Sru// -*- C++ -*-
2104862Sru/* Copyright (C) 2002 Free Software Foundation, Inc.
3104862Sru *
4104862Sru *  Gaius Mulley (gaius@glam.ac.uk) wrote html-table.cc
5104862Sru *
6104862Sru *  html-table.h
7104862Sru *
8104862Sru *  provides the methods necessary to handle indentation and tab
9104862Sru *  positions using html tables.
10104862Sru */
11104862Sru
12104862Sru/*
13104862SruThis file is part of groff.
14104862Sru
15104862Srugroff is free software; you can redistribute it and/or modify it under
16104862Sruthe terms of the GNU General Public License as published by the Free
17104862SruSoftware Foundation; either version 2, or (at your option) any later
18104862Sruversion.
19104862Sru
20104862Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
21104862SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
22104862SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23104862Srufor more details.
24104862Sru
25104862SruYou should have received a copy of the GNU General Public License along
26104862Sruwith groff; see the file COPYING.  If not, write to the Free Software
27104862SruFoundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
28104862Sru
29104862Sru#include "html.h"
30104862Sru
31104862Sru#if !defined(HTML_TABLE_H)
32104862Sru#define HTML_TABLE_H
33104862Sru
34104862Srutypedef struct tab_position {
35104862Sru  char alignment;
36104862Sru  int  position;
37104862Sru  struct tab_position *next;
38104862Sru} tab_position;
39104862Sru
40104862Sru
41104862Sruclass tabs {
42104862Srupublic:
43104862Sru         tabs         ();
44104862Sru        ~tabs         ();
45104862Sru  void  clear         (void);
46104862Sru  int   compatible    (const char *s);
47104862Sru  void  init          (const char *s);
48104862Sru  int   find_tab      (int pos);
49104862Sru  int   get_tab_pos   (int n);
50104862Sru  char  get_tab_align (int n);
51104862Sru  void  dump_tabs     (void);
52104862Sru
53104862Sruprivate:
54104862Sru  void  delete_list (void);
55104862Sru  tab_position *tab;
56104862Sru};
57104862Sru
58104862Sru/*
59104862Sru *  define a column
60104862Sru */
61104862Sru
62104862Srutypedef struct cols {
63104862Sru  int          left, right;
64104862Sru  int          no;
65104862Sru  char         alignment;
66104862Sru  struct cols *next;
67104862Sru} cols;
68104862Sru
69104862Sruclass html_table {
70104862Srupublic:
71104862Sru      html_table          (simple_output *op, int linelen);
72104862Sru     ~html_table          (void);
73104862Sru  int   add_column        (int coln, int hstart, int hend, char align);
74104862Sru  cols *get_column        (int coln);
75104862Sru  int   insert_column     (int coln, int hstart, int hend, char align);
76104862Sru  int   modify_column     (cols *c, int hstart, int hend, char align);
77104862Sru  int   find_tab_column   (int pos);
78104862Sru  int   find_column       (int pos);
79104862Sru  int   get_tab_pos       (int n);
80104862Sru  char  get_tab_align     (int n);
81104862Sru  void  set_linelength    (int linelen);
82104862Sru  int   no_columns        (void);
83104862Sru  int   no_gaps           (void);
84104862Sru  int   is_gap            (cols *c);
85104862Sru  void  dump_table        (void);
86104862Sru  void  emit_table_header (int space);
87104862Sru  void  emit_col          (int n);
88104862Sru  void  emit_new_row      (void);
89104862Sru  void  emit_finish_table (void);
90104862Sru  int   get_right         (cols *c);
91104862Sru  void  add_indent        (int indent);
92104862Sru  void  finish_row        (void);
93104862Sru  int   get_effective_linelength (void);
94104862Sru
95104862Sru  tabs          *tab_stops;    /* tab stop positions */
96104862Sruprivate:
97104862Sru  cols          *columns;      /* column entries */
98104862Sru  simple_output *out;
99104862Sru  int            linelength;
100104862Sru  cols          *last_col;     /* last column started */
101104862Sru  int            start_space;  /* encapsulate with <p> </p> */
102104862Sru
103104862Sru  void  remove_cols (cols *c);
104104862Sru};
105104862Sru
106104862Sru/*
107104862Sru *  the indentation wrapper.
108104862Sru *  Builds an indentation from a html-table.
109104862Sru *  This table is only emitted if the paragraph is emitted.
110104862Sru */
111104862Sru
112104862Sruclass html_indent {
113104862Srupublic:
114104862Sru  html_indent  (simple_output *op, int ind, int pageoffset, int linelength);
115104862Sru  ~html_indent (void);
116104862Sru  void begin   (int space);   // called if we need to use the indent
117104862Sru  void get_reg (int *ind, int *pageoffset, int *linelength);
118104862Sru
119104862Sru  // the indent is shutdown when it is deleted
120104862Sru
121104862Sruprivate:
122104862Sru  void end     (void);
123104862Sru  int         is_used;
124104862Sru  int         pg;        // values of the registers as passed via initialization
125104862Sru  int         ll;
126104862Sru  int         in;
127104862Sru  html_table *table;
128104862Sru};
129104862Sru
130104862Sru#endif
131