home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume18 / xmandel / part02 < prev    next >
Encoding:
Text File  |  1992-07-12  |  50.1 KB  |  1,714 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: tony@ajfcal.cuc.ab.ca (Tony Field)
  4. Subject: v18i016: Xmandelbrot, Part02/03
  5. Message-ID: <1992Jul13.155041.6681@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-18i015-xmandel@uunet.UU.NET>
  10. Date: Mon, 13 Jul 1992 15:50:41 GMT
  11. Approved: dcmartin@msi.com
  12. Lines: 1700
  13.  
  14. Submitted-by: tony@ajfcal.cuc.ab.ca (Tony Field)
  15. Posting-number: Volume 18, Issue 16
  16. Archive-name: xmandel/part02
  17.  
  18. #!/bin/sh
  19. # this is part.02 (part 2 of a multipart archive)
  20. # do not concatenate these parts, unpack them in order with /bin/sh
  21. # file mainaw.c continued
  22. #
  23. if test ! -r _shar_seq_.tmp; then
  24.     echo 'Please unpack part 1 first!'
  25.     exit 1
  26. fi
  27. (read Scheck
  28.  if test "$Scheck" != 2; then
  29.     echo Please unpack part "$Scheck" next!
  30.     exit 1
  31.  else
  32.     exit 0
  33.  fi
  34. ) < _shar_seq_.tmp || exit 1
  35. if test ! -f _shar_wnt_.tmp; then
  36.     echo 'x - still skipping mainaw.c'
  37. else
  38. echo 'x - continuing file mainaw.c'
  39. sed 's/^X//' << 'SHAR_EOF' >> 'mainaw.c' &&
  40. X    if (activeimage == &manparm)
  41. X        redraw_mandel (NULL);
  42. X    else
  43. X        redraw_julia (NULL);
  44. }
  45. X
  46. /************************************************************************
  47. *    rotateminus            button = -colour    rotate colour negative        *
  48. ************************************************************************/
  49. X
  50. static void rotateminus (w, client_data, call_data)
  51. Widget w;
  52. caddr_t client_data;
  53. caddr_t call_data;
  54. {
  55. X    rotate (activeimage,  -activeimage->rotation);
  56. X    if (activeimage == &manparm)
  57. X        redraw_mandel (NULL);
  58. X    else
  59. X        redraw_julia (NULL);
  60. }
  61. X
  62. X
  63. /************************************************************************
  64. *    CancelRotate()        button = colour/ancel    ignore colour rotation    *
  65. ************************************************************************/
  66. X
  67. static void CancelRotate (w, client_data, call_data)
  68. Widget w;
  69. caddr_t client_data;
  70. caddr_t call_data;
  71. {
  72. X    XtPopdown(cshell);
  73. X    XFlush (display);
  74. }
  75. X
  76. X
  77. /************************************************************************
  78. *    rotate()            rotate the image through colours by val offset    *
  79. ************************************************************************/
  80. X
  81. static void rotate (parm, val)
  82. struct imageparm *parm;
  83. int val;
  84. {
  85. X    int        nbits, x, y, im, i, ib;
  86. X    unsigned char *b;
  87. X    unsigned int mask[8];
  88. X    unsigned int v[8];
  89. X
  90. X    /*    with a touch of brute force */
  91. X
  92. X    parm->totrot += val;
  93. X    switch (depth)
  94. X    {
  95. X    case 8:
  96. X        nbits = parm->pixheight * parm->pixwidth;
  97. X        b = parm->pix;
  98. X        while (nbits--)
  99. X            *b++ += val;
  100. X        break;
  101. X
  102. X    case 4:
  103. X        for (i = 0;  i < 2;  i++)
  104. X        {    mask[i] = (0x0f << i*4);
  105. X            v[i] = val << i*4;
  106. X        }
  107. X        for (y = 0;  y < parm->pixheight;  y++)
  108. X        {    b = parm->pix + y * parm->bytewidth;
  109. X            for (x = 0;  x < parm->pixwidth;  x++)
  110. X            {    im = (x % 2);
  111. X                ib = x >> 1;
  112. X                b[ib] = ((((unsigned int) (b[ib] & mask[im]) + (v[im]) & mask[im])) & mask[im])
  113. X                        | ( b[ib] & ~mask[im]);
  114. X            }
  115. X        }
  116. X        break;
  117. X
  118. X    case 2:
  119. X        for (i = 0;  i < 4;  i++)
  120. X        {    mask[i] = (0x03 << i*2);
  121. X            v[i] = val << i*2;
  122. X        }
  123. X        for (y = 0;  y < parm->pixheight;  y++)
  124. X        {    b = parm->pix + y * parm->bytewidth;
  125. X            for (x = 0;  x < parm->pixwidth;  x++)
  126. X            {    im = x % 4;
  127. X                ib = x >> 2;
  128. X                b[ib] = ((((unsigned int) (b[ib] & mask[im]) + (v[im]) & mask[im])) & mask[im])
  129. X                        | ( b[ib] & ~mask[im]);
  130. X            }
  131. X        }
  132. X        break;
  133. X
  134. X    case 1:
  135. X        for (y = 0;  y < parm->pixheight;  y++)
  136. X        {    b = parm->pix + y * parm->bytewidth;
  137. X            for (x = 0;  x < parm->bytewidth;  x++)
  138. X                b[x] = ~b[x];
  139. X        }
  140. X        break;
  141. X    }
  142. }
  143. X
  144. X
  145. /* actions  */
  146. X
  147. /************************************************************************
  148. *    nothing()            do nothing if <enter> is received in dialogue    *
  149. ************************************************************************/
  150. X
  151. static XtActionProc nothing (w, event, params, num_params)
  152. Widget w;
  153. XXButtonEvent *event;
  154. String *params;
  155. Cardinal *num_params;
  156. {
  157. X    String     s, ss;
  158. X    Widget    parent;
  159. X    int        atoi();
  160. X
  161. X
  162. X    parent = w->core.parent;
  163. X    s = XawDialogGetValueString(parent);
  164. X    if (s)
  165. X    {    ss = tidy (s);
  166. X        if (*ss)
  167. X        {    if (strcmp (parent->core.name, "fname") == 0)
  168. X            {    XtPopdown(pshell);
  169. X                XFlush (display);
  170. X                if (activeimage->pix)
  171. X                {    printf ("%s gif file = %s\n", (activeimage == &manparm ? "Mandelbrot" : "Julia"), s);
  172. X                    write_gif_image (ss, activeimage);
  173. X                }
  174. X            }
  175. X            else if (strcmp (parent->core.name, "colour") == 0)
  176. X            {    XtPopdown(cshell);
  177. X                XFlush (display);
  178. X                activeimage->rotation = atoi (ss);
  179. X                rotate (activeimage,  activeimage->rotation);
  180. X                if (activeimage == &manparm)
  181. X                    redraw_mandel (NULL);
  182. X                else
  183. X                    redraw_julia (NULL);
  184. X            }
  185. X        }
  186. X        XtFree (s);
  187. X    }
  188. }
  189. X
  190. /************************************************************************
  191. *    reshape_widgets ()        make widgets uniform in size                *
  192. ************************************************************************/
  193. X
  194. /*    the following code to reshape a widget set is mangled from xman sources 
  195. X    full_size widgets are placed on independent lines
  196. X    small_size widgest are scaled so that all short widgets
  197. X               fit into the same total width as the longest widget.
  198. */
  199. X
  200. static void reshape_widgets(parent, full_size, small_size)
  201. Widget parent;
  202. char **full_size, **small_size;
  203. {
  204. X    Widget *full_widgets, *half_widgets, *temp, long_widget;
  205. X    Dimension longest, length, b_width;
  206. X    int interior_dist;
  207. X    Arg arglist[2];
  208. X    int    nhalf;
  209. X
  210. X    for (nhalf = 0;    small_size[nhalf];    nhalf++)
  211. X        ;
  212. X    full_widgets = ConvertNamesToWidgets(parent, full_size);
  213. X    half_widgets = ConvertNamesToWidgets(parent, small_size);
  214. X    
  215. X    long_widget = NULL;
  216. X    longest = 0;
  217. X    XtSetArg(arglist[0], XtNwidth, &length);
  218. X    XtSetArg(arglist[1], XtNborderWidth, &b_width);
  219. X
  220. X    /* Find Longest widget. */
  221. X
  222. X    for ( temp = full_widgets ; *temp != (Widget) NULL ; temp++) 
  223. X    { XtGetValues(*temp, arglist, (Cardinal) 2);
  224. X        length += 2 * b_width;
  225. X        if (length > longest) 
  226. X        { longest = length;
  227. X            long_widget = *temp;
  228. X        }
  229. X    }
  230. X
  231. X    if (long_widget == (Widget) NULL) 
  232. X    {    printf ("Could not find longest widget, aborting...");
  233. X        XtFree(full_widgets);
  234. X        XtFree(half_widgets);
  235. X        return;
  236. X    }
  237. X
  238. X    /* Set all other full_widgets to this length. */
  239. X
  240. X    for ( temp = full_widgets ; *temp != (Widget) NULL ; temp++ )
  241. X    {    if ( long_widget != *temp) 
  242. X        {    Dimension width, border_width;
  243. X
  244. X            XtSetArg(arglist[0], XtNborderWidth, &border_width);
  245. X            XtGetValues(*temp, arglist, (Cardinal) 1);
  246. X        
  247. X            width = longest - 2 * border_width;
  248. X            XtSetArg(arglist[0], XtNwidth, width);
  249. X            XtSetValues(*temp, arglist, (Cardinal) 1);
  250. X        }
  251. X    }
  252. X
  253. X    /*    Set all the half widgets to the right length. */
  254. X
  255. X    XtSetArg(arglist[0], XtNdefaultDistance, &interior_dist);
  256. X    XtGetValues(parent, arglist, (Cardinal) 1);
  257. X    
  258. X    for ( temp = half_widgets ; *temp != (Widget) NULL ; temp++) 
  259. X    {    Dimension width, border_width;
  260. X
  261. X        XtSetArg(arglist[0], XtNwidth, &length);
  262. X        XtSetArg(arglist[1], XtNborderWidth, &b_width);
  263. X        XtGetValues(*temp, arglist, (Cardinal) 2);
  264. X        
  265. X        XtSetArg(arglist[0], XtNborderWidth, &border_width);
  266. X        XtGetValues(*temp, arglist, (Cardinal) 1);
  267. X        
  268. X        width = (longest - interior_dist)/nhalf - nhalf * border_width;
  269. X        if (width > b_width)
  270. X        {     XtSetArg(arglist[0], XtNwidth, width);
  271. X             XtSetValues(*temp, arglist, (Cardinal) 1);
  272. X        }
  273. X    }
  274. X    XtFree(full_widgets);
  275. X    XtFree(half_widgets);
  276. }
  277. X
  278. /************************************************************************
  279. *    ConvertNamesToWidgets()        get a widget vector from a name vector    *
  280. ************************************************************************/
  281. X
  282. static Widget *
  283. ConvertNamesToWidgets(parent, names)
  284. Widget parent;
  285. char ** names;
  286. {
  287. X    char ** temp;
  288. X    Widget * ids, * temp_ids;
  289. X    int count;
  290. X
  291. X    for (count = 0, temp = names; *temp != NULL ; count++, temp++);
  292. X
  293. X    ids = (Widget *) XtMalloc( (count + 1) * sizeof(Widget));
  294. X
  295. X    for ( temp_ids = ids; *names != NULL ; names++, temp_ids++) 
  296. X    {    *temp_ids = XtNameToWidget(parent, *names);
  297. X        if (*temp_ids == NULL) 
  298. X        {    printf("Could not find widget named '%s'", *names);
  299. X            XtFree(ids);
  300. X            return(NULL);
  301. X        }
  302. X    }
  303. X    *temp_ids = (Widget) NULL;
  304. X    return(ids);
  305. }
  306. X
  307. /************************************************************************
  308. *    update_coordinates()    write zoom coordinates to stdout            *
  309. ************************************************************************/
  310. X
  311. void update_coordinates (image, lf)
  312. struct imageparm *image;
  313. int        lf;
  314. {
  315. X    if (lf < 0)
  316. X        return;
  317. X    printf ("%s (lx,ly) (ux,uy) = (%11.7lf,%11.7lf) (%11.7lf,%11.7lf)%c",
  318. X                image == &manparm ? "mandel:" : "julia: ",
  319. X                image->lx, image->ly, image->ux, image->uy, (lf ? '\n' : '\r'));
  320. X    fflush (stdout);
  321. X    XFlush (display);
  322. }
  323. X
  324. /************************************************************************
  325. *    update_point()            write point coord and colour to stdout        *
  326. ************************************************************************/
  327. X
  328. void update_point (image)
  329. struct imageparm *image;
  330. {
  331. X    printf ("point:  (x,y) = (%11.7lf,%11.7lf)  colour = %d  \r",
  332. X            image->px, image->py, image->pcolour);
  333. X    fflush (stdout);
  334. X    XFlush (display);
  335. X                        
  336. }
  337. X
  338. X
  339. #ifdef NEEDMEMCPY
  340. X
  341. /************************************************************************
  342. *    memcpy()                slow version of memcpy                        *
  343. ************************************************************************/
  344. X
  345. memcpy (dest, src, n)
  346. char *dest, *src;
  347. int n;
  348. {
  349. X    if (n > 0)
  350. X    {    while (n--)
  351. X            dest++ = *src++;
  352. X    }
  353. }
  354. X
  355. #endif
  356. X
  357. X
  358. SHAR_EOF
  359. echo 'File mainaw.c is complete' &&
  360. chmod 0644 mainaw.c ||
  361. echo 'restore of mainaw.c failed'
  362. Wc_c="`wc -c < 'mainaw.c'`"
  363. test 27742 -eq "$Wc_c" ||
  364.     echo 'mainaw.c: original size 27742, current size' "$Wc_c"
  365. rm -f _shar_wnt_.tmp
  366. fi
  367. # ============= mainmotif.c ==============
  368. if test -f 'mainmotif.c' -a X"$1" != X"-c"; then
  369.     echo 'x - skipping mainmotif.c (File already exists)'
  370.     rm -f _shar_wnt_.tmp
  371. else
  372. > _shar_wnt_.tmp
  373. echo 'x - extracting mainmotif.c (Text)'
  374. sed 's/^X//' << 'SHAR_EOF' > 'mainmotif.c' &&
  375. /* ta=4         tabs set to 4 */
  376. /************************************************************************
  377. *            mandebrot and julia set generator                            *
  378. ************************************************************************/
  379. /*
  380. X * $Id:$
  381. X * $Log:$
  382. X *
  383. */
  384. X
  385. #include <stdio.h>
  386. X
  387. #include <X11/X.h>
  388. #include <X11/Xlib.h>
  389. #include <X11/IntrinsicP.h>
  390. #include <X11/StringDefs.h>
  391. #include <X11/Shell.h>
  392. #ifdef VASIMPLE
  393. #include <Xm/VaSimple.h>
  394. #endif
  395. #include <Xm/Xm.h>
  396. #include <Xm/PanedW.h>
  397. #include <Xm/PushB.h>
  398. #include <Xm/DrawingA.h>
  399. #include <Xm/BulletinB.h>
  400. #include <Xm/Text.h>
  401. X
  402. #include <Xm/Label.h>
  403. X
  404. #include <Xm/LabelG.h>
  405. #include <Xm/RowColumn.h>
  406. #include <Xm/ToggleBG.h>
  407. X
  408. #include "mandel.h"
  409. #include "mandel.bit"
  410. X
  411. #ifdef __STDC__
  412. static int make_buttons(struct button_list *button, int text_wide, int text_high, int left_offset, int top_offset);
  413. static int make_dialogue(Widget w, struct enter_buttons *but, int x, int y, int labelchars, int textchars, int font_wide, int text_high);
  414. static int make_selector(Widget parent, int xoffset, int nexty, int text_wide, int text_high, int font_wide);
  415. static void do_mandel(Widget w, caddr_t client_data, caddr_t call_data);
  416. static void do_julia(Widget w, caddr_t client_data, caddr_t call_data);
  417. static void do_quit(Widget w, caddr_t client_data, caddr_t call_data);
  418. static void do_select(Widget w, caddr_t client_data, XmToggleButtonCallbackStruct *call_data);
  419. static void button_set(Widget w, int how);
  420. static void set_zoom(Widget w, caddr_t client_data, caddr_t call_data);
  421. static void recalc(Widget w, caddr_t client_data, caddr_t call_data);
  422. static void do_remove(Widget w, caddr_t client_data, caddr_t call_data);
  423. static void generate_gif(Widget w, caddr_t client_data, caddr_t call_data);
  424. static void rotateplus(Widget w, caddr_t client_data, caddr_t call_data);
  425. static void rotateminus(Widget w, caddr_t client_data, caddr_t call_data);
  426. static void rotate(struct imageparm *parm, int val);
  427. static int current_rotate(void);
  428. static void save_coord(struct imageparm *image);
  429. static int check_coord_change(struct imageparm *image);
  430. static void update_control(struct imageparm *image);
  431. static void updoubleval(char *name, double x);
  432. static void upintval(char *name, int x);
  433. static void font_box_size(Widget w, int *wide, int *high);
  434. static String tidy(String s);
  435. static char *anynumber(char *s);
  436. #else
  437. static int make_buttons();
  438. static int make_dialogue();
  439. static int make_selector();
  440. static void do_mandel();
  441. static void do_julia();
  442. static void do_quit();
  443. static void do_select();
  444. static void button_set();
  445. static void set_zoom();
  446. static void recalc();
  447. static void do_remove();
  448. static void generate_gif();
  449. static void rotateplus();
  450. static void rotateminus();
  451. static void rotate();
  452. static int current_rotate();
  453. static void save_coord();
  454. static int check_coord_change();
  455. static void update_control();
  456. static void updoubleval();
  457. static void upintval();
  458. static void font_box_size();
  459. static String tidy();
  460. static char *anynumber();
  461. #endif
  462. X
  463. extern struct imageparm manparm;
  464. extern struct imageparm juliaparm;
  465. X
  466. char            *progname;
  467. X
  468. Display *display;
  469. Screen    *screen;
  470. Window root;
  471. X
  472. Widget toplevel;
  473. Widget mandelshell = NULL;
  474. Widget juliashell  = NULL;
  475. X
  476. int depth;
  477. int dots_per_byte;                    /*    pixel dots in a byte        */
  478. extern int julia_in_progress;
  479. extern struct imageparm manparm;
  480. extern struct imageparm juliaparm;
  481. struct imageparm *activeimage = &manparm;
  482. X
  483. static Widget        bboard;
  484. static Widget    mandel_select, julia_select, cstep_value;
  485. static Pixmap         mandel_pixmap, manim_pixmap, julim_pixmap;
  486. X
  487. static Dimension mandel_initial_height;
  488. X
  489. struct enter_buttons enter[] =
  490. {    { "GIF\nfile:", 0, 0,     "fname", 30 },
  491. X    { "ZOOM COORDINATES", 0, 1, NULL, 0 },
  492. X    { "lx:", 0, 2,         "flx", 15 },
  493. X    { "ly:", 1, 2,         "fly", 15 },
  494. X    { "ux:", 0, 3,         "fux", 15 },
  495. X    { "uy:", 1, 3,         "fuy", 15 },
  496. X    { "POINT COORDINATES", 0, 4, NULL, 0 },
  497. X    { "x:", 0, 5,          "px", 15 },
  498. X    { "y:", 1, 5,          "py", 15 },
  499. X    { NULL }
  500. } ;
  501. X
  502. struct button_list button[] = 
  503. {
  504. X    { "mandel",        do_mandel     ,    0,     0 },
  505. X    { "julia",        do_julia     ,    1,     0 },
  506. X    { "quit",        do_quit         ,    2,     0 },
  507. X    { NULL,            NULL         ,    5,     0 }
  508. };
  509. X
  510. struct button_list work[] = 
  511. {
  512. X    { "zoom",        set_zoom     ,    1,     0 },
  513. X    { "unzoom",        do_unzoom     ,    1,     1 },
  514. X    { "+colour",    rotateplus     ,    2,     0 },
  515. X    { "-colour",    rotateminus     ,    2,     1 },
  516. X    { "recalc",        recalc         ,    3,     0 },
  517. X    { NULL,            NULL         ,    5,     0 }
  518. };
  519. X
  520. /********************************************************************
  521. *    main ()                                                            *
  522. ********************************************************************/
  523. X
  524. main (argc, argv)
  525. int        argc;
  526. char    **argv;
  527. {
  528. X    Widget        new, prev;
  529. X    Widget        gifout;
  530. X    Arg            av[10];
  531. X    int            i, n;
  532. X    int            font_high, font_wide;
  533. X    char        depth_str[10];
  534. X    Dimension    text_high, text_wide;
  535. X    short        marg_high, marg_wide, mm;
  536. X    Position    text_loc;
  537. X    Position    nexty, y_button1, y_button2, y_selector;
  538. X    Dimension    ww, bb, hh;
  539. X    Position    xx, yy;
  540. X
  541. X    /*    initialize Xt Intrinsics */
  542. X    
  543. X    toplevel = XtInitialize (argv[0], "XMandel", NULL, 0, &argc, argv);
  544. X
  545. X    i = 0;
  546. X    XtSetArg (av[i], XmNallowShellResize, TRUE);        i++;
  547. X    XtSetValues (toplevel, av, i);
  548. X
  549. X    display = XtDisplay(toplevel);
  550. X    root = RootWindow (display, DefaultScreen(display));
  551. X    screen  = XtScreen (toplevel);
  552. X    depth = DefaultDepthOfScreen (XtScreen(toplevel));
  553. X    switch (depth)
  554. X    {
  555. X    case 8:        dots_per_byte = 1;  break;
  556. X    case 4:        dots_per_byte = 2;  break;
  557. X    case 2:        dots_per_byte = 4;    break;
  558. X    case 1:        dots_per_byte = 8;    break;
  559. X    default:    printf ("Cannot handle %d bit colour\n", depth);
  560. X                exit (1);
  561. X    }
  562. X    sprintf (depth_str, "%d", depth);        /*    default for "colour" button */
  563. X    manparm.rotation = juliaparm.rotation = depth;
  564. X
  565. X    /*    create a resizable container for user buttons and graphics */
  566. X
  567. X    i = 0;
  568. X    XtSetArg (av[i], XmNallowOverlap, True);            i++;
  569. X    XtSetArg (av[i], XmNresizePolicy, XmRESIZE_ANY);    i++;
  570. X    XtSetArg (av[i], XmNx, 0);                          i++;
  571. X    XtSetArg (av[i], XmNy,0);                              i++;
  572. X    bboard = XmCreateBulletinBoard (toplevel, "name", av, i);
  573. X
  574. X    i = 0;
  575. X    XtSetArg (av[i], XmNmarginHeight, &marg_high);            i++;
  576. X    XtSetArg (av[i], XmNmarginWidth,  &marg_wide);            i++;
  577. X    XtGetValues (bboard, av, i);
  578. X    
  579. X    font_box_size (bboard, &font_wide, &font_high);
  580. X    text_wide = font_wide * 10;
  581. X    text_high = font_high * 2;
  582. X    text_loc = 0;
  583. X
  584. X    /*    top 2 rows of push buttons */
  585. X    
  586. X    y_button1 = make_buttons (button, (5 * text_wide) / 3, text_high, marg_wide, marg_high);
  587. X    y_button2 = nexty = make_buttons (work, text_wide, text_high, marg_wide, y_button1);
  588. X
  589. X    /*    radio button and colour step */
  590. X
  591. X    y_selector = nexty = make_selector (bboard, marg_wide, y_button1, text_wide, text_high, font_wide);
  592. X
  593. X    /*    various x-y coordinate boxes */
  594. X
  595. X    nexty = MAX (y_button1, y_button2);
  596. X    nexty = MAX (nexty, y_selector);
  597. X    nexty = make_dialogue (bboard, enter, 6, nexty, 6, 15, font_wide, text_high + 6);
  598. X
  599. X    /*    disable editing of "point coordinates" */
  600. X    
  601. X    i = 0;
  602. X    XtSetArg(av[i], XmNeditable, False);            i++;
  603. X    prev = XtNameToWidget(bboard, "px");
  604. X    XtSetValues(prev, av, i);
  605. X    prev = XtNameToWidget(bboard, "py");
  606. X    XtSetValues(prev, av, i);
  607. X
  608. X    /*    "save" button for gif file: first get end of "fname" widget */
  609. X
  610. X    prev = XtNameToWidget(bboard, "fname");
  611. X    i = 0;
  612. X    XtSetArg(av[i], XmNwidth, &ww);                    i++;
  613. X    XtSetArg(av[i], XmNborderWidth, &bb);            i++;
  614. X    XtSetArg(av[i], XmNx, &xx);                        i++;
  615. X    XtGetValues(prev, av, i);
  616. X
  617. X    i = 0;
  618. X    XtSetArg (av[i], XmNx,         xx + ww + bb * 2 + 4);    i++;
  619. X    XtSetArg (av[i], XmNy,         y_button2 + 3);              i++;
  620. X    XtSetArg (av[i], XmNwidth,  text_wide);            i++;
  621. X    XtSetArg (av[i], XmNheight, text_high);            i++;
  622. X    gifout =  XtCreateManagedWidget ("Save", xmPushButtonWidgetClass, bboard, av, i);
  623. X    XtAddCallback (gifout, XmNactivateCallback, generate_gif, 0);
  624. X    XtManageChild (bboard);
  625. X
  626. X    manparm.lx = START_LX;
  627. X    manparm.ly = START_LY;
  628. X    manparm.ux = START_UX;
  629. X    manparm.uy = START_UY;
  630. X    activeimage = &manparm;
  631. X    update_coordinates (&manparm, 0);
  632. X    
  633. X    mandel_pixmap = XCreateBitmapFromData (XtDisplay (toplevel),
  634. X                        RootWindowOfScreen (XtScreen (toplevel)),
  635. X                        mandel_bits,
  636. X                        mandel_width,
  637. X                        mandel_height);
  638. X    XtSetArg (av[0], XtNiconPixmap, mandel_pixmap);
  639. X    XtSetValues (toplevel, av, 1);
  640. X
  641. X    XtRealizeWidget (toplevel);
  642. X    XtMainLoop ();
  643. }
  644. X
  645. /***********    button creation routines    *****************/
  646. X
  647. /************************************************************************
  648. *    make_button()  make a set of buttons based on the button table        *
  649. ************************************************************************/
  650. X
  651. static int make_buttons (button, text_wide, text_high, left_offset, top_offset)
  652. struct button_list *button;
  653. int        text_wide;
  654. int     text_high;
  655. int     left_offset;
  656. int     top_offset;
  657. {
  658. X    Arg            av[10];
  659. X    int            i, n;
  660. X    Position    nexty;
  661. X    int            text_loc;
  662. X    Widget         prev, new;
  663. X    
  664. X    text_loc = 0;
  665. X    for (prev = NULL, n = 0;  button[n].ident;  n++)
  666. X    {    i = 0;
  667. X        XtSetArg (av[i], XmNx,         button[n].x * (text_wide + 4) + left_offset);  i++;
  668. X        XtSetArg (av[i], XmNy,         button[n].y * (text_high + 4) + top_offset);  i++;
  669. X        XtSetArg (av[i], XmNwidth,   text_wide);                    i++;
  670. X        XtSetArg (av[i], XmNheight,  text_high);                    i++;
  671. X        new =  XtCreateManagedWidget (button[n].ident, xmPushButtonWidgetClass, bboard, av, i);
  672. X        XtAddCallback (new, XmNactivateCallback, button[n].bcall , 0);
  673. X        prev = new;
  674. X        text_loc = MAX (text_loc, button[n].y);
  675. X    }
  676. X    nexty = (text_loc+1) * (text_high + 4) + top_offset;
  677. X    return (nexty);
  678. }
  679. X
  680. /*    routines to make various buttons */
  681. X
  682. /************************************************************************
  683. *    make_dialogue()                make widgets to allow data entry        *
  684. ************************************************************************/
  685. X
  686. #define XSEP    6
  687. #define YSEP    0
  688. X
  689. static int make_dialogue (w, but, x, y, labelchars, textchars, font_wide, text_high)
  690. Widget         w;
  691. struct enter_buttons *but;        /*    list of buttons to create         */
  692. int            x;                    /*    x-offset in pixels                */
  693. int            y;                    /*    y-offset in pixels                */
  694. int         labelchars;            /*    labelwidth in characters        */
  695. int         textchars;            /*    textwidth in chars                */
  696. int            font_wide;
  697. int            text_high;
  698. {
  699. X    Widget        editor, activate;
  700. X    int            ncol;
  701. X    Dimension    labelwide, fieldwide;
  702. X    Position    labelx[10], fieldx[10];
  703. X    int            i, n;
  704. X    Arg            av[10];
  705. X    Position    thisy, nexty;
  706. X    XmString    str;
  707. X
  708. X    
  709. X    nexty = y;
  710. X    labelwide = labelchars;
  711. X    fieldwide = textchars + 2;
  712. X    ncol = 0;
  713. X    for (n = 0;  but[n].button;  n++)
  714. X    {    ncol  = MAX (ncol, but[n].bx);
  715. X    }
  716. X    ncol++;
  717. X    for (n = 0;  n < ncol;  n++)
  718. X    {
  719. X        labelx[n] = ((labelwide + fieldwide) * font_wide + XSEP ) * n + x;
  720. X        fieldx[n] = labelx[n] + labelwide * font_wide + XSEP;
  721. X    }
  722. X    for (n = 0;  but[n].button;  n++)
  723. X    {
  724. X        i = 0;
  725. X        str = XmStringCreateLtoR (but[n].button, XmSTRING_DEFAULT_CHARSET);
  726. X        XtSetArg (av[i], XmNx,         labelx[but[n].bx]);  i++;
  727. X        thisy = but[n].by * (text_high + YSEP) + y;
  728. X        nexty = MAX (thisy + text_high + YSEP, nexty);
  729. X        XtSetArg (av[i], XmNy,         thisy);  i++;
  730. X        if (but[n].field)
  731. X        {    XtSetArg (av[i], XmNwidth,  labelwide * font_wide );            i++;
  732. X        }
  733. X        else
  734. X        {    XtSetArg (av[i], XmNwidth,  strlen (but[n].button) * font_wide + XSEP);    i++;
  735. X        }        
  736. X        XtSetArg (av[i], XmNheight,  text_high);                    i++;
  737. X        XtSetArg (av[i], XmNlabelString, str);   i++;
  738. X        XtSetArg (av[i], XmNalignment, XmALIGNMENT_END);            i++;
  739. X        activate =  XtCreateManagedWidget (but[n].button, xmLabelGadgetClass, w, av, i);
  740. X
  741. X        if (but[n].field)
  742. X        {    i = 0;
  743. X            XtSetArg (av[i], XmNx,         fieldx[but[n].bx]);  i++;
  744. X            XtSetArg (av[i], XmNy,         but[n].by * (text_high + YSEP) + y);  i++;
  745. X            XtSetArg (av[i], XmNwidth,  (but[n].fsize + 2) * font_wide);                    i++;
  746. X            XtSetArg (av[i], XmNheight,  text_high);                    i++;
  747. X            editor = XtCreateManagedWidget (but[n].field, xmTextWidgetClass, w, av, i);
  748. X        }
  749. X        free (str);
  750. X    }
  751. X    return (nexty);
  752. }
  753. X
  754. X
  755. /************************************************************************
  756. *    make_selector()            make radio buttons and colour step widgets    *
  757. ************************************************************************/
  758. X
  759. static int make_selector (parent, xoffset, nexty, text_wide, text_high, font_wide)
  760. Widget         parent;
  761. int            xoffset;
  762. int            nexty;
  763. int            text_wide;
  764. int            text_high;
  765. int            font_wide;
  766. {
  767. X    int            i;
  768. X    Arg            av[10];
  769. X    Widget        row_column;
  770. X    Widget        activate;
  771. X    XmString    str;
  772. X    char        s[100];
  773. X    Dimension    hh;
  774. X    Position    yy;
  775. X    short        mm;
  776. X    char        *text = "Rotate:";
  777. X
  778. X    i = 0;
  779. X    XtSetArg (av[i], XmNx,         xoffset);            i++;
  780. X    XtSetArg (av[i], XmNy,         nexty);             i++;
  781. X    XtSetArg (av[i], XmNorientation, XmVERTICAL);    i++;
  782. X    XtSetArg (av[i], XmNradioBehavior, True);        i++;
  783. X    XtSetArg (av[i], XmNradioAlwaysOne, True);        i++;
  784. X    XtSetArg (av[i], XmNisHomogeneous,     False);        i++;
  785. X    row_column = XmCreateRowColumn (parent, "rowcol", av, i);
  786. X    XtManageChild (row_column);
  787. X    
  788. X    i = 0;
  789. X    XtSetArg (av[i], XmNset,              True);      i++;
  790. X    XtSetArg (av[i], XmNshadowThickness, 0);          i++;
  791. X    XtSetArg (av[i], XmNmarginHeight,      0);          i++;
  792. X    XtSetArg (av[i], XmNmarginWidth,      0);          i++;
  793. X    mandel_select =    XmCreateToggleButtonGadget (row_column, "mandel", av, i);
  794. X    XtManageChild (mandel_select);
  795. X    XtAddCallback (mandel_select, XmNdisarmCallback, do_select , 0);
  796. X
  797. X    i = 0;
  798. X    XtSetArg (av[i], XmNshadowThickness, 0);          i++;
  799. X    XtSetArg (av[i], XmNmarginHeight,      0);          i++;
  800. X    XtSetArg (av[i], XmNmarginWidth,      0);          i++;
  801. X    julia_select =     XmCreateToggleButtonGadget (row_column, "julia", av, i);
  802. X    XtManageChild (julia_select);
  803. X    XtAddCallback (julia_select, XmNdisarmCallback, do_select , 0);
  804. X
  805. X    button_set (NULL, False);
  806. X
  807. X    i = 0;
  808. X    XtSetArg (av[i], XmNx,         (text_wide + xoffset) * 3);     i++;
  809. X    XtSetArg (av[i], XmNy,         nexty + text_high + 6);        i++;
  810. X    str = XmStringCreateLtoR ("Rotate:", XmSTRING_DEFAULT_CHARSET);
  811. X    XtSetArg (av[i], XmNlabelString, str);   i++;
  812. X    activate =  XtCreateManagedWidget ("ctext", xmLabelGadgetClass, parent, av, i);
  813. X
  814. X    sprintf (s, "%d", activeimage->rotation);
  815. X    i = 0;
  816. X    yy = (text_wide + xoffset) * 3 + font_wide * strlen (text) + xoffset;
  817. X    XtSetArg (av[i], XmNx,         yy);                i++;
  818. X    XtSetArg (av[i], XmNy,         nexty + text_high);    i++;
  819. X    XtSetArg (av[i], XmNwidth,  6 * font_wide);        i++;
  820. X    XtSetArg (av[i], XmNvalue, s);  i++;
  821. X    cstep_value = XtCreateManagedWidget ("cstep", xmTextWidgetClass, parent, av, i);
  822. X    XtFree (str);
  823. X
  824. X    i = 0;
  825. X    XtSetArg(av[i], XmNheight, &hh);                i++;
  826. X    XtSetArg(av[i], XmNy, &yy);                        i++;
  827. X    XtSetArg (av[i], XmNmarginHeight, &mm);            i++;
  828. X    XtGetValues(row_column, av, i);
  829. X    return (yy + hh + mm*2);
  830. }
  831. X
  832. /************    callbacks    ***************/
  833. X
  834. /************************************************************************
  835. *    do_mandel()        button = mandel:    create/use mandelbrot window    *
  836. ************************************************************************/
  837. X
  838. static void do_mandel (w, client_data, call_data)
  839. Widget w;
  840. caddr_t client_data;
  841. caddr_t call_data;
  842. {    Dimension        wide;
  843. X    double            dx, dy;
  844. X    int                i;
  845. X    Arg                av[10];
  846. X
  847. X    if (manparm.window == 0)
  848. X    {    manparm.lx = START_LX;
  849. X        manparm.ly = START_LY;
  850. X        manparm.ux = START_UX;
  851. X        manparm.uy = START_UY;
  852. X        dx = START_UX - START_LX;
  853. X        dx = ABS (dx);
  854. X        dy = START_UY - START_LY;
  855. X        dy = ABS (dy);
  856. X        wide = 200;
  857. X        mandel_initial_height = (double) wide * (dy / dx);
  858. X
  859. X        i = 0;
  860. X        XtSetArg (av[i], XmNwidth,       wide);                    i++;
  861. X        XtSetArg (av[i], XmNheight,      mandel_initial_height);    i++;
  862. X        XtSetArg (av[i], XmNtitle,        "Mandelbrot");            i++;
  863. X        XtSetArg (av[i], XmNiconName,    "Mandel");                i++;
  864. X        mandelshell = XtCreateApplicationShell ("Mandelshell", topLevelShellWidgetClass, av, i);
  865. X        XtAddEventHandler (mandelshell, ExposureMask, FALSE,  expose_mandel, NULL);
  866. X
  867. X        manim_pixmap = XCreateBitmapFromData (XtDisplay (mandelshell),
  868. X                        RootWindowOfScreen (XtScreen (mandelshell)),
  869. X                        manim_bits,
  870. X                        manim_width,
  871. X                        manim_height);
  872. X        XtSetArg (av[0], XtNiconPixmap, manim_pixmap);
  873. X        XtSetValues (mandelshell, av, 1);
  874. X
  875. X        XtRealizeWidget (mandelshell);
  876. X        manparm.window = XtWindow (mandelshell);
  877. X    }
  878. X    activeimage = &manparm;
  879. X    button_set (mandel_select, True);
  880. X    update_coordinates (&manparm, 0);
  881. X    start_mandel ();
  882. }
  883. X
  884. /************************************************************************
  885. *    do_julia()        button = julia:        create/use julia window            *
  886. ************************************************************************/
  887. X
  888. static void do_julia (w, client_data, call_data)
  889. Widget w;
  890. caddr_t client_data;
  891. caddr_t call_data;
  892. {    int        i;
  893. X    Arg        av[10];
  894. X    struct imageparm *save;
  895. X
  896. X    if (manparm.window == 0)
  897. X        return;
  898. X    juliaparm.lx = -1.5;
  899. X    juliaparm.ly = -1.5;
  900. X    juliaparm.ux = 1.5;
  901. X    juliaparm.uy = 1.5;
  902. X
  903. X    if (juliashell == NULL)
  904. X    {    i = 0;
  905. X        XtSetArg (av[i], XmNwidth,       mandel_initial_height);        i++;
  906. X        XtSetArg (av[i], XmNheight,      mandel_initial_height);        i++;
  907. X        XtSetArg (av[i], XmNtitle,        "Julia");                    i++;
  908. X        XtSetArg (av[i], XmNiconName,    "Julia");                    i++;
  909. X        juliashell = XtCreateApplicationShell ("Juliashell", topLevelShellWidgetClass, av, i);
  910. X        XtAddEventHandler (juliashell, ExposureMask, FALSE,  expose_julia, NULL);
  911. X        XtAddCallback (juliashell, XmNdestroyCallback, do_remove , 0);
  912. X
  913. X        julim_pixmap = XCreateBitmapFromData (XtDisplay (juliashell),
  914. X                        RootWindowOfScreen (XtScreen (juliashell)),
  915. X                        julim_bits,
  916. X                        julim_width,
  917. X                        julim_height);
  918. X        XtSetArg (av[0], XtNiconPixmap, julim_pixmap);
  919. X        XtSetValues (juliashell, av, 1);
  920. X
  921. X        XtRealizeWidget (juliashell);
  922. X    }
  923. X    else
  924. X        XtMapWidget (juliashell);
  925. X    juliaparm.slx[0] =  juliaparm.sly[0]  =  juliaparm.sux[0]  =  juliaparm.suy[0] = 0;
  926. X    juliaparm.window = XtWindow (juliashell);
  927. X    juliaparm.totrot = 0;
  928. X    save = activeimage;
  929. X    activeimage = &manparm;
  930. X    update_control (activeimage);
  931. X    button_set (mandel_select, True);
  932. X    start_julia (1, 1);
  933. X    if (save != activeimage)
  934. X    {    activeimage = save;
  935. X        update_control (activeimage);
  936. X        button_set (julia_select, True);
  937. X    }
  938. }
  939. X
  940. /************************************************************************
  941. *    do_quit():        button = quit,   leave xmandel.                        *
  942. ************************************************************************/
  943. X
  944. static void do_quit (w, client_data, call_data)
  945. Widget w;
  946. caddr_t client_data;
  947. caddr_t call_data;
  948. {
  949. X    exit (0);
  950. }
  951. X
  952. /************************************************************************
  953. *    do_select    button = mandel/julia        select default set            *
  954. ************************************************************************/
  955. X
  956. static void do_select (w, client_data, call_data)
  957. Widget w;
  958. caddr_t client_data;
  959. XXmToggleButtonCallbackStruct  *call_data;
  960. {
  961. X    if (manparm.window == 0)
  962. X    {    button_set (NULL, False);
  963. X        return;
  964. X    }
  965. X    if (w == julia_select   &&  juliaparm.window == 0)
  966. X    {    button_set (mandel_select, True);
  967. X        activeimage = &manparm;
  968. X        return;
  969. X    }
  970. X    if (w == mandel_select)
  971. X    {    if (activeimage == &manparm)
  972. X            return;
  973. X        activeimage = &manparm;
  974. X    }
  975. X    else
  976. X    {    if (activeimage == &juliaparm)
  977. X            return;
  978. X        activeimage = &juliaparm;
  979. X    }
  980. X
  981. X    upintval    ("cstep", activeimage->rotation);
  982. X
  983. X    updoubleval ("flx", activeimage->lx);
  984. X    updoubleval ("fly", activeimage->ly);
  985. X    updoubleval ("fux", activeimage->ux);
  986. X    updoubleval ("fuy", activeimage->uy);
  987. X    updoubleval ("px",  activeimage->px);
  988. X    updoubleval ("py",  activeimage->py);
  989. X
  990. X    XFlush (display);
  991. }
  992. X
  993. static void button_set (w, how)
  994. Widget w;
  995. int how;
  996. {    int        i;
  997. X    Arg        av[10];
  998. X    Widget    on, off;
  999. X
  1000. X    if (w == NULL)
  1001. X    {    /*    set bot to on or off */
  1002. X        i = 0;
  1003. X        XtSetArg (av[i], XmNset, how);    i++;
  1004. X        XtSetValues (mandel_select, av, i);
  1005. X        XtSetValues (julia_select, av, i);
  1006. X    }
  1007. X    else
  1008. X    {    /*     set one to on, other to off */
  1009. X    
  1010. X        if (w == mandel_select)
  1011. X        {    if (how == True)
  1012. X            {    off = julia_select;
  1013. X                on  = mandel_select;
  1014. X            }
  1015. X            else
  1016. X            {    off = mandel_select;
  1017. X                on  = julia_select;
  1018. X            }
  1019. X        }
  1020. X        else
  1021. X        {    if (how == True)
  1022. X            {    on  = julia_select;
  1023. X                off = mandel_select;
  1024. X            }
  1025. X            else
  1026. X            {    on  = mandel_select;
  1027. X                off = julia_select;
  1028. X            }
  1029. X        }
  1030. X        i = 0;
  1031. X        XtSetArg (av[i], XmNset, False);    i++;
  1032. X        XtSetValues (off, av, i);
  1033. X        i = 0;
  1034. X        XtSetArg (av[i], XmNset, True);    i++;
  1035. X        XtSetValues (on, av, i);
  1036. X    }
  1037. }
  1038. X
  1039. /************************************************************************
  1040. *    set_zoom()        button = zoom: start the zoom                        *
  1041. ************************************************************************/
  1042. X
  1043. static void set_zoom (w, client_data, call_data)
  1044. Widget w;
  1045. caddr_t client_data;
  1046. caddr_t call_data;
  1047. {    struct zoomd *zoomtmp;
  1048. X
  1049. X    if (check_coord_change(activeimage))
  1050. X    {    zoomtmp = (struct zoomd *) malloc (sizeof (struct zoomd));
  1051. X        zoomtmp->zp = activeimage->zoom;        /* push onto stack */
  1052. X        zoomtmp->ux = activeimage->ux;
  1053. X        zoomtmp->lx = activeimage->lx;
  1054. X        zoomtmp->ly = activeimage->ly;
  1055. X        zoomtmp->uy = activeimage->uy;
  1056. X        if (activeimage->zoom == NULL)
  1057. X            zoomtmp->zp = NULL;
  1058. X        activeimage->zoom = zoomtmp;            /* activeimage->zoom is current pointer */
  1059. X        if (activeimage == &manparm)
  1060. X            redo_mandel ();
  1061. X        else
  1062. X            julia (1, 0);
  1063. X    }
  1064. X    else
  1065. X        do_zoom (w, client_data, call_data);    /*    normal zoom with mouse */
  1066. }
  1067. X
  1068. /************************************************************************
  1069. *    recalc()        button = recalc            recompute current image        *
  1070. ************************************************************************/
  1071. X
  1072. static void recalc (w, client_data, call_data)
  1073. Widget w;
  1074. caddr_t client_data;
  1075. caddr_t call_data;
  1076. {
  1077. X
  1078. X    if (check_coord_change(activeimage))
  1079. X    {    activeimage->zoom->ux = activeimage->ux;
  1080. X        activeimage->zoom->lx = activeimage->lx;
  1081. X        activeimage->zoom->ly = activeimage->ly;
  1082. X        activeimage->zoom->uy = activeimage->uy;
  1083. X    }
  1084. X
  1085. X    if (activeimage == &manparm)
  1086. X        redo_mandel();
  1087. X    else
  1088. X        julia (1, 0);
  1089. }
  1090. X
  1091. X
  1092. /************************************************************************
  1093. *    do_remove():        callback if julia window is closed.                *
  1094. ************************************************************************/
  1095. X
  1096. static void do_remove (w, client_data, call_data)
  1097. Widget w;
  1098. caddr_t client_data;
  1099. caddr_t call_data;
  1100. {
  1101. X    if (julia_in_progress)
  1102. X        return;
  1103. X    juliaparm.window = 0;
  1104. X    juliashell = NULL;
  1105. X    if (activeimage == &juliaparm)
  1106. X    {    activeimage = &manparm;
  1107. X        button_set (mandel_select, True);
  1108. X        update_control (activeimage);
  1109. X    }
  1110. }
  1111. X
  1112. /************************************************************************
  1113. *    generate_gif ()        button = save       write image to gif file        *
  1114. ************************************************************************/
  1115. X
  1116. static void generate_gif (w, client_data, call_data)
  1117. Widget w;
  1118. caddr_t client_data;
  1119. caddr_t call_data;
  1120. {
  1121. X    char     *s, *ss;
  1122. X    Widget    answer;
  1123. X
  1124. X    answer = XtNameToWidget(bboard, "fname");
  1125. X    if (answer == NULL)
  1126. X    {    printf ("Cannot find widget 'fname'\n");
  1127. X        exit (1);
  1128. X    }
  1129. X    s = XmTextGetString (answer);
  1130. X    if (s == NULL)
  1131. X        return;    
  1132. X    ss = tidy (s);
  1133. X    if (*ss  && activeimage->pix)
  1134. X        write_gif_image (ss, activeimage);
  1135. X    XtFree (s);
  1136. }
  1137. X
  1138. /************************************************************************
  1139. *    rotateplus            button = +colour    rotate colour positive        *
  1140. ************************************************************************/
  1141. X
  1142. static void rotateplus (w, client_data, call_data)
  1143. Widget w;
  1144. caddr_t client_data;
  1145. caddr_t call_data;
  1146. {
  1147. X    activeimage->rotation = current_rotate();
  1148. X    rotate (activeimage, activeimage->rotation);
  1149. X    if (activeimage == &manparm)
  1150. X        redraw_mandel (NULL);
  1151. X    else
  1152. X        redraw_julia (NULL);
  1153. }
  1154. X
  1155. /************************************************************************
  1156. *    rotateminus            button = -colour    rotate colour negative        *
  1157. ************************************************************************/
  1158. X
  1159. static void rotateminus (w, client_data, call_data)
  1160. Widget w;
  1161. caddr_t client_data;
  1162. caddr_t call_data;
  1163. {
  1164. X    rotate (activeimage, -activeimage->rotation);
  1165. X    if (activeimage == &manparm)
  1166. X        redraw_mandel (NULL);
  1167. X    else
  1168. X        redraw_julia (NULL);
  1169. }
  1170. X
  1171. /************************************************************************
  1172. *    rotate()            rotate the image through colours by val offset    *
  1173. ************************************************************************/
  1174. X
  1175. static void rotate (parm, val)
  1176. struct imageparm *parm;            /*    rotate this image        */
  1177. int val;                        /*    by this much.            */
  1178. {
  1179. X    int        nbits, x, y, im, i, ib;
  1180. X    unsigned char *b;
  1181. X    unsigned int mask[8];
  1182. X    unsigned int v[8];
  1183. X
  1184. X    /*    with a touch of brute force */
  1185. X
  1186. X    parm->totrot += val;
  1187. X    switch (depth)
  1188. X    {
  1189. X    case 8:
  1190. X        nbits = parm->pixheight * parm->pixwidth;
  1191. X        b = parm->pix;
  1192. X        while (nbits--)
  1193. X            *b++ += val;
  1194. X        break;
  1195. X
  1196. X    case 4:
  1197. X        for (i = 0;  i < 2;  i++)
  1198. X        {    mask[i] = (0x0f << i*4);
  1199. X            v[i] = val << i*4;
  1200. X        }
  1201. X        for (y = 0;  y < parm->pixheight;  y++)
  1202. X        {    b = parm->pix + y * parm->bytewidth;
  1203. X            for (x = 0;  x < parm->pixwidth;  x++)
  1204. X            {    im = (x % 2);
  1205. X                ib = x >> 1;
  1206. X                b[ib] = ((((unsigned int) (b[ib] & mask[im]) + (v[im]) & mask[im])) & mask[im])
  1207. X                        | ( b[ib] & ~mask[im]);
  1208. X            }
  1209. X        }
  1210. X        break;
  1211. X
  1212. X    case 2:
  1213. X        for (i = 0;  i < 4;  i++)
  1214. X        {    mask[i] = (0x03 << i*2);
  1215. X            v[i] = val << i*2;
  1216. X        }
  1217. X        for (y = 0;  y < parm->pixheight;  y++)
  1218. X        {    b = parm->pix + y * parm->bytewidth;
  1219. X            for (x = 0;  x < parm->pixwidth;  x++)
  1220. X            {    im = x % 4;
  1221. X                ib = x >> 2;
  1222. X                b[ib] = ((((unsigned int) (b[ib] & mask[im]) + (v[im]) & mask[im])) & mask[im])
  1223. X                        | ( b[ib] & ~mask[im]);
  1224. X            }
  1225. X        }
  1226. X        break;
  1227. X
  1228. X    case 1:
  1229. X        for (y = 0;  y < parm->pixheight;  y++)
  1230. X        {    b = parm->pix + y * parm->bytewidth;
  1231. X            for (x = 0;  x < parm->bytewidth;  x++)
  1232. X                b[x] = ~b[x];
  1233. X        }
  1234. X        break;
  1235. X    }
  1236. }
  1237. X
  1238. X
  1239. /***********    support routines    ***********/
  1240. X
  1241. /************************************************************************
  1242. *    current_rotate()        get current colour rotate from dialogue        *
  1243. ************************************************************************/
  1244. X
  1245. static int current_rotate ()
  1246. {    Widget     w;
  1247. X    char    *s;
  1248. X
  1249. X    w = XtNameToWidget(bboard, "cstep");
  1250. X    s = XmTextGetString (w);
  1251. X    return (atoi(s));
  1252. }
  1253. X
  1254. /************************************************************************
  1255. *    save_coord()  save text of usr coords to detect changes                *
  1256. ************************************************************************/
  1257. X
  1258. static void save_coord (image)
  1259. struct imageparm *image;
  1260. {    Widget     w;
  1261. X    char    *s;
  1262. X
  1263. X    XFlush (display);
  1264. X    if (w = XtNameToWidget(bboard, "flx"))
  1265. X    {    if (s = XmTextGetString (w))
  1266. X        {    strncpy (image->slx, s, SAVESIZE);
  1267. X            image->slx[SAVESIZE-1] = 0;
  1268. X            XtFree (s);
  1269. X        }
  1270. X    }
  1271. X    
  1272. X    if (w = XtNameToWidget(bboard, "fux"))
  1273. X    {    if (s = XmTextGetString (w))
  1274. X        {    strncpy (image->sux, s, SAVESIZE);
  1275. X            image->sux[SAVESIZE-1] = 0;
  1276. X            XtFree (s);
  1277. X        }
  1278. X    }
  1279. X
  1280. X    if (w = XtNameToWidget(bboard, "fly"))
  1281. X    {    if (s = XmTextGetString (w))
  1282. X        {    strncpy (image->sly, s, SAVESIZE);
  1283. X            image->sly[SAVESIZE-1] = 0;
  1284. X            XtFree (s);
  1285. X        }
  1286. X    }
  1287. X
  1288. X    if (w = XtNameToWidget(bboard, "fuy"))
  1289. X    {    if (s = XmTextGetString (w))
  1290. X        {    strncpy (image->suy, s, SAVESIZE);
  1291. X            image->suy[SAVESIZE-1] = 0;
  1292. X            XtFree (s);
  1293. X        }
  1294. X    }
  1295. }
  1296. X
  1297. X
  1298. /************************************************************************
  1299. *    check_coord_change()        did the user change the numbers.        *
  1300. ************************************************************************/
  1301. X
  1302. #define TinyV 0.000000001
  1303. X
  1304. static int check_coord_change (image)
  1305. struct imageparm *image;
  1306. {    Widget     w;
  1307. X    char    *s, *ss;
  1308. X    double    val, atof(), xu, yu, xl, yl;
  1309. X    int        changed;
  1310. X    
  1311. X    changed = 0;
  1312. X
  1313. X    if (image->slx[0] ||  image->sly[0]  ||  image->sux[0]  ||  image->suy[0])
  1314. X    {
  1315. X        w = XtNameToWidget(bboard, "flx");
  1316. X        s = XmTextGetString (w);
  1317. X        if (strcmp (image->slx, s))
  1318. X        {    ss = anynumber (s);
  1319. X            image->lx = atof (ss);
  1320. X            changed = 1;
  1321. X        }
  1322. X        XtFree (s);
  1323. X    
  1324. X        w = XtNameToWidget(bboard, "fux");
  1325. X        s = XmTextGetString (w);
  1326. X        if (strcmp (image->sux, s))
  1327. X        {    ss = anynumber (s);
  1328. X            image->ux = atof (ss);
  1329. X            changed = 1;
  1330. X        }
  1331. X        XtFree (s);
  1332. X
  1333. X        w = XtNameToWidget(bboard, "fly");
  1334. X        s = XmTextGetString (w);
  1335. X        if (strcmp (image->sly, s))
  1336. X        {    ss = anynumber (s);
  1337. X            image->ly = atof (ss);
  1338. X            changed = 1;
  1339. X        }
  1340. X        XtFree (s);
  1341. X
  1342. X        w = XtNameToWidget(bboard, "fuy");
  1343. X        s = XmTextGetString (w);
  1344. X        if (strcmp (image->suy, s))
  1345. X        {    ss = anynumber (s);
  1346. X            image->uy = atof (ss);
  1347. X            changed = 1;
  1348. X        }
  1349. X        XtFree (s);
  1350. X        if (changed)
  1351. X        {    /*    ensure user types something that won't cause failure */
  1352. X            xu = MAX (image->ux, image->lx);
  1353. X            xl = MIN (image->ux, image->lx);
  1354. X            yu = MAX (image->uy, image->ly);
  1355. X            yl = MIN (image->uy, image->ly);
  1356. X            if ((xu - xl) < TinyV)
  1357. X                xu = xl + TinyV;
  1358. X            if ((yu - yl) < TinyV)
  1359. X                yu = yl + TinyV;
  1360. X            image->ux = xu;
  1361. X            image->uy = yu;
  1362. X            image->lx = xl;
  1363. X            image->ly = yl;
  1364. X        }
  1365. X    }
  1366. X    return (changed);
  1367. }
  1368. X
  1369. /************************************************************************
  1370. *    up*()                various routines to update data entry fields.    *
  1371. ************************************************************************/
  1372. X
  1373. static void update_control (image)
  1374. struct imageparm *image;
  1375. {
  1376. X    update_coordinates (image, 0);
  1377. X    update_point (image);
  1378. }
  1379. X
  1380. void update_coordinates (image, lf)
  1381. struct imageparm *image;
  1382. int        lf;
  1383. {
  1384. X    if (image == activeimage)
  1385. X    {    updoubleval ("flx", image->lx);
  1386. X        updoubleval ("fly", image->ly);
  1387. X        updoubleval ("fux", image->ux);
  1388. X        updoubleval ("fuy", image->uy);
  1389. X        save_coord (image);
  1390. X    }
  1391. }
  1392. X
  1393. void update_point (image)
  1394. struct imageparm *image;
  1395. {
  1396. X    updoubleval ("px", image->px);
  1397. X    updoubleval ("py", image->py);
  1398. }
  1399. X
  1400. static void updoubleval (name, x)
  1401. char *name;
  1402. double x;
  1403. {    int        i;
  1404. X    Arg        av[10];
  1405. X    char    s[100];
  1406. X    Widget    w;
  1407. X
  1408. X    
  1409. X    sprintf (s, "%.8lf", x);
  1410. X    w = XtNameToWidget(bboard, name);
  1411. X    if (w == NULL)
  1412. X    {    printf ("Cannot find set widget [%s] to %s\n", name, s);
  1413. X        exit (1);
  1414. X    }
  1415. X    i = 0;
  1416. X    XtSetArg (av[i], XmNvalue, s);  i++;
  1417. X    XtSetValues (w, av, i);    
  1418. }
  1419. X
  1420. static void upintval (name, x)
  1421. char *name;
  1422. int x;
  1423. {    int        i;
  1424. X    Arg        av[10];
  1425. X    char    s[100];
  1426. X    Widget    w;
  1427. X
  1428. X    
  1429. X    i = 0;
  1430. X    XtSetArg (av[i], XmNvalue, s);  i++;
  1431. X    w = cstep_value;        /*    only this widget uses integers */
  1432. X    sprintf (s, "%d", x);
  1433. X    if (w == NULL)
  1434. X    {    printf ("Cannot find set widget [%s] to %s\n", name, s);
  1435. X        exit (1);
  1436. X    }
  1437. X    XtSetValues (w, av, i);    
  1438. }
  1439. X
  1440. X
  1441. /************************************************************************
  1442. *    font_box_size()                get size of font box for default font    *
  1443. ************************************************************************/
  1444. X
  1445. static void font_box_size (w, wide, high)
  1446. Widget w;
  1447. int *wide;            /*    returned font wdith        */
  1448. int    *high;            /*    returned font height    */
  1449. {    XFontStruct    *font;
  1450. X    XID            font_id;
  1451. X    int            screen_num;
  1452. X    
  1453. X    screen_num = DefaultScreen(display);
  1454. X    font_id = XGContextFromGC (DefaultGC (display, screen_num));
  1455. X    font = XQueryFont (display, font_id);
  1456. X
  1457. X    *high = font->max_bounds.ascent + font->max_bounds.descent;    
  1458. X    *wide = font->max_bounds.width;
  1459. }
  1460. X
  1461. X
  1462. /************************************************************************
  1463. *    tidy()        return the first non-blank word (ascii dependent!)        *
  1464. ************************************************************************/
  1465. X
  1466. static String tidy (s)
  1467. String s;
  1468. {    String cs;
  1469. X
  1470. X    while (*s  &&  *s == ' ')
  1471. X        s++;
  1472. X    cs = s;
  1473. X    while (*s  &&  *s > ' '  &&  *s <= 'z')
  1474. X        s++;
  1475. X    *s = 0;
  1476. X    return (cs);
  1477. }
  1478. X
  1479. X
  1480. X
  1481. /************************************************************************
  1482. *    anynumber()                get a numeric string from s                    *
  1483. ************************************************************************/
  1484. X
  1485. static char *anynumber (s)
  1486. char *s;
  1487. {
  1488. X    static char numstring[100];
  1489. X    char    *ns;
  1490. X    
  1491. X    ns = numstring;
  1492. X    while (*s  &&  ((*s >= '0'  &&  *s <= '9')  
  1493. X                    ||  *s == '+'  ||  *s == '-'  ||  *s == '.'))
  1494. X    {    *ns++ = *s++;
  1495. X    }
  1496. X    *ns = 0;
  1497. X    return (numstring);
  1498. }
  1499. X
  1500. X
  1501. #ifdef NEEDMEMCPY
  1502. X
  1503. /************************************************************************
  1504. *    memcpy()                slow version of memcpy                        *
  1505. ************************************************************************/
  1506. X
  1507. memcpy (dest, src, n)
  1508. char *dest, *src;
  1509. int n;
  1510. {
  1511. X    if (n > 0)
  1512. X    {    while (n--)
  1513. X            dest++ = *src++;
  1514. X    }
  1515. }
  1516. X
  1517. #endif
  1518. X
  1519. X
  1520. SHAR_EOF
  1521. chmod 0644 mainmotif.c ||
  1522. echo 'restore of mainmotif.c failed'
  1523. Wc_c="`wc -c < 'mainmotif.c'`"
  1524. test 30806 -eq "$Wc_c" ||
  1525.     echo 'mainmotif.c: original size 30806, current size' "$Wc_c"
  1526. rm -f _shar_wnt_.tmp
  1527. fi
  1528. # ============= mandel.bit ==============
  1529. if test -f 'mandel.bit' -a X"$1" != X"-c"; then
  1530.     echo 'x - skipping mandel.bit (File already exists)'
  1531.     rm -f _shar_wnt_.tmp
  1532. else
  1533. > _shar_wnt_.tmp
  1534. echo 'x - extracting mandel.bit (Text)'
  1535. sed 's/^X//' << 'SHAR_EOF' > 'mandel.bit' &&
  1536. #define mandel_width 48
  1537. #define mandel_height 48
  1538. static char mandel_bits[] = {
  1539. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1540. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
  1541. X   0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00,
  1542. X   0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
  1543. X   0x00, 0x00, 0x00, 0x80, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0x00,
  1544. X   0x00, 0x00, 0x00, 0x84, 0x31, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1b, 0x04,
  1545. X   0x00, 0x00, 0x00, 0xe7, 0xfb, 0x1c, 0x00, 0x00, 0x00, 0xfe, 0xe0, 0x0f,
  1546. X   0x00, 0x80, 0x00, 0x1c, 0x00, 0x07, 0x00, 0x80, 0x01, 0x0e, 0x00, 0x0e,
  1547. X   0x00, 0xe0, 0x00, 0x07, 0x00, 0x1c, 0x00, 0x80, 0x0f, 0x03, 0x00, 0x58,
  1548. X   0x00, 0xc0, 0x9f, 0x03, 0x00, 0xf8, 0x00, 0xe1, 0xf9, 0x01, 0x00, 0x30,
  1549. X   0x00, 0x6a, 0xe0, 0x00, 0x00, 0x38, 0x00, 0x7c, 0x40, 0x00, 0x00, 0x38,
  1550. X   0x18, 0x26, 0x00, 0x00, 0x00, 0x1c, 0xe7, 0x03, 0x00, 0x00, 0x00, 0x0e,
  1551. X   0x18, 0x26, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x7c, 0x40, 0x00, 0x00, 0x38,
  1552. X   0x00, 0x6a, 0xe0, 0x00, 0x00, 0x38, 0x00, 0xe1, 0xf9, 0x01, 0x00, 0x30,
  1553. X   0x00, 0xc0, 0x9f, 0x03, 0x00, 0xf8, 0x00, 0x80, 0x0f, 0x03, 0x00, 0x58,
  1554. X   0x00, 0xe0, 0x00, 0x07, 0x00, 0x1c, 0x00, 0x80, 0x01, 0x0e, 0x00, 0x0e,
  1555. X   0x00, 0x80, 0x00, 0x1c, 0x00, 0x07, 0x00, 0x00, 0x00, 0xfe, 0xe0, 0x0f,
  1556. X   0x00, 0x00, 0x00, 0xe7, 0xfb, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x1b, 0x04,
  1557. X   0x00, 0x00, 0x00, 0x84, 0x31, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0x00,
  1558. X   0x00, 0x00, 0x00, 0x80, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
  1559. X   0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00,
  1560. X   0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
  1561. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1562. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  1563. X
  1564. #define manmask_width 48
  1565. #define manmask_height 48
  1566. static char manmask_bits[] = {
  1567. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1568. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
  1569. X   0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
  1570. X   0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00,
  1571. X   0x00, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x7f, 0x00,
  1572. X   0x00, 0x00, 0x00, 0x84, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1f, 0x04,
  1573. X   0x00, 0x00, 0x80, 0xef, 0xff, 0x1c, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f,
  1574. X   0x00, 0x80, 0x00, 0xff, 0xff, 0x03, 0x00, 0x80, 0x01, 0xfe, 0xff, 0x07,
  1575. X   0x00, 0xe0, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x80, 0x1f, 0xff, 0xff, 0x5f,
  1576. X   0x00, 0xc0, 0xbf, 0xff, 0xff, 0xff, 0x00, 0xed, 0xff, 0xff, 0xff, 0x3f,
  1577. X   0x00, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1f,
  1578. X   0x98, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07,
  1579. X   0x98, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1f,
  1580. X   0x00, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x00, 0xed, 0xff, 0xff, 0xff, 0x3f,
  1581. X   0x00, 0xc0, 0xbf, 0xff, 0xff, 0xff, 0x00, 0x80, 0x1f, 0xff, 0xff, 0x5f,
  1582. X   0x00, 0xe0, 0x00, 0xfe, 0xff, 0x0f, 0x00, 0x80, 0x01, 0xfe, 0xff, 0x07,
  1583. X   0x00, 0x80, 0x00, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f,
  1584. X   0x00, 0x00, 0x80, 0xef, 0xff, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x1f, 0x04,
  1585. X   0x00, 0x00, 0x00, 0x84, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xc4, 0x7f, 0x00,
  1586. X   0x00, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00,
  1587. X   0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
  1588. X   0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
  1589. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1590. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  1591. X
  1592. #ifdef MOTIF
  1593. X
  1594. #define manim_height 48
  1595. #define manim_width  48
  1596. static char manim_bits[] = {
  1597. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1598. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
  1599. X   0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00,
  1600. X   0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
  1601. X   0x00, 0x00, 0x00, 0x80, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0x00,
  1602. X   0x00, 0x00, 0x00, 0x84, 0x31, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1b, 0x04,
  1603. X   0x00, 0x00, 0x00, 0xe7, 0xfb, 0x1c, 0x00, 0x00, 0x00, 0xfe, 0xe0, 0x0f,
  1604. X   0x00, 0x80, 0x00, 0x1c, 0x00, 0x07, 0x00, 0x80, 0x01, 0x0e, 0x00, 0x0e,
  1605. X   0x00, 0xe0, 0x00, 0x47, 0x40, 0x1c, 0x00, 0x80, 0x0f, 0x63, 0xc0, 0x58,
  1606. X   0x00, 0xc0, 0x9f, 0xe3, 0xe0, 0xf8, 0x00, 0xe1, 0xf9, 0xc1, 0x60, 0x30,
  1607. X   0x00, 0x6a, 0xe0, 0xe0, 0xe0, 0x38, 0x00, 0x7c, 0x40, 0xe0, 0xf1, 0x38,
  1608. X   0x18, 0x26, 0x00, 0x40, 0x5b, 0x1c, 0xe7, 0x03, 0x00, 0x40, 0x5f, 0x0e,
  1609. X   0x18, 0x26, 0x00, 0x40, 0x4e, 0x1c, 0x00, 0x7c, 0x40, 0xc0, 0x64, 0x38,
  1610. X   0x00, 0x6a, 0xe0, 0xc0, 0x60, 0x38, 0x00, 0xe1, 0xf9, 0xc1, 0x60, 0x30,
  1611. X   0x00, 0xc0, 0x9f, 0x63, 0xc0, 0xf8, 0x00, 0x80, 0x0f, 0x33, 0x80, 0x59,
  1612. X   0x00, 0xe0, 0x00, 0x07, 0x00, 0x1c, 0x00, 0x80, 0x01, 0x0e, 0x00, 0x0e,
  1613. X   0x00, 0x80, 0x00, 0x1c, 0x00, 0x07, 0x00, 0x00, 0x00, 0xfe, 0xe0, 0x0f,
  1614. X   0x00, 0x00, 0x00, 0xe7, 0xfb, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x1b, 0x04,
  1615. X   0x00, 0x00, 0x00, 0x84, 0x31, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0x00,
  1616. X   0x00, 0x00, 0x00, 0x80, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
  1617. X   0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00,
  1618. X   0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
  1619. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1620. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  1621. X
  1622. #endif
  1623. X
  1624. #define julim_width 48
  1625. #define julim_height 48
  1626. static char julim_bits[] = {
  1627. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1628. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
  1629. X   0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00,
  1630. X   0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
  1631. X   0x00, 0x00, 0x00, 0x80, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0x00,
  1632. X   0x00, 0x00, 0x00, 0x84, 0x31, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1b, 0x04,
  1633. X   0x00, 0x00, 0x00, 0xe7, 0xfb, 0x1c, 0x00, 0x00, 0x00, 0xfe, 0xe0, 0x0f,
  1634. X   0x00, 0x80, 0x00, 0x1c, 0x00, 0x07, 0x00, 0x80, 0x01, 0x0e, 0x00, 0x0e,
  1635. X   0x00, 0xe0, 0x00, 0x07, 0x00, 0x1c, 0x00, 0x80, 0x0f, 0x03, 0x80, 0x59,
  1636. X   0x00, 0xc0, 0x9f, 0x83, 0xff, 0xf8, 0x00, 0xe1, 0xf9, 0xc1, 0x7f, 0x30,
  1637. X   0x00, 0x6a, 0xe0, 0x60, 0x18, 0x38, 0x00, 0x7c, 0x40, 0x00, 0x18, 0x38,
  1638. X   0x18, 0x26, 0x00, 0x00, 0x1c, 0x1c, 0xe7, 0x03, 0x00, 0x00, 0x1c, 0x0e,
  1639. X   0x18, 0x26, 0x00, 0x00, 0x3a, 0x1c, 0x00, 0x7c, 0x40, 0x40, 0x1c, 0x38,
  1640. X   0x00, 0x6a, 0xe0, 0xe0, 0x1c, 0x38, 0x00, 0xe1, 0xf9, 0x71, 0x18, 0x30,
  1641. X   0x00, 0xc0, 0x9f, 0x6b, 0x18, 0xf8, 0x00, 0x80, 0x0f, 0xe3, 0x18, 0x58,
  1642. X   0x00, 0xe0, 0x00, 0xc7, 0x1f, 0x1c, 0x00, 0x80, 0x01, 0x8e, 0x0f, 0x0e,
  1643. X   0x00, 0x80, 0x00, 0x1c, 0x00, 0x07, 0x00, 0x00, 0x00, 0xfe, 0xe0, 0x0f,
  1644. X   0x00, 0x00, 0x00, 0xe7, 0xfb, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x1b, 0x04,
  1645. X   0x00, 0x00, 0x00, 0x84, 0x31, 0x00, 0x00, 0x00, 0x00, 0x80, 0x31, 0x00,
  1646. X   0x00, 0x00, 0x00, 0x80, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
  1647. X   0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00,
  1648. X   0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
  1649. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1650. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  1651. SHAR_EOF
  1652. chmod 0644 mandel.bit ||
  1653. echo 'restore of mandel.bit failed'
  1654. Wc_c="`wc -c < 'mandel.bit'`"
  1655. test 7543 -eq "$Wc_c" ||
  1656.     echo 'mandel.bit: original size 7543, current size' "$Wc_c"
  1657. rm -f _shar_wnt_.tmp
  1658. fi
  1659. # ============= mandel.c ==============
  1660. if test -f 'mandel.c' -a X"$1" != X"-c"; then
  1661.     echo 'x - skipping mandel.c (File already exists)'
  1662.     rm -f _shar_wnt_.tmp
  1663. else
  1664. > _shar_wnt_.tmp
  1665. echo 'x - extracting mandel.c (Text)'
  1666. sed 's/^X//' << 'SHAR_EOF' > 'mandel.c' &&
  1667. /* ta=4 */
  1668. X
  1669. #include <stdio.h>
  1670. #include <X11/Intrinsic.h>
  1671. #include "mandel.h"
  1672. X
  1673. struct imageparm manparm = { 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0, NULL, NULL, "\0", "\0", "\0", "\0" };
  1674. X
  1675. extern Display *display;
  1676. extern Screen *screen;
  1677. extern struct imageparm *activeimage;
  1678. X
  1679. static int    scanline = -1;
  1680. X
  1681. static struct zoomd *zoomtmp;
  1682. /*
  1683. char *malloc(), *calloc();
  1684. */
  1685. extern int depth;                /*    depth of bit plane                */
  1686. extern int    dots_per_byte;
  1687. int bias = 16;                    /* bias into color table */
  1688. X
  1689. static XImage *ximage = NULL;
  1690. static char *image_data = NULL;
  1691. X
  1692. #ifdef __STDC__
  1693. static void mandel();
  1694. #else
  1695. static void mandel();
  1696. #endif
  1697. X
  1698. X
  1699. /************************************************************************
  1700. *    do_mandel()            button: mandel,     compute mandelbort set        *
  1701. ************************************************************************/
  1702. SHAR_EOF
  1703. true || echo 'restore of mandel.c failed'
  1704. fi
  1705. echo 'End of  part 2'
  1706. echo 'File mandel.c is continued in part 3'
  1707. echo 3 > _shar_seq_.tmp
  1708. exit 0
  1709. -- 
  1710. --
  1711. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1712. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1713. Sunnyvale, California 94086            at&t: 408/522-9236
  1714.