annotate lisp/oobr/tree-x/tree.h @ 58:8b0bdfdf0cf0 r19-16-pre4

Import from CVS: tag r19-16-pre4
author cvs
date Mon, 13 Aug 2007 08:58:37 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 * File : tree.h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 * Purpose : Header file for dynamic tree program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 * ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 #define INTF 1 /* enable interface-specific code */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 #define FOREACH_CHILD(child, tree) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 for ((child) = (tree)->child ; (child) ; (child) = (child)->sibling)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 #define PT_IN_RECT(p1, p2, x1, y1, x2, y2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ((p1) > (x1) && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 (p2) > (y1) && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 (p1) < (x2) && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 (p2) < (y2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 #define PT_IN_EXTENT(p1, p2, extent) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ((p1) > (extent).pos.x && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 (p2) > (extent).pos.y && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (p1) < ((extent).pos.x + (extent).width) && \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (p2) < ((extent).pos.y + (extent).height))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 #define IS_LEAF(node) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ((node)->child == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 typedef struct line Polyline;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 typedef struct tnode Tree;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 typedef struct point {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 int x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 int y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 } Point;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 typedef struct extent {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 Point pos; /* top left corner of rectangle */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 int width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 int height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 } Extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 struct line {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 int dx, dy;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Polyline *link;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 typedef struct polygon {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 struct {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 Polyline *head;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 Polyline *tail;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 } lower, upper;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 } Polygon;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 typedef struct label {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 char *text; /* the actual label text */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 int len; /* length of label text */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 int xoffset; /* the X offset of label inside rectangle */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 int yoffset; /* the Y offset of label inside rectangle */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 } Label;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 struct tnode {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Tree *parent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 Tree *child;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 Tree *sibling;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 int width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 int height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 int border;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 Polygon contour;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Point offset; /* offset is relative to 'predecessor' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 Point pos; /* position is screen coordinates of node */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 Point old_pos; /* position is screen coordinates of node */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 int node_height; /* height of node in tree */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 /* all fields below are interface-specific */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 Label label;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 char* value;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 Extent subextent; /* extent of subtree (excluding this node) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 Polygon old_contour; /* for caching old contour in elision */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 char elision; /* TRUE if this node is collapsed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 char on_path; /* true if on path to root from node */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 char split; /* flag for drawing subtree contours */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 char show_contour; /* flag to show or hide subtree contour */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 typedef enum {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 Erase,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 Draw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 } DrawMode;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 typedef enum {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 Old,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 New
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 } PosMode; /* Position mode */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 extern Polyline* MakeLine();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 extern Tree* MakeNode();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 extern Tree* ReadTreeFromFile();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 extern void ComputeTreeSize();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 extern void Unzip();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 extern void Zip();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 extern Tree *TheTree;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 extern int NumLines;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 extern int NumNodes;