#include "mview_view.h" #include "mview_misc.h" #include #include static Widget helpshell=NULL, helptext; static char dum[80]; #include #include void popdown_help(Widget w, int *tag, XmAnyCallbackStruct *cbs) { int k; Widget temp; temp = w; while(temp && !XtIsSubclass(temp, shellWidgetClass)) temp = XtParent(temp); for (k = 0; k < 6; k++) if (temp == helpshell) break; XtDestroyWidget(helpshell); helpshell = NULL; } void popup_help_file() { Arg helptext_args[11]; char *text; struct stat statb; FILE *hfile; Widget form, button; if (!helpshell) { helpshell = (Widget) XtVaAppCreateShell("Help", "help_shell", topLevelShellWidgetClass, display, XmNmwmDecorations, MWM_DECOR_TITLE | MWM_DECOR_RESIZEH, MWM_DECOR_BORDER | MWM_DECOR_MINIMIZE, NULL); form = XtVaCreateManagedWidget("form", xmFormWidgetClass, helpshell, NULL); button = XtVaCreateManagedWidget("Dismiss", xmPushButtonWidgetClass, form, XmNleftAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNshowAsDefault, 1, XmNdefaultButtonShadowThickness, 1, NULL); XtAddCallback(button, XmNactivateCallback, (XtCallbackProc) popdown_help, NULL); XtSetArg(helptext_args[0], XmNrows, 12); XtSetArg(helptext_args[1], XmNcolumns, 80); XtSetArg(helptext_args[2], XmNeditable, False); XtSetArg(helptext_args[3], XmNeditMode, XmMULTI_LINE_EDIT); XtSetArg(helptext_args[4], XmNtopAttachment, XmATTACH_FORM); XtSetArg(helptext_args[5], XmNbottomAttachment, XmATTACH_WIDGET); XtSetArg(helptext_args[6], XmNbottomWidget, button); XtSetArg(helptext_args[7], XmNleftAttachment, XmATTACH_FORM); XtSetArg(helptext_args[8], XmNrightAttachment, XmATTACH_FORM); XtSetArg(helptext_args[9], XmNcursorPositionVisible, False); XtSetArg(helptext_args[10], XmNtraversalOn, False); helptext = (Widget) XmCreateScrolledText(form, "text_w", helptext_args, 11); XtManageChild(helptext); sprintf(dum, "%s%s", helplocation, "mview.hlp"); if (stat(dum, &statb) == -1) { text = (char *) malloc(80*sizeof(char)); sprintf(text, "%s", "Help Not found ..."); } else { hfile = fopen(dum, "r"); text = (char *) XtMalloc((unsigned)(statb.st_size+1)); fread(text, sizeof(char), statb.st_size+1, hfile); text[statb.st_size] = 0; fclose(hfile); } XmTextSetString(helptext, text); XtFree(text); XtRealizeWidget(helpshell); } }