1104862Sru// -*- C++ -*-
2151497Sru/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3104862Sru *
4114402Sru *  Gaius Mulley (gaius@glam.ac.uk) wrote html-table.h
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
27151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, 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);
48151497Sru  void  check_init    (const char *s);
49104862Sru  int   find_tab      (int pos);
50104862Sru  int   get_tab_pos   (int n);
51104862Sru  char  get_tab_align (int n);
52104862Sru  void  dump_tabs     (void);
53104862Sru
54104862Sruprivate:
55104862Sru  void  delete_list (void);
56104862Sru  tab_position *tab;
57104862Sru};
58104862Sru
59104862Sru/*
60104862Sru *  define a column
61104862Sru */
62104862Sru
63104862Srutypedef struct cols {
64104862Sru  int          left, right;
65104862Sru  int          no;
66104862Sru  char         alignment;
67104862Sru  struct cols *next;
68104862Sru} cols;
69104862Sru
70104862Sruclass html_table {
71104862Srupublic:
72104862Sru      html_table          (simple_output *op, int linelen);
73104862Sru     ~html_table          (void);
74104862Sru  int   add_column        (int coln, int hstart, int hend, char align);
75104862Sru  cols *get_column        (int coln);
76104862Sru  int   insert_column     (int coln, int hstart, int hend, char align);
77104862Sru  int   modify_column     (cols *c, int hstart, int hend, char align);
78104862Sru  int   find_tab_column   (int pos);
79104862Sru  int   find_column       (int pos);
80104862Sru  int   get_tab_pos       (int n);
81104862Sru  char  get_tab_align     (int n);
82104862Sru  void  set_linelength    (int linelen);
83104862Sru  int   no_columns        (void);
84104862Sru  int   no_gaps           (void);
85104862Sru  int   is_gap            (cols *c);
86104862Sru  void  dump_table        (void);
87104862Sru  void  emit_table_header (int space);
88104862Sru  void  emit_col          (int n);
89104862Sru  void  emit_new_row      (void);
90104862Sru  void  emit_finish_table (void);
91104862Sru  int   get_right         (cols *c);
92104862Sru  void  add_indent        (int indent);
93104862Sru  void  finish_row        (void);
94104862Sru  int   get_effective_linelength (void);
95151497Sru  void  set_space         (int space);
96104862Sru
97104862Sru  tabs          *tab_stops;    /* tab stop positions */
98151497Sru  simple_output *out;
99104862Sruprivate:
100104862Sru  cols          *columns;      /* column entries */
101104862Sru  int            linelength;
102104862Sru  cols          *last_col;     /* last column started */
103151497Sru  int            start_space;  /* have we seen a `.sp' tag? */
104104862Sru
105104862Sru  void  remove_cols (cols *c);
106104862Sru};
107104862Sru
108104862Sru/*
109104862Sru *  the indentation wrapper.
110104862Sru *  Builds an indentation from a html-table.
111104862Sru *  This table is only emitted if the paragraph is emitted.
112104862Sru */
113104862Sru
114104862Sruclass html_indent {
115104862Srupublic:
116104862Sru  html_indent  (simple_output *op, int ind, int pageoffset, int linelength);
117104862Sru  ~html_indent (void);
118104862Sru  void begin   (int space);   // called if we need to use the indent
119104862Sru  void get_reg (int *ind, int *pageoffset, int *linelength);
120104862Sru
121104862Sru  // the indent is shutdown when it is deleted
122104862Sru
123104862Sruprivate:
124104862Sru  void end     (void);
125104862Sru  int         is_used;
126104862Sru  int         pg;        // values of the registers as passed via initialization
127104862Sru  int         ll;
128104862Sru  int         in;
129104862Sru  html_table *table;
130104862Sru};
131104862Sru
132104862Sru#endif
133