Xft support under OpenMotif 2.3.3 - I've been using this for quite a while on
[nedit.git] / Microline / examples / grid5.c
blob942c3e7b7203267a0f00c79d7cdcb26cca16dcbc
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is the Microline Widget Library, originally made available under the NPL by Neuron Data <http://www.neurondata.com>.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * In addition, as a special exception to the GNU GPL, the copyright holders
38 * give permission to link the code of this program with the Motif and Open
39 * Motif libraries (or with modified versions of these that use the same
40 * license), and distribute linked combinations including the two. You
41 * must obey the GNU General Public License in all respects for all of
42 * the code used other than linking with Motif/Open Motif. If you modify
43 * this file, you may extend this exception to your version of the file,
44 * but you are not obligated to do so. If you do not wish to do so,
45 * delete this exception statement from your version.
47 * ***** END LICENSE BLOCK ***** */
50 #include <Xm/Xm.h>
51 #include <XmL/Grid.h>
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"
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";
77 main(argc, argv)
78 int argc;
79 char *argv[];
81 XtAppContext app;
82 Widget shell, grid;
83 int i, r;
85 shell = XtAppInitialize(&app, "Grid5", NULL, 0,
86 &argc, argv, NULL, NULL, 0);
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);
103 XtVaSetValues(grid,
104 XmNlayoutFrozen, True,
105 NULL);
107 /* Add 'Income Summary' heading row with yellow background */
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);
120 /* Set span on '1996 Income Summary' cell in heading row */
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);
130 /* Add 'Shampoo Conditioner Soap' heading row with white background */
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);
141 /* Add content and footer rows with heading column 0 left justified */
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);
156 /* Add footer row with blue background */
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);
166 /* Bold 'Revenues' cell */
167 XtVaSetValues(grid,
168 XmNcolumnType, XmHEADING,
169 XmNcolumn, 0,
170 XmNrow, 0,
171 XtVaTypedArg, XmNcellFontList, XmRString, BOLDFONT,
172 strlen(BOLDFONT) + 1,
173 NULL);
175 /* Bold 'Less Expenses' cell */
176 XtVaSetValues(grid,
177 XmNcolumnType, XmHEADING,
178 XmNcolumn, 0,
179 XmNrow, 6,
180 XtVaTypedArg, XmNcellFontList, XmRString, BOLDFONT,
181 strlen(BOLDFONT) + 1,
182 NULL);
184 /* Grey middle and footer content column */
185 XtVaSetValues(grid,
186 XmNcolumnType, XmALL_TYPES,
187 XmNcolumnRangeStart, 2,
188 XmNcolumnRangeEnd, 4,
189 XmNcolumnStep, 2,
190 XtVaTypedArg, XmNcellBackground, XmRString, "#E8E8E8", 8,
191 NULL);
193 /* Grey 'Conditioner' and 'Total' cell in heading row 1 */
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);
204 /* Blue and bold 'Net Revenue' and 'Total Expenses' rows */
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);
216 XtVaSetValues(grid,
217 XmNlayoutFrozen, False,
218 NULL);
220 XmLGridSetStrings(grid, data);
222 XtRealizeWidget(shell);
223 XtAppMainLoop(app);