1/*	$NetBSD$	*/
2
3// -*- C++ -*-
4/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
5   Free Software Foundation, Inc.
6     Written by James Clark (jjc@jclark.com)
7
8This file is part of groff.
9
10groff is free software; you can redistribute it and/or modify it under
11the terms of the GNU General Public License as published by the Free
12Software Foundation; either version 2, or (at your option) any later
13version.
14
15groff is distributed in the hope that it will be useful, but WITHOUT ANY
16WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18for more details.
19
20You should have received a copy of the GNU General Public License along
21with groff; see the file COPYING.  If not, write to the Free Software
22Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
23
24struct place;
25
26enum object_type {
27  OTHER_OBJECT,
28  BOX_OBJECT,
29  CIRCLE_OBJECT,
30  ELLIPSE_OBJECT,
31  ARC_OBJECT,
32  SPLINE_OBJECT,
33  LINE_OBJECT,
34  ARROW_OBJECT,
35  MOVE_OBJECT,
36  TEXT_OBJECT,
37  BLOCK_OBJECT,
38  MARK_OBJECT
39  };
40
41struct bounding_box;
42
43struct object {
44  object *prev;
45  object *next;
46  object();
47  virtual ~object();
48  virtual position origin();
49  virtual double width();
50  virtual double radius();
51  virtual double height();
52  virtual position north();
53  virtual position south();
54  virtual position east();
55  virtual position west();
56  virtual position north_east();
57  virtual position north_west();
58  virtual position south_east();
59  virtual position south_west();
60  virtual position start();
61  virtual position end();
62  virtual position center();
63  virtual place *find_label(const char *);
64  virtual void move_by(const position &);
65  virtual int blank();
66  virtual void update_bounding_box(bounding_box *);
67  virtual object_type type() = 0;
68  virtual void print();
69  virtual void print_text();
70};
71
72typedef position (object::*corner)();
73
74struct place {
75  object *obj;
76  double x, y;
77};
78
79struct string_list;
80
81class path {
82  position pos;
83  corner crn;
84  string_list *label_list;
85  path *ypath;
86  int is_position;
87public:
88  path(corner = 0);
89  path(position);
90  path(char *, corner = 0);
91  ~path();
92  void append(corner);
93  void append(char *);
94  void set_ypath(path *);
95  int follow(const place &, place *) const;
96};
97
98struct object_list {
99  object *head;
100  object *tail;
101  object_list();
102  void append(object *);
103  void wrap_up_block(object_list *);
104};
105
106declare_ptable(place)
107
108// these go counterclockwise
109enum direction {
110  RIGHT_DIRECTION,
111  UP_DIRECTION,
112  LEFT_DIRECTION,
113  DOWN_DIRECTION
114  };
115
116struct graphics_state {
117  double x, y;
118  direction dir;
119};
120
121struct saved_state : public graphics_state {
122  saved_state *prev;
123  PTABLE(place) *tbl;
124};
125
126
127struct text_item {
128  text_item *next;
129  char *text;
130  adjustment adj;
131  const char *filename;
132  int lineno;
133
134  text_item(char *, const char *, int);
135  ~text_item();
136};
137
138const unsigned long IS_DOTTED = 01;
139const unsigned long IS_DASHED = 02;
140const unsigned long IS_CLOCKWISE = 04;
141const unsigned long IS_INVISIBLE = 020;
142const unsigned long HAS_LEFT_ARROW_HEAD = 040;
143const unsigned long HAS_RIGHT_ARROW_HEAD = 0100;
144const unsigned long HAS_SEGMENT = 0200;
145const unsigned long IS_SAME = 0400;
146const unsigned long HAS_FROM = 01000;
147const unsigned long HAS_AT = 02000;
148const unsigned long HAS_WITH = 04000;
149const unsigned long HAS_HEIGHT = 010000;
150const unsigned long HAS_WIDTH = 020000;
151const unsigned long HAS_RADIUS = 040000;
152const unsigned long HAS_TO = 0100000;
153const unsigned long IS_CHOPPED = 0200000;
154const unsigned long IS_DEFAULT_CHOPPED = 0400000;
155const unsigned long HAS_THICKNESS = 01000000;
156const unsigned long IS_FILLED = 02000000;
157const unsigned long IS_DEFAULT_FILLED = 04000000;
158const unsigned long IS_ALIGNED = 010000000;
159const unsigned long IS_SHADED = 020000000;
160const unsigned long IS_OUTLINED = 040000000;
161
162struct segment {
163  int is_absolute;
164  position pos;
165  segment *next;
166  segment(const position &, int, segment *);
167};
168
169class rectangle_object;
170class graphic_object;
171class linear_object;
172
173struct object_spec {
174  unsigned long flags;
175  object_type type;
176  object_list oblist;
177  PTABLE(place) *tbl;
178  double dash_width;
179  position from;
180  position to;
181  position at;
182  position by;
183  path *with;
184  text_item *text;
185  double height;
186  double radius;
187  double width;
188  double segment_width;
189  double segment_height;
190  double start_chop;
191  double end_chop;
192  double thickness;
193  double fill;
194  char *shaded;
195  char *outlined;
196  direction dir;
197  segment *segment_list;
198  position segment_pos;
199  int segment_is_absolute;
200
201  object_spec(object_type);
202  ~object_spec();
203  object *make_object(position *, direction *);
204  graphic_object *make_box(position *, direction *);
205  graphic_object *make_block(position *, direction *);
206  graphic_object *make_text(position *, direction *);
207  graphic_object *make_ellipse(position *, direction *);
208  graphic_object *make_circle(position *, direction *);
209  linear_object *make_line(position *, direction *);
210  linear_object *make_arc(position *, direction *);
211  graphic_object *make_linear(position *, direction *);
212  graphic_object *make_move(position *, direction *);
213  int position_rectangle(rectangle_object *p, position *curpos,
214			 direction *dirp);
215};
216
217
218object *make_object(object_spec *, position *, direction *);
219
220object *make_mark_object();
221object *make_command_object(char *, const char *, int);
222
223int lookup_variable(const char *name, double *val);
224void define_variable(const char *name, double val);
225
226void print_picture(object *);
227
228