home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / clients / xditview / xditview.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-30  |  16.8 KB  |  641 lines

  1. /* $XConsortium: xditview.c,v 1.30 91/07/30 14:10:37 keith Exp $ */
  2. /*
  3.  * Copyright 1991 Massachusetts Institute of Technology
  4.  *
  5.  * Permission to use, copy, modify, distribute, and sell this software and its
  6.  * documentation for any purpose is hereby granted without fee, provided that
  7.  * the above copyright notice appear in all copies and that both that
  8.  * copyright notice and this permission notice appear in supporting
  9.  * documentation, and that the name of M.I.T. not be used in advertising or
  10.  * publicity pertaining to distribution of the software without specific,
  11.  * written prior permission.  M.I.T. makes no representations about the
  12.  * suitability of this software for any purpose.  It is provided "as is"
  13.  * without express or implied warranty.
  14.  *
  15.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  16.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  17.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  19.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  20.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  *
  22.  */
  23.  
  24. /*
  25.  * xditview -- 
  26.  *
  27.  *   Display ditroff output in an X window
  28.  */
  29.  
  30. #include <X11/Intrinsic.h>
  31. #include <X11/StringDefs.h>
  32. #include <X11/Xatom.h>
  33. #include <X11/Shell.h>
  34. #include <X11/Xos.h>        /* rindex declaration */
  35. #include <X11/Xaw/Paned.h>
  36. #include <X11/Xaw/Panner.h>
  37. #include <X11/Xaw/Porthole.h>
  38. #include <X11/Xaw/Viewport.h>
  39. #include <X11/Xaw/Box.h>
  40. #include <X11/Xaw/Command.h>
  41. #include <X11/Xaw/Dialog.h>
  42. #include <X11/Xaw/Label.h>
  43. #include <X11/Xaw/MenuButton.h>
  44. #include <X11/Xaw/SimpleMenu.h>
  45. #include <X11/Xaw/SmeBSB.h>
  46. #include <X11/Xaw/AsciiText.h>
  47.  
  48. #include "Dvi.h"
  49.  
  50. #include "xdit.bm"
  51. #include "xdit_mask.bm"
  52. #include <stdio.h>
  53.  
  54. #ifndef sgi            /* SGI declares popen() in stdio.h */
  55. extern FILE *popen();
  56. #endif
  57. extern void exit();
  58.  
  59. /* Command line options table.  Only resources are entered here...there is a
  60.    pass over the remaining options after XtParseCommand is let loose. */
  61.  
  62. static XrmOptionDescRec options[] = {
  63. {"-page",        "*dvi.pageNumber",        XrmoptionSepArg,    NULL},
  64. {"-backingStore",   "*dvi.backingStore",    XrmoptionSepArg,    NULL},
  65. {"-noPolyText",        "*dvi.noPolyText",        XrmoptionNoArg,    "TRUE"},
  66. {"-resolution",        "*dvi.screenResolution",XrmoptionSepArg,    NULL},
  67. };
  68.  
  69. static char    current_file_name[1024];
  70. static FILE    *current_file;
  71.  
  72. /*
  73.  * Report the syntax for calling xditview.
  74.  */
  75.  
  76. static
  77. Syntax(call)
  78.     char *call;
  79. {
  80.     (void) printf ("Usage: %s [-fg <color>] [-bg <color>]\n", call);
  81.     (void) printf ("       [-bd <color>] [-bw <pixels>] [-help]\n");
  82.     (void) printf ("       [-display displayname] [-geometry geom]\n");
  83.     (void) printf ("       [-page <page-number>] [-backing <backing-store>]\n");
  84.     (void) printf ("       [-resolution <screen-resolution>]\n\n");
  85.     exit(1);
  86. }
  87.  
  88. static void    NewResolution ();
  89. static void    NewFile ();
  90. static void    DisplayPageNumber ();
  91. static void    VisitFile ();
  92. static Widget    toplevel, paned, porthole, dvi;
  93. #ifdef NOTDEF
  94. static Widget    form, panner;
  95. #endif
  96. static Widget    popupMenu;
  97. static Widget    menuBar;
  98. static Widget    fileMenuButton, fileMenu;
  99. static Widget    prevButton, pageNumber, nextButton;
  100.  
  101. static void    NextPage(), PreviousPage(), SetResolution ();
  102. static void    OpenFile(), RevisitFile (), Quit();
  103.  
  104. struct menuEntry {
  105.     char    *name;
  106.     void    (*function)();
  107. };
  108.  
  109. static struct menuEntry popupMenuEntries[] = {
  110.     "nextPage",        NextPage,
  111.     "previousPage", PreviousPage,
  112.     "setResolution",SetResolution,
  113.     "openFile",        OpenFile,
  114.     "revisitFile",  RevisitFile,
  115.     "quit",        Quit,
  116. };
  117.  
  118. static struct menuEntry fileMenuEntries[] = {
  119.     "openFile",        OpenFile,
  120.     "revisitFile",  RevisitFile,
  121.     "setResolution",SetResolution,
  122.     "quit",        Quit,
  123. };
  124.  
  125. static void    NextPageAction(), PreviousPageAction(), SetResolutionAction();
  126. static void    OpenFileAction(), RevisitFileAction (), QuitAction();
  127. static void    AcceptAction(), CancelAction();
  128. static void    UpdatePageNumber (), Noop ();
  129.  
  130. XtActionsRec xditview_actions[] = {
  131.     "NextPage",        NextPageAction,
  132.     "PreviousPage", PreviousPageAction,
  133.     "SetResolution",SetResolutionAction,
  134.     "OpenFile",        OpenFileAction,
  135.     "Quit",        QuitAction,
  136.     "Accept",        AcceptAction,
  137.     "Cancel",        CancelAction,
  138.     "SetPageNumber",UpdatePageNumber,
  139.     "Noop",        Noop,
  140. };
  141.  
  142. static Atom wm_delete_window;
  143.  
  144. /*    Function Name: PannerCallback
  145.  *    Description: called when the panner has moved.
  146.  *    Arguments: panner - the panner widget.
  147.  *                 closure - *** NOT USED ***.
  148.  *                 report_ptr - the panner record.
  149.  *    Returns: none.
  150.  */
  151.  
  152. /* ARGSUSED */
  153. void 
  154. PannerCallback(w, closure, report_ptr)
  155. Widget w;
  156. XtPointer closure, report_ptr;
  157. {
  158.     Arg args[2];
  159.     XawPannerReport *report = (XawPannerReport *) report_ptr;
  160.  
  161.     if (!dvi)
  162.     return;
  163.     XtSetArg (args[0], XtNx, -report->slider_x);
  164.     XtSetArg (args[1], XtNy, -report->slider_y);
  165.  
  166.     XtSetValues(dvi, args, 2);
  167. }
  168.  
  169. /*    Function Name: PortholeCallback
  170.  *    Description: called when the porthole or its child has
  171.  *                   changed 
  172.  *    Arguments: porthole - the porthole widget.
  173.  *                 panner_ptr - the panner widget.
  174.  *                 report_ptr - the porthole record.
  175.  *    Returns: none.
  176.  */
  177.  
  178. /* ARGSUSED */
  179. void 
  180. PortholeCallback(w, panner_ptr, report_ptr)
  181. Widget w;
  182. XtPointer panner_ptr, report_ptr;
  183. {
  184.     Arg args[10];
  185.     Cardinal n = 0;
  186.     XawPannerReport *report = (XawPannerReport *) report_ptr;
  187.     Widget panner = (Widget) panner_ptr;
  188.  
  189.     XtSetArg (args[n], XtNsliderX, report->slider_x); n++;
  190.     XtSetArg (args[n], XtNsliderY, report->slider_y); n++;
  191.     if (report->changed != (XawPRSliderX | XawPRSliderY)) {
  192.     XtSetArg (args[n], XtNsliderWidth, report->slider_width); n++;
  193.     XtSetArg (args[n], XtNsliderHeight, report->slider_height); n++;
  194.     XtSetArg (args[n], XtNcanvasWidth, report->canvas_width); n++;
  195.     XtSetArg (args[n], XtNcanvasHeight, report->canvas_height); n++;
  196.     }
  197.     XtSetValues (panner, args, n);
  198. }
  199.  
  200. void main(argc, argv)
  201.     int argc;
  202.     char **argv;
  203. {
  204.     char        *file_name = 0;
  205.     int            i;
  206.     XtAppContext    xtcontext;
  207.     Arg            topLevelArgs[2];
  208.     Widget          entry;
  209.  
  210.     toplevel = XtAppInitialize(&xtcontext, "Xditview",
  211.                    options, XtNumber (options),
  212.                    &argc, argv, NULL, NULL, 0);
  213.     if (argc > 2)
  214.     Syntax(argv[0]);
  215.  
  216.     XtAppAddActions(xtcontext, xditview_actions, XtNumber (xditview_actions));
  217.     XtOverrideTranslations
  218.     (toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: Quit()"));
  219.  
  220.     XtSetArg (topLevelArgs[0], XtNiconPixmap,
  221.           XCreateBitmapFromData (XtDisplay (toplevel),
  222.                      XtScreen(toplevel)->root,
  223.                      (char *) xdit_bits,
  224.                      xdit_width, xdit_height));
  225.                     
  226.     XtSetArg (topLevelArgs[1], XtNiconMask,
  227.           XCreateBitmapFromData (XtDisplay (toplevel),
  228.                      XtScreen(toplevel)->root,
  229.                      (char *) xdit_mask_bits, 
  230.                      xdit_mask_width, xdit_mask_height));
  231.     XtSetValues (toplevel, topLevelArgs, 2);
  232.     if (argc > 1)
  233.     file_name = argv[1];
  234.  
  235.     /*
  236.      * create the popup menu and insert the entries
  237.      */
  238.     popupMenu = XtCreatePopupShell ("popupMenu", simpleMenuWidgetClass, toplevel,
  239.                     NULL, 0);
  240.     for (i = 0; i < XtNumber (popupMenuEntries); i++) {
  241.     entry = XtCreateManagedWidget(popupMenuEntries[i].name, 
  242.                       smeBSBObjectClass, popupMenu,
  243.                       NULL, (Cardinal) 0);
  244.     XtAddCallback(entry, XtNcallback, popupMenuEntries[i].function, NULL);
  245.     }
  246.  
  247.     paned = XtCreateManagedWidget("paned", panedWidgetClass, toplevel,
  248.                     NULL, (Cardinal) 0);
  249.     menuBar = XtCreateManagedWidget ("menuBar", boxWidgetClass, paned, 0, 0);
  250.  
  251.     fileMenuButton = XtCreateManagedWidget ("fileMenuButton", menuButtonWidgetClass,
  252.                     menuBar, NULL, (Cardinal) 0);
  253.     fileMenu = XtCreatePopupShell ("fileMenu", simpleMenuWidgetClass,
  254.                     fileMenuButton, NULL, (Cardinal) 0);
  255.     for (i = 0; i < XtNumber (fileMenuEntries); i++) {
  256.     entry = XtCreateManagedWidget(fileMenuEntries[i].name,
  257.                       smeBSBObjectClass, fileMenu,
  258.                       NULL, (Cardinal) 0);
  259.     XtAddCallback (entry, XtNcallback, fileMenuEntries[i].function, NULL);
  260.     }
  261.  
  262.     prevButton = XtCreateManagedWidget ("prevButton", commandWidgetClass,
  263.                     menuBar, NULL, (Cardinal) 0);
  264.  
  265.     pageNumber = XtCreateManagedWidget("pageNumber", asciiTextWidgetClass,
  266.                     menuBar, NULL, (Cardinal) 0);
  267.   
  268.     nextButton = XtCreateManagedWidget ("nextButton", commandWidgetClass,
  269.                      menuBar, NULL, (Cardinal) 0);
  270.  
  271. #ifdef NOTDEF
  272.     form = XtCreateManagedWidget ("form", formWidgetClass, paned,
  273.                     NULL, (Cardinal) 0);
  274.     panner = XtCreateManagedWidget ("panner", pannerWidgetClass,
  275.                     form, NULL, 0);
  276.     porthole = XtCreateManagedWidget ("porthole", portholeWidgetClass,
  277.                       form, NULL, 0);
  278.     XtAddCallback(porthole, 
  279.           XtNreportCallback, PortholeCallback, (XtPointer) panner);
  280.     XtAddCallback(panner, 
  281.           XtNreportCallback, PannerCallback, (XtPointer) porthole);
  282. #else
  283.     porthole = XtCreateManagedWidget ("viewport", viewportWidgetClass,
  284.                       paned, NULL, 0);
  285. #endif
  286.     dvi = XtCreateManagedWidget ("dvi", dviWidgetClass, porthole, NULL, 0);
  287.     if (file_name)
  288.     VisitFile (file_name, FALSE);
  289.     XtRealizeWidget (toplevel);
  290.     wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
  291.                    False);
  292.     (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
  293.                             &wm_delete_window, 1);
  294.     XtAppMainLoop(xtcontext);
  295. }
  296.  
  297. static void
  298. DisplayPageNumber ()
  299. {
  300.     Arg    arg[2];
  301.     int    actual_number, last_page;
  302.     XawTextBlock    text;
  303.     int            length;
  304.     char        value[128];
  305.     char        *cur;
  306.  
  307.     XtSetArg (arg[0], XtNpageNumber, &actual_number);
  308.     XtSetArg (arg[1], XtNlastPageNumber, &last_page);
  309.     XtGetValues (dvi, arg, 2);
  310.     if (actual_number == 0)
  311.     sprintf (value, "<none>");
  312.     else if (last_page > 0)
  313.     sprintf (value, "%d of %d", actual_number, last_page);
  314.     else
  315.     sprintf (value, "%d", actual_number);
  316.     text.firstPos = 0;
  317.     text.length = strlen (value);
  318.     text.ptr = value;
  319.     text.format = FMT8BIT;
  320.     XtSetArg (arg[0], XtNstring, &cur);
  321.     XtGetValues (XawTextGetSource (pageNumber), arg, 1);
  322.     length = strlen (cur);
  323.     XawTextReplace (pageNumber, 0, length, &text);
  324. }
  325.  
  326. static void
  327. SetPageNumber (number)
  328. {
  329.     Arg    arg[1];
  330.  
  331.     XtSetArg (arg[0], XtNpageNumber, number);
  332.     XtSetValues (dvi, arg, 1);
  333.     DisplayPageNumber ();
  334. }
  335.  
  336. static void
  337. UpdatePageNumber ()
  338. {
  339.     char    *string;
  340.     Arg        arg[1];
  341.  
  342.     XtSetArg (arg[0], XtNstring, &string);
  343.     XtGetValues (XawTextGetSource(pageNumber), arg, 1);
  344.     SetPageNumber (atoi(string));
  345. }
  346.  
  347. static void
  348. NewResolution(resString)
  349. char    *resString;
  350. {
  351.     int    res;
  352.     Arg    arg[1];
  353.     
  354.     res = atoi (resString);
  355.     if (res <= 0)
  356.     return;
  357.     XtSetArg (arg[0], XtNscreenResolution, res);
  358.     XtSetValues (dvi, arg, 1);
  359. }
  360.  
  361. static void
  362. VisitFile (name, resetPage)
  363. char        *name;
  364. Boolean        resetPage;
  365. {
  366.     Arg        arg[3];
  367.     char    *n;
  368.     FILE    *new_file;
  369.     Boolean seek = 0;
  370.     int        i;
  371.  
  372.     if (current_file) {
  373.     if (!strcmp (current_file_name, "-"))
  374.         ;
  375.     else if (current_file_name[0] == '|')
  376.         pclose (current_file);
  377.     else
  378.         fclose (current_file);
  379.     }
  380.     if (!strcmp (name, "-"))
  381.     new_file = stdin;
  382.     else if (name[0] == '|')
  383.     new_file = popen (name+1, "r");
  384.     else {
  385.     new_file = fopen (name, "r");
  386.     seek = 1;
  387.     }
  388.     if (!new_file) {
  389.     /* XXX display error message */
  390.     return;
  391.     }
  392.     i = 0;
  393.     XtSetArg (arg[i], XtNfile, new_file); i++;
  394.     XtSetArg (arg[i], XtNseek, seek); i++;
  395.     if (resetPage) {
  396.     XtSetArg (arg[i], XtNpageNumber, 1); i++;
  397.     }
  398.     XtSetValues (dvi, arg, i);
  399.     XtSetArg (arg[0], XtNtitle, name);
  400.     if (name[0] != '/' && (n = rindex (name, '/')))
  401.     n = n + 1;
  402.     else
  403.     n = name;
  404.     XtSetArg (arg[1], XtNiconName, n);
  405.     XtSetValues (toplevel, arg, 2);
  406.     strcpy (current_file_name, name);
  407.     current_file = new_file;
  408.     DisplayPageNumber ();
  409. }
  410.  
  411. static void
  412. NewFile (name)
  413. char    *name;
  414. {
  415.     VisitFile (name, TRUE);
  416. }
  417.  
  418. static char fileBuf[1024];
  419. static char resolutionBuf[1024];
  420.  
  421. ResetMenuEntry (entry)
  422.     Widget  entry;
  423. {
  424.     Arg    arg[1];
  425.  
  426.     XtSetArg (arg[0], XtNpopupOnEntry, entry);
  427.     XtSetValues (XtParent(entry) , arg, (Cardinal) 1);
  428. }
  429.  
  430. /*ARGSUSED*/
  431. static void
  432. NextPage (entry, name, data)
  433.     Widget  entry;
  434.     caddr_t name, data;
  435. {
  436.     NextPageAction();
  437.     ResetMenuEntry (entry);
  438. }
  439.  
  440. static void
  441. NextPageAction ()
  442. {
  443.     Arg    args[1];
  444.     int    number;
  445.  
  446.     XtSetArg (args[0], XtNpageNumber, &number);
  447.     XtGetValues (dvi, args, 1);
  448.     SetPageNumber (number+1);
  449. }
  450.  
  451. /*ARGSUSED*/
  452. static void
  453. PreviousPage (entry, name, data)
  454.     Widget  entry;
  455.     caddr_t name, data;
  456. {
  457.     PreviousPageAction ();
  458.     ResetMenuEntry (entry);
  459. }
  460.  
  461. static void
  462. PreviousPageAction ()
  463. {
  464.     Arg    args[1];
  465.     int    number;
  466.  
  467.     XtSetArg (args[0], XtNpageNumber, &number);
  468.     XtGetValues (dvi, args, 1);
  469.     SetPageNumber (number-1);
  470. }
  471.  
  472. /*ARGSUSED*/
  473. static void
  474. SetResolution (entry, name, data)
  475.     Widget  entry;
  476.     caddr_t name, data;
  477. {
  478.     SetResolutionAction ();
  479.     ResetMenuEntry (entry);
  480. }
  481.  
  482. static void
  483. SetResolutionAction ()
  484. {
  485.     Arg        args[1];
  486.     int        cur;
  487.  
  488.     XtSetArg (args[0], XtNscreenResolution, &cur);
  489.     XtGetValues (dvi, args, 1);
  490.     sprintf (resolutionBuf, "%d", cur);
  491.     MakePrompt (toplevel, "Screen resolution:", NewResolution, resolutionBuf);
  492. }
  493.  
  494. /*ARGSUSED*/
  495. static void
  496. OpenFile (entry, name, data)
  497.     Widget  entry;
  498.     caddr_t name, data;
  499. {
  500.     OpenFileAction ();
  501.     ResetMenuEntry (entry);
  502. }
  503.  
  504. static void
  505. OpenFileAction ()
  506. {
  507.     if (current_file_name[0])
  508.     strcpy (fileBuf, current_file_name);
  509.     else
  510.     fileBuf[0] = '\0';
  511.     MakePrompt (toplevel, "File to open:", NewFile, fileBuf);
  512. }
  513.  
  514. /*ARGSUSED*/
  515. static void
  516. RevisitFile (entry, name, data)
  517.     Widget  entry;
  518.     caddr_t name, data;
  519. {
  520.     RevisitFileAction ();
  521.     ResetMenuEntry (entry);
  522. }
  523.  
  524. static void
  525. RevisitFileAction ()
  526. {
  527.     if (current_file_name[0])
  528.     VisitFile (current_file_name, FALSE);
  529. }
  530.  
  531. /*ARGSUSED*/
  532. static void
  533. Quit (entry, closure, data)
  534.     Widget  entry;
  535.     caddr_t closure, data;
  536. {
  537.     QuitAction ();
  538. }
  539.  
  540. static void
  541. QuitAction ()
  542. {
  543.     exit (0);
  544. }
  545.  
  546. Widget    promptShell, promptDialog;
  547. void    (*promptfunction)();
  548.  
  549. /* ARGSUSED */
  550. static
  551. void CancelAction (widget, event, params, num_params)
  552.     Widget    widget;
  553.     XEvent    *event;
  554.     String    *params;
  555.     Cardinal    *num_params;
  556. {
  557.     if (promptShell) {
  558.     XtSetKeyboardFocus(toplevel, (Widget) None);
  559.     XtDestroyWidget(promptShell);
  560.     promptShell = (Widget) 0;
  561.     }
  562. }
  563.  
  564.  
  565. /* ARGSUSED */
  566. static
  567. void AcceptAction (widget, event, params, num_params)
  568.     Widget    widget;
  569.     XEvent    *event;
  570.     String    *params;
  571.     Cardinal    *num_params;
  572. {
  573.     (*promptfunction)(XawDialogGetValueString(promptDialog));
  574.     CancelAction (widget, event, params, num_params);
  575. }
  576.  
  577. static
  578. void Noop ()
  579. {
  580. }
  581.  
  582. MakePrompt(centerw, prompt, func, def)
  583. Widget    centerw;
  584. char *prompt;
  585. void (*func)();
  586. char    *def;
  587. {
  588.     static Arg dialogArgs[] = {
  589.     {XtNlabel, NULL},
  590.     {XtNvalue, NULL},
  591.     };
  592.     Arg valueArgs[1];
  593.     Arg centerArgs[2];
  594.     Position    source_x, source_y;
  595.     Position    dest_x, dest_y;
  596.     Dimension center_width, center_height;
  597.     Dimension prompt_width, prompt_height;
  598.     Widget  valueWidget;
  599.     
  600.     CancelAction ((Widget)NULL, (XEvent *) 0, (String *) 0, (Cardinal *) 0);
  601.     promptShell = XtCreatePopupShell ("promptShell", transientShellWidgetClass,
  602.                       toplevel, NULL, (Cardinal) 0);
  603.     dialogArgs[0].value = (XtArgVal)prompt;
  604.     dialogArgs[1].value = (XtArgVal)def;
  605.     promptDialog = XtCreateManagedWidget( "promptDialog", dialogWidgetClass,
  606.             promptShell, dialogArgs, XtNumber (dialogArgs));
  607.     XawDialogAddButton(promptDialog, "accept", NULL, (caddr_t) 0);
  608.     XawDialogAddButton(promptDialog, "cancel", NULL, (caddr_t) 0);
  609.     valueWidget = XtNameToWidget (promptDialog, "value");
  610.     if (valueWidget) {
  611.         XtSetArg (valueArgs[0], XtNresizable, TRUE);
  612.         XtSetValues (valueWidget, valueArgs, 1);
  613.     /*
  614.      * as resizable isn't set until just above, the
  615.      * default value will be displayed incorrectly.
  616.      * rectify the situation by resetting the values
  617.      */
  618.         XtSetValues (promptDialog, dialogArgs, XtNumber (dialogArgs));
  619.     }
  620.     XtSetKeyboardFocus (promptDialog, valueWidget);
  621.     XtSetKeyboardFocus (toplevel, valueWidget);
  622.     XtRealizeWidget (promptShell);
  623.     /*
  624.      * place the widget in the center of the "parent"
  625.      */
  626.     XtSetArg (centerArgs[0], XtNwidth, ¢er_width);
  627.     XtSetArg (centerArgs[1], XtNheight, ¢er_height);
  628.     XtGetValues (centerw, centerArgs, 2);
  629.     XtSetArg (centerArgs[0], XtNwidth, &prompt_width);
  630.     XtSetArg (centerArgs[1], XtNheight, &prompt_height);
  631.     XtGetValues (promptShell, centerArgs, 2);
  632.     source_x = (int)(center_width - prompt_width) / 2;
  633.     source_y = (int)(center_height - prompt_height) / 3;
  634.     XtTranslateCoords (centerw, source_x, source_y, &dest_x, &dest_y);
  635.     XtSetArg (centerArgs[0], XtNx, dest_x);
  636.     XtSetArg (centerArgs[1], XtNy, dest_y);
  637.     XtSetValues (promptShell, centerArgs, 2);
  638.     XtMapWidget(promptShell);
  639.     promptfunction = func;
  640. }
  641.