2
* Copyright 1989 Massachusetts Institute of Technology
4
* Permission to use, copy, modify, and distribute this software and its
5
* documentation for any purpose and without fee is hereby granted, provided
6
* that the above copyright notice appear in all copies and that both that
7
* copyright notice and this permission notice appear in supporting
8
* documentation, and that the name of M.I.T. not be used in advertising
9
* or publicity pertaining to distribution of the software without specific,
10
* written prior permission. M.I.T. makes no representations about the
11
* suitability of this software for any purpose. It is provided "as is"
12
* without express or implied warranty.
14
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
15
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
16
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
18
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
19
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
* $Header: /usr/sww/share/src/X11R5/local/clients/xless-1.4/RCS/help.c,v 1.11 1993/02/26 02:09:54 dglo Exp dglo $
28
#include "XLessHelp.icon"
30
static Widget createHelp ARGS((void));
31
static void PopdownHelp ARGS((Widget, XtPointer, XtPointer));
33
/* Function Name: CreateHelp.
34
* Description: This function creates the help widget so that it will be
35
* ready to be displayed.
37
* Returns: the help widget
44
extern Widget toplevel;
48
const char *help_page;
50
Widget base, pane, helptext, button;
51
XtCallbackRec callback[2];
53
const String quitstr = "#override <Key>Q: set() notify() unset()\n";
55
/* try to open the help file */
56
env = getenv("XLESSHELPFILE");
58
help_file = fopen(env, "r");
60
help_file = fopen(resources.help_file, "r");
61
if (help_file == NULL) {
62
CouldntOpen(toplevel, resources.help_file);
65
help_page = InitData(help_file);
67
/* create a new application shell */
69
helpicon = XCreateBitmapFromData(disp, XRootWindow(disp, 0), XLessHelp_bits,
70
XLessHelp_width, XLessHelp_height);
71
XtSetArg(args[i], XtNiconPixmap, helpicon); i++;
72
XtSetArg(args[i], XtNiconName, "xless: help"); i++;
73
XtSetArg(args[i], XtNallowShellResize, TRUE); i++;
74
base = XtAppCreateShell("help", XLESS_CLASS, applicationShellWidgetClass,
77
pane = XtCreateManagedWidget("help_pane", panedWidgetClass, base, NULL, 0);
79
helptext = MakeText(pane, help_page);
81
/* set up Done button callback array */
82
callback[0].callback = PopdownHelp;
83
callback[0].closure = (XtPointer)base;
84
callback[1].callback = NULL;
85
callback[1].closure = (XtPointer)NULL;
87
/* set up Done button accelerator */
88
accel = XtParseAcceleratorTable(quitstr);
90
/* create Done button */
92
XtSetArg(args[i], XtNfont, buttonfont); i++;
93
XtSetArg(args[i], XtNlabel, "Done With Help"); i++;
94
XtSetArg(args[i], XtNcallback, callback); i++;
95
XtSetArg(args[i], XtNaccelerators, accel); i++;
96
button = XtCreateManagedWidget("help_quit", commandWidgetClass, pane,
98
XtInstallAccelerators(helptext, button);
100
XtRealizeWidget(base);
105
/* Function Name: PopdownHelp
106
* Description: This function pops down the help widget.
107
* Arguments: w - the widget we are calling back from.
108
* number - (closure) the number to switch on.
109
* junk - (call data) not used.
116
PopdownHelp(w, help_widget, junk)
118
XtPointer help_widget, junk;
120
XtPopdown((Widget )help_widget);
123
/* Function Name: PopupHelp
124
* Description: This function pops up the help widget, unless no
125
* help could be found.
126
* Arguments: w - the widget we are calling back from.
127
* number - (closure) the number to switch on.
128
* junk - (call data) not used.
135
PopupHelp(w, number, junk)
137
XtPointer number, junk;
139
static Widget help_widget = 0;
142
help_widget = createHelp();
144
XtPopup(help_widget, XtGrabNone);