home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xephem / part11 / xephem.c < prev   
Encoding:
C/C++ Source or Header  |  1993-05-15  |  20.4 KB  |  646 lines

  1. /* main() for xephem.
  2.  * Copyright (c) 1990,1991,1992,1993 by Elwood Charles Downey
  3.  * Permission is granted to make and distribute copies of this program free of
  4.  * charge, provided the copyright notice and this permission notice are
  5.  * preserved on all copies.  All other rights reserved.  No representation is
  6.  * made about the suitability of this software for any purpose.  It is provided
  7.  * "as is" without express or implied warranty, to the extent permitted by
  8.  * applicable law.
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <signal.h>
  13. #if defined(__STDC__)
  14. #include <stdlib.h>
  15. #endif
  16.  
  17. #include <X11/Xlib.h>
  18. #include <X11/IntrinsicP.h> /* for XT_REVISION */
  19.  
  20. /* define WANT_EDITRES if want to try and support X11R5's EditRes feature.
  21.  * this will require linking with -lXmu and -lXext too.
  22.  */
  23. #if defined(WANT_EDITRES) && (XT_REVISION >= 5)
  24. #define    DO_EDITRES
  25. #endif
  26.  
  27. #ifdef DO_EDITRES
  28. #include <X11/Xmu/Editres.h>
  29. #endif
  30.  
  31. #include <Xm/Xm.h>
  32. #include <X11/Shell.h>
  33. #include <Xm/PushB.h>
  34. #include <Xm/CascadeB.h>
  35. #include <Xm/Form.h>
  36. #include <Xm/Separator.h>
  37. #include <Xm/MainW.h>
  38. #include <Xm/RowColumn.h>
  39. #include <Xm/ToggleB.h>
  40.  
  41. #if defined(__STDC__) || defined(__cplusplus)
  42. #define P_(s) s
  43. #else
  44. #define P_(s) ()
  45. #endif
  46.  
  47. extern void config_help P_((void));
  48. extern void datetime_help P_((void));
  49. extern void db_manage P_((void));
  50. extern void dm_manage P_((void));
  51. extern void e_manage P_((void));
  52. extern void intro_help P_((void));
  53. extern void jm_manage P_((void));
  54. extern void lst_manage P_((void));
  55. extern void m_manage P_((void));
  56. extern void mainmenu_help P_((void));
  57. extern void mars_manage P_((void));
  58. extern void mm_manage P_((Widget main_window));
  59. extern void mm_reset P_((void));
  60. extern void msg_manage P_((void));
  61. extern void notes_help P_((void));
  62. extern void obj_manage P_((void));
  63. extern void operation_help P_((void));
  64. extern void plot_manage P_((void));
  65. extern void pref_create_pulldown P_((Widget menu_bar));
  66. extern void references_help P_((void));
  67. extern void sm_manage P_((void));
  68. extern void srch_manage P_((void));
  69. extern void ss_manage P_((void));
  70. extern void sv_manage P_((void));
  71. extern void version P_((void));
  72. extern void watch_cursor P_((int want));
  73. extern void xe_msg P_((char *msg, int app_modal));
  74.  
  75. void main_cursor P_((Cursor c));
  76. static void on_fpe P_((void));
  77. static Widget make_main_window P_((void));
  78. static void setup_window_properties P_((Widget w));
  79. static void m_activate_cb P_((Widget w, XtPointer client, XtPointer call));
  80.  
  81. #undef P_
  82.  
  83.  
  84. /* client arg to m_activate_cb().
  85.  */
  86. enum {
  87.     QUIT, XRESET, MSGTXT,
  88.     DATA, MOON, EARTH, MARS, JUPMOON, SATMOON, SKYVIEW, SOLARSYS,
  89.     PLOT, LIST, SEARCH,
  90.     OBJS,
  91.     DB,
  92.     VERSION, REFERENCES, INTRO, MAINMENU, CONFIGFILE, OPERATION, DATETIME, NOTES
  93. };
  94.  
  95. Widget toplevel_w;
  96. XtAppContext xe_app;
  97. char *myclass = "XEphem";
  98.  
  99. #define xephem_width 50
  100. #define xephem_height 50
  101. static unsigned char xephem_bits[] = {
  102.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  103.    0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  104.    0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
  105.    0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
  106.    0x00, 0x00, 0xf8, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00,
  107.    0xa0, 0x0f, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x10, 0xf0, 0x00, 0x02, 0x00,
  108.    0x00, 0x00, 0x0c, 0x00, 0x01, 0x01, 0x00, 0x00, 0x08, 0x0c, 0x00, 0x02,
  109.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  110.    0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03,
  111.    0x00, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0xf0, 0x0c, 0x00, 0x00,
  112.    0x03, 0x00, 0x00, 0x00, 0x1f, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1e,
  113.    0x00, 0x30, 0x00, 0xf8, 0x7f, 0x00, 0x3c, 0x00, 0x08, 0xb0, 0x07, 0x80,
  114.    0x07, 0x40, 0x00, 0x04, 0x78, 0x00, 0x00, 0x18, 0x80, 0x00, 0x04, 0x78,
  115.    0x00, 0x00, 0x20, 0x80, 0x00, 0x02, 0x30, 0x00, 0x02, 0x20, 0x00, 0x01,
  116.    0x02, 0x08, 0x80, 0x0f, 0x40, 0x00, 0x01, 0x82, 0x08, 0x00, 0x07, 0x40,
  117.    0x00, 0x01, 0x02, 0x08, 0x80, 0x0f, 0x40, 0x00, 0x01, 0x02, 0x10, 0x00,
  118.    0x02, 0x20, 0x04, 0x01, 0x04, 0x10, 0x00, 0x00, 0x20, 0x80, 0x00, 0x04,
  119.    0x60, 0x00, 0x00, 0x18, 0x80, 0x00, 0x08, 0x80, 0x07, 0x80, 0x07, 0x40,
  120.    0x00, 0x30, 0x00, 0xf8, 0x7f, 0x00, 0x30, 0x00, 0xc0, 0x00, 0x00, 0x00,
  121.    0x00, 0x0c, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x3c,
  122.    0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x0f, 0x00, 0x00,
  123.    0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  124.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
  125.    0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3c,
  126.    0x00, 0x00, 0x00, 0x60, 0xf0, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xf0, 0x0f,
  127.    0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  128.    0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  129.    0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00,
  130.    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  131.    0x00, 0x00};
  132.  
  133. static String fallbacks[] = {
  134.     "XEphem*Algorithms.Fast.set: true",
  135.     "XEphem*DBPromptD.textString: ephem.db",
  136.     "XEphem*DataSelMiscCols.Alt.set: true",
  137.     "XEphem*DataSelMiscCols.Az.set: true",
  138.     "XEphem*DataSelMiscCols.Cns.set: true",
  139.     "XEphem*DataSelMiscCols.Dec.set: true",
  140.     "XEphem*DataSelMiscCols.R_A.set: true",
  141.     "XEphem*DataSelRisetCols*Limb.set: true",
  142.     "XEphem*DataSelRisetCols.RiseTm.set: true",
  143.     "XEphem*DataSelRisetCols.SetTm.set: true",
  144.     "XEphem*DataSelRows.Moon.set: true",
  145.     "XEphem*DataSelRows.Sun.set: true",
  146.     "XEphem*DateFormat.MDY.set: True",
  147.     "XEphem*Earth*Map.height: 300",
  148.     "XEphem*Help*ScrolledText.columns: 80",
  149.     "XEphem*Help*ScrolledText.rows: 24",
  150.     "XEphem*Help.verticalSpacing: 20",
  151.     "XEphem*Jupiter*BigDots.set: True",
  152.     "XEphem*Jupiter*Map.height: 100",
  153.     "XEphem*Jupiter*Tags.set: True",
  154.     "XEphem*Mars*Map.height: 300",
  155.     "XEphem*Message*ScrolledText.columns: 80",
  156.     "XEphem*Message*ScrolledText.rows: 10",
  157.     "XEphem*Message.verticalSpacing: 20",
  158.     "XEphem*PlotDA.height: 300",
  159.     "XEphem*Saturn*BigDots.set: True",
  160.     "XEphem*Saturn*CtlForm.verticalSpacing: 5",
  161.     "XEphem*Saturn*Map.height: 100",
  162.     "XEphem*Saturn*Tags.set: True",
  163.     "XEphem*SkyFilter*Binary.set: True",
  164.     "XEphem*SkyFilter*BrightNeb.set: True",
  165.     "XEphem*SkyFilter*ClInNeb.set: True",
  166.     "XEphem*SkyFilter*DarkNeb.set: True",
  167.     "XEphem*SkyFilter*DiffuseNeb.set: True",
  168.     "XEphem*SkyFilter*Double.set: True",
  169.     "XEphem*SkyFilter*Elliptical.set: True",
  170.     "XEphem*SkyFilter*GalClusters.set: True",
  171.     "XEphem*SkyFilter*GlobularCl.set: True",
  172.     "XEphem*SkyFilter*Hyperbolic.set: True",
  173.     "XEphem*SkyFilter*Multiple.set: True",
  174.     "XEphem*SkyFilter*OpenCl.set: True",
  175.     "XEphem*SkyFilter*Parabolic.set: True",
  176.     "XEphem*SkyFilter*PlanetaryNeb.set: True",
  177.     "XEphem*SkyFilter*Planets.set: True",
  178.     "XEphem*SkyFilter*Quasars.set: True",
  179.     "XEphem*SkyFilter*SphericalGal.set: True",
  180.     "XEphem*SkyFilter*SpiralGal.set: True",
  181.     "XEphem*SkyFilter*Stars.set: True",
  182.     "XEphem*SkyFilter*Stellar.set: True",
  183.     "XEphem*SkyFilter*Undefined.set: True",
  184.     "XEphem*SkyFilter*Variable.set: True",
  185.     "XEphem*SkyView*AltAzMode.set: true",
  186.     "XEphem*SkyView*AltDecScale.value: 90",
  187.     "XEphem*SkyView*AzRAScale.maximum: 360",
  188.     "XEphem*SkyView*AzRAScale.value: 180",
  189.     "XEphem*SkyView*BrightMagScale.value: -28",
  190.     "XEphem*SkyView*FOVScale.value: 180",
  191.     "XEphem*SkyView*FaintMagScale.value: 6",
  192.     "XEphem*SkyView*JustDots.set: True",
  193.     "XEphem*SkyView*Map.height: 300",
  194.     "XEphem*SkyView*Map.width: 300",
  195.     "XEphem*SolarSystem*BigDots.set: true",
  196.     "XEphem*SolarSystem*HLatScale.value: 90",
  197.     "XEphem*SolarSystem*Names.set: true",
  198.     "XEphem*SolarSystem*SolarDA.height: 300",
  199.     "XEphem*SolarSystem*SolarDA.width: 300",
  200.     "XEphem*StdRefr.set: true",
  201.     "XEphem*Topocentric.set: true",
  202.     "XEphem*Units.English.set: True",
  203.     "XEphem*XmText*highlightOnEnter: false",
  204.     "XEphem*XmText*highlightThickness: 0",
  205.     "XEphem*XmText*traversalOn: true",
  206.     "XEphem*background: black",
  207.     "XEphem*fontList: fixed",
  208.     "XEphem*foreground: white",
  209.     "XEphem*highlightOnEnter: false",
  210.     "XEphem*highlightThickness: 0",
  211.     "XEphem*marginHeight: 1",
  212.     "XEphem*spacing: 1",
  213.     "XEphem*traversalOn: false",
  214.     "XEphem.Elevation: 800",
  215.     "XEphem.Epoch: 2000",
  216.     "XEphem.HELPFILE: xephem.hlp",
  217.     "XEphem.Lat: 41:51:0",
  218.     "XEphem.Long: 91:40:0",
  219.     "XEphem.NSteps: 1",
  220.     "XEphem.Pause: 0",
  221.     "XEphem.Pressure: 29.5",
  222.     "XEphem.StepSize: RTC",
  223.     "XEphem.TZName: CST",
  224.     "XEphem.TZone: 6",
  225.     "XEphem.Temp: 60",
  226.     "XEphem.TwilightDip: 18",
  227.     "XEphem.UT: Now",
  228.     "XEphem.allowShellResize: True",
  229.     "XEphem.viewsFont: fixed",
  230.     NULL
  231. };
  232.  
  233. static Widget main_window_w;
  234.  
  235. main(argc, argv)
  236. int argc;
  237. char *argv[];
  238. {
  239.     toplevel_w = XtAppInitialize (&xe_app, myclass, NULL, 0,
  240.                         &argc, argv, fallbacks, NULL, 0);
  241.  
  242. #ifdef DO_EDITRES
  243.     XtAddEventHandler (toplevel_w, (EventMask)0, True,
  244.                     _XEditResCheckMessages, NULL);
  245.     xe_msg ("Can editres!\n", 0);
  246. #endif
  247.  
  248.     /* report FPE errors, though we don't do anything about them */
  249.     (void) signal (SIGFPE, on_fpe);
  250.  
  251.     /* make the main menu bar and form (other stuff is in mainmenu.c) */
  252.     main_window_w = make_main_window ();
  253.  
  254.     XtManageChild(main_window_w);
  255.     XtRealizeWidget(toplevel_w);
  256.  
  257.     /* connect up the icon pixmap */
  258.     setup_window_properties (toplevel_w);
  259.  
  260.     XtAppMainLoop(xe_app);
  261.  
  262.     printf ("XtAppMainLoop returned :-)\n");
  263.     return (1);
  264. }
  265.  
  266. /* called to put up or remove the watch cursor.  */
  267. void
  268. main_cursor (c)
  269. Cursor c;
  270. {
  271.     Window win;
  272.  
  273.     if (main_window_w && (win = XtWindow(main_window_w))) {
  274.         Display *dsp = XtDisplay(main_window_w);
  275.         if (c)
  276.         XDefineCursor (dsp, win, c);
  277.         else
  278.         XUndefineCursor (dsp, win);
  279.     }
  280. }
  281.  
  282. static void
  283. on_fpe()
  284. {
  285.     (void) signal (SIGFPE, (void (*)())on_fpe);
  286.     xe_msg ("FP Error\n", 0);
  287. }
  288.  
  289. /* put together the menu bar, the main form, and fill in the form with the
  290.  * initial xephem buttons.
  291.  */
  292. static Widget
  293. make_main_window ()
  294. {
  295.  
  296.     Widget main_window;
  297.     Widget menu_bar;
  298.     Widget menu_pane;
  299.     Widget button;
  300.     Widget cascade;
  301.     Widget w;
  302.     XmString str;
  303.     Arg args[20];
  304.     int n;
  305.  
  306.     /*    Create MainWindow.  */
  307.     n = 0;
  308.     main_window = XmCreateMainWindow (toplevel_w, "xephem_main", args, n);
  309.     XtManageChild (main_window);
  310.  
  311.     /*    Create MenuBar in MainWindow.  */
  312.     n = 0;
  313.     menu_bar = XmCreateMenuBar (main_window, "menu_bar", args, n); 
  314.     XtManageChild (menu_bar);
  315.  
  316.     /*    Create "File" PulldownMenu.  */
  317.     n = 0;
  318.     menu_pane = XmCreatePulldownMenu (menu_bar, "file_pane", args, n);
  319.  
  320.     n = 0;
  321.     XtSetArg (args[n], XmNmnemonic, 'R'); n++;
  322.     button = XmCreatePushButton (menu_pane, "Reset", args, n);
  323.     XtManageChild (button);
  324.     XtAddCallback (button, XmNactivateCallback, m_activate_cb, 
  325.                             (XtPointer)XRESET);
  326.  
  327.     n = 0;
  328.     XtSetArg (args[n], XmNmnemonic, 'M'); n++;
  329.     button = XmCreatePushButton (menu_pane, "Messages", args, n);
  330.     XtManageChild (button);
  331.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  332.                             (XtPointer)MSGTXT);
  333.  
  334.     str = XmStringCreate ("Ctrl/d", XmSTRING_DEFAULT_CHARSET);
  335.     n = 0;
  336.     XtSetArg (args[n], XmNaccelerator, "Ctrl<Key>d:"); n++;
  337.     XtSetArg (args[n], XmNacceleratorText, str); n++;
  338.     XtSetArg (args[n], XmNmnemonic, 'Q'); n++;
  339.     button = XmCreatePushButton (menu_pane, "Quit", args, n);
  340.     XtManageChild (button);
  341.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  342.                             (XtPointer)QUIT);
  343.     XmStringFree (str);
  344.  
  345.     n = 0;
  346.     XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  347.     XtSetArg (args[n], XmNmnemonic, 'F'); n++;
  348.     cascade = XmCreateCascadeButton (menu_bar, "File", args, n);
  349.     XtManageChild (cascade);
  350.     
  351.     /*    Create "View" PulldownMenu.  */
  352.     n = 0;
  353.     menu_pane = XmCreatePulldownMenu (menu_bar, "view_pane", args, n);
  354.     
  355.     n = 0;
  356.     str = XmStringCreate ("Data Table", XmSTRING_DEFAULT_CHARSET);
  357.     XtSetArg (args[n], XmNlabelString, str); n++;
  358.     XtSetArg (args[n], XmNmnemonic, 'D'); n++;
  359.     button = XmCreatePushButton (menu_pane, "GenData", args, n);
  360.     XtManageChild (button);
  361.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  362.                             (XtPointer)DATA);
  363.     XmStringFree(str);
  364.     
  365.     n = 0;
  366.     w = XmCreateSeparator (menu_pane, "ViewSep1", args, n);
  367.     XtManageChild (w);
  368.  
  369.     n = 0;
  370.     XtSetArg (args[n], XmNmnemonic, 'M'); n++;
  371.     button = XmCreatePushButton (menu_pane, "Moon", args, n);
  372.     XtManageChild (button);
  373.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  374.                             (XtPointer)MOON);
  375.  
  376.     n = 0;
  377.     XtSetArg (args[n], XmNmnemonic, 'E'); n++;
  378.     button = XmCreatePushButton (menu_pane, "Earth", args, n);
  379.     XtManageChild (button);
  380.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  381.                             (XtPointer)EARTH);
  382.  
  383.     n = 0;
  384.     XtSetArg (args[n], XmNmnemonic, 'r'); n++;
  385.     button = XmCreatePushButton (menu_pane, "Mars", args, n);
  386.     XtManageChild (button);
  387.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  388.                             (XtPointer)MARS);
  389.  
  390.  
  391.     n = 0;
  392.     XtSetArg (args[n], XmNmnemonic, 'J'); n++;
  393.     button = XmCreatePushButton (menu_pane, "Jupiter", args, n);
  394.     XtManageChild (button);
  395.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  396.                             (XtPointer)JUPMOON);
  397.  
  398.     n = 0;
  399.     XtSetArg (args[n], XmNmnemonic, 'a'); n++;
  400.     button = XmCreatePushButton (menu_pane, "Saturn", args, n);
  401.     XtManageChild (button);
  402.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  403.                             (XtPointer)SATMOON);
  404.     
  405.     n = 0;
  406.     w = XmCreateSeparator (menu_pane, "ViewSep2", args, n);
  407.     XtManageChild (w);
  408.     
  409.     n = 0;
  410.     str = XmStringCreate ("Sky View", XmSTRING_DEFAULT_CHARSET);
  411.     XtSetArg (args[n], XmNlabelString, str); n++;
  412.     XtSetArg (args[n], XmNmnemonic, 'V'); n++;
  413.     button = XmCreatePushButton (menu_pane, "SkyV", args, n);
  414.     XtManageChild (button);
  415.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  416.                             (XtPointer)SKYVIEW);
  417.     XmStringFree(str);
  418.     
  419.     n = 0;
  420.     str = XmStringCreate ("Solar system", XmSTRING_DEFAULT_CHARSET);
  421.     XtSetArg (args[n], XmNlabelString, str); n++;
  422.     XtSetArg (args[n], XmNmnemonic, 'S'); n++;
  423.     button = XmCreatePushButton (menu_pane, "SolSys", args, n);
  424.     XtManageChild (button);
  425.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  426.                             (XtPointer)SOLARSYS);
  427.     XmStringFree(str);
  428.     
  429.     n = 0;
  430.     XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  431.     XtSetArg (args[n], XmNmnemonic, 'V'); n++;
  432.     cascade = XmCreateCascadeButton (menu_bar, "View", args, n);
  433.     XtManageChild (cascade);
  434.     
  435.     /*    Create "Control" PulldownMenu.  */
  436.     n = 0;
  437.     menu_pane = XmCreatePulldownMenu (menu_bar, "control_pane", args, n);
  438.     
  439.     n = 0;
  440.     XtSetArg (args[n], XmNmnemonic, 'P'); n++;
  441.     button = XmCreatePushButton (menu_pane, "Plot", args, n);
  442.     XtManageChild (button);
  443.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  444.                             (XtPointer)PLOT);
  445.     
  446.     n = 0;
  447.     XtSetArg (args[n], XmNmnemonic, 'L'); n++;
  448.     button = XmCreatePushButton (menu_pane, "Listing", args, n);
  449.     XtManageChild (button);
  450.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  451.                             (XtPointer)LIST);
  452.     
  453.     n = 0;
  454.     XtSetArg (args[n], XmNmnemonic, 'S'); n++;
  455.     button = XmCreatePushButton (menu_pane, "Search", args, n);
  456.     XtManageChild (button);
  457.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  458.                             (XtPointer)SEARCH);
  459.     
  460.     n = 0;
  461.     XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  462.     XtSetArg (args[n], XmNmnemonic, 'C'); n++;
  463.     cascade = XmCreateCascadeButton (menu_bar, "Control", args, n);
  464.     XtManageChild (cascade);
  465.  
  466.     /*    Create "ObjX/Y..." Cascade Button.  */
  467.     str = XmStringCreate ("ObjX/Y...", XmSTRING_DEFAULT_CHARSET);
  468.     n = 0;
  469.     XtSetArg (args[n], XmNlabelString, str); n++;
  470.     XtSetArg (args[n], XmNmnemonic, 'O'); n++;
  471.     cascade = XmCreateCascadeButton (menu_bar, "ObjXY", args, n);
  472.     XtManageChild (cascade);
  473.     XtAddCallback (cascade, XmNactivateCallback, m_activate_cb,
  474.                             (XtPointer)OBJS);
  475.     XmStringFree (str);
  476.  
  477.     /*    Create "DB..." Cascade Button.  */
  478.     str = XmStringCreate ("DB...", XmSTRING_DEFAULT_CHARSET);
  479.     n = 0;
  480.     XtSetArg (args[n], XmNlabelString, str); n++;
  481.     XtSetArg (args[n], XmNmnemonic, 'D'); n++;
  482.     cascade = XmCreateCascadeButton (menu_bar, "DB", args, n);
  483.     XtManageChild (cascade);
  484.     XtAddCallback (cascade, XmNactivateCallback, m_activate_cb,
  485.                             (XtPointer)DB);
  486.     XmStringFree (str);
  487.  
  488.     /*    Create "Preferences" PulldownMenu.  */
  489.  
  490.     pref_create_pulldown (menu_bar);
  491.     
  492.     /*    Create "Help" button.  */
  493.  
  494.     n = 0;
  495.     menu_pane = XmCreatePulldownMenu (menu_bar, "help_pane", args, n);
  496.     
  497.     n = 0;
  498.     str = XmStringCreate ("on Version", XmSTRING_DEFAULT_CHARSET);
  499.     XtSetArg (args[n], XmNlabelString, str); n++;
  500.     XtSetArg (args[n], XmNmnemonic, 'V'); n++;
  501.     button = XmCreatePushButton (menu_pane, "onVersion", args, n);
  502.     XtManageChild (button);
  503.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  504.                             (XtPointer)VERSION);
  505.     XmStringFree(str);
  506.  
  507.     n = 0;
  508.     str = XmStringCreate ("on Credits", XmSTRING_DEFAULT_CHARSET);
  509.     XtSetArg (args[n], XmNlabelString, str); n++;
  510.     XtSetArg (args[n], XmNmnemonic, 'C'); n++;
  511.     button = XmCreatePushButton (menu_pane, "onReferences", args, n);
  512.     XtManageChild (button);
  513.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  514.                             (XtPointer)REFERENCES);
  515.     XmStringFree(str);
  516.  
  517.     n = 0;
  518.     XtSetArg (args[n], XmNmnemonic, 'I'); n++;
  519.     button = XmCreatePushButton (menu_pane, "Introduction", args, n);
  520.     XtManageChild (button);
  521.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  522.                             (XtPointer)INTRO);
  523.  
  524.     n = 0;
  525.     str = XmStringCreate ("on Initialization", XmSTRING_DEFAULT_CHARSET);
  526.     XtSetArg (args[n], XmNlabelString, str); n++;
  527.     XtSetArg (args[n], XmNmnemonic, 'z'); n++;
  528.     button = XmCreatePushButton (menu_pane, "onInitialization", args, n);
  529.     XtManageChild (button);
  530.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  531.                             (XtPointer)CONFIGFILE);
  532.     XmStringFree(str);
  533.  
  534.     n = 0;
  535.     str = XmStringCreate ("on Main Menu", XmSTRING_DEFAULT_CHARSET);
  536.     XtSetArg (args[n], XmNlabelString, str); n++;
  537.     XtSetArg (args[n], XmNmnemonic, 'M'); n++;
  538.     button = XmCreatePushButton (menu_pane, "onMainMenu", args, n);
  539.     XtManageChild (button);
  540.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  541.                             (XtPointer)MAINMENU);
  542.     XmStringFree(str);
  543.  
  544.     n = 0;
  545.     str = XmStringCreate ("on Operation", XmSTRING_DEFAULT_CHARSET);
  546.     XtSetArg (args[n], XmNlabelString, str); n++;
  547.     XtSetArg (args[n], XmNmnemonic, 'O'); n++;
  548.     button = XmCreatePushButton (menu_pane, "onOperation", args, n);
  549.     XtManageChild (button);
  550.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  551.                             (XtPointer)OPERATION);
  552.     XmStringFree(str);
  553.  
  554.     n = 0;
  555.     str = XmStringCreate ("on Triad formats", XmSTRING_DEFAULT_CHARSET);
  556.     XtSetArg (args[n], XmNlabelString, str); n++;
  557.     XtSetArg (args[n], XmNmnemonic, 'T'); n++;
  558.     button = XmCreatePushButton (menu_pane, "onTriad", args, n);
  559.     XtManageChild (button);
  560.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  561.                             (XtPointer)DATETIME);
  562.     XmStringFree(str);
  563.  
  564.     n = 0;
  565.     XtSetArg (args[n], XmNmnemonic, 'N'); n++;
  566.     button = XmCreatePushButton (menu_pane, "Notes", args, n);
  567.     XtManageChild (button);
  568.     XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  569.                             (XtPointer)NOTES);
  570.  
  571.     n = 0;
  572.     XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  573.     XtSetArg (args[n], XmNmnemonic, 'H'); n++;
  574.     cascade = XmCreateCascadeButton (menu_bar, "Help", args, n);
  575.     XtManageChild (cascade);
  576.  
  577.     n = 0;
  578.     XtSetArg (args[n], XmNmenuHelpWidget, cascade);  n++;
  579.     XtSetValues (menu_bar, args, n);
  580.  
  581.     /* create and manage the main form */
  582.     mm_manage(main_window);
  583.  
  584.     return (main_window);
  585. }
  586.  
  587. static void
  588. setup_window_properties (w)
  589. Widget w;
  590. {
  591.     Pixmap icon_pm;
  592.     XSizeHints xsh;
  593.     Display *dsp = XtDisplay(w);
  594.     Window win = XtWindow (w);
  595.  
  596.     icon_pm = XCreateBitmapFromData (dsp, win, (char *)xephem_bits,
  597.                         xephem_width, xephem_height);
  598.     /* can set window size hints here if we like */
  599.     xsh.flags = 0;
  600.  
  601.     XSetStandardProperties (dsp, win, "xephem", "xephem", icon_pm,
  602.         (char **)0, 0, &xsh);
  603. }
  604.  
  605. /* ARGSUSED */
  606. static void
  607. m_activate_cb (w, client, call)
  608. Widget w;
  609. XtPointer client;
  610. XtPointer call;
  611. {
  612.     int code = (int)client;
  613.  
  614.     watch_cursor(1);
  615.  
  616.     switch (code) {
  617.     case XRESET:    mm_reset(); break;
  618.     case MSGTXT:    msg_manage(); break;
  619.     case QUIT:    exit(0); break;
  620.     case DATA:    dm_manage(); break;
  621.     case EARTH:    e_manage(); break;
  622.     case MOON:    m_manage(); break;
  623.     case MARS:    mars_manage(); break;
  624.     case JUPMOON:    jm_manage(); break;
  625.     case SATMOON:    sm_manage(); break;
  626.     case SKYVIEW:    sv_manage(); break;
  627.     case SOLARSYS:    ss_manage(); break;
  628.     case PLOT:    plot_manage(); break;
  629.     case LIST:    lst_manage(); break;
  630.     case SEARCH:    srch_manage(); break;
  631.     case OBJS:    obj_manage(); break;
  632.     case DB:    db_manage(); break;
  633.     case VERSION:    version(); break;
  634.     case REFERENCES:references_help(); break;
  635.     case INTRO:    intro_help(); break;
  636.     case CONFIGFILE:config_help(); break;
  637.     case MAINMENU:    mainmenu_help(); break;
  638.     case OPERATION:    operation_help(); break;
  639.     case DATETIME:    datetime_help(); break;
  640.     case NOTES:    notes_help(); break;
  641.     default:     printf ("Main menu bug: code=%d\n", code); exit(1);
  642.     }
  643.  
  644.     watch_cursor(0);
  645. }
  646.