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/Grid.h>
52
53 #define TITLEFONT "-*-helvetica-bold-r-*--*-140-*-*-*-*-iso8859-1"
54 #define BOLDFONT "-*-helvetica-bold-r-*--*-120-*-*-*-*-iso8859-1"
55 #define TEXTFONT "-*-helvetica-medium-r-*--*-100-*-*-*-*-iso8859-1"
56
57 static char *data =
58 "|1996 Income Summary\n\
59 |Shampoo|Conditioner|Soap|Total\n\
60 Revenues:\n\
61 Sales|$ 1,600,000|$ 1,000,000|$ 800,000|$ 3,400,000\n\
62 Less Discounts|(16,000)|(10,000)|(8,000)|(34,000)\n\
63 Less Return Allowance|(8,000)|(5,000)|(4,000)|(17,000)\n\
64 Net Revenue|1,576,000|985,000|792,000|3,349,000\n\
65 \n\
66 Less Expenses:\n\
67 Cost of Goods Sold|(640,000)|(330,000)|(264,000)|(1,234,000)\n\
68 Salary Expense|(380,000)|(280,000)|(180,000)|(840,000)\n\
69 Marketing Expense|(157,600)|(98,500)|(79,200)|(335,300)\n\
70 Rent Expense|(36,000)|(36,000)|(36,000)|(108,000)\n\
71 Misc. Other Expense|(36,408)|(22,335)|(16,776)|(75,519)\n\
72 Total Expenses|(1,250,008)|(766,835)|(575,976)|(2,592,819)\n\
73 \n\
74 Income Tax Expense|(130,397)|(87,266)|(86,410)|(304,072)\n\
75 Net Income|195,595|130,899|129,614|456,109";
76
77 main(argc, argv)
78 int argc;
79 char *argv[];
80 {
81 XtAppContext app;
82 Widget shell, grid;
83 int i, r;
84
85 shell = XtAppInitialize(&app,
"Grid5",
NULL,
0,
86 &argc, argv,
NULL,
NULL,
0);
87
88 grid = XtVaCreateManagedWidget(
"grid",
89 xmlGridWidgetClass, shell,
90 XtVaTypedArg, XmNbackground, XmRString,
"#C0C0C0",
8,
91 XtVaTypedArg, XmNforeground, XmRString,
"black",
6,
92 XmNheadingColumns,
1,
93 XmNcolumns,
3,
94 XmNfooterColumns,
1,
95 XmNsimpleWidths,
"24c 11c 11c 11c 11c",
96 XmNvisibleColumns,
10,
97 XmNvisibleRows,
14,
98 XtVaTypedArg, XmNfontList, XmRString,
TEXTFONT,
99 strlen(
TEXTFONT) +
1,
100 XmNselectionPolicy, XmSELECT_NONE,
101 NULL);
102
103 XtVaSetValues(grid,
104 XmNlayoutFrozen, True,
105 NULL);
106
107
108 XtVaSetValues(grid,
109 XmNcellDefaults, True,
110 XtVaTypedArg, XmNcellBackground, XmRString,
"#FFFF00",
8,
111 XtVaTypedArg, XmNcellForeground, XmRString,
"#000080",
8,
112 XmNcellLeftBorderType, XmBORDER_NONE,
113 XmNcellRightBorderType, XmBORDER_NONE,
114 XmNcellTopBorderType, XmBORDER_NONE,
115 XtVaTypedArg, XmNcellBottomBorderColor, XmRString,
"black",
6,
116 XmNcellAlignment, XmALIGNMENT_CENTER,
117 NULL);
118 XmLGridAddRows(grid, XmHEADING, -
1,
1);
119
120
121 XtVaSetValues(grid,
122 XmNrowType, XmHEADING,
123 XmNrow,
0,
124 XmNcolumn,
0,
125 XmNcellColumnSpan,
2,
126 XtVaTypedArg, XmNcellFontList, XmRString,
TITLEFONT,
127 strlen(
TITLEFONT) +
1,
128 NULL);
129
130
131 XtVaSetValues(grid,
132 XmNcellDefaults, True,
133 XtVaTypedArg, XmNcellFontList, XmRString,
BOLDFONT,
134 strlen(
BOLDFONT) +
1,
135 XtVaTypedArg, XmNcellBackground, XmRString,
"white",
6,
136 XtVaTypedArg, XmNcellForeground, XmRString,
"black",
6,
137 XmNcellBottomBorderType, XmBORDER_NONE,
138 NULL);
139 XmLGridAddRows(grid, XmHEADING, -
1,
1);
140
141
142 XtVaSetValues(grid,
143 XmNcellDefaults, True,
144 XmNcellAlignment, XmALIGNMENT_RIGHT,
145 XtVaTypedArg, XmNcellFontList, XmRString,
TEXTFONT,
146 strlen(
TEXTFONT) +
1,
147 NULL);
148 XtVaSetValues(grid,
149 XmNcellDefaults, True,
150 XmNcolumnType, XmHEADING,
151 XmNcolumn,
0,
152 XmNcellAlignment, XmALIGNMENT_LEFT,
153 NULL);
154 XmLGridAddRows(grid, XmCONTENT, -
1,
15);
155
156
157 XtVaSetValues(grid,
158 XmNcellDefaults, True,
159 XtVaTypedArg, XmNcellForeground, XmRString,
"white",
6,
160 XtVaTypedArg, XmNcellBackground, XmRString,
"#000080",
8,
161 XtVaTypedArg, XmNcellFontList, XmRString,
BOLDFONT,
162 strlen(
BOLDFONT) +
1,
163 NULL);
164 XmLGridAddRows(grid, XmFOOTER, -
1,
1);
165
166
167 XtVaSetValues(grid,
168 XmNcolumnType, XmHEADING,
169 XmNcolumn,
0,
170 XmNrow,
0,
171 XtVaTypedArg, XmNcellFontList, XmRString,
BOLDFONT,
172 strlen(
BOLDFONT) +
1,
173 NULL);
174
175
176 XtVaSetValues(grid,
177 XmNcolumnType, XmHEADING,
178 XmNcolumn,
0,
179 XmNrow,
6,
180 XtVaTypedArg, XmNcellFontList, XmRString,
BOLDFONT,
181 strlen(
BOLDFONT) +
1,
182 NULL);
183
184
185 XtVaSetValues(grid,
186 XmNcolumnType, XmALL_TYPES,
187 XmNcolumnRangeStart,
2,
188 XmNcolumnRangeEnd,
4,
189 XmNcolumnStep,
2,
190 XtVaTypedArg, XmNcellBackground, XmRString,
"#E8E8E8",
8,
191 NULL);
192
193
194 XtVaSetValues(grid,
195 XmNrowType, XmHEADING,
196 XmNrow,
1,
197 XmNcolumnType, XmALL_TYPES,
198 XmNcolumnRangeStart,
2,
199 XmNcolumnRangeEnd,
4,
200 XmNcolumnStep,
2,
201 XtVaTypedArg, XmNcellBackground, XmRString,
"#E8E8E8",
8,
202 NULL);
203
204
205 XtVaSetValues(grid,
206 XmNrowRangeStart,
4,
207 XmNrowRangeEnd,
12,
208 XmNrowStep,
8,
209 XmNcolumnType, XmALL_TYPES,
210 XtVaTypedArg, XmNcellForeground, XmRString,
"white",
6,
211 XtVaTypedArg, XmNcellBackground, XmRString,
"#000080",
8,
212 XtVaTypedArg, XmNcellFontList, XmRString,
BOLDFONT,
213 strlen(
BOLDFONT) +
1,
214 NULL);
215
216 XtVaSetValues(grid,
217 XmNlayoutFrozen, False,
218 NULL);
219
220 XmLGridSetStrings(grid, data);
221
222 XtRealizeWidget(shell);
223 XtAppMainLoop(app);
224 }
225