1 /* ----------------------------------------------------------------------------
3 * Purpose : Header file for dynamic tree program
4 * ----------------------------------------------------------------------------
7 #define INTF 1 /* enable interface-specific code */
9 #define FOREACH_CHILD(child, tree) \
10 for ((child) = (tree)->child ; (child) ; (child) = (child)->sibling)
12 #define PT_IN_RECT(p1, p2, x1, y1, x2, y2) \
18 #define PT_IN_EXTENT(p1, p2, extent) \
19 ((p1) > (extent).pos.x && \
20 (p2) > (extent).pos.y && \
21 (p1) < ((extent).pos.x + (extent).width) && \
22 (p2) < ((extent).pos.y + (extent).height))
24 #define IS_LEAF(node) \
25 ((node)->child == NULL)
27 typedef struct line Polyline;
28 typedef struct tnode Tree;
30 typedef struct point {
35 typedef struct extent {
36 Point pos; /* top left corner of rectangle */
46 typedef struct polygon {
53 typedef struct label {
54 char *text; /* the actual label text */
55 int len; /* length of label text */
56 int xoffset; /* the X offset of label inside rectangle */
57 int yoffset; /* the Y offset of label inside rectangle */
68 Point offset; /* offset is relative to 'predecessor' */
69 Point pos; /* position is screen coordinates of node */
70 Point old_pos; /* position is screen coordinates of node */
71 int node_height; /* height of node in tree */
72 /* all fields below are interface-specific */
75 Extent subextent; /* extent of subtree (excluding this node) */
76 Polygon old_contour; /* for caching old contour in elision */
77 char elision; /* TRUE if this node is collapsed */
78 char on_path; /* true if on path to root from node */
79 char split; /* flag for drawing subtree contours */
80 char show_contour; /* flag to show or hide subtree contour */
91 } PosMode; /* Position mode */
94 Polyline* MakeLine(short dx, short dy, Polyline *line);
96 void ComputeTreeSize(Tree *tree,
97 int *width, int *height,
98 int *x_offset, int *y_offset);
99 void Unzip (Tree *tree);
100 void Zip (Tree *tree);
101 void PetrifyTree (Tree *tree, int x, int y);
102 void DrawTree (Tree *tree, PosMode pos_mode);
103 void Delete (Tree *tree);
104 void DeleteTree (Tree *tree, int contour);
105 void Insert (Tree *parent, Tree *child, Tree *sibling);
106 void DrawTreeContour(Tree *tree, PosMode pos_mode,
107 int color, int detach_p, int select_p, int recursive);
108 void ComputeSubTreeExtent(Tree *tree);
109 void LayoutLeaf (Tree *tree);
110 void RuboutLeaf (Tree *tree);
111 void HiliteNode (Tree *tree, PosMode pos_mode);
112 void DeleteNode (Tree *node);
113 void DrawNode (Tree *node, PosMode pos_mode);
114 void ResetLabels (Tree *tree);
115 void SetupTree (Tree *tree);
116 int SearchTree (Tree *tree, int x, int y, Tree **node);
117 void LayoutTree (Tree *tree);
120 void BeginFrame (void);
121 void EndFrame (void);
123 extern Tree *TheTree;