home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / gnu / groff_src.lha / groff-1.10src / pic / object.h < prev    next >
C/C++ Source or Header  |  1995-06-22  |  5KB  |  218 lines

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3.      Written by James Clark (jjc@jclark.com)
  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 2, 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 COPYING.  If not, write to the Free Software
  19. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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.   path *ypath;
  82. public:
  83.   path(corner = 0);
  84.   path(char *, corner = 0);
  85.   ~path();
  86.   void append(corner);
  87.   void append(char *);
  88.   void set_ypath(path *);
  89.   int follow(const place &, place *) const;
  90. };
  91.  
  92. struct object_list {
  93.   object *head;
  94.   object *tail;
  95.   object_list();
  96.   void append(object *);
  97.   void wrap_up_block(object_list *);
  98. };
  99.  
  100. declare_ptable(place)
  101.  
  102. // these go counterclockwise
  103. enum direction {
  104.   RIGHT_DIRECTION,
  105.   UP_DIRECTION,
  106.   LEFT_DIRECTION,
  107.   DOWN_DIRECTION
  108.   };
  109.  
  110. struct graphics_state {
  111.   double x, y;
  112.   direction dir;
  113. };
  114.  
  115. struct saved_state : public graphics_state {
  116.   saved_state *prev;
  117.   PTABLE(place) *tbl;
  118. };
  119.  
  120.  
  121. struct text_item {
  122.   text_item *next;
  123.   char *text;
  124.   adjustment adj;
  125.   const char *filename;
  126.   int lineno;
  127.  
  128.   text_item(char *, const char *, int);
  129.   ~text_item();
  130. };
  131.  
  132. const unsigned long IS_DOTTED = 01;
  133. const unsigned long IS_DASHED = 02;
  134. const unsigned long IS_CLOCKWISE = 04;
  135. const unsigned long IS_INVISIBLE = 020;
  136. const unsigned long HAS_LEFT_ARROW_HEAD = 040;
  137. const unsigned long HAS_RIGHT_ARROW_HEAD = 0100;
  138. const unsigned long HAS_SEGMENT = 0200;
  139. const unsigned long IS_SAME = 0400;
  140. const unsigned long HAS_FROM = 01000;
  141. const unsigned long HAS_AT = 02000;
  142. const unsigned long HAS_WITH = 04000;
  143. const unsigned long HAS_HEIGHT = 010000;
  144. const unsigned long HAS_WIDTH = 020000;
  145. const unsigned long HAS_RADIUS = 040000;
  146. const unsigned long HAS_TO = 0100000;
  147. const unsigned long IS_CHOPPED = 0200000;
  148. const unsigned long IS_DEFAULT_CHOPPED = 0400000;
  149. const unsigned long HAS_THICKNESS = 01000000;
  150. const unsigned long IS_FILLED = 02000000;
  151. const unsigned long IS_DEFAULT_FILLED = 04000000;
  152. const unsigned long IS_ALIGNED = 010000000;
  153.  
  154. struct segment {
  155.   int is_absolute;
  156.   position pos;
  157.   segment *next;
  158.   segment(const position &, int, segment *);
  159. };
  160.  
  161. struct rectangle_object;
  162. struct graphic_object;
  163. struct linear_object;
  164.  
  165. struct object_spec {
  166.   unsigned long flags;
  167.   object_type type;
  168.   object_list oblist;
  169.   PTABLE(place) *tbl;
  170.   double dash_width;
  171.   position from;
  172.   position to;
  173.   position at;
  174.   position by;
  175.   path *with;
  176.   text_item *text;
  177.   double height;
  178.   double radius;
  179.   double width;
  180.   double segment_width;
  181.   double segment_height;
  182.   double start_chop;
  183.   double end_chop;
  184.   double thickness;
  185.   double fill;
  186.   direction dir;
  187.   segment *segment_list;
  188.   position segment_pos;
  189.   int segment_is_absolute;
  190.  
  191.   object_spec(object_type);
  192.   ~object_spec();
  193.   object *make_object(position *, direction *);
  194.   graphic_object *make_box(position *, direction *);
  195.   graphic_object *make_block(position *, direction *);
  196.   graphic_object *make_text(position *, direction *);
  197.   graphic_object *make_ellipse(position *, direction *);
  198.   graphic_object *make_circle(position *, direction *);
  199.   linear_object *make_line(position *, direction *);
  200.   linear_object *make_arc(position *, direction *);
  201.   graphic_object *make_linear(position *, direction *);
  202.   graphic_object *make_move(position *, direction *);
  203.   int position_rectangle(rectangle_object *p, position *curpos,
  204.              direction *dirp);
  205. };
  206.  
  207.  
  208. object *make_object(object_spec *, position *, direction *);
  209.  
  210. object *make_mark_object();
  211. object *make_command_object(char *, const char *, int);
  212.  
  213. int lookup_variable(const char *name, double *val);
  214. void define_variable(const char *name, double val);
  215.  
  216. void print_picture(object *);
  217.  
  218.