175584Sru// -*- C++ -*-
2151497Sru/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
3151497Sru   Free Software Foundation, Inc.
475584Sru     Written by James Clark (jjc@jclark.com)
575584Sru
675584SruThis file is part of groff.
775584Sru
875584Srugroff is free software; you can redistribute it and/or modify it under
975584Sruthe terms of the GNU General Public License as published by the Free
1075584SruSoftware Foundation; either version 2, or (at your option) any later
1175584Sruversion.
1275584Sru
1375584Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY
1475584SruWARRANTY; without even the implied warranty of MERCHANTABILITY or
1575584SruFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1675584Srufor more details.
1775584Sru
1875584SruYou should have received a copy of the GNU General Public License along
1975584Sruwith groff; see the file COPYING.  If not, write to the Free Software
20151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
2175584Sru
2275584Srustruct place;
2375584Sru
2475584Sruenum object_type {
2575584Sru  OTHER_OBJECT,
2675584Sru  BOX_OBJECT,
2775584Sru  CIRCLE_OBJECT,
2875584Sru  ELLIPSE_OBJECT,
2975584Sru  ARC_OBJECT,
3075584Sru  SPLINE_OBJECT,
3175584Sru  LINE_OBJECT,
3275584Sru  ARROW_OBJECT,
3375584Sru  MOVE_OBJECT,
3475584Sru  TEXT_OBJECT,
3575584Sru  BLOCK_OBJECT,
3675584Sru  MARK_OBJECT
3775584Sru  };
3875584Sru
3975584Srustruct bounding_box;
4075584Sru
4175584Srustruct object {
4275584Sru  object *prev;
4375584Sru  object *next;
4475584Sru  object();
4575584Sru  virtual ~object();
4675584Sru  virtual position origin();
4775584Sru  virtual double width();
4875584Sru  virtual double radius();
4975584Sru  virtual double height();
5075584Sru  virtual position north();
5175584Sru  virtual position south();
5275584Sru  virtual position east();
5375584Sru  virtual position west();
5475584Sru  virtual position north_east();
5575584Sru  virtual position north_west();
5675584Sru  virtual position south_east();
5775584Sru  virtual position south_west();
5875584Sru  virtual position start();
5975584Sru  virtual position end();
6075584Sru  virtual position center();
6175584Sru  virtual place *find_label(const char *);
6275584Sru  virtual void move_by(const position &);
6375584Sru  virtual int blank();
6475584Sru  virtual void update_bounding_box(bounding_box *);
6575584Sru  virtual object_type type() = 0;
6675584Sru  virtual void print();
6775584Sru  virtual void print_text();
6875584Sru};
6975584Sru
7075584Srutypedef position (object::*corner)();
7175584Sru
7275584Srustruct place {
7375584Sru  object *obj;
7475584Sru  double x, y;
7575584Sru};
7675584Sru
7775584Srustruct string_list;
7875584Sru
7975584Sruclass path {
80104862Sru  position pos;
8175584Sru  corner crn;
8275584Sru  string_list *label_list;
8375584Sru  path *ypath;
84104862Sru  int is_position;
8575584Srupublic:
8675584Sru  path(corner = 0);
87104862Sru  path(position);
8875584Sru  path(char *, corner = 0);
8975584Sru  ~path();
9075584Sru  void append(corner);
9175584Sru  void append(char *);
9275584Sru  void set_ypath(path *);
9375584Sru  int follow(const place &, place *) const;
9475584Sru};
9575584Sru
9675584Srustruct object_list {
9775584Sru  object *head;
9875584Sru  object *tail;
9975584Sru  object_list();
10075584Sru  void append(object *);
10175584Sru  void wrap_up_block(object_list *);
10275584Sru};
10375584Sru
10475584Srudeclare_ptable(place)
10575584Sru
10675584Sru// these go counterclockwise
10775584Sruenum direction {
10875584Sru  RIGHT_DIRECTION,
10975584Sru  UP_DIRECTION,
11075584Sru  LEFT_DIRECTION,
11175584Sru  DOWN_DIRECTION
11275584Sru  };
11375584Sru
11475584Srustruct graphics_state {
11575584Sru  double x, y;
11675584Sru  direction dir;
11775584Sru};
11875584Sru
11975584Srustruct saved_state : public graphics_state {
12075584Sru  saved_state *prev;
12175584Sru  PTABLE(place) *tbl;
12275584Sru};
12375584Sru
12475584Sru
12575584Srustruct text_item {
12675584Sru  text_item *next;
12775584Sru  char *text;
12875584Sru  adjustment adj;
12975584Sru  const char *filename;
13075584Sru  int lineno;
13175584Sru
13275584Sru  text_item(char *, const char *, int);
13375584Sru  ~text_item();
13475584Sru};
13575584Sru
13675584Sruconst unsigned long IS_DOTTED = 01;
13775584Sruconst unsigned long IS_DASHED = 02;
13875584Sruconst unsigned long IS_CLOCKWISE = 04;
13975584Sruconst unsigned long IS_INVISIBLE = 020;
14075584Sruconst unsigned long HAS_LEFT_ARROW_HEAD = 040;
14175584Sruconst unsigned long HAS_RIGHT_ARROW_HEAD = 0100;
14275584Sruconst unsigned long HAS_SEGMENT = 0200;
14375584Sruconst unsigned long IS_SAME = 0400;
14475584Sruconst unsigned long HAS_FROM = 01000;
14575584Sruconst unsigned long HAS_AT = 02000;
14675584Sruconst unsigned long HAS_WITH = 04000;
14775584Sruconst unsigned long HAS_HEIGHT = 010000;
14875584Sruconst unsigned long HAS_WIDTH = 020000;
14975584Sruconst unsigned long HAS_RADIUS = 040000;
15075584Sruconst unsigned long HAS_TO = 0100000;
15175584Sruconst unsigned long IS_CHOPPED = 0200000;
15275584Sruconst unsigned long IS_DEFAULT_CHOPPED = 0400000;
15375584Sruconst unsigned long HAS_THICKNESS = 01000000;
15475584Sruconst unsigned long IS_FILLED = 02000000;
15575584Sruconst unsigned long IS_DEFAULT_FILLED = 04000000;
15675584Sruconst unsigned long IS_ALIGNED = 010000000;
157104862Sruconst unsigned long IS_SHADED = 020000000;
158104862Sruconst unsigned long IS_OUTLINED = 040000000;
15975584Sru
16075584Srustruct segment {
16175584Sru  int is_absolute;
16275584Sru  position pos;
16375584Sru  segment *next;
16475584Sru  segment(const position &, int, segment *);
16575584Sru};
16675584Sru
167151497Sruclass rectangle_object;
168151497Sruclass graphic_object;
169151497Sruclass linear_object;
17075584Sru
17175584Srustruct object_spec {
17275584Sru  unsigned long flags;
17375584Sru  object_type type;
17475584Sru  object_list oblist;
17575584Sru  PTABLE(place) *tbl;
17675584Sru  double dash_width;
17775584Sru  position from;
17875584Sru  position to;
17975584Sru  position at;
18075584Sru  position by;
18175584Sru  path *with;
18275584Sru  text_item *text;
18375584Sru  double height;
18475584Sru  double radius;
18575584Sru  double width;
18675584Sru  double segment_width;
18775584Sru  double segment_height;
18875584Sru  double start_chop;
18975584Sru  double end_chop;
19075584Sru  double thickness;
19175584Sru  double fill;
192104862Sru  char *shaded;
193104862Sru  char *outlined;
19475584Sru  direction dir;
19575584Sru  segment *segment_list;
19675584Sru  position segment_pos;
19775584Sru  int segment_is_absolute;
19875584Sru
19975584Sru  object_spec(object_type);
20075584Sru  ~object_spec();
20175584Sru  object *make_object(position *, direction *);
20275584Sru  graphic_object *make_box(position *, direction *);
20375584Sru  graphic_object *make_block(position *, direction *);
20475584Sru  graphic_object *make_text(position *, direction *);
20575584Sru  graphic_object *make_ellipse(position *, direction *);
20675584Sru  graphic_object *make_circle(position *, direction *);
20775584Sru  linear_object *make_line(position *, direction *);
20875584Sru  linear_object *make_arc(position *, direction *);
20975584Sru  graphic_object *make_linear(position *, direction *);
21075584Sru  graphic_object *make_move(position *, direction *);
21175584Sru  int position_rectangle(rectangle_object *p, position *curpos,
21275584Sru			 direction *dirp);
21375584Sru};
21475584Sru
21575584Sru
21675584Sruobject *make_object(object_spec *, position *, direction *);
21775584Sru
21875584Sruobject *make_mark_object();
21975584Sruobject *make_command_object(char *, const char *, int);
22075584Sru
22175584Sruint lookup_variable(const char *name, double *val);
22275584Sruvoid define_variable(const char *name, double val);
22375584Sru
22475584Sruvoid print_picture(object *);
22575584Sru
226