/************************************************************************ ** ** FILE : hi.c ** ** ZWECK : ** ** AUTOR : Michael C. Ancutici ** Universitaet Stuttgart, Fakultaet Informatik ** ** DATUM : 14.03.93 ** *************************************************************************/ #include "hi.h" #include "hawin.h" #include "misc.h" #include #include #include #include #include #include #include #include Widget HiCom; Widget HiShell; Widget HiPane; Widget HiText; Widget HiOKCom; Widget HiSubPane; Widget HiDLabel; static BOOLEAN HiWinON = FALSE; static char HiFileName[ MAXPATHLEN]; /************************************************************************* ** FUNKTION: HiSayOK ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HiSayOK( w, client_data, call_data) Widget w; XtPointer client_data, call_data; { XtPopdown( HiShell); XFlush( MyDisplay); XtDestroyWidget( HiShell); HiWinON = FALSE; } /************************************************************************* ** FUNKTION: HiPopup ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HiPopup( w, client_data, call_data) Widget w; XtPointer client_data, call_data; { Position x, y; Dimension width, height; if ( (HiWinON) ) return; HiWinON =TRUE; XtVaGetValues( HiCom, /* Dimensionen Parent-Widget */ XtNheight, &height, NULL); XtTranslateCoords( HiCom, /* Mitte Parent-Widget als */ (Position) 0, /* absolute Koordinaten */ (Position) height, &x, &y); HiShell = XtVaCreatePopupShell( /* Popup Shell */ "HiShell", transientShellWidgetClass, HaGraphPlane, /* Parent Widget */ XtNx, x, XtNy, y, NULL); HiPane = XtVaCreateManagedWidget( /* Popup Shell */ "HiPane", panedWidgetClass, HiShell, /* Parent Widget */ NULL); HiText =XtVaCreateManagedWidget( /* File-Eingabefenster */ "HiText", /* widget name */ asciiTextWidgetClass, /* widget class */ HiPane, /* parent widget */ XtNtype, XawAsciiFile, XtNscrollVertical, XawtextScrollAlways, XtNstring, HiFileName, XtNwidth, 440, XtNheight, 300, NULL); /* terminate argument list */ HiSubPane = XtVaCreateManagedWidget( /* Popup Shell */ "HiSubPane", panedWidgetClass, HiPane, /* Parent Widget */ XtNorientation, XtEvertical, XtNmin, 20, XtNmax, 20, NULL); HiOKCom = XtVaCreateManagedWidget( "HiOKCom", commandWidgetClass, HiSubPane, XtNlabel, "OK", XtNmin, 50, XtNmax, 50, NULL); HiDLabel = XtVaCreateManagedWidget( "HiDLabel", labelWidgetClass, HiSubPane, XtNlabel, "", NULL); XtAddCallback( HiOKCom, XtNcallback, HiSayOK, 0); XtPopup( HiShell, XtGrabNonexclusive); XFlush( MyDisplay); } /************************************************************************* ** FUNKTION: ExistHFile ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ static BOOLEAN ExistHFile() { FILE *f; char *t; t = (char *)getenv( "XAPPLRESDIR" ); strcpy( HiFileName, t); strcat( HiFileName, "pns.hlp"); /* fprintf( stderr, "\n%s\n", HiFileName); */ if ( (f=fopen( HiFileName, "r")) ) { fclose( f); return TRUE; } else { fprintf( stderr, "*** ExistHFile: Can't open %s\n", HiFileName); HiFileName[ 0] = EOL; return FALSE; } } /************************************************************************* ** FUNKTION: HiInst ** ZWECK: ** EINGABE: ** AUSGABE: ** RETURN: ** ANMERK: *************************************************************************/ void HiInst() { HiCom = XtVaCreateManagedWidget( "HiCom", commandWidgetClass, HaTopPane, XtNlabel, "Help", XtNsensitive, ExistHFile(), NULL); XtAddCallback( HiCom, XtNcallback, HiPopup, 0); }