home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Graphics / Graphics.zip / xfitsvew.zip / XFITSview / menu.c < prev    next >
C/C++ Source or Header  |  1998-04-05  |  19KB  |  576 lines

  1. /* menu routines for XFITSview */
  2. /*-----------------------------------------------------------------------
  3. *  Copyright (C) 1996,1997
  4. *  Associated Universities, Inc. Washington DC, USA.
  5. *  This program is free software; you can redistribute it and/or
  6. *  modify it under the terms of the GNU General Public License as
  7. *  published by the Free Software Foundation; either version 2 of
  8. *  the License, or (at your option) any later version.
  9. *
  10. *  This program is distributed in the hope that it will be useful,
  11. *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. *  GNU General Public License for more details.
  14. *-----------------------------------------------------------------------*/
  15. /* Uncomment the following for a version which keeps the file open dialog */
  16. /*#define KEEP_FILE_DIALOG */
  17. #include <Xm/Xm.h> 
  18. #include <Xm/DrawingA.h> 
  19. #include <Xm/MainW.h> 
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22. #include <Xm/Separator.h>
  23. #include <Xm/Form.h>
  24. #include <Xm/PushB.h>
  25. #include <Xm/FileSB.h>
  26. #include <Xm/CascadeB.h>
  27. #include <Xm/RowColumn.h>
  28. #include <Xm/Label.h>
  29. #include <Xm/ToggleB.h>
  30. #include "xfitsview.h"
  31. #include "imagedisp.h"
  32. #include "FITS2Pix.h"
  33. #include "infobox.h"
  34. #include "moviebox.h"
  35. #include "blinkbox.h"
  36. #include "optionbox.h"
  37. #include "markpos.h"
  38. #include "lookpos.h"
  39. #include "color.h"
  40. #include "textfile.h"
  41. #include "scrolltext.h"
  42. #include "helpbox.h"
  43. #include "aboutbox.h"
  44. #include "logger.h"
  45. #include "messagebox.h"
  46. #include "menu.h"
  47.  
  48. /* global widget arrays for menu items */
  49. Widget Zoom_w[7] = {0, 0, 0, 0, 0, 0, 0};
  50. Widget File_w[5] = {0, 0, 0, 0,0};
  51.  
  52. Widget MakeMainMenu (Widget mainWindow, XtPointer image, XtPointer IDdata)
  53. /* routine to create main menu bar */
  54. {
  55.     Widget menu, pulldown, w;
  56.     ImageDisplay *IDDATA = (ImageDisplay*) IDdata;
  57.  
  58.     /* initialize help dialog */
  59.     MakeHelpBox (mainWindow, False); /* no immediate display */
  60.  
  61. /* add menu items */
  62.     menu = XmCreateMenuBar (mainWindow, "menuBar", NULL, 0);
  63.  
  64. /* "File" */
  65.     pulldown = XmCreatePulldownMenu (menu, "File", IDdata, 0);
  66.     w = XtVaCreateManagedWidget ("File", xmCascadeButtonWidgetClass,
  67.                  menu, XmNsubMenuId, pulldown, 
  68.                  XmNmnemonic, 'F',
  69.                  NULL);
  70.    /* "Open" */
  71.     File_w[0] = XtVaCreateManagedWidget ("Open", xmPushButtonWidgetClass,
  72.                    pulldown,
  73.                    XmNmnemonic, 'O',
  74.                    NULL);
  75.     /*    XtSetArg (File_w[0], XmNmnemonic, 'O');*/
  76.     XtAddCallback (File_w[0], XmNactivateCallback, OpenCB, IDdata);
  77.  
  78.    /* "Preview" */
  79.     File_w[1] = XtVaCreateManagedWidget ("Preview", xmPushButtonWidgetClass,
  80.                    pulldown,
  81.                    XmNmnemonic, 'P',
  82.                    NULL);
  83.     XtAddCallback (File_w[1], XmNactivateCallback, PreviewCB, IDdata);
  84.  
  85.    /* "Save as" */
  86.     File_w[2] = XtVaCreateManagedWidget ("Save As", xmPushButtonWidgetClass,
  87.                    pulldown,
  88.                    XmNmnemonic, 'S',
  89.                    NULL);
  90.     XtAddCallback (File_w[2], XmNactivateCallback, SaveAsCB, IDdata);
  91.  
  92.    /* "Source info" */
  93.     File_w[3] = XtVaCreateManagedWidget ("Source Info", xmPushButtonWidgetClass,
  94.                    pulldown,
  95.                    XmNmnemonic, 'I',
  96.                    NULL);
  97.     XtAddCallback (File_w[3], XmNactivateCallback, InfoBoxCB, IDdata);
  98.    /* "Position logging" */
  99.     File_w[4] = XtVaCreateManagedWidget ("Start Position Logging", 
  100.                    xmPushButtonWidgetClass,
  101.                    pulldown,
  102.                    XmNmnemonic, 'L',
  103.                    NULL);
  104.     XtAddCallback (File_w[4], XmNactivateCallback, LoggerCB, IDdata);
  105.     /* help */
  106.     w = XtVaCreateManagedWidget ("Help", xmPushButtonWidgetClass,
  107.                    pulldown,
  108.                    XmNmnemonic, 'H',
  109.                    NULL);
  110.     XtAddCallback (w, XmNactivateCallback, HelpBoxTopicCB, 
  111.            (XtPointer)"File menu");
  112.    /* separator */
  113.     w = XtCreateManagedWidget ("sep", xmSeparatorWidgetClass,
  114.                    pulldown, NULL, 0);
  115.    /* "quit" */
  116.     w = XtVaCreateManagedWidget ("Quit", xmPushButtonWidgetClass,
  117.                    pulldown,
  118.                    XmNmnemonic, 'Q',
  119.                    NULL);
  120.     XtAddCallback (w, XmNactivateCallback, QuitCB, IDdata);
  121.  
  122. /* "Options" */
  123.     pulldown = XmCreatePulldownMenu (menu, "options", IDdata, 0);
  124.     w = XtVaCreateManagedWidget ("Options", xmCascadeButtonWidgetClass,
  125.                  menu, XmNsubMenuId, pulldown, 
  126.                  XmNmnemonic, 'O',
  127.                  NULL);
  128.     w = XtVaCreateManagedWidget ("Set Options", xmPushButtonWidgetClass,
  129.                  pulldown, 
  130.                  XmNmnemonic, 'S',
  131.                  NULL);
  132.     XtAddCallback (w, XmNactivateCallback, OptionBoxCB, IDdata);
  133.     w = XtVaCreateManagedWidget ("Help", xmPushButtonWidgetClass,
  134.                  pulldown, 
  135.                  XmNmnemonic, 'H',
  136.                  NULL);
  137.     XtAddCallback (w, XmNactivateCallback, HelpBoxTopicCB, 
  138.            (XtPointer)"Options menu");
  139.  
  140. /* "Zoom" */
  141.     pulldown = XmCreatePulldownMenu (menu, "zoom", IDdata, 0); 
  142.     w = XtVaCreateManagedWidget ("Zoom", xmCascadeButtonWidgetClass,
  143.                  menu, XmNsubMenuId, pulldown, 
  144.                  XmNmnemonic, 'Z',
  145.                  NULL);
  146.    /* "Zoom 25%" */
  147.     Zoom_w[0] = XtVaCreateManagedWidget ("25%", xmPushButtonWidgetClass,
  148.                    pulldown, 
  149.                    XmNmnemonic, '%',
  150.                    NULL);
  151.     XtAddCallback (Zoom_w[0], XmNactivateCallback, Zoom25CB, IDdata);
  152.    /* "Zoom 50%" */
  153.     Zoom_w[1] = XtVaCreateManagedWidget ("50%", xmPushButtonWidgetClass,
  154.                    pulldown, 
  155.                    XmNmnemonic, '5',
  156.                    NULL);
  157.     XtAddCallback (Zoom_w[1], XmNactivateCallback, Zoom50CB, IDdata);
  158.    /* "Zoom 100%" */
  159.     Zoom_w[2] = XtVaCreateManagedWidget ("100% <=", xmPushButtonWidgetClass,
  160.                    pulldown, 
  161.                    XmNmnemonic, '1',
  162.                    NULL);
  163.     XtAddCallback (Zoom_w[2], XmNactivateCallback, Zoom100CB, IDdata);
  164.    /* "Zoom 200%" */
  165.     Zoom_w[3] = XtVaCreateManagedWidget ("200%", xmPushButtonWidgetClass,
  166.                    pulldown, 
  167.                    XmNmnemonic, '2',
  168.                    NULL);
  169.     XtAddCallback (Zoom_w[3], XmNactivateCallback, Zoom200CB, IDdata);
  170.    /* "Zoom 400%" */
  171.     Zoom_w[4] = XtVaCreateManagedWidget ("400%", xmPushButtonWidgetClass,
  172.                    pulldown, 
  173.                    XmNmnemonic, '4',
  174.                    NULL);
  175.     XtAddCallback (Zoom_w[4], XmNactivateCallback, Zoom400CB, IDdata);
  176.    /* "Zoom 800%" */
  177.     Zoom_w[5] = XtVaCreateManagedWidget ("800%", xmPushButtonWidgetClass,
  178.                    pulldown, 
  179.                    XmNmnemonic, '8',
  180.                    NULL);
  181.     XtAddCallback (Zoom_w[5], XmNactivateCallback, Zoom800CB, IDdata);
  182.    /* "Zoom 1600%" */
  183.     Zoom_w[6] = XtVaCreateManagedWidget ("1600%", xmPushButtonWidgetClass,
  184.                    pulldown, 
  185.                    XmNmnemonic, '6',
  186.                    NULL);
  187.     XtAddCallback (Zoom_w[6], XmNactivateCallback, Zoom1600CB, IDdata);
  188.     w = XtVaCreateManagedWidget ("Help", xmPushButtonWidgetClass,
  189.                    pulldown, 
  190.                    XmNmnemonic, 'H',
  191.                    NULL);
  192.     XtAddCallback (w, XmNactivateCallback, HelpBoxTopicCB, 
  193.            (XtPointer)"Zoom menu");
  194.  
  195. /* "Position" */
  196.     pulldown = XmCreatePulldownMenu (menu, "position", IDdata, 0);
  197.     w = XtVaCreateManagedWidget ("Position", xmCascadeButtonWidgetClass,
  198.                  menu, XmNsubMenuId, pulldown, 
  199.                  XmNmnemonic, 'P',
  200.                  NULL);
  201.    /* "Set Equinox" */
  202.     w = XtVaCreateManagedWidget ("Set Equinox", xmPushButtonWidgetClass,
  203.                  pulldown, 
  204.                  XmNmnemonic, 'S',
  205.                  NULL);
  206.     XtAddCallback (w, XmNactivateCallback, SetEquCB, IDdata);
  207.    /* "Mark Position" */
  208.     w = XtVaCreateManagedWidget ("Mark Position", xmPushButtonWidgetClass,
  209.                  pulldown, 
  210.                  XmNmnemonic, 'M',
  211.                  NULL);
  212.     XtAddCallback (w, XmNactivateCallback, MarkPosCB, IDdata);
  213.    /* "Lookup Position" */
  214.     w = XtVaCreateManagedWidget ("Lookup Position", xmPushButtonWidgetClass,
  215.                  pulldown, 
  216.                  XmNmnemonic, 'L',
  217.                  NULL);
  218.     XtAddCallback (w, XmNactivateCallback, LookPosCB, IDdata);
  219.     /* "Lookup Position" */
  220.      w = XtVaCreateManagedWidget ("Fit Position", xmPushButtonWidgetClass,
  221.                   pulldown, 
  222.                  XmNmnemonic, 'F',
  223.                  NULL);
  224.      XtAddCallback (w, XmNactivateCallback, FitPosCB, IDdata);
  225.     w = XtVaCreateManagedWidget ("Help", xmPushButtonWidgetClass,
  226.                  pulldown, 
  227.                  XmNmnemonic, 'H',
  228.                  NULL);
  229.     XtAddCallback (w, XmNactivateCallback, HelpBoxTopicCB, 
  230.            (XtPointer)"Position menu");
  231.  
  232. /* "Blink" */
  233.     pulldown = XmCreatePulldownMenu (menu, "blink", IDdata, 0);
  234.     w = XtVaCreateManagedWidget ("Blink", xmCascadeButtonWidgetClass,
  235.                  menu, XmNsubMenuId, pulldown, 
  236.                  XmNmnemonic, 'B',
  237.                  NULL);
  238.     w = XtVaCreateManagedWidget ("Swap Blink and Current", 
  239.                  xmPushButtonWidgetClass,
  240.                  pulldown, 
  241.                  XmNmnemonic, 'S',
  242.                  NULL);
  243.     XtAddCallback (w, XmNactivateCallback, BlinkSwapCB, IDdata);
  244.     w = XtVaCreateManagedWidget ("Blink Images", xmPushButtonWidgetClass,
  245.                  pulldown, 
  246.                  XmNmnemonic, 'B',
  247.                  NULL);
  248.     XtAddCallback (w, XmNactivateCallback, BlinkBlinkCB, IDdata);
  249.     w = XtVaCreateManagedWidget ("Help", xmPushButtonWidgetClass,
  250.                  pulldown, 
  251.                  XmNmnemonic, 'H',
  252.                  NULL);
  253.     XtAddCallback (w, XmNactivateCallback, HelpBoxTopicCB, 
  254.            (XtPointer)"Blink menu");
  255.  
  256.  
  257. /* "Movie" */
  258.     pulldown = XmCreatePulldownMenu (menu, "movie", IDdata, 0);
  259.     w = XtVaCreateManagedWidget ("Movie", xmCascadeButtonWidgetClass,
  260.                  menu, XmNsubMenuId, pulldown, 
  261.                  XmNmnemonic, 'M',
  262.                  NULL);
  263.     w = XtVaCreateManagedWidget ("Movie control", xmPushButtonWidgetClass,
  264.                  pulldown, 
  265.                  XmNmnemonic, 'M',
  266.                  NULL);
  267.     XtAddCallback (w, XmNactivateCallback, MovieBoxCB, IDdata);
  268.     w = XtVaCreateManagedWidget ("Help", xmPushButtonWidgetClass,
  269.                  pulldown, 
  270.                  XmNmnemonic, 'H',
  271.                  NULL);
  272.     XtAddCallback (w, XmNactivateCallback, HelpBoxTopicCB, 
  273.            (XtPointer)"Movie menu");
  274.  
  275. /* "Colorize" */
  276.     pulldown = XmCreatePulldownMenu (menu, "colorize", IDdata, 0);
  277.     w = XtVaCreateManagedWidget ("Colorize", xmCascadeButtonWidgetClass,
  278.                  menu, XmNsubMenuId, pulldown, 
  279.                  XmNmnemonic, 'C',
  280.                  NULL);
  281.    /* "Color Contour" */
  282.     w = XtVaCreateManagedWidget ("Color Contour", xmPushButtonWidgetClass,
  283.                  pulldown,
  284.                  XmNmnemonic, 'C',
  285.                  NULL);
  286.     XtAddCallback (w, XmNactivateCallback, ColContourCB, IDdata);
  287.  
  288.    /* "Pseudo Flame" */
  289.     w = XtVaCreateManagedWidget ("Pseudo Flame", xmPushButtonWidgetClass,
  290.                  pulldown, 
  291.                  XmNmnemonic, 'P',
  292.                  NULL);
  293.     XtAddCallback (w, XmNactivateCallback, PhlameCB, IDdata);
  294.  
  295.    /* "Grayscale" */
  296.     w = XtVaCreateManagedWidget ("Grayscale", xmPushButtonWidgetClass,
  297.                  pulldown, 
  298.                  XmNmnemonic, 'G',
  299.                  NULL);
  300.     XtAddCallback (w, XmNactivateCallback, GrayscaleCB, IDdata);
  301.  
  302.    /* "Reverse colors" */
  303.     w = XtVaCreateManagedWidget ("Reverse colors", xmPushButtonWidgetClass,
  304.                  pulldown, 
  305.                  XmNmnemonic, 'v',
  306.                  NULL);
  307.     XtAddCallback (w, XmNactivateCallback, ReverseColCB, IDdata) ;
  308.  
  309.    /* "Reset" */
  310.     w = XtVaCreateManagedWidget ("Reset", xmPushButtonWidgetClass,
  311.                  pulldown, 
  312.                  XmNmnemonic, 'R',
  313.                  NULL);
  314.     XtAddCallback (w, XmNactivateCallback, ResetColCB, IDdata);
  315.     w = XtVaCreateManagedWidget ("Help", xmPushButtonWidgetClass,
  316.                                  pulldown, 
  317.                  XmNmnemonic, 'H',
  318.                  NULL);
  319.     XtAddCallback (w, XmNactivateCallback, HelpBoxTopicCB, 
  320.            (XtPointer)"Colorize menu");
  321.  
  322.  
  323. /* "Help" */
  324.     pulldown = XmCreatePulldownMenu (menu, "help", IDdata, 0);
  325.     w = XtVaCreateManagedWidget ("Help", xmCascadeButtonWidgetClass,
  326.                  menu, XmNsubMenuId, pulldown, 
  327.                  XmNmnemonic, 'H',
  328.                  NULL);
  329.     w = XtVaCreateManagedWidget ("About XFITSview", xmPushButtonWidgetClass,
  330.                  pulldown, 
  331.                  XmNmnemonic, 'A',
  332.                  NULL);
  333.     XtAddCallback (w, XmNactivateCallback, HelpAboutCB, IDdata);
  334.     w = XtVaCreateManagedWidget ("Help me", xmPushButtonWidgetClass,
  335.                  pulldown, 
  336.                  XmNmnemonic, 'H',
  337.                  NULL);
  338.     XtAddCallback (w, XmNactivateCallback, HelpBoxTopicCB, 
  339.            (XtPointer)"How to use help");
  340.  
  341.     XtManageChild (menu);
  342.     return (menu);
  343. } /* end of MakeMainMenu */
  344.  
  345. /* callback functions */
  346. void QuitCB (Widget w, XtPointer clientData, XtPointer callData)
  347. /* bail out */
  348. {
  349. /* turn off logging if necessary */
  350.   if (doLog) LoggerCB (w, clientData, callData);
  351.  
  352. /* terminate program */
  353.   exit (0);
  354. } /* end QuitCB */
  355.  
  356. void FileOKCB (Widget filebox, XtPointer clientData, XtPointer callData)
  357. /* loads selected FITS file into the ImageData attached to the display */
  358. /* resets display when image is read */
  359. {
  360.   char *filename, *directory;
  361.   XmFileSelectionBoxCallbackStruct *cbs;
  362.   ImageDisplay  *IDdata;
  363.  
  364.   cbs = (XmFileSelectionBoxCallbackStruct *) callData;
  365.   IDdata = (ImageDisplay *)clientData;
  366.  
  367. /* get file name */
  368.  if (!XmStringGetLtoR (cbs->value, XmSTRING_DEFAULT_CHARSET, &filename))
  369.    return; /* error */
  370. /* read FITS file to pixmap */
  371.   StringFill (image[CurImag].FileName, filename);
  372. /* read FITS file to PixMap */
  373.   if (FITS2Pix (&image[CurImag], IDdata, 1))
  374.     {
  375.       /* error */
  376.       sprintf (szErrMess, "Error reading FITS file = %s", filename);
  377.       MessageShow (szErrMess);
  378.   }
  379.  
  380. /* get directory name */
  381.  if (!XmStringGetLtoR (cbs->dir, XmSTRING_DEFAULT_CHARSET, &directory))
  382.    return; /* error */
  383.   if (!FITS_dir) FITS_dir = MakeString(" ");
  384.   StringFill (FITS_dir, directory);
  385.   XtFree(filename);
  386.   XtFree(directory);
  387.  
  388. /* Shazam disappear and die */
  389. #ifndef KEEP_FILE_DIALOG  /* option to let it hang around */
  390.   XtUnmanageChild (filebox);
  391.   XtPopdown (XtParent (filebox));
  392.   XtDestroyWidget(filebox); 
  393. #endif
  394.  
  395. /* reset display */
  396.   ResetDisplay(IDdata);
  397.  
  398. } /* end FileOKCB */
  399.  
  400. void FileCancelCB (Widget filebox, XtPointer clientData, XtPointer callData)
  401. /* cancel file selection dialog box */
  402. {
  403. /* Shazam disappear and die */
  404.   XtUnmanageChild (filebox); 
  405.   XtPopdown (XtParent (filebox)); 
  406.   XtDestroyWidget(filebox); 
  407. } /* end FileCancelCB */
  408.  
  409. void OpenCB (Widget w, XtPointer clientData, XtPointer callData)
  410. /* Load new FITS file */
  411. {
  412.   Widget       filebox;
  413.   ImageDisplay *IDdata;
  414.   XmString     wierdstring = NULL;
  415.   Arg          wargs[5]; 
  416.  
  417.   IDdata = (ImageDisplay *)clientData;
  418. /* sometimes c is too stupid to live */
  419.   filebox = (Widget) XmCreateFileSelectionDialog (w, "file_open", NULL, 0);
  420.   XtAddCallback (filebox, XmNokCallback, FileOKCB, clientData);
  421.   XtAddCallback (filebox, XmNcancelCallback, FileCancelCB, clientData);
  422.   XtAddCallback (filebox, XmNhelpCallback, HelpBoxTopicCB, 
  423.            (XtPointer)"Browser");
  424.  
  425. /* set directory if it is defined */
  426.   if (FITS_dir) {
  427.     wierdstring = XmStringCreateSimple (FITS_dir->sp);
  428.     XtSetArg (wargs[0], XmNdirectory, wierdstring);
  429.     XtSetValues (filebox, wargs, 1);
  430.     if (wierdstring) XmStringFree(wierdstring); wierdstring = NULL;
  431.   }
  432. /* Shazam appear: */
  433.   XtManageChild (filebox);
  434.   XtPopup (XtParent (filebox), XtGrabNone);
  435. /* all the action is in the callback routine */
  436. } /* end OpenCB */
  437.  
  438. void PreviewCB (Widget w, XtPointer clientData, XtPointer callData)
  439. /* show test or FITS header in scroll box */
  440. {
  441.   ImageDisplay *IDdata;
  442.   TextFilePtr TFilePtr;
  443.  
  444.   IDdata = (ImageDisplay *)clientData;
  445.  
  446. /* make dummy text file */
  447.   TFilePtr = TextFileMake (IDdata->shell, NULL, NULL);
  448.  
  449. /* set directory if known*/
  450.   if (FITS_dir)
  451.     {if(TFilePtr->directory) free(TFilePtr->directory);
  452.      TFilePtr->directory = (char*)malloc(FITS_dir->length+1);
  453.      strcpy (TFilePtr->directory, FITS_dir->sp);}
  454.  
  455. /* ask which file and copy to ScrollText */
  456.   TextFileFind (1, TFilePtr, ScrollTextCopy, (TextFileProc)TextFileKill);
  457. } /* end PreviewCB */
  458.  
  459. /* set Zoom menu labels to indicate which zoom is on */
  460. /* number is the menu item number 0 = 25% to 6=1600% */
  461. void MenuMarkZoom (int number)
  462. {
  463.   XmString  wierdstring;
  464.   int       loop;
  465.   char      *clear[] = 
  466.     {"25%", "50%", "100%", "200%", "400%", "800%", "1600%"};
  467.   char      *set[] = 
  468.     {"25% <=", "50% <=", "100% <=", "200% <=", "400% <=", "800% <=", 
  469.        "1600% <="};
  470.  
  471. /* sanity checks */
  472.   if ((number<0) || (number>6)) return;
  473.   if (!Zoom_w[0]) return;
  474.  
  475. /* clear all first */
  476.   for (loop=0; loop<7; loop++)
  477.     {
  478.       wierdstring = XmStringCreateSimple (clear[loop]);
  479.       XtVaSetValues(Zoom_w[loop], 
  480.             XmNlabelString,  wierdstring,
  481.             NULL);
  482.       if (wierdstring) XmStringFree(wierdstring); wierdstring = NULL;
  483.     }
  484. /* set the specified one */
  485.   wierdstring = XmStringCreateSimple (set[number]);
  486.   XtVaSetValues(Zoom_w[number], 
  487.         XmNlabelString,  wierdstring,
  488.         NULL);
  489.   if (wierdstring) XmStringFree(wierdstring); wierdstring = NULL;
  490. } /* end MenuMarkZoom */
  491.  
  492. /* set position logging menu label to indicate if hitting it will */
  493. /* start or stop position logging, 1 = turn on, 2 = turn off */
  494. void MenuMarkLogger (int onoff)
  495. {
  496.   XmString  wierdstring;
  497.  
  498.   if (onoff==1) /* turn on */
  499.     wierdstring = XmStringCreateSimple ("Start Position Logging");
  500.   else if (onoff==2) /* turn off */
  501.     wierdstring = XmStringCreateSimple ("Stop Position Logging");
  502.   else /* can't deal with this */
  503.     return;
  504.  
  505.   XtVaSetValues(File_w[4], XmNlabelString,  wierdstring, NULL);
  506.   if (wierdstring) XmStringFree(wierdstring);
  507. } /* end MenuMarkLogger */
  508.  
  509. void CopyOKCB (Widget filebox, XtPointer clientData, XtPointer callData)
  510. /* Copy current displayed FITS file to specified name */
  511. {
  512.   char *filename;
  513.   XmFileSelectionBoxCallbackStruct *cbs;
  514.   ImageDisplay  *IDdata;
  515.   FStrng *FileName;
  516.  
  517.   cbs = (XmFileSelectionBoxCallbackStruct *) callData;
  518.   IDdata = (ImageDisplay *)clientData;
  519.  
  520. /* get file name */
  521.  if (!XmStringGetLtoR (cbs->value, XmFONTLIST_DEFAULT_TAG, &filename))
  522.    return; /* error */
  523.   FileName = MakeString (filename);
  524. /* copy current file to output */
  525.   if (!DeepCopyFITSfile (image[CurImag].FileName, FileName))
  526.     {
  527.       /* error */
  528.       sprintf (szErrMess, "Error copying FITS file %s", 
  529.            image[CurImag].FileName->sp);
  530.       MessageShow (szErrMess);
  531.       sprintf (szErrMess, "to %s", filename);
  532.       MessageShow (szErrMess);
  533.   }
  534.   KillString (FileName);
  535.   XtFree(filename);
  536.  
  537. /* Shazam disappear and die */
  538.   XtUnmanageChild (filebox); 
  539.   XtPopdown (XtParent (filebox)); 
  540.   XtDestroyWidget(filebox); 
  541.  
  542. /* reset display */
  543.   ResetDisplay(IDdata);
  544.  
  545. } /* end CopyOKCB */
  546.  
  547. void SaveAsCB (Widget w, XtPointer clientData, XtPointer callData)
  548. /* save copy of FITS file*/
  549. {
  550.   Widget       filebox;
  551.   ImageDisplay *IDdata;
  552.   XmString     wierdstring;
  553.   Arg          wargs[5]; 
  554.  
  555.   IDdata = (ImageDisplay *)clientData;
  556.  
  557.   filebox = (Widget) XmCreateFileSelectionDialog (w, "save_as", NULL, 0);
  558.   XtAddCallback (filebox, XmNokCallback, CopyOKCB, clientData);
  559.   XtAddCallback (filebox, XmNcancelCallback, FileCancelCB, clientData);
  560.   XtAddCallback (filebox, XmNhelpCallback, HelpBoxTopicCB, 
  561.            (XtPointer)"Browser");
  562.  
  563. /* set directory if it is defined */
  564.   if (FITS_dir) {
  565.     wierdstring = XmStringLtoRCreate (FITS_dir->sp, 
  566.                       XmSTRING_DEFAULT_CHARSET);
  567.     XtSetArg (wargs[0], XmNdirectory, wierdstring);
  568.     XtSetValues (filebox, wargs, 1);
  569.     XmStringFree(wierdstring);
  570.   }
  571. /* Shazam appear: */
  572.   XtManageChild (filebox);
  573.   XtPopup (XtParent (filebox), XtGrabNone);
  574. /* all the action is in the callback routine */
  575. } /* end SaveAsCB */
  576.