home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
n
/
newmarch.zip
/
HELP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-08
|
3KB
|
145 lines
/* Author: $Author: jan $
* File: $Source: /usr/usrs/jan/desktop/X_Book.boo/programs/RCS/help.c,v $
* Date: $Date: 1992/09/09 00:10:02 $
* Revision: $Revision: 1.1 $
*/
#include "copyright.h"
#include <stdio.h>
#include <Xm/PushB.h>
#include <Xm/MessageB.h>
char Class_name[] ="XmHelp";
#define MAX_ARGS 20
#define BUFSIZ 1024
void CloseCB ();
/*------------------------------------------------------
** CreateHelp - create help window
*/
Widget CreateHelp (parent)
Widget parent; /* parent widget */
{
Widget button;
Widget message_box; /* Information Dialog */
Arg args[MAX_ARGS]; /* arg list */
int n; /* arg count */
static char message[BUFSIZ]; /* help text */
XmString title_string;
XmString message_string;
XmString button_string;
/* Generate message to display.
*/
sprintf (message, "\
This is a general help message. \n\
See a human if you have problems. \n\
This program doesn't know what is going on.");
message_string = XmStringCreateLtoR (message,
XmSTRING_DEFAULT_CHARSET);
button_string = XmStringCreateLtoR ("Close",
XmSTRING_DEFAULT_CHARSET);
title_string = XmStringCreateLtoR (
"Help dialog",
XmSTRING_DEFAULT_CHARSET);
/* Create Information Dialog
** using a MessageBox
*/
n = 0;
XtSetArg (args[n], XmNdialogTitle,
title_string); n++;
XtSetArg (args[n], XmNokLabelString,
button_string); n++;
XtSetArg (args[n], XmNmessageString,
message_string); n++;
message_box = XmCreateInformationDialog (parent,
"helpbox", args, n);
XtAddCallback (message_box, XmNokCallback,
CloseCB, NULL);
/* Get rid of unwanted buttons */
button = XmMessageBoxGetChild (message_box,
XmDIALOG_CANCEL_BUTTON);
XtUnmanageChild (button);
button = XmMessageBoxGetChild (message_box,
XmDIALOG_HELP_BUTTON);
XtUnmanageChild (button);
/* Free strings and return MessageBox.
*/
XmStringFree (title_string);
XmStringFree (message_string);
XmStringFree (button_string);
return (message_box);
}
/*------------------------------------------------------
** CloseCB - callback for close button
*/
void CloseCB (message_box, client_data, call_data)
Widget message_box; /* widget id */
caddr_t client_data; /* NULL */
caddr_t call_data; /* data from
widget class */
{
Widget shell = XtParent (message_box);
/* Unmanage and destroy widgets.
*/
XtUnmanageChild (message_box);
XtDestroyWidget (shell);
}
void
PushCB(w, client_data, call_data)
Widget w;
caddr_t client_data;
caddr_t call_data;
{ Widget help;
help = CreateHelp (w);
XtManageChild (help);
}
main(argc, argv)
int argc;
char **argv;
{
Widget toplevel;
Widget button;
/* Initialize the intrinsics
with a toplevel widget */
toplevel = XtInitialize(NULL,
Class_name,
NULL,
0,
&argc, argv);
/* Create a widget, with the
toplevel as manager;
*/
button = XmCreatePushButton(toplevel,
"Press here for help",
NULL,
0);
XtAddCallback (button, XmNactivateCallback,
PushCB);
XtManageChild (button);
/* display all of the widgets */
XtRealizeWidget(toplevel);
/* enter the main processing loop */
XtMainLoop();
}