1 /* $XConsortium: onHelp.c /main/4 1995/07/15 20:44:13 drk $ */
2 /*
3 * Motif
4 *
5 * Copyright (c) 1987-2012, The Open Group. All rights reserved.
6 *
7 * These libraries and programs are free software; you can
8 * redistribute them and/or modify them under the terms of the GNU
9 * Lesser General Public License as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
11 * any later version.
12 *
13 * These libraries and programs are distributed in the hope that
14 * they will be useful, but WITHOUT ANY WARRANTY; without even the
15 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU Lesser General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with these librararies and programs; if not, write
21 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
22 * Floor, Boston, MA 02110-1301 USA
23 *
24 */
25 /*
26 * HISTORY
27 */
28
29 #include <stdlib.h>
30 #include <Xm/Xm.h>
31 #include "Help.h"
32
quitCB(Widget widget,char * tag,XmAnyCallbackStruct * callback_data)33 void quitCB( Widget widget, char *tag, XmAnyCallbackStruct *callback_data )
34 {
35 exit(0);
36 }
37
38 /*
39 * Main program
40 */
main(int argc,String argv[])41 int main(int argc, String argv[])
42 {
43 Arg args[10];
44 XtAppContext app_context;
45 int n;
46 Widget toplevel, help;
47 Cardinal size;
48 XmRendition rend[10];
49 XmRenderTable rt;
50 int i;
51 XmTab tabs[5];
52 XmTabList tablist;
53 Widget dismiss;
54
55 toplevel = XtVaAppInitialize(&app_context, "HelpOnHelp", NULL, 0,
56 &argc, argv, NULL, NULL);
57 n = 0;
58 XtSetArg(args[n], XmdNhelpFile, "helpOn"); n++;
59 help = XmdCreateHelp(toplevel, "help", args, n);
60 dismiss = XtNameToWidget(help, "*Dismiss");
61 XtAddCallback(dismiss, XmNactivateCallback,
62 (XtCallbackProc) quitCB, NULL);
63 /* Get the rendertable and add some new renditions */
64 XtVaGetValues(help, XmNrenderTable, &rt, NULL, NULL);
65 /* Make the tabs for the tables */
66 n = 0;
67 tabs[n] = XmTabCreate(2.0, XmINCHES, XmABSOLUTE,
68 XmALIGNMENT_BEGINNING, NULL); n++;
69 tabs[n] = XmTabCreate(4.0, XmINCHES, XmABSOLUTE,
70 XmALIGNMENT_BEGINNING, NULL); n++;
71 tablist = XmTabListInsertTabs(NULL, tabs, n, 0);
72 for(i = 0; i < n; i++) XmTabFree(tabs[i]);
73
74 /* Add extra renditions needed for the help file */
75 n = 0; i = 0;
76 XtSetArg(args[n], XmNtabList, tablist); n++;
77 rend[i] = XmRenditionCreate(help, "table", args, n); i++;
78 n = 0;
79 XtSetArg(args[n], XmNfontName, "*courier-medium-r-*-12-*"); n++;
80 XtSetArg(args[n], XmNfontType, XmFONT_IS_FONT); n++;
81 rend[i] = XmRenditionCreate(help, "program", args, n); i++;
82 n = 0;
83 XtSetArg(args[n], XmNunderlineType, XmSINGLE_LINE); n++;
84 rend[i] = XmRenditionCreate(help, "underline", args, n); i++;
85 /* Make a copy so that setvalues will work correctly */
86 rt = XmRenderTableCopy(rt, NULL, 0);
87 rt = XmRenderTableAddRenditions(rt, rend, i, XmMERGE_NEW);
88 for(n = 0; n < i; n++) XmRenditionFree(rend[n]);
89
90 XtVaSetValues(help, XmNrenderTable, rt, NULL, NULL);
91 XmRenderTableFree(rt);
92
93 XtManageChild(help);
94
95 XtRealizeWidget(toplevel);
96
97 XtAppMainLoop(app_context);
98
99 return 0; /* make compiler happy */
100 }
101