Mercurial > hg > xemacs-beta
comparison pkg-src/tree-x/tree.h @ 163:0132846995bd r20-3b8
Import from CVS: tag r20-3b8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:43:35 +0200 |
parents | |
children | 85ec50267440 |
comparison
equal
deleted
inserted
replaced
162:4de2936b4e77 | 163:0132846995bd |
---|---|
1 /* ---------------------------------------------------------------------------- | |
2 * File : tree.h | |
3 * Purpose : Header file for dynamic tree program | |
4 * ---------------------------------------------------------------------------- | |
5 */ | |
6 | |
7 #define INTF 1 /* enable interface-specific code */ | |
8 | |
9 #define FOREACH_CHILD(child, tree) \ | |
10 for ((child) = (tree)->child ; (child) ; (child) = (child)->sibling) | |
11 | |
12 #define PT_IN_RECT(p1, p2, x1, y1, x2, y2) \ | |
13 ((p1) > (x1) && \ | |
14 (p2) > (y1) && \ | |
15 (p1) < (x2) && \ | |
16 (p2) < (y2)) | |
17 | |
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)) | |
23 | |
24 #define IS_LEAF(node) \ | |
25 ((node)->child == NULL) | |
26 | |
27 typedef struct line Polyline; | |
28 typedef struct tnode Tree; | |
29 | |
30 typedef struct point { | |
31 int x; | |
32 int y; | |
33 } Point; | |
34 | |
35 typedef struct extent { | |
36 Point pos; /* top left corner of rectangle */ | |
37 int width; | |
38 int height; | |
39 } Extent; | |
40 | |
41 struct line { | |
42 int dx, dy; | |
43 Polyline *link; | |
44 }; | |
45 | |
46 typedef struct polygon { | |
47 struct { | |
48 Polyline *head; | |
49 Polyline *tail; | |
50 } lower, upper; | |
51 } Polygon; | |
52 | |
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 */ | |
58 } Label; | |
59 | |
60 struct tnode { | |
61 Tree *parent; | |
62 Tree *child; | |
63 Tree *sibling; | |
64 int width; | |
65 int height; | |
66 int border; | |
67 Polygon contour; | |
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 */ | |
73 Label label; | |
74 char* value; | |
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 */ | |
81 }; | |
82 | |
83 typedef enum { | |
84 Erase, | |
85 Draw | |
86 } DrawMode; | |
87 | |
88 typedef enum { | |
89 Old, | |
90 New | |
91 } PosMode; /* Position mode */ | |
92 | |
93 extern Polyline* MakeLine(); | |
94 extern Tree* MakeNode(); | |
95 extern Tree* ReadTreeFromFile(); | |
96 extern void ComputeTreeSize(); | |
97 extern void Unzip(); | |
98 extern void Zip(); | |
99 | |
100 extern Tree *TheTree; | |
101 extern int NumLines; | |
102 extern int NumNodes; |