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