home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xephem / part11 < prev    next >
Encoding:
Text File  |  1993-05-15  |  76.4 KB  |  2,647 lines

  1. Newsgroups: comp.sources.x
  2. From: ecdowney@pobox.cca.cr.rockwell.com (Elwood Downey)
  3. Subject: v19i099:  xephem - astronomical ephemeris program, Part11/21
  4. Message-ID: <1993May10.221054.8740@sparky.imd.sterling.com>
  5. X-Md4-Signature: 8b17db69a88b9a02042a2a6b2441b3ab
  6. Date: Mon, 10 May 1993 22:10:54 GMT
  7. Approved: chris@sparky.imd.sterling.com
  8.  
  9. Submitted-by: ecdowney@pobox.cca.cr.rockwell.com (Elwood Downey)
  10. Posting-number: Volume 19, Issue 99
  11. Archive-name: xephem/part11
  12. Environment: X11r4, OSF/Motif
  13. Supersedes: xephem: Volume 16, Issue 112-134
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  cal_mjd.c datamenu.c xephem.c
  22. # Wrapped by chris@nova on Mon May 10 16:41:48 1993
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 11 (of 21)."'
  26. if test -f 'cal_mjd.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'cal_mjd.c'\"
  28. else
  29.   echo shar: Extracting \"'cal_mjd.c'\" \(3726 characters\)
  30.   sed "s/^X//" >'cal_mjd.c' <<'END_OF_FILE'
  31. X#include <stdio.h>
  32. X#include <math.h>
  33. X#include "astro.h"
  34. X
  35. X/* given a date in months, mn, days, dy, years, yr,
  36. X * return the modified Julian date (number of days elapsed since 1900 jan 0.5),
  37. X * *mjd.
  38. X */
  39. Xvoid
  40. Xcal_mjd (mn, dy, yr, mjd)
  41. Xint mn, yr;
  42. Xdouble dy;
  43. Xdouble *mjd;
  44. X{
  45. X    static double last_mjd, last_dy;
  46. X    static int last_mn, last_yr;
  47. X    int b, d, m, y;
  48. X    long c;
  49. X
  50. X    if (mn == last_mn && yr == last_yr && dy == last_dy) {
  51. X        *mjd = last_mjd;
  52. X        return;
  53. X    }
  54. X
  55. X    m = mn;
  56. X    y = (yr < 0) ? yr + 1 : yr;
  57. X    if (mn < 3) {
  58. X        m += 12;
  59. X        y -= 1;
  60. X    }
  61. X
  62. X    if (yr < 1582 || yr == 1582 && (mn < 10 || mn == 10 && dy < 15)) 
  63. X        b = 0;
  64. X    else {
  65. X        int a;
  66. X        a = y/100;
  67. X        b = 2 - a + a/4;
  68. X    }
  69. X
  70. X    if (y < 0)
  71. X        c = (long)((365.25*y) - 0.75) - 694025L;
  72. X    else
  73. X        c = (long)(365.25*y) - 694025L;
  74. X
  75. X    d = 30.6001*(m+1);
  76. X
  77. X    *mjd = b + c + d + dy - 0.5;
  78. X
  79. X    last_mn = mn;
  80. X    last_dy = dy;
  81. X    last_yr = yr;
  82. X    last_mjd = *mjd;
  83. X}
  84. X
  85. X/* given the modified Julian date (number of days elapsed since 1900 jan 0.5,),
  86. X * mjd, return the calendar date in months, *mn, days, *dy, and years, *yr.
  87. X */
  88. Xvoid
  89. Xmjd_cal (mjd, mn, dy, yr)
  90. Xdouble mjd;
  91. Xint *mn, *yr;
  92. Xdouble *dy;
  93. X{
  94. X    static double last_mjd, last_dy;
  95. X    static int last_mn, last_yr;
  96. X    double d, f;
  97. X    double i, a, b, ce, g;
  98. X
  99. X    if (mjd == last_mjd) {
  100. X        *mn = last_mn;
  101. X        *yr = last_yr;
  102. X        *dy = last_dy;
  103. X        return;
  104. X    }
  105. X
  106. X    d = mjd + 0.5;
  107. X    i = floor(d);
  108. X    f = d-i;
  109. X    if (f == 1) {
  110. X        f = 0;
  111. X        i += 1;
  112. X    }
  113. X
  114. X    if (i > -115860.0) {
  115. X        a = floor((i/36524.25)+.9983573)+14;
  116. X        i += 1 + a - floor(a/4.0);
  117. X    }
  118. X
  119. X    b = floor((i/365.25)+.802601);
  120. X    ce = i - floor((365.25*b)+.750001)+416;
  121. X    g = floor(ce/30.6001);
  122. X    *mn = g - 1;
  123. X    *dy = ce - floor(30.6001*g)+f;
  124. X    *yr = b + 1899;
  125. X
  126. X    if (g > 13.5)
  127. X        *mn = g - 13;
  128. X    if (*mn < 2.5)
  129. X        *yr = b + 1900;
  130. X    if (*yr < 1)
  131. X        *yr -= 1;
  132. X
  133. X    last_mn = *mn;
  134. X    last_dy = *dy;
  135. X    last_yr = *yr;
  136. X    last_mjd = mjd;
  137. X}
  138. X
  139. X/* given an mjd, set *dow to 0..6 according to which day of the week it falls
  140. X * on (0=sunday) or set it to -1 if can't figure it out.
  141. X */
  142. Xvoid
  143. Xmjd_dow (mjd, dow)
  144. Xdouble mjd;
  145. Xint *dow;
  146. X{
  147. X    /* cal_mjd() uses Gregorian dates on or after Oct 15, 1582.
  148. X     * (Pope Gregory XIII dropped 10 days, Oct 5..14, and improved the leap-
  149. X     * year algorithm). however, Great Britian and the colonies did not
  150. X     * adopt it until Sept 14, 1752 (they dropped 11 days, Sept 3-13,
  151. X     * due to additional accumulated error). leap years before 1752 thus
  152. X     * can not easily be accounted for from the cal_mjd() number...
  153. X     */
  154. X    if (mjd < -53798.5) {
  155. X        /* pre sept 14, 1752 too hard to correct */
  156. X        *dow = -1;
  157. X        return;
  158. X    }
  159. X    *dow = ((long)floor(mjd-.5) + 1) % 7;/* 1/1/1900 (mjd 0.5) is a Monday*/
  160. X    if (*dow < 0)
  161. X        *dow += 7;
  162. X}
  163. X
  164. X/* given a mjd, return the the number of days in the month.  */
  165. Xvoid
  166. Xmjd_dpm (mjd, ndays)
  167. Xdouble mjd;
  168. Xint *ndays;
  169. X{
  170. X    static short dpm[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  171. X    int m, y;
  172. X    double d;
  173. X
  174. X    mjd_cal (mjd, &m, &d, &y);
  175. X    *ndays = (m==2 && ((y%4==0 && y%100!=0)||y%400==0)) ? 29 : dpm[m-1];
  176. X}
  177. X
  178. X/* given a mjd, return the year as a double. */
  179. Xvoid
  180. Xmjd_year (mjd, yr)
  181. Xdouble mjd;
  182. Xdouble *yr;
  183. X{
  184. X    static double last_mjd, last_yr;
  185. X    int m, y;
  186. X    double d;
  187. X    double e0, e1;    /* mjd of start of this year, start of next year */
  188. X
  189. X    if (mjd == last_mjd) {
  190. X        *yr = last_yr;
  191. X        return;
  192. X    }
  193. X
  194. X    mjd_cal (mjd, &m, &d, &y);
  195. X    if (y == -1) y = -2;
  196. X    cal_mjd (1, 1.0, y, &e0);
  197. X    cal_mjd (1, 1.0, y+1, &e1);
  198. X    *yr = y + (mjd - e0)/(e1 - e0);
  199. X
  200. X    last_mjd = mjd;
  201. X    last_yr = *yr;
  202. X}
  203. X
  204. X/* given a decimal year, return mjd */
  205. Xvoid
  206. Xyear_mjd (y, mjd)
  207. Xdouble y;
  208. Xdouble *mjd;
  209. X{
  210. X    double e0, e1;    /* mjd of start of this year, start of next year */
  211. X    int yf = floor (y);
  212. X    if (yf == -1) yf = -2;
  213. X
  214. X    cal_mjd (1, 1.0, yf, &e0);
  215. X    cal_mjd (1, 1.0, yf+1, &e1);
  216. X    *mjd = e0 + (y - yf)*(e1-e0);
  217. X}
  218. END_OF_FILE
  219.   if test 3726 -ne `wc -c <'cal_mjd.c'`; then
  220.     echo shar: \"'cal_mjd.c'\" unpacked with wrong size!
  221.   fi
  222.   # end of 'cal_mjd.c'
  223. fi
  224. if test -f 'datamenu.c' -a "${1}" != "-c" ; then 
  225.   echo shar: Will not clobber existing file \"'datamenu.c'\"
  226. else
  227.   echo shar: Extracting \"'datamenu.c'\" \(47722 characters\)
  228.   sed "s/^X//" >'datamenu.c' <<'END_OF_FILE'
  229. X/* code to manage the stuff on the "data" menu.
  230. X * functions for the main data table are prefixed with dm.
  231. X * functions for the setup menu are prefixed with ds.
  232. X */
  233. X
  234. X#include <stdio.h>
  235. X#include <ctype.h>
  236. X#include <math.h>
  237. X#if defined(__STDC__)
  238. X#include <stdlib.h>
  239. X#endif
  240. X#include <Xm/Xm.h>
  241. X#include <Xm/Form.h>
  242. X#include <Xm/Frame.h>
  243. X#include <Xm/Label.h>
  244. X#include <Xm/PushB.h>
  245. X#include <Xm/ToggleB.h>
  246. X#include <Xm/RowColumn.h>
  247. X#include <Xm/Separator.h>
  248. X#include "astro.h"
  249. X#include "circum.h"
  250. X#include "preferences.h"
  251. X
  252. Xextern Widget    toplevel_w;
  253. X
  254. X#if defined(__STDC__) || defined(__cplusplus)
  255. X#define P_(s) s
  256. X#else
  257. X#define P_(s) ()
  258. X#endif
  259. X
  260. Xextern Now *mm_get_now P_((void));
  261. Xextern Obj *db_basic P_((int id));
  262. Xextern int any_ison P_((void));
  263. Xextern void confnd P_((double r, double d, double e, char **name));
  264. Xextern void db_update P_((Obj *op));
  265. Xextern void f_angle P_((Widget w, double a));
  266. Xextern void f_double P_((Widget w, char *fmt, double f));
  267. Xextern void f_mtime P_((Widget w, double t));
  268. Xextern void f_ra P_((Widget w, double ra));
  269. Xextern void f_showit P_((Widget w, char *s));
  270. Xextern void f_string P_((Widget w, char *s));
  271. Xextern void get_something P_((Widget w, char *resource, char *value));
  272. Xextern void get_xmstring P_((Widget w, char *resource, char **txtp));
  273. Xextern void hlp_dialog P_((char *tag, char *deflt[], int ndeflt));
  274. Xextern void prompt_map_cb P_((Widget w, XtPointer client, XtPointer call));
  275. Xextern void register_selection P_((char *name));
  276. Xextern void riset_cir P_((Now *np, Obj *op, double dis, RiseSet *rp));
  277. Xextern void set_something P_((Widget w, char *resource, char *value));
  278. Xextern void timestamp P_((Now *np, Widget w));
  279. Xextern void unrefract P_((double pr, double tr, double aa, double *ta));
  280. Xextern void watch_cursor P_((int want));
  281. Xextern void xe_msg P_((char *msg, int app_modal));
  282. X
  283. Xvoid dm_manage P_((void));
  284. Xvoid dm_newobj P_((int dbidx));
  285. Xvoid dm_update P_((Now *np, int how_much));
  286. Xvoid dm_selection_mode P_((int whether));
  287. Xvoid dm_cursor P_((Cursor c));
  288. Xstatic void dm_create_form P_((void));
  289. Xstatic void dm_set_buttons P_((int whether));
  290. Xstatic void dm_create_table P_((Widget parent));
  291. Xstatic void dm_activate_cb P_((Widget w, XtPointer client, XtPointer call));
  292. Xstatic void dm_close_cb P_((Widget w, XtPointer client, XtPointer call));
  293. Xstatic void dm_setup_cb P_((Widget w, XtPointer client, XtPointer call));
  294. Xstatic void dm_help_cb P_((Widget w, XtPointer client, XtPointer call));
  295. Xstatic void dm_compute P_((int r, int force, Now *np));
  296. Xstatic void dm_format P_((Now *np, Obj *op, RiseSet *rp, int c, Widget w));
  297. Xstatic void dm_rs_addplus P_((Widget w, int addplus));
  298. Xstatic void dm_rs_hrsup P_((Widget w, RiseSet *rp));
  299. Xstatic void show_constellation P_((Now *np, Obj *op, Widget w));
  300. Xstatic void dm_separation P_((Obj *p, Obj *q, int how, Widget w));
  301. Xstatic void ds_create_selection P_((Widget parent));
  302. Xstatic void ds_setup_row_selections P_((void));
  303. Xstatic void ds_setup_col_selections P_((int what));
  304. Xstatic void ds_apply_selections P_((void));
  305. Xstatic void ds_ctl_cb P_((Widget w, XtPointer client, XtPointer call));
  306. Xstatic void ds_help P_((void));
  307. Xstatic void ds_row_toggle_cb P_((Widget w, XtPointer client, XtPointer call));
  308. Xstatic void ds_col_toggle_cb P_((Widget w, XtPointer client, XtPointer call));
  309. Xstatic void ds_row_all_cb P_((Widget w, XtPointer client, XtPointer call));
  310. Xstatic void ds_col_all_cb P_((Widget w, XtPointer client, XtPointer call));
  311. Xstatic void ds_row_reset_cb P_((Widget w, XtPointer client, XtPointer call));
  312. Xstatic void ds_col_reset_cb P_((Widget w, XtPointer client, XtPointer call));
  313. X
  314. X#undef P_
  315. X
  316. Xtypedef struct {
  317. X    int dbidx;        /* db index of object on this row */
  318. X    int on;        /* whether this row is currently to be on */
  319. X    Widget lw;        /* label widget for this row's header */
  320. X    Widget sw;        /* pushbutton widget for this row in selection menu */
  321. X} RowHdr;
  322. X
  323. Xstatic RowHdr row[NOBJ] = {
  324. X    {SUN},
  325. X    {MOON},
  326. X    {MERCURY},
  327. X    {VENUS},
  328. X    {MARS},
  329. X    {JUPITER},
  330. X    {SATURN},
  331. X    {URANUS},
  332. X    {NEPTUNE},
  333. X    {PLUTO},
  334. X    {OBJX},
  335. X    {OBJY},
  336. X};
  337. X
  338. Xtypedef struct {
  339. X    int type;        /* one of XXX_COL, below */
  340. X    char *name;        /* name of column, unless SEP_COL then use db_name */
  341. X    int dbidx;        /* if type == SEP_COL, db index of cross object */
  342. X    int on;        /* whether this column is currently to be on */
  343. X    Widget rcw;        /* RowColumn widget for this column */
  344. X    Widget lw;        /* label widget for this column's header */
  345. X    Widget sw;        /* pushbutton widget for this col in selection menu */
  346. X} ColHdr;
  347. X
  348. X/* possible values for ColHdr.type. */
  349. Xenum {
  350. X    MISC_COL, RISET_COL, SEP_COL
  351. X};
  352. X
  353. X/* identifiers for each entry in col[]. these must match the order therein.
  354. X */
  355. Xenum {
  356. X    CONSTEL_ID, RA_ID, DEC_ID, AZ_ID, ALT_ID, HLONG_ID, HLAT_ID,
  357. X    EDST_ID, SDST_ID, ELONG_ID, SIZE_ID, VMAG_ID, PHS_ID, RSTIME_ID,
  358. X    RSAZ_ID, TRTIME_ID, TRALT_ID, SETTIME_ID, SETAZ_ID, HRSUP_ID
  359. X};
  360. X
  361. X/* tags for the various Data Selection control panel buttons */
  362. Xenum {OK, APPLY, CANCEL, HELP};
  363. X
  364. Xstatic ColHdr col[] = {
  365. X    {MISC_COL,    "Cns"},
  366. X    {MISC_COL,    "R_A"},
  367. X    {MISC_COL,    "Dec"},
  368. X    {MISC_COL,    "Az"},
  369. X    {MISC_COL,    "Alt"},
  370. X    {MISC_COL,    "HeLong"},
  371. X    {MISC_COL,    "HeLat"},
  372. X    {MISC_COL,    "EaDst"},
  373. X    {MISC_COL,    "SnDst"},
  374. X    {MISC_COL,    "Elong"},
  375. X    {MISC_COL,    "Size"},
  376. X    {MISC_COL,    "VMag"},
  377. X    {MISC_COL,    "Phase"},
  378. X    {RISET_COL,    "RiseTm"},
  379. X    {RISET_COL,    "RiseAz"},
  380. X    {RISET_COL,    "TrnTm"},
  381. X    {RISET_COL,    "TrnAlt"},
  382. X    {RISET_COL,    "SetTm"},
  383. X    {RISET_COL,    "SetAz"},
  384. X    {RISET_COL,    "HrsUp"},
  385. X    {SEP_COL, (char *)0, SUN},
  386. X    {SEP_COL, (char *)0, MOON},
  387. X    {SEP_COL, (char *)0, MERCURY},
  388. X    {SEP_COL, (char *)0, VENUS},
  389. X    {SEP_COL, (char *)0, MARS},
  390. X    {SEP_COL, (char *)0, JUPITER},
  391. X    {SEP_COL, (char *)0, SATURN},
  392. X    {SEP_COL, (char *)0, URANUS},
  393. X    {SEP_COL, (char *)0, NEPTUNE},
  394. X    {SEP_COL, (char *)0, PLUTO},
  395. X    {SEP_COL, (char *)0, OBJX},
  396. X    {SEP_COL, (char *)0, OBJY},
  397. X};
  398. X
  399. X#define    NR    XtNumber(row)
  400. X#define    NC    XtNumber(col)
  401. X
  402. Xstatic Widget t_w[NR][NC];    /* pushbuttons within table */
  403. Xstatic Widget dataform_w;    /* the overall table form */
  404. Xstatic Widget table_w;        /* the overall RowColumn table */
  405. Xstatic Widget corner_w;        /* upper left corner of table */
  406. Xstatic Widget hdrcol_w;        /* RowColumn for first column */
  407. Xstatic Widget sel_w;        /* setup menu */
  408. Xstatic Widget dt_w;        /* date/time stamp label widget */
  409. X
  410. X/* separation perspective */
  411. Xenum {GEO_CEN, TOPO_CEN};
  412. X
  413. Xenum {STDREFR, ADPREFR};
  414. Xenum {LIMB, CENTER};
  415. X
  416. Xstatic Widget stdrefr_w;    /* the StdRefr toggle button */
  417. Xstatic Widget limb_w;        /* the Center/Limb toggle button */
  418. Xstatic Widget refr_w;        /* the horizon label on the data table */
  419. Xstatic Widget limbl_w;        /* the Limb label on the data table */
  420. Xstatic int horizon;        /* one of STDREFR or ADPREFR */
  421. Xstatic int limb;        /* one of CENTER or LIMB */
  422. Xstatic Widget geocen_w;        /* the Geocentric toggle button */
  423. Xstatic Widget centric_w;    /* the centric label on the data table */
  424. Xstatic int centric;        /* one of GEO_CEN or TOPO_CEN */
  425. X
  426. Xstatic int dm_selecting;    /* set while our fields are being selected */
  427. X
  428. X/* called when the data menu is activated via the main menu pulldown.
  429. X * if never called before, create all the widgets form;
  430. X * otherwise, just toggle whether the form is managed.
  431. X */
  432. Xvoid
  433. Xdm_manage ()
  434. X{
  435. X    if (!dataform_w)
  436. X        dm_create_form();
  437. X    
  438. X    if (XtIsManaged(dataform_w)) {
  439. X        XtUnmanageChild (dataform_w);
  440. X        if (XtIsManaged(sel_w))
  441. X        XtUnmanageChild(sel_w);
  442. X    } else {
  443. X        XtManageChild (dataform_w);
  444. X        dm_update (mm_get_now(), 1);
  445. X        dm_set_buttons (dm_selecting);
  446. X    }
  447. X}
  448. X
  449. X/* user-defined object dbidx has changed.
  450. X * might have a new name, or might be defined or undefined now.
  451. X * must check both the data table and the selection menu.
  452. X * N.B. no need to recompute math -- dm_update() will be called for us.
  453. X */
  454. Xvoid
  455. Xdm_newobj(dbidx)
  456. Xint dbidx;
  457. X{
  458. X    static char me[] = "dm_newobj()";
  459. X    int i, c;
  460. X
  461. X    /* might get called before we have been managed the first time */
  462. X    if (!dataform_w)
  463. X        return;
  464. X
  465. X    for (i = 0; i < NR; i++)
  466. X        if (row[i].dbidx == dbidx) {
  467. X        Obj *op = db_basic (dbidx);
  468. X        if (op->type == UNDEFOBJ) {
  469. X            /* it's now undefined so turn off */
  470. X            row[i].on = False;
  471. X            for (c = 0; c < NC; c++)
  472. X            XtUnmanageChild (t_w[i][c]);
  473. X            XtUnmanageChild (row[i].lw);
  474. X            XtUnmanageChild (row[i].sw);
  475. X            XmToggleButtonSetState (row[i].sw, False, False);
  476. X        } else {
  477. X            f_string (row[i].lw, op->o_name);
  478. X            XtManageChild (row[i].sw);
  479. X            f_string (row[i].sw, op->o_name);
  480. X        }
  481. X        break;
  482. X        }
  483. X    if (i == NR) {
  484. X        printf ("Bug: %s: dbidx not in row[]: 0x%x\n", me, dbidx);
  485. X        exit (1);
  486. X    }
  487. X
  488. X    for (i = 0; i < NC; i++)
  489. X        if (col[i].type == SEP_COL && col[i].dbidx == dbidx) {
  490. X        Obj *op = db_basic (dbidx);
  491. X        if (op->type == UNDEFOBJ) {
  492. X            /* it's now undefined so turn off */
  493. X            col[i].on = False;
  494. X            XtUnmanageChild (col[i].rcw);
  495. X            XtUnmanageChild (col[i].sw);
  496. X            XmToggleButtonSetState (col[i].sw, False, False);
  497. X        } else {
  498. X            f_string (col[i].lw, op->o_name);
  499. X            XtManageChild (col[i].sw);
  500. X            f_string (col[i].sw, op->o_name);
  501. X        }
  502. X        break;
  503. X        }
  504. X    if (i == NC) {
  505. X        printf ("Bug: %s: dbidx not in col[]: 0x%x\n", me, dbidx);
  506. X        exit (1);
  507. X    }
  508. X}
  509. X
  510. X/* called to recompute and fill in values for the data menu.
  511. X * don't bother if it doesn't exist or is unmanaged now or no one is logging.
  512. X */
  513. Xvoid
  514. Xdm_update (np, how_much)
  515. XNow *np;
  516. Xint how_much;
  517. X{
  518. X    int i;
  519. X
  520. X    if (!dataform_w)
  521. X        return;
  522. X    if (!XtIsManaged(dataform_w) && !any_ison() && !how_much)
  523. X        return;
  524. X
  525. X    /* update each row that is on */
  526. X    for (i = 0; i < NR; i++)
  527. X        if (row[i].on)
  528. X        dm_compute (i, how_much, np);
  529. X
  530. X    /* update the datestamp */
  531. X    timestamp (np, dt_w);
  532. X}
  533. X
  534. X/* called by other menus as they want to hear from our buttons or not.
  535. X * the "on"s and "off"s stack - only really redo the buttons if it's the
  536. X * first on or the last off.
  537. X */
  538. Xvoid
  539. Xdm_selection_mode (whether)
  540. Xint whether;    /* whether setting up for plotting or for not plotting */
  541. X{
  542. X    dm_selecting += whether ? 1 : -1;
  543. X
  544. X    if (dataform_w && XtIsManaged(dataform_w))
  545. X        if (whether && dm_selecting == 1     /* first one to want on */
  546. X        || !whether && dm_selecting == 0 /* last one to want off */)
  547. X        dm_set_buttons (whether);
  548. X}
  549. X
  550. X/* called to put up or remove the watch cursor.  */
  551. Xvoid
  552. Xdm_cursor (c)
  553. XCursor c;
  554. X{
  555. X    Window win;
  556. X
  557. X    if (dataform_w && (win = XtWindow(dataform_w))) {
  558. X        Display *dsp = XtDisplay(dataform_w);
  559. X        if (c)
  560. X        XDefineCursor (dsp, win, c);
  561. X        else
  562. X        XUndefineCursor (dsp, win);
  563. X    }
  564. X
  565. X    if (sel_w && (win = XtWindow(sel_w))) {
  566. X        Display *dsp = XtDisplay(sel_w);
  567. X        if (c)
  568. X        XDefineCursor (dsp, win, c);
  569. X        else
  570. X        XUndefineCursor (dsp, win);
  571. X    }
  572. X}
  573. X
  574. Xstatic void
  575. Xdm_create_form()
  576. X{
  577. X    Widget ctlrc_w, w;
  578. X    Arg args[20];
  579. X    int n;
  580. X
  581. X    /* create the form */
  582. X    n = 0;
  583. X    XtSetArg (args[n], XmNallowShellResize, True); n++;
  584. X    XtSetArg (args[n], XmNautoUnmanage, False); n++;
  585. X    XtSetArg (args[n], XmNdefaultPosition, False); n++;
  586. X    XtSetArg (args[n], XmNallowOverlap, False); n++;
  587. X    dataform_w = XmCreateFormDialog (toplevel_w, "Data", args, n);
  588. X
  589. X    /* set some stuff in the parent DialogShell.
  590. X     * setting XmNdialogTitle in the Form didn't work..
  591. X     */
  592. X    n = 0;
  593. X    XtSetArg (args[n], XmNtitle, "xephem General Data Table"); n++;
  594. X    XtSetValues (XtParent(dataform_w), args, n);
  595. X
  596. X    /* make a rowcolumn for the bottom control panel */
  597. X
  598. X    n = 0;
  599. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  600. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  601. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  602. X    XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
  603. X    XtSetArg (args[n], XmNpacking, XmPACK_TIGHT); n++;
  604. X    XtSetArg (args[n], XmNentryAlignment, XmALIGNMENT_CENTER); n++;
  605. X    ctlrc_w = XmCreateRowColumn (dataform_w, "DataTblRC", args, n);
  606. X    XtManageChild (ctlrc_w);
  607. X
  608. X        /* make the Setup button */
  609. X
  610. X        n = 0;
  611. X        w = XmCreatePushButton (ctlrc_w, "Setup", args, n);
  612. X        XtAddCallback (w, XmNactivateCallback, dm_setup_cb, 0);
  613. X        XtManageChild (w);
  614. X
  615. X        /* make the close button */
  616. X
  617. X        n = 0;
  618. X        w = XmCreatePushButton (ctlrc_w, "Close", args, n);
  619. X        XtAddCallback (w, XmNactivateCallback, dm_close_cb, 0);
  620. X        XtManageChild (w);
  621. X
  622. X        /* make the help pushbutton */
  623. X
  624. X        n = 0;
  625. X        w = XmCreatePushButton (ctlrc_w, "Help", args, n);
  626. X        XtAddCallback (w, XmNactivateCallback, dm_help_cb, 0);
  627. X        XtManageChild (w);
  628. X
  629. X        /* make the horizon, limb and centric indicators in frames.
  630. X         * turn them on and off by managing the frames -- but not yet!
  631. X         */
  632. X
  633. X        n = 0;
  634. X        w = XmCreateFrame (ctlrc_w, "DRefrF", args, n);
  635. X        n = 0;
  636. X        refr_w = XmCreateLabel (w, "DRefrL", args, n);
  637. X        XtManageChild (refr_w);
  638. X        n = 0;
  639. X        w = XmCreateFrame (ctlrc_w, "DLimblF", args, n);
  640. X        n = 0;
  641. X        limbl_w = XmCreateLabel (w, "DLimblL", args, n);
  642. X        XtManageChild (limbl_w);
  643. X        n = 0;
  644. X        w = XmCreateFrame (ctlrc_w, "DCentricF", args, n);
  645. X        n = 0;
  646. X        centric_w = XmCreateLabel (w, "DCentricL", args, n);
  647. X        XtManageChild (centric_w);
  648. X
  649. X        /* make a label for the date/time stamp */
  650. X
  651. X        n = 0;
  652. X        dt_w = XmCreateLabel (ctlrc_w, "DateStamp", args, n);
  653. X        timestamp (mm_get_now(), dt_w);    /* sets initial size correctly*/
  654. X        XtManageChild (dt_w);
  655. X
  656. X    /* create the table */
  657. X
  658. X    n = 0;
  659. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  660. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  661. X    XtSetArg (args[n], XmNbottomWidget, ctlrc_w); n++;
  662. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  663. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  664. X    XtSetArg (args[n], XmNorientation, XmHORIZONTAL); n++;
  665. X    XtSetArg (args[n], XmNpacking, XmPACK_TIGHT); n++;
  666. X    table_w = XmCreateRowColumn (dataform_w, "DataTable", args, n);
  667. X    XtManageChild (table_w);
  668. X
  669. X    dm_create_table (table_w);
  670. X
  671. X    /* create the selection dialog.
  672. X     * don't manage it yet but its state info is used right off.
  673. X     */
  674. X    ds_create_selection(toplevel_w);
  675. X    ds_apply_selections();
  676. X}
  677. X
  678. X/* go through all the buttons and set whether they
  679. X * should appear to look like buttons or just flat labels.
  680. X */
  681. Xstatic void
  682. Xdm_set_buttons (whether)
  683. Xint whether;    /* whether setting up for plotting or for not plotting */
  684. X{
  685. X    static Arg look_like_button[] = {
  686. X        {XmNtopShadowColor, (XtArgVal) 0},
  687. X        {XmNbottomShadowColor, (XtArgVal) 0},
  688. X        {XmNfillOnArm, (XtArgVal) True},
  689. X    };
  690. X    static Arg look_like_label[] = {
  691. X        {XmNtopShadowColor, (XtArgVal) 0},
  692. X        {XmNbottomShadowColor, (XtArgVal) 0},
  693. X        {XmNfillOnArm, (XtArgVal) False},
  694. X    };
  695. X    static int called;
  696. X    int r, c;
  697. X    Arg *ap;
  698. X    int na;
  699. X
  700. X    if (!called) {
  701. X        /* get baseline label and shadow appearances.
  702. X         * also make the corner and headers look like labels forever.
  703. X         */
  704. X        Pixel topshad, botshad, bgcol;
  705. X        Arg args[20];
  706. X        int n;
  707. X        int i;
  708. X
  709. X        n = 0;
  710. X        XtSetArg (args[n], XmNtopShadowColor, &topshad); n++;
  711. X        XtSetArg (args[n], XmNbottomShadowColor, &botshad); n++;
  712. X        XtSetArg (args[n], XmNbackground, &bgcol); n++;
  713. X        XtGetValues (corner_w, args, n);
  714. X
  715. X        look_like_button[0].value = topshad;
  716. X        look_like_button[1].value = botshad;
  717. X        look_like_label[0].value = bgcol;
  718. X        look_like_label[1].value = bgcol;
  719. X
  720. X        ap = look_like_label;
  721. X        na = XtNumber(look_like_label);
  722. X        XtSetValues (corner_w, ap, na);
  723. X        for (i = 0; i < NR; i++)
  724. X        XtSetValues (row[i].lw, ap, na);
  725. X        for (i = 0; i < NC; i++)
  726. X        XtSetValues (col[i].lw, ap, na);
  727. X
  728. X        called = 1;
  729. X    }
  730. X
  731. X    if (whether) {
  732. X        ap = look_like_button;
  733. X        na = XtNumber(look_like_button);
  734. X    } else {
  735. X        ap = look_like_label;
  736. X        na = XtNumber(look_like_label);
  737. X    }
  738. X    for (r = 0; r < NR; r++)
  739. X        for (c = 0; c < NC; c++)
  740. X        if (t_w[r][c])
  741. X            XtSetValues (t_w[r][c], ap, na);
  742. X}
  743. X
  744. X/* create the main data table - everything but the first column is unmanaged.
  745. X */
  746. Xstatic void
  747. Xdm_create_table(parent)
  748. XWidget parent;    /* overall RowColumn */
  749. X{
  750. X    Arg args[20];
  751. X    XmString str;
  752. X    Widget w;
  753. X    int r, c;
  754. X    int n;
  755. X
  756. X    /* first column is the row headers.
  757. X     * it's always managed so init what rows we can too.
  758. X     */
  759. X    n = 0;
  760. X    hdrcol_w = XmCreateRowColumn (parent, "DataHdrC", args, n);
  761. X    XtManageChild (hdrcol_w);
  762. X
  763. X        /* first row is a dummy */
  764. X        n = 0;
  765. X        str = XmStringCreateLtoR (" ", XmSTRING_DEFAULT_CHARSET);
  766. X        n = 0;
  767. X        XtSetArg (args[n], XmNlabelString, str); n++;
  768. X        corner_w = XmCreatePushButton (hdrcol_w, "DataCorner", args, n);
  769. X        XmStringFree (str);
  770. X        XtManageChild (corner_w);
  771. X
  772. X        /* remaining rows are per object */
  773. X        for (r = 0; r < NR; r++) {
  774. X        Obj *op = db_basic (row[r].dbidx);
  775. X        n = 0;
  776. X        if (op->type != UNDEFOBJ)
  777. X            w = XmCreatePushButton (hdrcol_w, op->o_name, args, n);
  778. X        else
  779. X            w = XmCreatePushButton (hdrcol_w, "DRow", args, n);
  780. X        row[r].lw = w;
  781. X
  782. X        }
  783. X
  784. X    /* remaining columns.
  785. X     * don't manage any but set names of what we can now too.
  786. X     */
  787. X    for (c = 0; c < NC; c++) {
  788. X        Widget rcw;
  789. X
  790. X        n = 0;
  791. X        XtSetArg (args[n], XmNadjustMargin, False); n++;
  792. X        XtSetArg (args[n], XmNisAligned, False); n++;
  793. X        rcw = col[c].rcw = XmCreateRowColumn (parent, "DataCol", args, n);
  794. X
  795. X        /* first row is column header */
  796. X        n = 0;
  797. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  798. X        if (col[c].type != SEP_COL)
  799. X        w = XmCreatePushButton (rcw, col[c].name, args, n);
  800. X        else {
  801. X        Obj *op = db_basic (col[c].dbidx);
  802. X        if (op->type != UNDEFOBJ)
  803. X            w = XmCreatePushButton (rcw, op->o_name, args, n);
  804. X        else
  805. X            w = XmCreatePushButton (rcw, "DCHdr", args, n);
  806. X        }
  807. X        col[c].lw = w;
  808. X        XtManageChild (w);
  809. X
  810. X        /* remaining rows are per object */
  811. X        for (r = 0; r < NR; r++) {
  812. X        n = 0;
  813. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  814. X        w = t_w[r][c] = XmCreatePushButton (rcw, "DataPB", args, n);
  815. X        XtAddCallback(w, XmNactivateCallback, dm_activate_cb,
  816. X                    (XtPointer)((c<<8)|r));
  817. X        }
  818. X    }
  819. X}
  820. X
  821. X/* callback from any of the data menu buttons being activated.
  822. X * do nothing unless we are being used to set up a selection collection.
  823. X * if the latter, make a name for our field, put it in UserData and inform
  824. X * all interested parties.
  825. X * to form the name, client data is (col<<8)|row
  826. X * N.B. we assume we can't be called if our row and column are not on.
  827. X */
  828. Xstatic void
  829. X/* ARGSUSED */
  830. Xdm_activate_cb (w, client, call)
  831. XWidget w;
  832. XXtPointer client;
  833. XXtPointer call;
  834. X{
  835. X    static char me[] = "dm_activate_cb()";
  836. X
  837. X    if (dm_selecting) {
  838. X        int r = (unsigned)client & 0xff;
  839. X        int c = (unsigned)client >> 8;
  840. X        char *name, *rname, *cname;
  841. X        Obj *op;
  842. X        char *userD;   /* Heller, pg 852, say's this is type Pointer?? */
  843. X        int len;
  844. X
  845. X        /* figure out our row name */
  846. X        if (!row[r].on) {
  847. X        printf ("Bug: %s: row[%d] not on\n", me, r);
  848. X        exit (1);
  849. X        }
  850. X        op = db_basic (row[r].dbidx);
  851. X        rname = op->o_name;
  852. X        len = strlen (rname);
  853. X
  854. X        /* figure out our col name */
  855. X        if (!col[c].on) {
  856. X        printf ("Bug: %s: col[%d] not on\n", me, c);
  857. X        exit (1);
  858. X        }
  859. X        if (col[c].type == SEP_COL) {
  860. X        op = db_basic (col[c].dbidx);
  861. X        cname = op->o_name;
  862. X        } else
  863. X        cname = col[c].name;
  864. X        len += strlen(cname);
  865. X
  866. X        name = XtMalloc (len + 2);    /* '.' plus '\0' */
  867. X        (void) sprintf (name, "%s.%s", rname, cname);
  868. X
  869. X        /* set XmNuserData to be the name we want to go by */
  870. X        get_something (w, XmNuserData, (char *)&userD);
  871. X        if (userD)
  872. X        XtFree (userD);
  873. X        userD = name;
  874. X        set_something (w, XmNuserData, userD);
  875. X
  876. X        /* tell the world our name */
  877. X        register_selection (name);
  878. X    }
  879. X}
  880. X
  881. X/* callback from the Data table Close button
  882. X */
  883. Xstatic void
  884. X/* ARGSUSED */
  885. Xdm_close_cb (w, client, call)
  886. XWidget w;
  887. XXtPointer client;
  888. XXtPointer call;
  889. X{
  890. X    XtUnmanageChild (dataform_w);
  891. X    if (XtIsManaged (sel_w))
  892. X        XtUnmanageChild (sel_w);
  893. X}
  894. X
  895. X/* callback from the Data table Setup button.
  896. X */
  897. Xstatic void
  898. X/* ARGSUSED */
  899. Xdm_setup_cb (w, client, call)
  900. XWidget w;
  901. XXtPointer client;
  902. XXtPointer call;
  903. X{
  904. X    if (XtIsManaged(sel_w))
  905. X        XtUnmanageChild (sel_w);
  906. X    else {
  907. X        ds_setup_row_selections();
  908. X        ds_setup_col_selections(MISC_COL);
  909. X        ds_setup_col_selections(RISET_COL);
  910. X        ds_setup_col_selections(SEP_COL);
  911. X        XtManageChild (sel_w);
  912. X    }
  913. X}
  914. X
  915. X/* callback from the Data table Help button
  916. X */
  917. Xstatic void
  918. X/* ARGSUSED */
  919. Xdm_help_cb (w, client, call)
  920. XWidget w;
  921. XXtPointer client;
  922. XXtPointer call;
  923. X{
  924. X    static char *msg[] = {
  925. X"This table displays various information about the planets and objects.",
  926. X"To reduce computation and save screen space, each row and column may be",
  927. X"individually turned off or on using the Select button."
  928. X};
  929. X
  930. X    hlp_dialog ("Data Table", msg, XtNumber(msg));
  931. X}
  932. X
  933. X/* compute and print body info in data menu format */
  934. X/* ARGSUSED */
  935. Xstatic void
  936. Xdm_compute (r, force, np)
  937. Xint r;        /* which row */
  938. Xint force;    /* whether to print for sure or only if things have changed */
  939. XNow *np;
  940. X{
  941. X    RiseSet rs;
  942. X    Obj *op;
  943. X    int c;
  944. X    int did_rs = 0;
  945. X
  946. X    op = db_basic (row[r].dbidx);
  947. X    db_update (op);
  948. X
  949. X    for (c = 0; c < NC; c++)
  950. X        if (col[c].on) {
  951. X        if (col[c].type == RISET_COL && !did_rs) {
  952. X            double dis = 0;    /* rads apparent horizon is from true */
  953. X            int close = is_planet(op,MOON) || is_planet(op,SUN); 
  954. X
  955. X            /* refraction correction */
  956. X            if (horizon == STDREFR) {
  957. X            /* `nominal' atmospheric refraction. */
  958. X            dis += STDREF;
  959. X            } else {
  960. X            /* `Adaptive:' actual refraction conditions  */
  961. X            double ref;
  962. X            unrefract (pressure, temp, 0.0, &ref);
  963. X            dis -= ref;    /* downwards */
  964. X            }
  965. X
  966. X            /* add object's semi-diameter if want upper limb.
  967. X             * only worth it for SUN and MOON.
  968. X             */
  969. X            if (limb == LIMB && close)
  970. X            dis += degrad((double)op->s_size/3600./2.0);
  971. X
  972. X            /* add effect of being above surface
  973. X             * TODO: this works but refraction model breaks down.
  974. X            dis += asin (sqrt(surfalt*surfalt + 2.0*ERAD*surfalt)
  975. X                  /(ERAD + surfalt));
  976. X             */
  977. X            
  978. X            riset_cir (np, op, dis, &rs);
  979. X            did_rs = 1;
  980. X        }
  981. X        dm_format(np, op, &rs, c, t_w[r][c]);
  982. X        }
  983. X}
  984. X
  985. Xstatic void
  986. Xdm_format (np, op, rp, c, w)
  987. XNow *np;
  988. XObj *op;
  989. XRiseSet *rp;
  990. Xint c;
  991. XWidget w;
  992. X{
  993. X    static char me[] = "dm_format()";
  994. X
  995. X    switch (c) {
  996. X    case CONSTEL_ID:
  997. X        show_constellation (np, op, w);
  998. X        break;
  999. X    case RA_ID:
  1000. X        f_ra (w, op->s_ra);
  1001. X        break;
  1002. X    case DEC_ID:
  1003. X        f_angle (w, op->s_dec);
  1004. X        break;
  1005. X    case AZ_ID:
  1006. X        f_angle (w, op->s_az);
  1007. X        break;
  1008. X    case ALT_ID:
  1009. X        f_angle (w, op->s_alt);
  1010. X        break;
  1011. X    case HLONG_ID:
  1012. X        if (is_ssobj(op))
  1013. X        f_angle (w, op->s_hlong);
  1014. X        else
  1015. X        f_string (w, " ");
  1016. X        break;
  1017. X    case HLAT_ID:
  1018. X        if (is_ssobj(op))
  1019. X        f_angle (w, op->s_hlat);
  1020. X        else
  1021. X        f_string (w, " ");
  1022. X        break;
  1023. X    case EDST_ID:
  1024. X        if (is_planet(op, MOON)) {
  1025. X        double tmp = op->s_edist;
  1026. X        if (pref_get(PREF_UNITS) == PREF_ENGLISH) {
  1027. X            /* s_edist is stored in km, show in miles */
  1028. X            tmp /= 1.609344;
  1029. X        }
  1030. X        f_double (w, "%6.0f", tmp);
  1031. X        } else if (is_ssobj(op)) {
  1032. X        /* show distance in au */
  1033. X        f_double (w, op->s_edist >= 9.99995 ? "%6.3f" : "%6.4f",
  1034. X                                op->s_edist);
  1035. X        } else
  1036. X        f_string (w, " ");
  1037. X        break;
  1038. X    case SDST_ID:
  1039. X        if (is_ssobj(op) && !is_planet(op, SUN))
  1040. X        f_double (w, op->s_sdist >= 9.99995 ? "%6.3f" : "%6.4f",
  1041. X                                op->s_sdist);
  1042. X        else
  1043. X        f_string (w, "      ");
  1044. X        break;
  1045. X    case ELONG_ID:
  1046. X        if (is_ssobj(op) && !is_planet(op, SUN))
  1047. X        f_double (w, "%6.1f", op->s_elong);
  1048. X        else
  1049. X        f_string (w, " ");
  1050. X        break;
  1051. X    case SIZE_ID:
  1052. X        f_double (w, "%4.0f", (double)(op->s_size));
  1053. X        break;
  1054. X    case VMAG_ID: {
  1055. X        double m = (double) (op->s_mag / MAGSCALE);
  1056. X        f_double (w, m <= -9.95 ? "%4.0f" : "%4.1f", m);
  1057. X    }
  1058. X        break;
  1059. X    case PHS_ID:
  1060. X        if (is_ssobj(op) && !is_planet(op, SUN))
  1061. X        f_double (w, "%3.0f", op->s_phase);
  1062. X        else
  1063. X        f_string (w, "   ");
  1064. X        break;
  1065. X
  1066. X    case RSTIME_ID:
  1067. X        if (rp->rs_flags & RS_ERROR)
  1068. X        f_string (w, "Error ");
  1069. X        else if (rp->rs_flags & RS_CIRCUMPOLAR)
  1070. X        f_string (w, "CirPol");
  1071. X        else if (rp->rs_flags & RS_NEVERUP)
  1072. X        f_string (w, "NvrUp ");
  1073. X        else if (rp->rs_flags & RS_NORISE)
  1074. X        f_string (w, "NoRise");
  1075. X        else {
  1076. X        f_mtime (w, rp->rs_risetm);    /* 5 chars wide */
  1077. X        dm_rs_addplus (w, rp->rs_flags & RS_2RISES);    /* adds 1 */
  1078. X        }
  1079. X        break;
  1080. X
  1081. X    case RSAZ_ID:
  1082. X        if (rp->rs_flags & RS_ERROR)
  1083. X        f_string (w, "Error ");
  1084. X        else if (rp->rs_flags & RS_CIRCUMPOLAR)
  1085. X        f_string (w, "CirPol");
  1086. X        else if (rp->rs_flags & RS_NEVERUP)
  1087. X        f_string (w, "NvrUp ");
  1088. X        else if (rp->rs_flags & RS_NORISE)
  1089. X        f_string (w, "NoRise");
  1090. X        else
  1091. X        f_angle (w, rp->rs_riseaz);    /* 6 chars wide */
  1092. X        break;
  1093. X
  1094. X    case SETTIME_ID:
  1095. X        if (rp->rs_flags & RS_ERROR)
  1096. X        f_string (w, "Error ");
  1097. X        else if (rp->rs_flags & RS_CIRCUMPOLAR)
  1098. X        f_string (w, "CirPol");
  1099. X        else if (rp->rs_flags & RS_NEVERUP)
  1100. X        f_string (w, "NvrUp ");
  1101. X        else if (rp->rs_flags & RS_NOSET)
  1102. X        f_string (w, "NoSet ");
  1103. X        else {
  1104. X        f_mtime (w, rp->rs_settm);    /* 5 chars wide */
  1105. X        dm_rs_addplus (w, rp->rs_flags & RS_2SETS);    /* adds 1 */
  1106. X        }
  1107. X        break;
  1108. X
  1109. X    case SETAZ_ID:
  1110. X        if (rp->rs_flags & RS_ERROR)
  1111. X        f_string (w, "Error ");
  1112. X        else if (rp->rs_flags & RS_CIRCUMPOLAR)
  1113. X        f_string (w, "CirPol");
  1114. X        else if (rp->rs_flags & RS_NEVERUP)
  1115. X        f_string (w, "NvrUp ");
  1116. X        else if (rp->rs_flags & RS_NOSET)
  1117. X        f_string (w, "NoSet ");
  1118. X        else
  1119. X        f_angle (w, rp->rs_setaz);    /* 6 chars wide */
  1120. X        break;
  1121. X
  1122. X    case TRTIME_ID:
  1123. X        if (rp->rs_flags & RS_ERROR)
  1124. X        f_string (w, "Error ");
  1125. X        else if (rp->rs_flags & RS_NEVERUP)
  1126. X        f_string (w, "NvrUp ");
  1127. X        else if (rp->rs_flags & RS_NOTRANS)
  1128. X        f_string (w, "NoTran");
  1129. X        else {
  1130. X        f_mtime (w, rp->rs_trantm);    /* 5 chars wide */
  1131. X        dm_rs_addplus (w, rp->rs_flags & RS_2TRANS);    /* adds 1 */
  1132. X        }
  1133. X        break;
  1134. X
  1135. X    case TRALT_ID:
  1136. X        if (rp->rs_flags & RS_ERROR)
  1137. X        f_string (w, "Error ");
  1138. X        else if (rp->rs_flags & RS_NEVERUP)
  1139. X        f_string (w, "NvrUp ");
  1140. X        else if (rp->rs_flags & RS_NOTRANS)
  1141. X        f_string (w, "NoTran");
  1142. X        else {
  1143. X        f_angle (w, rp->rs_tranalt);    /* 6 chars wide */
  1144. X        }
  1145. X        break;
  1146. X
  1147. X    case HRSUP_ID:
  1148. X        dm_rs_hrsup (w, rp);
  1149. X        break;
  1150. X
  1151. X    default:
  1152. X        /* these are effectively all the separation columns */
  1153. X        if (c < 0 || c >= NC) {
  1154. X        printf ("Bug: %s: c = %d but max = %d\n", me, c, NC-1);
  1155. X        exit (1);
  1156. X        }
  1157. X        if (col[c].type != SEP_COL) {
  1158. X        printf ("Bug: %s: col[%d].type = 0x%x\n", me, c, col[c].type);
  1159. X        exit (1);
  1160. X        }
  1161. X        if (op != db_basic(col[c].dbidx)) {
  1162. X        db_update(db_basic(col[c].dbidx));
  1163. X        dm_separation (op, db_basic(col[c].dbidx), centric, w);
  1164. X        } else
  1165. X        f_string (w, " ");
  1166. X        break;
  1167. X    }
  1168. X}
  1169. X
  1170. Xstatic void
  1171. Xdm_rs_addplus (w, addplus)
  1172. XWidget w;
  1173. Xint addplus;
  1174. X{
  1175. X    char *orig, *new;
  1176. X
  1177. X    get_xmstring (w, XmNlabelString, &orig);
  1178. X    new = XtMalloc(strlen(orig)+2); /* '+' plus the '\0' */
  1179. X    (void) sprintf (new, addplus ? "%s+" : "%s ", orig);
  1180. X    f_string (w, new);
  1181. X    XtFree (orig);
  1182. X    XtFree (new);
  1183. X}
  1184. X
  1185. X/* display the total hours this object has been up.
  1186. X * N.B. insure string length is always 6 chars wide.
  1187. X */
  1188. Xstatic void
  1189. Xdm_rs_hrsup (w, rp)
  1190. XWidget w;
  1191. XRiseSet *rp;
  1192. X{
  1193. X    double r, s, hrs;
  1194. X
  1195. X    if (rp->rs_flags & (RS_ERROR|RS_RISERR)) {
  1196. X        f_string (w, "Error ");
  1197. X        return;
  1198. X    }
  1199. X    if (rp->rs_flags & RS_CIRCUMPOLAR) {
  1200. X        f_double (w, "%3.0f:00", 24.0); /* f_mtime() changes to 00:00 */
  1201. X        return;
  1202. X    }
  1203. X    if (rp->rs_flags & RS_NEVERUP) {
  1204. X        f_mtime (w, 0.0);        /* 5 chars wide */
  1205. X        dm_rs_addplus(w, 0);    /* adds 1 */
  1206. X        return;
  1207. X    }
  1208. X
  1209. X    r = (rp->rs_flags & RS_NORISE) ?  0.0 : rp->rs_risetm;
  1210. X    s = (rp->rs_flags & RS_NOSET)  ? 24.0 : rp->rs_settm;
  1211. X    hrs = s - r;
  1212. X    if (hrs < 0)
  1213. X        hrs += 24.0;
  1214. X    f_mtime (w, hrs);    /* 5 chars wide */
  1215. X    dm_rs_addplus(w, rp->rs_flags&(RS_NORISE|RS_NOSET|RS_2RISES|RS_2SETS));
  1216. X}
  1217. X
  1218. Xstatic void
  1219. Xshow_constellation (np, op, w)
  1220. XNow *np;
  1221. XObj *op;
  1222. XWidget w;
  1223. X{
  1224. X    char nm[10], *name;
  1225. X
  1226. X        confnd (op->s_ra, op->s_dec, epoch == EOD ? mjd : epoch, &name);
  1227. X    (void) sprintf (nm, "%.3s", name);
  1228. X    f_string(w, nm);
  1229. X}
  1230. X
  1231. X/* compute and display the separation between the two sky locations */
  1232. Xstatic void
  1233. Xdm_separation (p, q, how, w)
  1234. XObj *p, *q;
  1235. Xint how;    /* GEO_CEN or TOPO_CEN */
  1236. XWidget w;
  1237. X{
  1238. X    double spy, cpy, px, qx, sqy, cqy;
  1239. X    double sep;
  1240. X
  1241. X    if (how == GEO_CEN) {
  1242. X        /* use ra for "x", dec for "y". */
  1243. X        spy = sin (p->s_dec);
  1244. X        cpy = cos (p->s_dec);
  1245. X        px = p->s_ra;
  1246. X        qx = q->s_ra;
  1247. X        sqy = sin (q->s_dec);
  1248. X        cqy = cos (q->s_dec);
  1249. X    } else {
  1250. X        /* use azimuth for "x", altitude for "y". */
  1251. X        spy = sin (p->s_alt);
  1252. X        cpy = cos (p->s_alt);
  1253. X        px = p->s_az;
  1254. X        qx = q->s_az;
  1255. X        sqy = sin (q->s_alt);
  1256. X        cqy = cos (q->s_alt);
  1257. X    }
  1258. X
  1259. X    sep = acos(spy*sqy + cpy*cqy*cos(px-qx));
  1260. X    f_angle (w, sep);
  1261. X}
  1262. X
  1263. X/* create the selections dialog */
  1264. Xstatic void
  1265. Xds_create_selection(parent)
  1266. XWidget parent;
  1267. X{
  1268. X    static char me[] = "ds_create_selection()";
  1269. X    static struct { /* info to streamline creation of control buttons */
  1270. X        int id;
  1271. X        int lpos, rpos;
  1272. X        char *name;
  1273. X    } ctlbtns[] = {
  1274. X        {OK, 1, 3, "Ok"},
  1275. X        {APPLY, 4, 6, "Apply"},
  1276. X        {CANCEL, 7, 9, "Close"},
  1277. X        {HELP, 10, 12, "Help"}
  1278. X    };
  1279. X    Arg args[20];
  1280. X    XmString str;
  1281. X    Widget rl_w, cl_w;
  1282. X    Widget rf_w, mf_w, rsf_w, sf_w, ctlf_w, rowrc_w, mrc_w, rsrc_w, src_w;
  1283. X    Widget sep_w, w, tb1, tb2;
  1284. X    Widget rb_w;
  1285. X    int n;
  1286. X    int i;
  1287. X
  1288. X    /* create form */
  1289. X    n = 0;
  1290. X    XtSetArg (args[n], XmNallowShellResize, True); n++;
  1291. X    XtSetArg (args[n], XmNautoUnmanage, False); n++;
  1292. X    XtSetArg (args[n], XmNdefaultPosition, False); n++;
  1293. X    XtSetArg (args[n], XmNallowOverlap, False); n++;
  1294. X    sel_w = XmCreateFormDialog (parent, "DataSelection", args, n);
  1295. X    XtAddCallback (sel_w, XmNmapCallback, prompt_map_cb, NULL);
  1296. X
  1297. X    /* set some stuff in the parent DialogShell.
  1298. X     * setting XmNdialogTitle in the Form didn't work..
  1299. X     */
  1300. X    n = 0;
  1301. X    XtSetArg (args[n], XmNtitle, "xephem Data Table setup"); n++;
  1302. X    XtSetValues (XtParent(sel_w), args, n);
  1303. X
  1304. X    /* make a form for bottom control panel */
  1305. X    n = 0;
  1306. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1307. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1308. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1309. X    XtSetArg (args[n], XmNfractionBase, 13); n++;
  1310. X    XtSetArg (args[n], XmNverticalSpacing, 5); n++;
  1311. X    ctlf_w = XmCreateForm (sel_w, "DataSelF", args, n);
  1312. X    XtManageChild (ctlf_w);
  1313. X
  1314. X        /* make the control buttons */
  1315. X
  1316. X        for (i = 0; i < XtNumber(ctlbtns); i++) {
  1317. X        n = 0;
  1318. X        XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1319. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1320. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  1321. X        XtSetArg (args[n], XmNleftPosition, ctlbtns[i].lpos); n++;
  1322. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  1323. X        XtSetArg (args[n], XmNrightPosition, ctlbtns[i].rpos); n++;
  1324. X        w = XmCreatePushButton (ctlf_w, ctlbtns[i].name, args, n);
  1325. X        XtAddCallback (w, XmNactivateCallback, ds_ctl_cb,
  1326. X                            (XtPointer)ctlbtns[i].id);
  1327. X        XtManageChild (w);
  1328. X        }
  1329. X
  1330. X    /* make a top separator */
  1331. X    n = 0;
  1332. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1333. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1334. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1335. X    sep_w = XmCreateSeparator (sel_w, "DSSep", args, n);
  1336. X    XtManageChild (sep_w);
  1337. X
  1338. X    /* make the Rows heading */
  1339. X
  1340. X    n = 0;
  1341. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1342. X    XtSetArg (args[n], XmNtopWidget, sep_w); n++;
  1343. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1344. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  1345. X    rl_w = XmCreateLabel (sel_w, "Rows:", args, n);
  1346. X    XtManageChild (rl_w);
  1347. X
  1348. X    /* make the row selection rc in a frame */
  1349. X
  1350. X    n = 0;
  1351. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1352. X    XtSetArg (args[n], XmNtopWidget, rl_w); n++;
  1353. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1354. X    XtSetArg (args[n], XmNbottomWidget, ctlf_w); n++;
  1355. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1356. X    rf_w = XmCreateFrame (sel_w, "DSRFrame", args, n);
  1357. X    XtManageChild (rf_w);
  1358. X
  1359. X    n = 0;
  1360. X    XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
  1361. X    XtSetArg (args[n], XmNadjustMargin, False); n++;
  1362. X    XtSetArg (args[n], XmNisAligned, False); n++;
  1363. X    XtSetArg (args[n], XmNpacking, XmPACK_TIGHT); n++;
  1364. X    rowrc_w = XmCreateRowColumn (rf_w, "DataSelRows", args, n);
  1365. X    XtManageChild (rowrc_w);
  1366. X
  1367. X        /* fill up with buttons for each possible row.
  1368. X         * fill in name if it's a planet since that won't change.
  1369. X         */
  1370. X
  1371. X        /* make the "Toggle" push button */
  1372. X
  1373. X        str = XmStringCreate("Toggle", XmSTRING_DEFAULT_CHARSET);
  1374. X        n = 0;
  1375. X        XtSetArg (args[n], XmNlabelString, str); n++;
  1376. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1377. X        w = XmCreatePushButton (rowrc_w, "DSRToggle", args, n);
  1378. X        XtAddCallback (w, XmNactivateCallback, ds_row_toggle_cb, 0);
  1379. X        XtManageChild (w);
  1380. X        XmStringFree (str);
  1381. X
  1382. X        /* make the "All" push button */
  1383. X
  1384. X        str = XmStringCreate("All", XmSTRING_DEFAULT_CHARSET);
  1385. X        n = 0;
  1386. X        XtSetArg (args[n], XmNlabelString, str); n++;
  1387. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1388. X        w = XmCreatePushButton (rowrc_w, "DSRAll", args, n);
  1389. X        XtAddCallback (w, XmNactivateCallback, ds_row_all_cb, 0);
  1390. X        XtManageChild (w);
  1391. X        XmStringFree (str);
  1392. X
  1393. X        /* make the "Reset" push button */
  1394. X
  1395. X        str = XmStringCreate("Reset", XmSTRING_DEFAULT_CHARSET);
  1396. X        n = 0;
  1397. X        XtSetArg (args[n], XmNlabelString, str); n++;
  1398. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1399. X        w = XmCreatePushButton (rowrc_w, "DSRReset", args, n);
  1400. X        XtAddCallback (w, XmNactivateCallback, ds_row_reset_cb, 0);
  1401. X        XtManageChild (w);
  1402. X        XmStringFree (str);
  1403. X
  1404. X        for (i = 0; i < NR; i++) {
  1405. X        Obj *op = db_basic(row[i].dbidx);
  1406. X        n = 0;
  1407. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  1408. X        if (op->type != UNDEFOBJ) {
  1409. X            w = row[i].sw = XmCreateToggleButton(rowrc_w, op->o_name,
  1410. X                                    args, n);
  1411. X            XtManageChild (w);
  1412. X        } else
  1413. X            row[i].sw = XmCreateToggleButton(rowrc_w, "RowSelObj",
  1414. X                                    args, n);
  1415. X        }
  1416. X
  1417. X    /* make the Columns heading */
  1418. X
  1419. X    n = 0;
  1420. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1421. X    XtSetArg (args[n], XmNtopWidget, sep_w); n++;
  1422. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1423. X    XtSetArg (args[n], XmNleftWidget, rf_w); n++;
  1424. X    XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  1425. X    cl_w = XmCreateLabel (sel_w, "Columns:", args, n);
  1426. X    XtManageChild (cl_w);
  1427. X
  1428. X    /* make the misc col selection rc in a frame */
  1429. X
  1430. X    n = 0;
  1431. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1432. X    XtSetArg (args[n], XmNtopWidget, cl_w); n++;
  1433. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1434. X    XtSetArg (args[n], XmNbottomWidget, ctlf_w); n++;
  1435. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1436. X    XtSetArg (args[n], XmNleftWidget, rf_w); n++;
  1437. X    mf_w = XmCreateFrame (sel_w, "DSMCFrame", args, n);
  1438. X    XtManageChild (mf_w);
  1439. X
  1440. X    n = 0;
  1441. X    XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
  1442. X    XtSetArg (args[n], XmNadjustMargin, False); n++;
  1443. X    XtSetArg (args[n], XmNisAligned, False); n++;
  1444. X    XtSetArg (args[n], XmNpacking, XmPACK_TIGHT); n++;
  1445. X    mrc_w = XmCreateRowColumn (mf_w, "DataSelMiscCols", args, n);
  1446. X    XtManageChild (mrc_w);
  1447. X
  1448. X        /* fill up with buttons for each possible col in misc range.
  1449. X         * set those columns names that are stable.
  1450. X         */
  1451. X
  1452. X        /* make the "Toggle" push button */
  1453. X
  1454. X        n = 0;
  1455. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1456. X        w = XmCreatePushButton (mrc_w, "Toggle", args, n);
  1457. X        XtAddCallback (w, XmNactivateCallback, ds_col_toggle_cb,
  1458. X                            (XtPointer)MISC_COL);
  1459. X        XtManageChild (w);
  1460. X
  1461. X        /* make the "All" push button */
  1462. X
  1463. X        n = 0;
  1464. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1465. X        w = XmCreatePushButton (mrc_w, "All", args, n);
  1466. X        XtAddCallback (w, XmNactivateCallback, ds_col_all_cb,
  1467. X                            (XtPointer)MISC_COL);
  1468. X        XtManageChild (w);
  1469. X
  1470. X        /* make the "Reset" push button */
  1471. X
  1472. X        n = 0;
  1473. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1474. X        w = XmCreatePushButton (mrc_w, "Reset", args, n);
  1475. X        XtAddCallback (w, XmNactivateCallback, ds_col_reset_cb,
  1476. X                            (XtPointer)MISC_COL);
  1477. X        XtManageChild (w);
  1478. X
  1479. X    /* make the rise/set col selection rc in a frame */
  1480. X
  1481. X    n = 0;
  1482. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1483. X    XtSetArg (args[n], XmNtopWidget, cl_w); n++;
  1484. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1485. X    XtSetArg (args[n], XmNbottomWidget, ctlf_w); n++;
  1486. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1487. X    XtSetArg (args[n], XmNleftWidget, mf_w); n++;
  1488. X    rsf_w = XmCreateFrame (sel_w, "DSRCFrame", args, n);
  1489. X    XtManageChild (rsf_w);
  1490. X
  1491. X    n = 0;
  1492. X    XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
  1493. X    XtSetArg (args[n], XmNadjustMargin, False); n++;
  1494. X    XtSetArg (args[n], XmNisAligned, False); n++;
  1495. X    XtSetArg (args[n], XmNpacking, XmPACK_TIGHT); n++;
  1496. X    rsrc_w = XmCreateRowColumn (rsf_w, "DataSelRisetCols", args, n);
  1497. X    XtManageChild (rsrc_w);
  1498. X
  1499. X        /* fill up with buttons for each possible col in rise/set range.
  1500. X         * set those columns names that are stable.
  1501. X         */
  1502. X
  1503. X        /* make the "Toggle" push button */
  1504. X
  1505. X        n = 0;
  1506. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1507. X        w = XmCreatePushButton (rsrc_w, "Toggle", args, n);
  1508. X        XtAddCallback (w, XmNactivateCallback, ds_col_toggle_cb,
  1509. X                            (XtPointer)RISET_COL);
  1510. X        XtManageChild (w);
  1511. X
  1512. X        /* make the "All" push button */
  1513. X
  1514. X        n = 0;
  1515. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1516. X        w = XmCreatePushButton (rsrc_w, "All", args, n);
  1517. X        XtAddCallback (w, XmNactivateCallback, ds_col_all_cb,
  1518. X                            (XtPointer)RISET_COL);
  1519. X        XtManageChild (w);
  1520. X
  1521. X        /* make the "Reset" push button */
  1522. X
  1523. X        n = 0;
  1524. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1525. X        w = XmCreatePushButton (rsrc_w, "Reset", args, n);
  1526. X        XtAddCallback (w, XmNactivateCallback, ds_col_reset_cb,
  1527. X                            (XtPointer)RISET_COL);
  1528. X        XtManageChild (w);
  1529. X
  1530. X        /* make the STDREFR/ADPREFR radio box */
  1531. X
  1532. X        n = 0;
  1533. X        w = XmCreateFrame (rsrc_w, "DSRefrF", args, n);
  1534. X        XtManageChild (w);
  1535. X        n = 0;
  1536. X        rb_w = XmCreateRadioBox (w, "DSRefrRB", args, n);
  1537. X        XtManageChild (rb_w);
  1538. X
  1539. X        n = 0;
  1540. X        stdrefr_w = tb1 = XmCreateToggleButton (rb_w, "StdRefr",args,n);
  1541. X        XtManageChild (tb1);
  1542. X        n = 0;
  1543. X        tb2 = XmCreateToggleButton (rb_w, "AdpRefr", args, n);
  1544. X        XtManageChild (tb2);
  1545. X        /* if neither or both is set up in defaults, set for StdRefr */
  1546. X        if (XmToggleButtonGetState(tb1) == XmToggleButtonGetState(tb2)){
  1547. X            xe_msg (
  1548. X             "Conflicting Refraction resources -- defaulting to StdRefr\n",
  1549. X                                        0);
  1550. X            XmToggleButtonSetState (tb1, True, True);
  1551. X        }
  1552. X
  1553. X        /* make the CENTER/LIMB radio box */
  1554. X
  1555. X        n = 0;
  1556. X        w = XmCreateFrame (rsrc_w, "DSLimbF", args, n);
  1557. X        XtManageChild (w);
  1558. X        n = 0;
  1559. X        rb_w = XmCreateRadioBox (w, "DSLimbRB", args, n);
  1560. X        XtManageChild (rb_w);
  1561. X
  1562. X        n = 0;
  1563. X        limb_w = tb1 = XmCreateToggleButton (rb_w, "Limb", args, n);
  1564. X        XtManageChild (tb1);
  1565. X        n = 0;
  1566. X        tb2 = XmCreateToggleButton (rb_w, "Center", args, n);
  1567. X        XtManageChild (tb2);
  1568. X        /* if neither or both is set up in defaults, set for Limb */
  1569. X        if (XmToggleButtonGetState(tb1) == XmToggleButtonGetState(tb2)){
  1570. X            xe_msg (
  1571. X              "Conflicting Limb resources -- defaulting to Limb\n",
  1572. X                                        0);
  1573. X            XmToggleButtonSetState (tb1, True, True);
  1574. X        }
  1575. X
  1576. X    /* make the separations col selection rc in a frame */
  1577. X
  1578. X    n = 0;
  1579. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  1580. X    XtSetArg (args[n], XmNtopWidget, cl_w); n++;
  1581. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  1582. X    XtSetArg (args[n], XmNbottomWidget, ctlf_w); n++;
  1583. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1584. X    XtSetArg (args[n], XmNleftWidget, rsf_w); n++;
  1585. X    sf_w = XmCreateFrame (sel_w, "DSRCFrame", args, n);
  1586. X    XtManageChild (sf_w);
  1587. X
  1588. X    n = 0;
  1589. X    XtSetArg (args[n], XmNorientation, XmVERTICAL); n++;
  1590. X    XtSetArg (args[n], XmNadjustMargin, False); n++;
  1591. X    XtSetArg (args[n], XmNisAligned, False); n++;
  1592. X    XtSetArg (args[n], XmNpacking, XmPACK_TIGHT); n++;
  1593. X    src_w = XmCreateRowColumn (sf_w, "DataSelSepCols", args, n);
  1594. X    XtManageChild (src_w);
  1595. X
  1596. X        /* fill up with buttons for each possible col in sep range.
  1597. X         * set those columns names that are stable.
  1598. X         */
  1599. X
  1600. X        /* make the "Toggle" push button */
  1601. X
  1602. X        n = 0;
  1603. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1604. X        w = XmCreatePushButton (src_w, "Toggle", args, n);
  1605. X        XtAddCallback (w, XmNactivateCallback, ds_col_toggle_cb,
  1606. X                            (XtPointer)SEP_COL);
  1607. X        XtManageChild (w);
  1608. X
  1609. X        /* make the "All" push button */
  1610. X
  1611. X        n = 0;
  1612. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1613. X        w = XmCreatePushButton (src_w, "All", args, n);
  1614. X        XtAddCallback (w, XmNactivateCallback, ds_col_all_cb,
  1615. X                            (XtPointer)SEP_COL);
  1616. X        XtManageChild (w);
  1617. X
  1618. X        /* make the "Reset" push button */
  1619. X
  1620. X        n = 0;
  1621. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_CENTER); n++;
  1622. X        w = XmCreatePushButton (src_w, "Reset", args, n);
  1623. X        XtAddCallback (w, XmNactivateCallback, ds_col_reset_cb,
  1624. X                            (XtPointer)SEP_COL);
  1625. X        XtManageChild (w);
  1626. X
  1627. X        /* make the GEOCENTRIC/TOPOCENTRIC radio box */
  1628. X
  1629. X        n = 0;
  1630. X        w = XmCreateFrame (src_w, "DSCentricF", args, n);
  1631. X        XtManageChild (w);
  1632. X        n = 0;
  1633. X        rb_w = XmCreateRadioBox (w, "DSCentricRB", args, n);
  1634. X        XtManageChild (rb_w);
  1635. X
  1636. X        n = 0;
  1637. X        geocen_w = tb1 = XmCreateToggleButton (rb_w, "Geocentric",
  1638. X                                    args, n);
  1639. X        XtManageChild (tb1);
  1640. X        n = 0;
  1641. X        tb2 = XmCreateToggleButton (rb_w, "Topocentric", args, n);
  1642. X        XtManageChild (tb2);
  1643. X        /* if neither or both is set up in defaults, set for geocntrc */
  1644. X        if (XmToggleButtonGetState(tb1) == XmToggleButtonGetState(tb2)){
  1645. X            xe_msg ("conflicting Centric resources -- defaulting to Geocentric\n", 0);
  1646. X            XmToggleButtonSetState (tb1, True, True);
  1647. X        }
  1648. X
  1649. X    /* now fill in the column entries */
  1650. X    for (i = 0; i < NC; i++) {
  1651. X        n = 0;
  1652. X        XtSetArg (args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  1653. X        switch (col[i].type) {
  1654. X        case MISC_COL:
  1655. X        /* one of the misc columns */
  1656. X        w = col[i].sw = XmCreateToggleButton(mrc_w, col[i].name,args,n);
  1657. X        XtManageChild (w);
  1658. X        break;
  1659. X        case RISET_COL:
  1660. X        /* one of the rise/set columns */
  1661. X        w = col[i].sw = XmCreateToggleButton(rsrc_w,col[i].name,args,n);
  1662. X        XtManageChild (w);
  1663. X        break;
  1664. X        case SEP_COL: {
  1665. X        /* one of the separation columns */
  1666. X        Obj *op = db_basic (col[i].dbidx);
  1667. X        if (op->type != UNDEFOBJ) {
  1668. X            w = col[i].sw = XmCreateToggleButton(src_w,op->o_name,args,n);
  1669. X            XtManageChild (w);
  1670. X        } else
  1671. X            col[i].sw = XmCreateToggleButton(src_w, "ColSelObj",args,n);
  1672. X        break;
  1673. X        }
  1674. X        default:
  1675. X        printf ("Bug: %s: col[%d].type = 0x%x\n", me, i, col[i].type);
  1676. X        exit (1);
  1677. X        break;
  1678. X        }
  1679. X    }
  1680. X}
  1681. X
  1682. X/* set up the Data selection row menu based on what is currently on and defined.
  1683. X */
  1684. Xstatic void
  1685. Xds_setup_row_selections()
  1686. X{
  1687. X    int i;
  1688. X
  1689. X    for (i = 0; i < NR; i++) {
  1690. X        Widget sw = row[i].sw;
  1691. X        Obj *op = db_basic (row[i].dbidx);
  1692. X        if (op->type == UNDEFOBJ)
  1693. X        XtUnmanageChild (sw);
  1694. X        else 
  1695. X        XtManageChild (sw);
  1696. X        XmToggleButtonSetState (sw, row[i].on, False);
  1697. X    }
  1698. X}
  1699. X
  1700. X/* set up a Data selection col menu based on what is currently on and defined.
  1701. X */
  1702. Xstatic void
  1703. Xds_setup_col_selections(what)
  1704. Xint what;
  1705. X{
  1706. X    int i;
  1707. X
  1708. X    for (i = 0; i < NC; i++) {
  1709. X        if (col[i].type == what) {
  1710. X        Widget sw = col[i].sw;
  1711. X        if (col[i].type == SEP_COL) {
  1712. X            Obj *op = db_basic (col[i].dbidx);
  1713. X            if (op->type == UNDEFOBJ)
  1714. X            XtUnmanageChild (sw);
  1715. X            else 
  1716. X            XtManageChild (sw);
  1717. X        }
  1718. X        XmToggleButtonSetState (sw, col[i].on, False);
  1719. X        }
  1720. X    }
  1721. X
  1722. X    switch (what) {
  1723. X    case RISET_COL:
  1724. X        XmToggleButtonSetState (stdrefr_w, horizon == STDREFR, True);
  1725. X        XmToggleButtonSetState (limb_w, limb == LIMB, True);
  1726. X        break;
  1727. X    case SEP_COL:
  1728. X        XmToggleButtonSetState (geocen_w, centric == GEO_CEN, True);
  1729. X        break;
  1730. X    }
  1731. X}
  1732. X
  1733. X
  1734. X/* change the Data table according to what is now defined and set up in the
  1735. X * Selection menu.
  1736. X * N.B. can be called before we are managed.
  1737. X */
  1738. Xstatic void
  1739. Xds_apply_selections()
  1740. X{
  1741. X    int i, c;
  1742. X    int n_riset, n_sep;
  1743. X    int wasman;
  1744. X
  1745. X    watch_cursor(1);
  1746. X
  1747. X    if (wasman = XtIsManaged(dataform_w))
  1748. X        XtUnmanageChild (dataform_w);
  1749. X
  1750. X    for (i = 0; i < NR; i++) {
  1751. X        int wantset = XmToggleButtonGetState(row[i].sw);
  1752. X        if (wantset != row[i].on) {
  1753. X        if (wantset) {
  1754. X            for (c = 0; c < NC; c++)
  1755. X            XtManageChild (t_w[i][c]);
  1756. X            XtManageChild (row[i].lw);
  1757. X        } else {
  1758. X            for (c = 0; c < NC; c++)
  1759. X            XtUnmanageChild (t_w[i][c]);
  1760. X            XtUnmanageChild (row[i].lw);
  1761. X        }
  1762. X        row[i].on = wantset;
  1763. X        }
  1764. X    }
  1765. X
  1766. X    n_riset = n_sep = 0;
  1767. X    for (i = 0; i < NC; i++) {
  1768. X        int wantset = XmToggleButtonGetState(col[i].sw);
  1769. X        if (wantset != col[i].on) {
  1770. X        if (wantset)
  1771. X            XtManageChild (col[i].rcw);
  1772. X        else
  1773. X            XtUnmanageChild (col[i].rcw);
  1774. X        col[i].on = wantset;
  1775. X        }
  1776. X        if (col[i].type == RISET_COL && col[i].on)
  1777. X        n_riset++;
  1778. X        if (col[i].type == SEP_COL && col[i].on)
  1779. X        n_sep++;
  1780. X    }
  1781. X
  1782. X    horizon = XmToggleButtonGetState (stdrefr_w) ? STDREFR : ADPREFR;
  1783. X    limb = XmToggleButtonGetState (limb_w) ? LIMB : CENTER;
  1784. X    if (n_riset) {
  1785. X        f_showit (refr_w, horizon==STDREFR ? "StdRefr" : "AdpRefr");
  1786. X        XtManageChild (XtParent(refr_w));
  1787. X        f_showit (limbl_w, limb==LIMB ? "UpLimb" : "Center");
  1788. X        XtManageChild (XtParent(limbl_w));
  1789. X    } else {
  1790. X        XtUnmanageChild (XtParent(refr_w));
  1791. X        XtUnmanageChild (XtParent(limbl_w));
  1792. X    }
  1793. X
  1794. X    centric = XmToggleButtonGetState (geocen_w) ? GEO_CEN : TOPO_CEN;
  1795. X    if (n_sep) {
  1796. X        f_string (centric_w,
  1797. X            centric==GEO_CEN ? "GeoSeps" : "TopoSeps");
  1798. X        XtManageChild (XtParent(centric_w));
  1799. X    } else
  1800. X        XtUnmanageChild (XtParent(centric_w));
  1801. X
  1802. X    if (wasman)
  1803. X        XtManageChild (dataform_w);
  1804. X
  1805. X    watch_cursor(0);
  1806. X}
  1807. X
  1808. X/* callback from any of the Data selection control panel buttons.
  1809. X * which is in client.
  1810. X */
  1811. Xstatic void
  1812. X/* ARGSUSED */
  1813. Xds_ctl_cb (w, client, call)
  1814. XWidget w;
  1815. XXtPointer client;
  1816. XXtPointer call;
  1817. X{
  1818. X    int id = (int) client;
  1819. X
  1820. X    switch (id) {
  1821. X    case OK:
  1822. X        ds_apply_selections();
  1823. X        dm_update (mm_get_now(), 1);
  1824. X        XtUnmanageChild (sel_w);
  1825. X        break;
  1826. X    case APPLY:
  1827. X        ds_apply_selections();
  1828. X        dm_update (mm_get_now(), 1);
  1829. X        break;
  1830. X    case CANCEL:
  1831. X        XtUnmanageChild (sel_w);
  1832. X        break;
  1833. X    case HELP:
  1834. X        ds_help();
  1835. X        break;
  1836. X    }
  1837. X}
  1838. X
  1839. X/* called from the Data selection table Help button
  1840. X */
  1841. Xstatic void
  1842. Xds_help ()
  1843. X{
  1844. X    static char *msg[] = {
  1845. X"This table lets you configure the rows and columns of the data table."
  1846. X};
  1847. X
  1848. X    hlp_dialog ("DataSelection Table", msg, XtNumber(msg));
  1849. X}
  1850. X
  1851. X/* callback from the Data selection row toggle button.
  1852. X */
  1853. Xstatic void
  1854. X/* ARGSUSED */
  1855. Xds_row_toggle_cb (w, client, call)
  1856. XWidget w;
  1857. XXtPointer client;
  1858. XXtPointer call;
  1859. X{
  1860. X    int i;
  1861. X
  1862. X    for (i = 0; i < NR; i++) {
  1863. X        Widget sw = row[i].sw;
  1864. X        if (XtIsManaged(sw))
  1865. X        XmToggleButtonSetState (sw,
  1866. X            !XmToggleButtonGetState(sw), False);
  1867. X    }
  1868. X}
  1869. X
  1870. X/* callback from any of the Data selection col toggle button.
  1871. X */
  1872. Xstatic void
  1873. X/* ARGSUSED */
  1874. Xds_col_toggle_cb (w, client, call)
  1875. XWidget w;
  1876. XXtPointer client;
  1877. XXtPointer call;
  1878. X{
  1879. X    int what = (int)client;
  1880. X    int i;
  1881. X
  1882. X    for (i = 0; i < NC; i++)
  1883. X        if (col[i].type == what) {
  1884. X        Widget sw = col[i].sw;
  1885. X        if (XtIsManaged(sw))
  1886. X            XmToggleButtonSetState (sw,
  1887. X            !XmToggleButtonGetState(sw), False);
  1888. X        }
  1889. X}
  1890. X
  1891. X/* callback from the Data selection row all toggle button.
  1892. X */
  1893. Xstatic void
  1894. X/* ARGSUSED */
  1895. Xds_row_all_cb (w, client, call)
  1896. XWidget w;
  1897. XXtPointer client;
  1898. XXtPointer call;
  1899. X{
  1900. X    int i;
  1901. X
  1902. X    for (i = 0; i < NR; i++) {
  1903. X        Widget sw = row[i].sw;
  1904. X        if (XtIsManaged(sw) && !XmToggleButtonGetState (sw))
  1905. X        XmToggleButtonSetState(sw, True, False);
  1906. X    }
  1907. X}
  1908. X
  1909. X/* callback from any of the Data selection col all toggle buttons.
  1910. X */
  1911. Xstatic void
  1912. X/* ARGSUSED */
  1913. Xds_col_all_cb (w, client, call)
  1914. XWidget w;
  1915. XXtPointer client;
  1916. XXtPointer call;
  1917. X{
  1918. X    int what = (int)client;
  1919. X    int i;
  1920. X
  1921. X    for (i = 0; i < NC; i++)
  1922. X        if (col[i].type == what) {
  1923. X            Widget sw = col[i].sw;
  1924. X        if (XtIsManaged(sw) && !XmToggleButtonGetState (sw))
  1925. X            XmToggleButtonSetState(sw, True, False);
  1926. X        }
  1927. X}
  1928. X
  1929. X/* callback from the Data selection row reset button.
  1930. X */
  1931. Xstatic void
  1932. X/* ARGSUSED */
  1933. Xds_row_reset_cb (w, client, call)
  1934. XWidget w;
  1935. XXtPointer client;
  1936. XXtPointer call;
  1937. X{
  1938. X    ds_setup_row_selections();
  1939. X}
  1940. X
  1941. X/* callback from any of the Data selection col reset buttons.
  1942. X */
  1943. X/* ARGSUSED */
  1944. Xstatic void
  1945. Xds_col_reset_cb (w, client, call)
  1946. XWidget w;
  1947. XXtPointer client;
  1948. XXtPointer call;
  1949. X{
  1950. X    ds_setup_col_selections((int)client);
  1951. X}
  1952. END_OF_FILE
  1953.   if test 47722 -ne `wc -c <'datamenu.c'`; then
  1954.     echo shar: \"'datamenu.c'\" unpacked with wrong size!
  1955.   fi
  1956.   # end of 'datamenu.c'
  1957. fi
  1958. if test -f 'xephem.c' -a "${1}" != "-c" ; then 
  1959.   echo shar: Will not clobber existing file \"'xephem.c'\"
  1960. else
  1961.   echo shar: Extracting \"'xephem.c'\" \(20922 characters\)
  1962.   sed "s/^X//" >'xephem.c' <<'END_OF_FILE'
  1963. X/* main() for xephem.
  1964. X * Copyright (c) 1990,1991,1992,1993 by Elwood Charles Downey
  1965. X * Permission is granted to make and distribute copies of this program free of
  1966. X * charge, provided the copyright notice and this permission notice are
  1967. X * preserved on all copies.  All other rights reserved.  No representation is
  1968. X * made about the suitability of this software for any purpose.  It is provided
  1969. X * "as is" without express or implied warranty, to the extent permitted by
  1970. X * applicable law.
  1971. X */
  1972. X
  1973. X#include <stdio.h>
  1974. X#include <signal.h>
  1975. X#if defined(__STDC__)
  1976. X#include <stdlib.h>
  1977. X#endif
  1978. X
  1979. X#include <X11/Xlib.h>
  1980. X#include <X11/IntrinsicP.h> /* for XT_REVISION */
  1981. X
  1982. X/* define WANT_EDITRES if want to try and support X11R5's EditRes feature.
  1983. X * this will require linking with -lXmu and -lXext too.
  1984. X */
  1985. X#if defined(WANT_EDITRES) && (XT_REVISION >= 5)
  1986. X#define    DO_EDITRES
  1987. X#endif
  1988. X
  1989. X#ifdef DO_EDITRES
  1990. X#include <X11/Xmu/Editres.h>
  1991. X#endif
  1992. X
  1993. X#include <Xm/Xm.h>
  1994. X#include <X11/Shell.h>
  1995. X#include <Xm/PushB.h>
  1996. X#include <Xm/CascadeB.h>
  1997. X#include <Xm/Form.h>
  1998. X#include <Xm/Separator.h>
  1999. X#include <Xm/MainW.h>
  2000. X#include <Xm/RowColumn.h>
  2001. X#include <Xm/ToggleB.h>
  2002. X
  2003. X#if defined(__STDC__) || defined(__cplusplus)
  2004. X#define P_(s) s
  2005. X#else
  2006. X#define P_(s) ()
  2007. X#endif
  2008. X
  2009. Xextern void config_help P_((void));
  2010. Xextern void datetime_help P_((void));
  2011. Xextern void db_manage P_((void));
  2012. Xextern void dm_manage P_((void));
  2013. Xextern void e_manage P_((void));
  2014. Xextern void intro_help P_((void));
  2015. Xextern void jm_manage P_((void));
  2016. Xextern void lst_manage P_((void));
  2017. Xextern void m_manage P_((void));
  2018. Xextern void mainmenu_help P_((void));
  2019. Xextern void mars_manage P_((void));
  2020. Xextern void mm_manage P_((Widget main_window));
  2021. Xextern void mm_reset P_((void));
  2022. Xextern void msg_manage P_((void));
  2023. Xextern void notes_help P_((void));
  2024. Xextern void obj_manage P_((void));
  2025. Xextern void operation_help P_((void));
  2026. Xextern void plot_manage P_((void));
  2027. Xextern void pref_create_pulldown P_((Widget menu_bar));
  2028. Xextern void references_help P_((void));
  2029. Xextern void sm_manage P_((void));
  2030. Xextern void srch_manage P_((void));
  2031. Xextern void ss_manage P_((void));
  2032. Xextern void sv_manage P_((void));
  2033. Xextern void version P_((void));
  2034. Xextern void watch_cursor P_((int want));
  2035. Xextern void xe_msg P_((char *msg, int app_modal));
  2036. X
  2037. Xvoid main_cursor P_((Cursor c));
  2038. Xstatic void on_fpe P_((void));
  2039. Xstatic Widget make_main_window P_((void));
  2040. Xstatic void setup_window_properties P_((Widget w));
  2041. Xstatic void m_activate_cb P_((Widget w, XtPointer client, XtPointer call));
  2042. X
  2043. X#undef P_
  2044. X
  2045. X
  2046. X/* client arg to m_activate_cb().
  2047. X */
  2048. Xenum {
  2049. X    QUIT, XRESET, MSGTXT,
  2050. X    DATA, MOON, EARTH, MARS, JUPMOON, SATMOON, SKYVIEW, SOLARSYS,
  2051. X    PLOT, LIST, SEARCH,
  2052. X    OBJS,
  2053. X    DB,
  2054. X    VERSION, REFERENCES, INTRO, MAINMENU, CONFIGFILE, OPERATION, DATETIME, NOTES
  2055. X};
  2056. X
  2057. XWidget toplevel_w;
  2058. XXtAppContext xe_app;
  2059. Xchar *myclass = "XEphem";
  2060. X
  2061. X#define xephem_width 50
  2062. X#define xephem_height 50
  2063. Xstatic unsigned char xephem_bits[] = {
  2064. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2065. X   0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2066. X   0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
  2067. X   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
  2068. X   0x00, 0x00, 0xf8, 0xff, 0xff, 0x7f, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00,
  2069. X   0xa0, 0x0f, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x10, 0xf0, 0x00, 0x02, 0x00,
  2070. X   0x00, 0x00, 0x0c, 0x00, 0x01, 0x01, 0x00, 0x00, 0x08, 0x0c, 0x00, 0x02,
  2071. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2072. X   0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03,
  2073. X   0x00, 0x0f, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0xf0, 0x0c, 0x00, 0x00,
  2074. X   0x03, 0x00, 0x00, 0x00, 0x1f, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1e,
  2075. X   0x00, 0x30, 0x00, 0xf8, 0x7f, 0x00, 0x3c, 0x00, 0x08, 0xb0, 0x07, 0x80,
  2076. X   0x07, 0x40, 0x00, 0x04, 0x78, 0x00, 0x00, 0x18, 0x80, 0x00, 0x04, 0x78,
  2077. X   0x00, 0x00, 0x20, 0x80, 0x00, 0x02, 0x30, 0x00, 0x02, 0x20, 0x00, 0x01,
  2078. X   0x02, 0x08, 0x80, 0x0f, 0x40, 0x00, 0x01, 0x82, 0x08, 0x00, 0x07, 0x40,
  2079. X   0x00, 0x01, 0x02, 0x08, 0x80, 0x0f, 0x40, 0x00, 0x01, 0x02, 0x10, 0x00,
  2080. X   0x02, 0x20, 0x04, 0x01, 0x04, 0x10, 0x00, 0x00, 0x20, 0x80, 0x00, 0x04,
  2081. X   0x60, 0x00, 0x00, 0x18, 0x80, 0x00, 0x08, 0x80, 0x07, 0x80, 0x07, 0x40,
  2082. X   0x00, 0x30, 0x00, 0xf8, 0x7f, 0x00, 0x30, 0x00, 0xc0, 0x00, 0x00, 0x00,
  2083. X   0x00, 0x0c, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x3c,
  2084. X   0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x0f, 0x00, 0x00,
  2085. X   0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2086. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
  2087. X   0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3c,
  2088. X   0x00, 0x00, 0x00, 0x60, 0xf0, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xf0, 0x0f,
  2089. X   0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2090. X   0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2091. X   0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00,
  2092. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2093. X   0x00, 0x00};
  2094. X
  2095. Xstatic String fallbacks[] = {
  2096. X    "XEphem*Algorithms.Fast.set: true",
  2097. X    "XEphem*DBPromptD.textString: ephem.db",
  2098. X    "XEphem*DataSelMiscCols.Alt.set: true",
  2099. X    "XEphem*DataSelMiscCols.Az.set: true",
  2100. X    "XEphem*DataSelMiscCols.Cns.set: true",
  2101. X    "XEphem*DataSelMiscCols.Dec.set: true",
  2102. X    "XEphem*DataSelMiscCols.R_A.set: true",
  2103. X    "XEphem*DataSelRisetCols*Limb.set: true",
  2104. X    "XEphem*DataSelRisetCols.RiseTm.set: true",
  2105. X    "XEphem*DataSelRisetCols.SetTm.set: true",
  2106. X    "XEphem*DataSelRows.Moon.set: true",
  2107. X    "XEphem*DataSelRows.Sun.set: true",
  2108. X    "XEphem*DateFormat.MDY.set: True",
  2109. X    "XEphem*Earth*Map.height: 300",
  2110. X    "XEphem*Help*ScrolledText.columns: 80",
  2111. X    "XEphem*Help*ScrolledText.rows: 24",
  2112. X    "XEphem*Help.verticalSpacing: 20",
  2113. X    "XEphem*Jupiter*BigDots.set: True",
  2114. X    "XEphem*Jupiter*Map.height: 100",
  2115. X    "XEphem*Jupiter*Tags.set: True",
  2116. X    "XEphem*Mars*Map.height: 300",
  2117. X    "XEphem*Message*ScrolledText.columns: 80",
  2118. X    "XEphem*Message*ScrolledText.rows: 10",
  2119. X    "XEphem*Message.verticalSpacing: 20",
  2120. X    "XEphem*PlotDA.height: 300",
  2121. X    "XEphem*Saturn*BigDots.set: True",
  2122. X    "XEphem*Saturn*CtlForm.verticalSpacing: 5",
  2123. X    "XEphem*Saturn*Map.height: 100",
  2124. X    "XEphem*Saturn*Tags.set: True",
  2125. X    "XEphem*SkyFilter*Binary.set: True",
  2126. X    "XEphem*SkyFilter*BrightNeb.set: True",
  2127. X    "XEphem*SkyFilter*ClInNeb.set: True",
  2128. X    "XEphem*SkyFilter*DarkNeb.set: True",
  2129. X    "XEphem*SkyFilter*DiffuseNeb.set: True",
  2130. X    "XEphem*SkyFilter*Double.set: True",
  2131. X    "XEphem*SkyFilter*Elliptical.set: True",
  2132. X    "XEphem*SkyFilter*GalClusters.set: True",
  2133. X    "XEphem*SkyFilter*GlobularCl.set: True",
  2134. X    "XEphem*SkyFilter*Hyperbolic.set: True",
  2135. X    "XEphem*SkyFilter*Multiple.set: True",
  2136. X    "XEphem*SkyFilter*OpenCl.set: True",
  2137. X    "XEphem*SkyFilter*Parabolic.set: True",
  2138. X    "XEphem*SkyFilter*PlanetaryNeb.set: True",
  2139. X    "XEphem*SkyFilter*Planets.set: True",
  2140. X    "XEphem*SkyFilter*Quasars.set: True",
  2141. X    "XEphem*SkyFilter*SphericalGal.set: True",
  2142. X    "XEphem*SkyFilter*SpiralGal.set: True",
  2143. X    "XEphem*SkyFilter*Stars.set: True",
  2144. X    "XEphem*SkyFilter*Stellar.set: True",
  2145. X    "XEphem*SkyFilter*Undefined.set: True",
  2146. X    "XEphem*SkyFilter*Variable.set: True",
  2147. X    "XEphem*SkyView*AltAzMode.set: true",
  2148. X    "XEphem*SkyView*AltDecScale.value: 90",
  2149. X    "XEphem*SkyView*AzRAScale.maximum: 360",
  2150. X    "XEphem*SkyView*AzRAScale.value: 180",
  2151. X    "XEphem*SkyView*BrightMagScale.value: -28",
  2152. X    "XEphem*SkyView*FOVScale.value: 180",
  2153. X    "XEphem*SkyView*FaintMagScale.value: 6",
  2154. X    "XEphem*SkyView*JustDots.set: True",
  2155. X    "XEphem*SkyView*Map.height: 300",
  2156. X    "XEphem*SkyView*Map.width: 300",
  2157. X    "XEphem*SolarSystem*BigDots.set: true",
  2158. X    "XEphem*SolarSystem*HLatScale.value: 90",
  2159. X    "XEphem*SolarSystem*Names.set: true",
  2160. X    "XEphem*SolarSystem*SolarDA.height: 300",
  2161. X    "XEphem*SolarSystem*SolarDA.width: 300",
  2162. X    "XEphem*StdRefr.set: true",
  2163. X    "XEphem*Topocentric.set: true",
  2164. X    "XEphem*Units.English.set: True",
  2165. X    "XEphem*XmText*highlightOnEnter: false",
  2166. X    "XEphem*XmText*highlightThickness: 0",
  2167. X    "XEphem*XmText*traversalOn: true",
  2168. X    "XEphem*background: black",
  2169. X    "XEphem*fontList: fixed",
  2170. X    "XEphem*foreground: white",
  2171. X    "XEphem*highlightOnEnter: false",
  2172. X    "XEphem*highlightThickness: 0",
  2173. X    "XEphem*marginHeight: 1",
  2174. X    "XEphem*spacing: 1",
  2175. X    "XEphem*traversalOn: false",
  2176. X    "XEphem.Elevation: 800",
  2177. X    "XEphem.Epoch: 2000",
  2178. X    "XEphem.HELPFILE: xephem.hlp",
  2179. X    "XEphem.Lat: 41:51:0",
  2180. X    "XEphem.Long: 91:40:0",
  2181. X    "XEphem.NSteps: 1",
  2182. X    "XEphem.Pause: 0",
  2183. X    "XEphem.Pressure: 29.5",
  2184. X    "XEphem.StepSize: RTC",
  2185. X    "XEphem.TZName: CST",
  2186. X    "XEphem.TZone: 6",
  2187. X    "XEphem.Temp: 60",
  2188. X    "XEphem.TwilightDip: 18",
  2189. X    "XEphem.UT: Now",
  2190. X    "XEphem.allowShellResize: True",
  2191. X    "XEphem.viewsFont: fixed",
  2192. X    NULL
  2193. X};
  2194. X
  2195. Xstatic Widget main_window_w;
  2196. X
  2197. Xmain(argc, argv)
  2198. Xint argc;
  2199. Xchar *argv[];
  2200. X{
  2201. X    toplevel_w = XtAppInitialize (&xe_app, myclass, NULL, 0,
  2202. X                        &argc, argv, fallbacks, NULL, 0);
  2203. X
  2204. X#ifdef DO_EDITRES
  2205. X    XtAddEventHandler (toplevel_w, (EventMask)0, True,
  2206. X                    _XEditResCheckMessages, NULL);
  2207. X    xe_msg ("Can editres!\n", 0);
  2208. X#endif
  2209. X
  2210. X    /* report FPE errors, though we don't do anything about them */
  2211. X    (void) signal (SIGFPE, on_fpe);
  2212. X
  2213. X    /* make the main menu bar and form (other stuff is in mainmenu.c) */
  2214. X    main_window_w = make_main_window ();
  2215. X
  2216. X    XtManageChild(main_window_w);
  2217. X    XtRealizeWidget(toplevel_w);
  2218. X
  2219. X    /* connect up the icon pixmap */
  2220. X    setup_window_properties (toplevel_w);
  2221. X
  2222. X    XtAppMainLoop(xe_app);
  2223. X
  2224. X    printf ("XtAppMainLoop returned :-)\n");
  2225. X    return (1);
  2226. X}
  2227. X
  2228. X/* called to put up or remove the watch cursor.  */
  2229. Xvoid
  2230. Xmain_cursor (c)
  2231. XCursor c;
  2232. X{
  2233. X    Window win;
  2234. X
  2235. X    if (main_window_w && (win = XtWindow(main_window_w))) {
  2236. X        Display *dsp = XtDisplay(main_window_w);
  2237. X        if (c)
  2238. X        XDefineCursor (dsp, win, c);
  2239. X        else
  2240. X        XUndefineCursor (dsp, win);
  2241. X    }
  2242. X}
  2243. X
  2244. Xstatic void
  2245. Xon_fpe()
  2246. X{
  2247. X    (void) signal (SIGFPE, (void (*)())on_fpe);
  2248. X    xe_msg ("FP Error\n", 0);
  2249. X}
  2250. X
  2251. X/* put together the menu bar, the main form, and fill in the form with the
  2252. X * initial xephem buttons.
  2253. X */
  2254. Xstatic Widget
  2255. Xmake_main_window ()
  2256. X{
  2257. X
  2258. X    Widget main_window;
  2259. X    Widget menu_bar;
  2260. X    Widget menu_pane;
  2261. X    Widget button;
  2262. X    Widget cascade;
  2263. X    Widget w;
  2264. X    XmString str;
  2265. X    Arg args[20];
  2266. X    int n;
  2267. X
  2268. X    /*    Create MainWindow.  */
  2269. X    n = 0;
  2270. X    main_window = XmCreateMainWindow (toplevel_w, "xephem_main", args, n);
  2271. X    XtManageChild (main_window);
  2272. X
  2273. X    /*    Create MenuBar in MainWindow.  */
  2274. X    n = 0;
  2275. X    menu_bar = XmCreateMenuBar (main_window, "menu_bar", args, n); 
  2276. X    XtManageChild (menu_bar);
  2277. X
  2278. X    /*    Create "File" PulldownMenu.  */
  2279. X    n = 0;
  2280. X    menu_pane = XmCreatePulldownMenu (menu_bar, "file_pane", args, n);
  2281. X
  2282. X    n = 0;
  2283. X    XtSetArg (args[n], XmNmnemonic, 'R'); n++;
  2284. X    button = XmCreatePushButton (menu_pane, "Reset", args, n);
  2285. X    XtManageChild (button);
  2286. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb, 
  2287. X                            (XtPointer)XRESET);
  2288. X
  2289. X    n = 0;
  2290. X    XtSetArg (args[n], XmNmnemonic, 'M'); n++;
  2291. X    button = XmCreatePushButton (menu_pane, "Messages", args, n);
  2292. X    XtManageChild (button);
  2293. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2294. X                            (XtPointer)MSGTXT);
  2295. X
  2296. X    str = XmStringCreate ("Ctrl/d", XmSTRING_DEFAULT_CHARSET);
  2297. X    n = 0;
  2298. X    XtSetArg (args[n], XmNaccelerator, "Ctrl<Key>d:"); n++;
  2299. X    XtSetArg (args[n], XmNacceleratorText, str); n++;
  2300. X    XtSetArg (args[n], XmNmnemonic, 'Q'); n++;
  2301. X    button = XmCreatePushButton (menu_pane, "Quit", args, n);
  2302. X    XtManageChild (button);
  2303. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2304. X                            (XtPointer)QUIT);
  2305. X    XmStringFree (str);
  2306. X
  2307. X    n = 0;
  2308. X    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  2309. X    XtSetArg (args[n], XmNmnemonic, 'F'); n++;
  2310. X    cascade = XmCreateCascadeButton (menu_bar, "File", args, n);
  2311. X    XtManageChild (cascade);
  2312. X    
  2313. X    /*    Create "View" PulldownMenu.  */
  2314. X    n = 0;
  2315. X    menu_pane = XmCreatePulldownMenu (menu_bar, "view_pane", args, n);
  2316. X    
  2317. X    n = 0;
  2318. X    str = XmStringCreate ("Data Table", XmSTRING_DEFAULT_CHARSET);
  2319. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2320. X    XtSetArg (args[n], XmNmnemonic, 'D'); n++;
  2321. X    button = XmCreatePushButton (menu_pane, "GenData", args, n);
  2322. X    XtManageChild (button);
  2323. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2324. X                            (XtPointer)DATA);
  2325. X    XmStringFree(str);
  2326. X    
  2327. X    n = 0;
  2328. X    w = XmCreateSeparator (menu_pane, "ViewSep1", args, n);
  2329. X    XtManageChild (w);
  2330. X
  2331. X    n = 0;
  2332. X    XtSetArg (args[n], XmNmnemonic, 'M'); n++;
  2333. X    button = XmCreatePushButton (menu_pane, "Moon", args, n);
  2334. X    XtManageChild (button);
  2335. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2336. X                            (XtPointer)MOON);
  2337. X
  2338. X    n = 0;
  2339. X    XtSetArg (args[n], XmNmnemonic, 'E'); n++;
  2340. X    button = XmCreatePushButton (menu_pane, "Earth", args, n);
  2341. X    XtManageChild (button);
  2342. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2343. X                            (XtPointer)EARTH);
  2344. X
  2345. X    n = 0;
  2346. X    XtSetArg (args[n], XmNmnemonic, 'r'); n++;
  2347. X    button = XmCreatePushButton (menu_pane, "Mars", args, n);
  2348. X    XtManageChild (button);
  2349. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2350. X                            (XtPointer)MARS);
  2351. X
  2352. X
  2353. X    n = 0;
  2354. X    XtSetArg (args[n], XmNmnemonic, 'J'); n++;
  2355. X    button = XmCreatePushButton (menu_pane, "Jupiter", args, n);
  2356. X    XtManageChild (button);
  2357. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2358. X                            (XtPointer)JUPMOON);
  2359. X
  2360. X    n = 0;
  2361. X    XtSetArg (args[n], XmNmnemonic, 'a'); n++;
  2362. X    button = XmCreatePushButton (menu_pane, "Saturn", args, n);
  2363. X    XtManageChild (button);
  2364. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2365. X                            (XtPointer)SATMOON);
  2366. X    
  2367. X    n = 0;
  2368. X    w = XmCreateSeparator (menu_pane, "ViewSep2", args, n);
  2369. X    XtManageChild (w);
  2370. X    
  2371. X    n = 0;
  2372. X    str = XmStringCreate ("Sky View", XmSTRING_DEFAULT_CHARSET);
  2373. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2374. X    XtSetArg (args[n], XmNmnemonic, 'V'); n++;
  2375. X    button = XmCreatePushButton (menu_pane, "SkyV", args, n);
  2376. X    XtManageChild (button);
  2377. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2378. X                            (XtPointer)SKYVIEW);
  2379. X    XmStringFree(str);
  2380. X    
  2381. X    n = 0;
  2382. X    str = XmStringCreate ("Solar system", XmSTRING_DEFAULT_CHARSET);
  2383. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2384. X    XtSetArg (args[n], XmNmnemonic, 'S'); n++;
  2385. X    button = XmCreatePushButton (menu_pane, "SolSys", args, n);
  2386. X    XtManageChild (button);
  2387. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2388. X                            (XtPointer)SOLARSYS);
  2389. X    XmStringFree(str);
  2390. X    
  2391. X    n = 0;
  2392. X    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  2393. X    XtSetArg (args[n], XmNmnemonic, 'V'); n++;
  2394. X    cascade = XmCreateCascadeButton (menu_bar, "View", args, n);
  2395. X    XtManageChild (cascade);
  2396. X    
  2397. X    /*    Create "Control" PulldownMenu.  */
  2398. X    n = 0;
  2399. X    menu_pane = XmCreatePulldownMenu (menu_bar, "control_pane", args, n);
  2400. X    
  2401. X    n = 0;
  2402. X    XtSetArg (args[n], XmNmnemonic, 'P'); n++;
  2403. X    button = XmCreatePushButton (menu_pane, "Plot", args, n);
  2404. X    XtManageChild (button);
  2405. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2406. X                            (XtPointer)PLOT);
  2407. X    
  2408. X    n = 0;
  2409. X    XtSetArg (args[n], XmNmnemonic, 'L'); n++;
  2410. X    button = XmCreatePushButton (menu_pane, "Listing", args, n);
  2411. X    XtManageChild (button);
  2412. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2413. X                            (XtPointer)LIST);
  2414. X    
  2415. X    n = 0;
  2416. X    XtSetArg (args[n], XmNmnemonic, 'S'); n++;
  2417. X    button = XmCreatePushButton (menu_pane, "Search", args, n);
  2418. X    XtManageChild (button);
  2419. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2420. X                            (XtPointer)SEARCH);
  2421. X    
  2422. X    n = 0;
  2423. X    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  2424. X    XtSetArg (args[n], XmNmnemonic, 'C'); n++;
  2425. X    cascade = XmCreateCascadeButton (menu_bar, "Control", args, n);
  2426. X    XtManageChild (cascade);
  2427. X
  2428. X    /*    Create "ObjX/Y..." Cascade Button.  */
  2429. X    str = XmStringCreate ("ObjX/Y...", XmSTRING_DEFAULT_CHARSET);
  2430. X    n = 0;
  2431. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2432. X    XtSetArg (args[n], XmNmnemonic, 'O'); n++;
  2433. X    cascade = XmCreateCascadeButton (menu_bar, "ObjXY", args, n);
  2434. X    XtManageChild (cascade);
  2435. X    XtAddCallback (cascade, XmNactivateCallback, m_activate_cb,
  2436. X                            (XtPointer)OBJS);
  2437. X    XmStringFree (str);
  2438. X
  2439. X    /*    Create "DB..." Cascade Button.  */
  2440. X    str = XmStringCreate ("DB...", XmSTRING_DEFAULT_CHARSET);
  2441. X    n = 0;
  2442. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2443. X    XtSetArg (args[n], XmNmnemonic, 'D'); n++;
  2444. X    cascade = XmCreateCascadeButton (menu_bar, "DB", args, n);
  2445. X    XtManageChild (cascade);
  2446. X    XtAddCallback (cascade, XmNactivateCallback, m_activate_cb,
  2447. X                            (XtPointer)DB);
  2448. X    XmStringFree (str);
  2449. X
  2450. X    /*    Create "Preferences" PulldownMenu.  */
  2451. X
  2452. X    pref_create_pulldown (menu_bar);
  2453. X    
  2454. X    /*    Create "Help" button.  */
  2455. X
  2456. X    n = 0;
  2457. X    menu_pane = XmCreatePulldownMenu (menu_bar, "help_pane", args, n);
  2458. X    
  2459. X    n = 0;
  2460. X    str = XmStringCreate ("on Version", XmSTRING_DEFAULT_CHARSET);
  2461. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2462. X    XtSetArg (args[n], XmNmnemonic, 'V'); n++;
  2463. X    button = XmCreatePushButton (menu_pane, "onVersion", args, n);
  2464. X    XtManageChild (button);
  2465. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2466. X                            (XtPointer)VERSION);
  2467. X    XmStringFree(str);
  2468. X
  2469. X    n = 0;
  2470. X    str = XmStringCreate ("on Credits", XmSTRING_DEFAULT_CHARSET);
  2471. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2472. X    XtSetArg (args[n], XmNmnemonic, 'C'); n++;
  2473. X    button = XmCreatePushButton (menu_pane, "onReferences", args, n);
  2474. X    XtManageChild (button);
  2475. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2476. X                            (XtPointer)REFERENCES);
  2477. X    XmStringFree(str);
  2478. X
  2479. X    n = 0;
  2480. X    XtSetArg (args[n], XmNmnemonic, 'I'); n++;
  2481. X    button = XmCreatePushButton (menu_pane, "Introduction", args, n);
  2482. X    XtManageChild (button);
  2483. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2484. X                            (XtPointer)INTRO);
  2485. X
  2486. X    n = 0;
  2487. X    str = XmStringCreate ("on Initialization", XmSTRING_DEFAULT_CHARSET);
  2488. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2489. X    XtSetArg (args[n], XmNmnemonic, 'z'); n++;
  2490. X    button = XmCreatePushButton (menu_pane, "onInitialization", args, n);
  2491. X    XtManageChild (button);
  2492. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2493. X                            (XtPointer)CONFIGFILE);
  2494. X    XmStringFree(str);
  2495. X
  2496. X    n = 0;
  2497. X    str = XmStringCreate ("on Main Menu", XmSTRING_DEFAULT_CHARSET);
  2498. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2499. X    XtSetArg (args[n], XmNmnemonic, 'M'); n++;
  2500. X    button = XmCreatePushButton (menu_pane, "onMainMenu", args, n);
  2501. X    XtManageChild (button);
  2502. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2503. X                            (XtPointer)MAINMENU);
  2504. X    XmStringFree(str);
  2505. X
  2506. X    n = 0;
  2507. X    str = XmStringCreate ("on Operation", XmSTRING_DEFAULT_CHARSET);
  2508. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2509. X    XtSetArg (args[n], XmNmnemonic, 'O'); n++;
  2510. X    button = XmCreatePushButton (menu_pane, "onOperation", args, n);
  2511. X    XtManageChild (button);
  2512. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2513. X                            (XtPointer)OPERATION);
  2514. X    XmStringFree(str);
  2515. X
  2516. X    n = 0;
  2517. X    str = XmStringCreate ("on Triad formats", XmSTRING_DEFAULT_CHARSET);
  2518. X    XtSetArg (args[n], XmNlabelString, str); n++;
  2519. X    XtSetArg (args[n], XmNmnemonic, 'T'); n++;
  2520. X    button = XmCreatePushButton (menu_pane, "onTriad", args, n);
  2521. X    XtManageChild (button);
  2522. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2523. X                            (XtPointer)DATETIME);
  2524. X    XmStringFree(str);
  2525. X
  2526. X    n = 0;
  2527. X    XtSetArg (args[n], XmNmnemonic, 'N'); n++;
  2528. X    button = XmCreatePushButton (menu_pane, "Notes", args, n);
  2529. X    XtManageChild (button);
  2530. X    XtAddCallback (button, XmNactivateCallback, m_activate_cb,
  2531. X                            (XtPointer)NOTES);
  2532. X
  2533. X    n = 0;
  2534. X    XtSetArg (args[n], XmNsubMenuId, menu_pane);  n++;
  2535. X    XtSetArg (args[n], XmNmnemonic, 'H'); n++;
  2536. X    cascade = XmCreateCascadeButton (menu_bar, "Help", args, n);
  2537. X    XtManageChild (cascade);
  2538. X
  2539. X    n = 0;
  2540. X    XtSetArg (args[n], XmNmenuHelpWidget, cascade);  n++;
  2541. X    XtSetValues (menu_bar, args, n);
  2542. X
  2543. X    /* create and manage the main form */
  2544. X    mm_manage(main_window);
  2545. X
  2546. X    return (main_window);
  2547. X}
  2548. X
  2549. Xstatic void
  2550. Xsetup_window_properties (w)
  2551. XWidget w;
  2552. X{
  2553. X    Pixmap icon_pm;
  2554. X    XSizeHints xsh;
  2555. X    Display *dsp = XtDisplay(w);
  2556. X    Window win = XtWindow (w);
  2557. X
  2558. X    icon_pm = XCreateBitmapFromData (dsp, win, (char *)xephem_bits,
  2559. X                        xephem_width, xephem_height);
  2560. X    /* can set window size hints here if we like */
  2561. X    xsh.flags = 0;
  2562. X
  2563. X    XSetStandardProperties (dsp, win, "xephem", "xephem", icon_pm,
  2564. X        (char **)0, 0, &xsh);
  2565. X}
  2566. X
  2567. X/* ARGSUSED */
  2568. Xstatic void
  2569. Xm_activate_cb (w, client, call)
  2570. XWidget w;
  2571. XXtPointer client;
  2572. XXtPointer call;
  2573. X{
  2574. X    int code = (int)client;
  2575. X
  2576. X    watch_cursor(1);
  2577. X
  2578. X    switch (code) {
  2579. X    case XRESET:    mm_reset(); break;
  2580. X    case MSGTXT:    msg_manage(); break;
  2581. X    case QUIT:    exit(0); break;
  2582. X    case DATA:    dm_manage(); break;
  2583. X    case EARTH:    e_manage(); break;
  2584. X    case MOON:    m_manage(); break;
  2585. X    case MARS:    mars_manage(); break;
  2586. X    case JUPMOON:    jm_manage(); break;
  2587. X    case SATMOON:    sm_manage(); break;
  2588. X    case SKYVIEW:    sv_manage(); break;
  2589. X    case SOLARSYS:    ss_manage(); break;
  2590. X    case PLOT:    plot_manage(); break;
  2591. X    case LIST:    lst_manage(); break;
  2592. X    case SEARCH:    srch_manage(); break;
  2593. X    case OBJS:    obj_manage(); break;
  2594. X    case DB:    db_manage(); break;
  2595. X    case VERSION:    version(); break;
  2596. X    case REFERENCES:references_help(); break;
  2597. X    case INTRO:    intro_help(); break;
  2598. X    case CONFIGFILE:config_help(); break;
  2599. X    case MAINMENU:    mainmenu_help(); break;
  2600. X    case OPERATION:    operation_help(); break;
  2601. X    case DATETIME:    datetime_help(); break;
  2602. X    case NOTES:    notes_help(); break;
  2603. X    default:     printf ("Main menu bug: code=%d\n", code); exit(1);
  2604. X    }
  2605. X
  2606. X    watch_cursor(0);
  2607. X}
  2608. END_OF_FILE
  2609.   if test 20922 -ne `wc -c <'xephem.c'`; then
  2610.     echo shar: \"'xephem.c'\" unpacked with wrong size!
  2611.   fi
  2612.   # end of 'xephem.c'
  2613. fi
  2614. echo shar: End of archive 11 \(of 21\).
  2615. cp /dev/null ark11isdone
  2616. MISSING=""
  2617. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
  2618.     if test ! -f ark${I}isdone ; then
  2619.     MISSING="${MISSING} ${I}"
  2620.     fi
  2621. done
  2622. if test "${MISSING}" = "" ; then
  2623.     echo You have unpacked all 21 archives.
  2624.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2625.     echo Building ephem.db
  2626.     cat > ephem.db.Z.uu ephem.db.Z.uu.?
  2627.     uudecode ephem.db.Z.uu
  2628.     rm ephem.db.Z.uu ephem.db.Z.uu.?
  2629.     uncompress ephem.db.Z
  2630.     echo Building skyviewmenu.c
  2631.     cat > skyviewmenu.c skyviewmenu.c.?
  2632.     rm skyviewmenu.c.?
  2633.     echo Building smallfm.xbm
  2634.     cat > smallfm.xbm smallfm.xbm.?
  2635.     rm smallfm.xbm.?
  2636. else
  2637.     echo You still must unpack the following archives:
  2638.     echo "        " ${MISSING}
  2639. fi
  2640. exit 0
  2641. exit 0 # Just in case...
  2642. -- 
  2643.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  2644. \X/  Amiga - The only way to fly!      |
  2645.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  2646.   casual observer..."                  |
  2647.