Commit | Line | Data |
---|---|---|
e79d4cdd WJ |
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 | struct place; | |
22 | ||
23 | enum object_type { | |
24 | OTHER_OBJECT, | |
25 | BOX_OBJECT, | |
26 | CIRCLE_OBJECT, | |
27 | ELLIPSE_OBJECT, | |
28 | ARC_OBJECT, | |
29 | SPLINE_OBJECT, | |
30 | LINE_OBJECT, | |
31 | ARROW_OBJECT, | |
32 | MOVE_OBJECT, | |
33 | TEXT_OBJECT, | |
34 | BLOCK_OBJECT, | |
35 | MARK_OBJECT | |
36 | }; | |
37 | ||
38 | struct bounding_box; | |
39 | ||
40 | struct object { | |
41 | object *prev; | |
42 | object *next; | |
43 | object(); | |
44 | virtual ~object(); | |
45 | virtual position origin(); | |
46 | virtual double width(); | |
47 | virtual double radius(); | |
48 | virtual double height(); | |
49 | virtual position north(); | |
50 | virtual position south(); | |
51 | virtual position east(); | |
52 | virtual position west(); | |
53 | virtual position north_east(); | |
54 | virtual position north_west(); | |
55 | virtual position south_east(); | |
56 | virtual position south_west(); | |
57 | virtual position start(); | |
58 | virtual position end(); | |
59 | virtual position center(); | |
60 | virtual place *find_label(const char *); | |
61 | virtual void move_by(const position &); | |
62 | virtual int blank(); | |
63 | virtual void update_bounding_box(bounding_box *); | |
64 | virtual object_type type() = 0; | |
65 | virtual void print(); | |
66 | virtual void print_text(); | |
67 | }; | |
68 | ||
69 | typedef position (object::*corner)(); | |
70 | ||
71 | struct place { | |
72 | object *obj; | |
73 | double x, y; | |
74 | }; | |
75 | ||
76 | struct string_list; | |
77 | ||
78 | class path { | |
79 | corner crn; | |
80 | string_list *label_list; | |
81 | public: | |
82 | path(corner = 0); | |
83 | path(char *, corner = 0); | |
84 | ~path(); | |
85 | void append(corner); | |
86 | void append(char *); | |
87 | int follow(const place &, place *) const; | |
88 | }; | |
89 | ||
90 | struct object_list { | |
91 | object *head; | |
92 | object *tail; | |
93 | object_list(); | |
94 | void append(object *); | |
95 | void wrap_up_block(object_list *); | |
96 | }; | |
97 | ||
98 | declare_ptable(place) | |
99 | ||
100 | // these go counterclockwise | |
101 | enum direction { | |
102 | RIGHT_DIRECTION, | |
103 | UP_DIRECTION, | |
104 | LEFT_DIRECTION, | |
105 | DOWN_DIRECTION | |
106 | }; | |
107 | ||
108 | struct graphics_state { | |
109 | double x, y; | |
110 | direction dir; | |
111 | }; | |
112 | ||
113 | struct saved_state : graphics_state { | |
114 | saved_state *prev; | |
115 | PTABLE(place) *tbl; | |
116 | }; | |
117 | ||
118 | ||
119 | struct text_item { | |
120 | text_item *next; | |
121 | char *text; | |
122 | adjustment adj; | |
123 | const char *filename; | |
124 | int lineno; | |
125 | ||
126 | text_item(char *, const char *, int); | |
127 | ~text_item(); | |
128 | }; | |
129 | ||
130 | ||
131 | enum { | |
132 | IS_DOTTED = 01, | |
133 | IS_DASHED = 02, | |
134 | IS_CLOCKWISE = 04, | |
135 | IS_INVISIBLE = 020, | |
136 | HAS_LEFT_ARROW_HEAD = 040, | |
137 | HAS_RIGHT_ARROW_HEAD = 0100, | |
138 | HAS_SEGMENT = 0200, | |
139 | IS_SAME = 0400, | |
140 | HAS_FROM = 01000, | |
141 | HAS_AT = 02000, | |
142 | HAS_WITH = 04000, | |
143 | HAS_HEIGHT = 010000, | |
144 | HAS_WIDTH = 020000, | |
145 | HAS_RADIUS = 040000, | |
146 | HAS_TO = 0100000, | |
147 | IS_CHOPPED = 0200000, | |
148 | IS_DEFAULT_CHOPPED = 0400000, | |
149 | HAS_THICKNESS = 01000000, | |
150 | IS_FILLED = 02000000, | |
151 | IS_DEFAULT_FILLED = 04000000, | |
152 | IS_ALIGNED = 010000000, | |
153 | }; | |
154 | ||
155 | struct segment { | |
156 | int is_absolute; | |
157 | position pos; | |
158 | segment *next; | |
159 | segment(const position &, int, segment *); | |
160 | }; | |
161 | ||
162 | struct rectangle_object; | |
163 | struct graphic_object; | |
164 | struct linear_object; | |
165 | ||
166 | struct object_spec { | |
167 | unsigned flags; | |
168 | object_type type; | |
169 | object_list oblist; | |
170 | PTABLE(place) *tbl; | |
171 | double dash_width; | |
172 | position from; | |
173 | position to; | |
174 | position at; | |
175 | position by; | |
176 | path *with; | |
177 | text_item *text; | |
178 | double height; | |
179 | double radius; | |
180 | double width; | |
181 | double segment_width; | |
182 | double segment_height; | |
183 | double start_chop; | |
184 | double end_chop; | |
185 | double thickness; | |
186 | double fill; | |
187 | direction dir; | |
188 | segment *segment_list; | |
189 | position segment_pos; | |
190 | int segment_is_absolute; | |
191 | ||
192 | object_spec(object_type); | |
193 | ~object_spec(); | |
194 | object *make_object(position *, direction *); | |
195 | graphic_object *make_box(position *, direction *); | |
196 | graphic_object *make_block(position *, direction *); | |
197 | graphic_object *make_text(position *, direction *); | |
198 | graphic_object *make_ellipse(position *, direction *); | |
199 | graphic_object *make_circle(position *, direction *); | |
200 | linear_object *make_line(position *, direction *); | |
201 | linear_object *make_arc(position *, direction *); | |
202 | graphic_object *make_linear(position *, direction *); | |
203 | graphic_object *make_move(position *, direction *); | |
204 | int position_rectangle(rectangle_object *p, position *curpos, | |
205 | direction *dirp); | |
206 | }; | |
207 | ||
208 | ||
209 | object *make_object(object_spec *, position *, direction *); | |
210 | ||
211 | object *make_mark_object(); | |
212 | object *make_command_object(char *, const char *, int); | |
213 | ||
214 | int lookup_variable(const char *name, double *val); | |
215 | void define_variable(const char *name, double val); | |
216 | ||
217 | void print_picture(object *); | |
218 |