1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 #include <Xm/Xm.h>
51 #include <XmL/Tree.h>
52
53 #define sphere_width
16
54 #define sphere_height
16
55 static unsigned char sphere_bits[] = {
56 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0x38, 0x3f,
57 0xb8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x3f, 0xf0, 0x1f, 0xe0, 0x0f,
58 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
59 #define monitor_width
16
60 #define monitor_height
16
61 static unsigned char monitor_bits[] = {
62 0x00, 0x00, 0xf8, 0x3f, 0xf8, 0x3f, 0x18, 0x30, 0x58, 0x37, 0x18, 0x30,
63 0x58, 0x37, 0x18, 0x30, 0xf8, 0x3f, 0xf8, 0x3f, 0x80, 0x03, 0x80, 0x03,
64 0xf0, 0x1f, 0xf0, 0x1f, 0x00, 0x00, 0x00, 0x00};
65
66 main(argc, argv)
67 int argc;
68 char *argv[];
69 {
70 XtAppContext app;
71 Widget shell, tree;
72 XmLTreeRowDefinition *rows;
73 Pixmap monitorPixmap, spherePixmap;
74 Pixel black, white;
75 int i, n, size;
76 static struct
77 {
78 Boolean expands;
79 int level;
80 char *string;
81 } data[] =
82 {
83 { True,
0,
"Root" },
84 { True,
1,
"Parent A" },
85 { False,
2,
"Node A1" },
86 { False,
2,
"Node A2" },
87 { True,
2,
"Parent B" },
88 { False,
3,
"Node B1" },
89 { False,
3,
"Node B2" },
90 { True,
1,
"Parent C" },
91 { False,
2,
"Node C1" },
92 { True,
1,
"Parent D" },
93 { False,
2,
"Node D1" },
94 };
95
96 shell = XtAppInitialize(&app,
"Tree3",
NULL,
0,
97 &argc, argv,
NULL,
NULL,
0);
98
99 black = BlackPixelOfScreen(XtScreen(shell));
100 white = WhitePixelOfScreen(XtScreen(shell));
101 spherePixmap = XCreatePixmapFromBitmapData(XtDisplay(shell),
102 DefaultRootWindow(XtDisplay(shell)),
103 sphere_bits, sphere_width, sphere_height,
104 black, white,
105 DefaultDepthOfScreen(XtScreen(shell)));
106 monitorPixmap = XCreatePixmapFromBitmapData(XtDisplay(shell),
107 DefaultRootWindow(XtDisplay(shell)),
108 monitor_bits, monitor_width, monitor_height,
109 black, white,
110 DefaultDepthOfScreen(XtScreen(shell)));
111
112
113
114
115
116 tree = XtVaCreateManagedWidget(
"tree",
117 xmlTreeWidgetClass, shell,
118 XtVaTypedArg, XmNbackground, XmRString,
"#C0C0C0",
8,
119 XtVaTypedArg, XmNforeground, XmRString,
"black",
6,
120 XtVaTypedArg, XmNblankBackground, XmRString,
"white",
6,
121 XtVaTypedArg, XmNselectBackground, XmRString,
"#000080",
8,
122 XtVaTypedArg, XmNselectForeground, XmRString,
"white",
6,
123 XtVaTypedArg, XmNconnectingLineColor, XmRString,
"#808080",
8,
124 XmNallowColumnResize, True,
125 XmNheadingRows,
1,
126 XmNvisibleRows,
14,
127 XmNcolumns,
3,
128 XmNvisibleColumns,
5,
129 XmNsimpleWidths,
"12c 8c 10c",
130 XmNsimpleHeadings,
"All Folders|SIZE|DATA2",
131 XmNselectionPolicy, XmSELECT_MULTIPLE_ROW,
132 XmNhighlightRowMode, True,
133 XmNglobalPixmapWidth,
16,
134 XmNglobalPixmapHeight,
16,
135 NULL);
136
137
138 XtVaSetValues(tree,
139 XmNcellDefaults, True,
140 XtVaTypedArg, XmNcellBackground, XmRString,
"white",
6,
141 XmNcellLeftBorderType, XmBORDER_NONE,
142 XmNcellRightBorderType, XmBORDER_NONE,
143 XmNcellTopBorderType, XmBORDER_NONE,
144 XmNcellBottomBorderType, XmBORDER_NONE,
145 NULL);
146
147
148
149 n =
11;
150 size =
sizeof(XmLTreeRowDefinition) * n;
151 rows = (XmLTreeRowDefinition *)malloc(size);
152 for (i =
0; i < n; i++)
153 {
154 rows[i].level = data[i].level;
155 rows[i].expands = data[i].expands;
156 rows[i].isExpanded = True;
157 if (data[i].expands)
158 rows[i].pixmap = spherePixmap;
159 else
160 rows[i].pixmap = monitorPixmap;
161 rows[i].pixmask = XmUNSPECIFIED_PIXMAP;
162 rows[i].string = XmStringCreateSimple(data[i].string);
163 }
164 XmLTreeAddRows(tree, rows, n, -
1);
165
166
167
168 for (i =
0; i < n; i++)
169 {
170 XmStringFree(rows[i].string);
171 XmLGridSetStringsPos(tree, XmCONTENT, i, XmCONTENT,
1,
"1032|1123");
172 }
173 free((
char *)rows);
174
175 XtRealizeWidget(shell);
176 XtAppMainLoop(app);
177 }
178