home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xfig / part25 < prev    next >
Encoding:
Text File  |  1993-05-26  |  67.4 KB  |  2,393 lines

  1. Newsgroups: comp.sources.x
  2. From: envbvs@epb9.lbl.gov (Brian V. Smith)
  3. Subject: v19i137:  xfig - Draw amd manipulate objects in an X-Window, Part25/27
  4. Message-ID: <1993May21.021801.7711@sparky.imd.sterling.com>
  5. X-Md4-Signature: c0dee1d71d41adc68f3c1b4308929723
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Fri, 21 May 1993 02:18:01 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: envbvs@epb9.lbl.gov (Brian V. Smith)
  12. Posting-number: Volume 19, Issue 137
  13. Archive-name: xfig/part25
  14. Environment: X11
  15. Supersedes: xfig: Volume 16, Issue 6-30,39
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 25 (of 27)."
  24. # Contents:  e_edit.c
  25. # Wrapped by envbvs@epb9.lbl.gov.lbl.gov on Mon May  3 12:06:09 1993
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'e_edit.c' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'e_edit.c'\"
  29. else
  30. echo shar: Extracting \"'e_edit.c'\" \(64464 characters\)
  31. sed "s/^X//" >'e_edit.c' <<'END_OF_FILE'
  32. X/*
  33. X * FIG : Facility for Interactive Generation of figures
  34. X * Copyright (c) 1985 by Supoj Sutanthavibul
  35. X * Change function implemented by Frank Schmuck (schmuck@svax.cs.cornell.edu)
  36. X * X version by Jon Tombs <jon@uk.ac.oxford.robots>
  37. X *
  38. X * "Permission to use, copy, modify, distribute, and sell this software and its
  39. X * documentation for any purpose is hereby granted without fee, provided that
  40. X * the above copyright notice appear in all copies and that both the copyright
  41. X * notice and this permission notice appear in supporting documentation. 
  42. X * No representations are made about the suitability of this software for 
  43. X * any purpose.  It is provided "as is" without express or implied warranty."
  44. X */
  45. X
  46. X#include "fig.h"
  47. X#include "figx.h"
  48. X#include "resources.h"
  49. X#include "mode.h"
  50. X#include "object.h"
  51. X#include "paintop.h"
  52. X#include "u_fonts.h"
  53. X#include "u_search.h"
  54. X#include "u_list.h"
  55. X#include "u_create.h"
  56. X#include "w_canvas.h"
  57. X#include "w_drawprim.h"
  58. X#include "w_icons.h"
  59. X#include "w_util.h"
  60. X#include "w_mousefun.h"
  61. X
  62. Xextern char    *panel_get_value();
  63. Xextern PIX_ROT_FONT lookfont();
  64. XWidget        make_popup_menu();
  65. Xstatic Widget    make_color_popup_menu();
  66. X
  67. Xextern Pixmap    psfont_menu_bitmaps[];
  68. Xextern Pixmap    latexfont_menu_bitmaps[];
  69. Xextern void    Quit();
  70. Xextern        fontpane_popup();
  71. X
  72. Xstatic void    new_generic_values();
  73. Xstatic void    new_arrow_values();
  74. Xstatic        generic_window();
  75. Xstatic        font_image_panel();
  76. Xstatic        color_selection_panel();
  77. Xstatic        float_panel();
  78. Xstatic        float_label();
  79. Xstatic        int_panel();
  80. Xstatic        int_label();
  81. Xstatic        str_panel();
  82. Xstatic        xy_panel();
  83. Xstatic        f_pos_panel();
  84. Xstatic        get_f_pos();
  85. Xstatic        points_panel();
  86. Xstatic        get_points();
  87. Xint        panel_set_value();
  88. Xstatic XtCallbackProc done_button(), apply_button(), cancel_button();
  89. Xstatic XtCallbackProc toggle_for_arrow(), toggle_back_arrow();
  90. Xstatic void    line_style_select();
  91. Xstatic void    textjust_select();
  92. Xstatic void    fill_style_select();
  93. Xstatic void    flip_eps_select();
  94. Xstatic void    hidden_text_select();
  95. Xstatic void    rigid_text_select();
  96. Xstatic void    special_text_select();
  97. Xstatic void    color_select();
  98. Xstatic void    set_color_name();
  99. Xstatic Widget    popup, form;
  100. Xstatic Widget    below, beside;
  101. X
  102. X#define NUM_IMAGES    16
  103. X
  104. Xstatic int    done_line();
  105. Xstatic int    done_text();
  106. Xstatic int    done_arc();
  107. Xstatic int    done_ellipse();
  108. Xstatic int    done_spline();
  109. Xstatic int    done_compound();
  110. X
  111. Xstatic Widget    origsize;
  112. Xstatic Widget    shrink, expand;
  113. Xstatic Widget    label;
  114. Xstatic Widget    thickness_panel;
  115. Xstatic Widget    color_panel;
  116. Xstatic Widget    depth_panel;
  117. Xstatic Widget    angle_panel;
  118. Xstatic Widget    textjust_panel;
  119. Xstatic Widget    hidden_text_panel;
  120. Xstatic Widget    rigid_text_panel;
  121. Xstatic Widget    special_text_panel;
  122. Xstatic Widget    fill_style_panel;
  123. Xstatic Widget    flip_eps_panel;
  124. Xstatic Widget    style_val_label;
  125. Xstatic Widget    fill_style_label;
  126. Xstatic Widget    style_panel;
  127. Xstatic Widget    style_val_panel;
  128. Xstatic Widget    for_arrow_height,for_arrow_width,for_arrow_thick;
  129. Xstatic Widget    back_arrow_height,back_arrow_width,back_arrow_thick;
  130. Xstatic Widget    for_thick_label,for_height_label,for_width_label;
  131. Xstatic Widget    back_thick_label,back_height_label,back_width_label;
  132. Xstatic Widget    for_thick_val,for_height_val,for_width_val;
  133. Xstatic Widget    back_thick_val,back_height_val,back_width_val;
  134. Xstatic Boolean    for_arrow, back_arrow;
  135. X
  136. Xstatic Widget    text_panel;
  137. Xstatic Widget    eps_name_panel;
  138. Xstatic Widget    x1_panel, y1_panel;
  139. Xstatic Widget    x2_panel, y2_panel;
  140. Xstatic Widget    x3_panel, y3_panel;
  141. Xstatic Widget    hw_ratio_panel;
  142. Xstatic Widget    orig_hw_panel;
  143. Xstatic Widget    rotn_panel;
  144. Xstatic Widget    font_panel;
  145. Xstatic Widget    cur_fontsize_panel;
  146. Xstatic Widget    fill_flag_panel;
  147. Xstatic Widget    radius, num_objects;
  148. Xstatic Widget    menu, hidden_text_menu, textjust_menu;
  149. Xstatic Widget    special_text_menu, rigid_text_menu;
  150. Xstatic Widget    but1;
  151. X
  152. XDeclareStaticArgs(12);
  153. Xstatic char    buf[64];
  154. X
  155. Xstatic Widget    px_panel[MAXNUMPTS];
  156. Xstatic Widget    py_panel[MAXNUMPTS];
  157. X
  158. Xstatic int    ellipse_flag;
  159. Xstatic int    fill_flag;
  160. Xstatic int    flip_eps_flag;
  161. Xstatic int    (*done_proc) ();
  162. Xstatic int    button_result;
  163. Xstatic int    textjust;
  164. Xstatic Color    color;
  165. Xstatic int    hidden_text_flag;
  166. Xstatic int    special_text_flag;
  167. Xstatic int    rigid_text_flag;
  168. Xstatic int    new_ps_font, new_latex_font;
  169. Xstatic int    new_psflag;
  170. Xstatic int    changed;
  171. X
  172. Xstatic String   edit_translations =
  173. X    "<Message>WM_PROTOCOLS: DoneEdit()\n";
  174. Xstatic void     edit_cancel();
  175. Xstatic XtActionsRec     edit_actions[] =
  176. X{
  177. X    {"DoneEdit", (XtActionProc) edit_cancel},
  178. X};
  179. X
  180. X
  181. X#define CANCEL        0
  182. X#define DONE        1
  183. X#define APPLY        2
  184. X
  185. Xstatic struct {
  186. X    int            thickness;
  187. X    Color        color;
  188. X    int            depth;
  189. X    int            style;
  190. X    float        style_val;
  191. X    int            pen;
  192. X    int            fill_style;
  193. X    F_arrow       *for_arrow;
  194. X    F_arrow       *back_arrow;
  195. X}        generic_vals;
  196. X
  197. X#define put_generic_vals(x) \
  198. X    generic_vals.thickness    = x->thickness; \
  199. X    generic_vals.color    = x->color; \
  200. X    generic_vals.depth    = x->depth; \
  201. X    generic_vals.style    = x->style; \
  202. X    generic_vals.style_val    = x->style_val; \
  203. X    generic_vals.pen    = x->pen; \
  204. X    generic_vals.fill_style = x->fill_style
  205. X
  206. X#define get_generic_vals(x) \
  207. X    new_generic_values(); \
  208. X    x->thickness    = generic_vals.thickness; \
  209. X    x->color    = generic_vals.color; \
  210. X    x->depth    = generic_vals.depth; \
  211. X    x->style    = generic_vals.style; \
  212. X    x->style_val    = generic_vals.style_val; \
  213. X    x->pen        = generic_vals.pen; \
  214. X    x->fill_style    = generic_vals.fill_style
  215. X
  216. X#define put_generic_arrows(x) \
  217. X    generic_vals.for_arrow    = x->for_arrow; \
  218. X    generic_vals.back_arrow = x->back_arrow
  219. X
  220. X#define get_generic_arrows(x) \
  221. X    new_arrow_values(); \
  222. X    x->for_arrow  = (for_arrow?  generic_vals.for_arrow  : NULL); \
  223. X    x->back_arrow = (back_arrow? generic_vals.back_arrow : NULL)
  224. X
  225. Xint        edit_item();
  226. X
  227. Xedit_item_selected()
  228. X{
  229. X    set_mousefun("edit object", "", "");
  230. X    canvas_kbd_proc = null_proc;
  231. X    canvas_locmove_proc = null_proc;
  232. X    init_searchproc_left(edit_item);
  233. X    canvas_leftbut_proc = object_search_left;
  234. X    canvas_middlebut_proc = null_proc;
  235. X    canvas_rightbut_proc = null_proc;
  236. X    set_cursor(pick9_cursor);
  237. X    reset_action_on();
  238. X}
  239. X
  240. Xedit_item(p, type, x, y)
  241. X    char       *p;
  242. X    int            type;
  243. X    int            x, y;
  244. X{
  245. X    extern Atom wm_delete_window;
  246. X
  247. X    changed = 0;
  248. X    switch (type) {
  249. X    case O_POLYLINE:
  250. X    make_window_line((F_line *) p);
  251. X    break;
  252. X    case O_TEXT:
  253. X    make_window_text((F_text *) p);
  254. X    break;
  255. X    case O_ELLIPSE:
  256. X    make_window_ellipse((F_ellipse *) p);
  257. X    break;
  258. X    case O_ARC:
  259. X    make_window_arc((F_arc *) p);
  260. X    break;
  261. X    case O_SPLINE:
  262. X    make_window_spline((F_spline *) p);
  263. X    break;
  264. X    case O_COMPOUND:
  265. X    make_window_compound((F_compound *) p);
  266. X    break;
  267. X    }
  268. X
  269. X    XtPopup(popup, XtGrabExclusive);
  270. X    (void) XSetWMProtocols(XtDisplay(popup), XtWindow(popup),
  271. X                 &wm_delete_window, 1);
  272. X
  273. X}
  274. X
  275. Xstatic void
  276. Xexpand_eps(w, ev)
  277. X    Widget        w;
  278. X    XButtonEvent   *ev;
  279. X{
  280. X    struct f_point  p1, p2;
  281. X    int            dx, dy, rotation;
  282. X    float        ratio;
  283. X    register float  orig_ratio = new_l->eps->hw_ratio;
  284. X
  285. X    p1.x = atoi(panel_get_value(x1_panel));
  286. X    p1.y = atoi(panel_get_value(y1_panel));
  287. X    p2.x = atoi(panel_get_value(x2_panel));
  288. X    p2.y = atoi(panel_get_value(y2_panel));
  289. X    dx = p2.x - p1.x;
  290. X    dy = p2.y - p1.y;
  291. X    rotation = 0;
  292. X    if (dx < 0 && dy < 0)
  293. X    rotation = 180;
  294. X    else if (dx < 0 && dy >= 0)
  295. X    rotation = 270;
  296. X    else if (dy < 0 && dx >= 0)
  297. X    rotation = 90;
  298. X    if (dx == 0 || dy == 0 || orig_ratio == 0.0)
  299. X    return;
  300. X    if (((rotation == 0 || rotation == 180) && !flip_eps_flag) ||
  301. X    (rotation != 0 && rotation != 180 && flip_eps_flag)) {
  302. X    ratio = fabs((float) dy / (float) dx);
  303. X    if (ratio < orig_ratio)
  304. X        p2.y = p1.y + signof(dy) * (int) (fabs((float) dx) * orig_ratio);
  305. X    else
  306. X        p2.x = p1.x + signof(dx) * (int) (fabs((float) dy) / orig_ratio);
  307. X    } else {
  308. X    ratio = fabs((float) dx / (float) dy);
  309. X    if (ratio < orig_ratio)
  310. X        p2.x = p1.x + signof(dx) * (int) (fabs((float) dy) * orig_ratio);
  311. X    else
  312. X        p2.y = p1.y + signof(dy) * (int) (fabs((float) dx) / orig_ratio);
  313. X    }
  314. X    sprintf(buf, "%d", p2.x);
  315. X    panel_set_value(x2_panel, buf);
  316. X    sprintf(buf, "%d", p2.y);
  317. X    panel_set_value(y2_panel, buf);
  318. X    sprintf(buf, "%1.1f", orig_ratio);
  319. X    FirstArg(XtNlabel, buf);
  320. X    SetValues(hw_ratio_panel);
  321. X}
  322. X
  323. Xstatic void
  324. Xshrink_eps(w, ev)
  325. X    Widget        w;
  326. X    XButtonEvent   *ev;
  327. X{
  328. X    struct f_point  p1, p2;
  329. X    int            dx, dy, rotation;
  330. X    float        ratio;
  331. X    register float  orig_ratio = new_l->eps->hw_ratio;
  332. X
  333. X    p1.x = atoi(panel_get_value(x1_panel));
  334. X    p1.y = atoi(panel_get_value(y1_panel));
  335. X    p2.x = atoi(panel_get_value(x2_panel));
  336. X    p2.y = atoi(panel_get_value(y2_panel));
  337. X    dx = p2.x - p1.x;
  338. X    dy = p2.y - p1.y;
  339. X    rotation = 0;
  340. X    if (dx < 0 && dy < 0)
  341. X    rotation = 180;
  342. X    else if (dx < 0 && dy >= 0)
  343. X    rotation = 270;
  344. X    else if (dy < 0 && dx >= 0)
  345. X    rotation = 90;
  346. X    if (dx == 0 || dy == 0 || orig_ratio == 0.0)
  347. X    return;
  348. X    if (((rotation == 0 || rotation == 180) && !flip_eps_flag) ||
  349. X    (rotation != 0 && rotation != 180 && flip_eps_flag)) {
  350. X    ratio = fabs((float) dy / (float) dx);
  351. X    if (ratio > orig_ratio)
  352. X        p2.y = p1.y + signof(dy) * (int) (fabs((float) dx) * orig_ratio);
  353. X    else
  354. X        p2.x = p1.x + signof(dx) * (int) (fabs((float) dy) / orig_ratio);
  355. X    } else {
  356. X    ratio = fabs((float) dx / (float) dy);
  357. X    if (ratio > orig_ratio)
  358. X        p2.x = p1.x + signof(dx) * (int) (fabs((float) dy) * orig_ratio);
  359. X    else
  360. X        p2.y = p1.y + signof(dy) * (int) (fabs((float) dx) / orig_ratio);
  361. X    }
  362. X    sprintf(buf, "%d", p2.x);
  363. X    panel_set_value(x2_panel, buf);
  364. X    sprintf(buf, "%d", p2.y);
  365. X    panel_set_value(y2_panel, buf);
  366. X    sprintf(buf, "%1.1f", orig_ratio);
  367. X    FirstArg(XtNlabel, buf);
  368. X    SetValues(hw_ratio_panel);
  369. X}
  370. X
  371. Xstatic void
  372. Xorigsize_eps(w, ev)
  373. X    Widget        w;
  374. X    XButtonEvent   *ev;
  375. X{
  376. X    struct f_point  p1, p2;
  377. X    int            dx, dy, rotation;
  378. X    float        ratio;
  379. X    register float  orig_ratio = new_l->eps->hw_ratio;
  380. X
  381. X    p1.x = atoi(panel_get_value(x1_panel));
  382. X    p1.y = atoi(panel_get_value(y1_panel));
  383. X    p2.x = atoi(panel_get_value(x2_panel));
  384. X    p2.y = atoi(panel_get_value(y2_panel));
  385. X    dx = p2.x - p1.x;
  386. X    dy = p2.y - p1.y;
  387. X
  388. X    if (dx == 0 || dy == 0 || orig_ratio == 0.0)
  389. X    return;
  390. X
  391. X    p2.x = p1.x + signof(dx) * new_l->eps->size_x;
  392. X    p2.y = p1.y + signof(dy) * new_l->eps->size_y;
  393. X    sprintf(buf, "%d", p2.x);
  394. X    panel_set_value(x2_panel, buf);
  395. X    sprintf(buf, "%d", p2.y);
  396. X    panel_set_value(y2_panel, buf);
  397. X    sprintf(buf, "%1.1f", orig_ratio);
  398. X    FirstArg(XtNlabel, buf);
  399. X    SetValues(hw_ratio_panel);
  400. X}
  401. X
  402. X
  403. Xstatic char    *flip_eps_items[] = {"Normal            ",
  404. X"Flipped about diag"};
  405. X
  406. Xmake_window_compound(c)
  407. X    F_compound       *c;
  408. X{
  409. X    set_temp_cursor(panel_cursor);
  410. X    mask_toggle_compoundmarker(c);
  411. X    new_c = copy_compound(c);
  412. X    new_c->next = c;
  413. X    generic_window("COMPOUND", "", &glue_ic, done_compound, 0, 0);
  414. X    f_pos_panel(&c->nwcorner, "Top Left Corner:", &x1_panel, &y1_panel);
  415. X    f_pos_panel(&c->secorner, "Bottom Right Corner:", &x2_panel, &y2_panel);
  416. X    int_label(object_count(c), "Num Objects: ", &num_objects);
  417. X}
  418. X
  419. Xstatic
  420. Xget_new_compound_values()
  421. X{
  422. X    int            dx, dy, nw_x, nw_y, se_x, se_y;
  423. X    float        scalex, scaley;
  424. X
  425. X    nw_x = atoi(panel_get_value(x1_panel));
  426. X    nw_y = atoi(panel_get_value(y1_panel));
  427. X    se_x = atoi(panel_get_value(x2_panel));
  428. X    se_y = atoi(panel_get_value(y2_panel));
  429. X    dx = nw_x - new_c->nwcorner.x;
  430. X    dy = nw_y - new_c->nwcorner.y;
  431. X    scalex = (float) (nw_x - se_x) /
  432. X    (float) (new_c->nwcorner.x - new_c->secorner.x);
  433. X    scaley = (float) (nw_y - se_y) /
  434. X    (float) (new_c->nwcorner.y - new_c->secorner.y);
  435. X
  436. X    translate_compound(new_c, dx, dy);
  437. X    scale_compound(new_c, scalex, scaley, nw_x, nw_y);
  438. X
  439. X    sprintf(buf, "%d", new_c->nwcorner.x);
  440. X    panel_set_value(x1_panel, buf);
  441. X    sprintf(buf, "%d", new_c->nwcorner.y);
  442. X    panel_set_value(y1_panel, buf);
  443. X    sprintf(buf, "%d", new_c->secorner.x);
  444. X    panel_set_value(x2_panel, buf);
  445. X    sprintf(buf, "%d", new_c->secorner.y);
  446. X    panel_set_value(y2_panel, buf);
  447. X}
  448. X
  449. Xstatic
  450. Xdone_compound()
  451. X{
  452. X    old_c = new_c->next;
  453. X    switch (button_result) {
  454. X    case APPLY:
  455. X    draw_compoundelements(new_c, ERASE);
  456. X    changed = 1;
  457. X    get_new_compound_values();
  458. X    draw_compoundelements(new_c, PAINT);
  459. X    break;
  460. X    case DONE:
  461. X    draw_compoundelements(new_c, ERASE);
  462. X    get_new_compound_values();
  463. X    new_c->next = NULL;
  464. X    change_compound(old_c, new_c);
  465. X    draw_compoundelements(new_c, PAINT);
  466. X    toggle_compoundmarker(new_c);
  467. X    reset_cursor();
  468. X    break;
  469. X    case CANCEL:
  470. X    if (changed) {
  471. X        draw_compoundelements(new_c, ERASE);
  472. X        draw_compoundelements(old_c, PAINT);
  473. X    }
  474. X    new_c->next = NULL;
  475. X    free_compound(&new_c);
  476. X    toggle_compoundmarker(old_c);
  477. X    new_c = old_c;
  478. X    reset_cursor();
  479. X    break;
  480. X    }
  481. X}
  482. X
  483. Xmake_window_line(l)
  484. X    F_line       *l;
  485. X{
  486. X    struct f_point  p1, p2;
  487. X    int            dx, dy, rotation;
  488. X    float        ratio;
  489. X
  490. X    set_temp_cursor(panel_cursor);
  491. X    mask_toggle_linemarker(l);
  492. X    new_l = copy_line(l);
  493. X    new_l->next = l;
  494. X    put_generic_vals(new_l);
  495. X    color = new_l->color;
  496. X    switch (new_l->type) {
  497. X    case T_POLYLINE:
  498. X    put_generic_arrows(new_l);
  499. X    generic_window("POLYLINE", "Polyline", &line_ic, done_line, 1, 1);
  500. X    points_panel(new_l->points, 0);
  501. X    break;
  502. X    case T_POLYGON:
  503. X    generic_window("POLYLINE", "Polygon", &polygon_ic, done_line, 1, 0);
  504. X    points_panel(new_l->points, 1);
  505. X    break;
  506. X    case T_BOX:
  507. X    generic_window("POLYLINE", "Box", &box_ic, done_line, 1, 0);
  508. X    p1 = *new_l->points;
  509. X    p2 = *new_l->points->next->next;
  510. X    xy_panel(p1.x, p1.y, "First Corner:", &x1_panel, &y1_panel);
  511. X    xy_panel(p2.x, p2.y, "Opposite Corner:", &x2_panel, &y2_panel);
  512. X    break;
  513. X    case T_ARC_BOX:
  514. X    generic_window("POLYLINE", "ArcBox", &arc_box_ic, done_line, 1, 0);
  515. X    p1 = *new_l->points;
  516. X    p2 = *new_l->points->next->next;
  517. X    xy_panel(p1.x, p1.y, "First Corner:", &x1_panel, &y1_panel);
  518. X    xy_panel(p2.x, p2.y, "Opposite Corner:", &x2_panel, &y2_panel);
  519. X    int_panel(new_l->radius, form, "Radius =", &radius);
  520. X    break;
  521. X    case T_EPS_BOX:
  522. X    generic_window("POLYLINE", "EPS", &epsobj_ic, done_line, 0, 0);
  523. X    int_panel(new_l->depth, form, "Depth =", &depth_panel);
  524. X    if (!strcmp(new_l->eps->file, EMPTY_EPS))
  525. X        new_l->eps->file[0] = '\0';
  526. X    str_panel(new_l->eps->file, "EPS Filename =", &eps_name_panel);
  527. X    p1 = *new_l->points;
  528. X    p2 = *new_l->points->next->next;
  529. X    xy_panel(p1.x, p1.y, "First Corner:", &x1_panel, &y1_panel);
  530. X    xy_panel(p2.x, p2.y, "Opposite corner:", &x2_panel, &y2_panel);
  531. X
  532. X    /* make popup flipped menu */
  533. X    FirstArg(XtNfromVert, below);
  534. X    NextArg(XtNborderWidth, 0);
  535. X    beside = XtCreateManagedWidget("Orientation =", labelWidgetClass,
  536. X                       form, Args, ArgCount);
  537. X    FirstArg(XtNfromVert, below);
  538. X    NextArg(XtNfromHoriz, beside);
  539. X    flip_eps_flag = new_l->eps->flipped;
  540. X    flip_eps_panel = XtCreateManagedWidget(
  541. X           flip_eps_items[flip_eps_flag ? 1 : 0], menuButtonWidgetClass,
  542. X                           form, Args, ArgCount);
  543. X    below = flip_eps_panel;
  544. X    menu = make_popup_menu(flip_eps_items, XtNumber(flip_eps_items),
  545. X                   flip_eps_panel, flip_eps_select);
  546. X
  547. X    dx = p2.x - p1.x;
  548. X    dy = p2.y - p1.y;
  549. X    rotation = 0;
  550. X    if (dx < 0 && dy < 0)
  551. X        rotation = 180;
  552. X    else if (dx < 0 && dy >= 0)
  553. X        rotation = 270;
  554. X    else if (dy < 0 && dx >= 0)
  555. X        rotation = 90;
  556. X    if (dx == 0 || dy == 0)
  557. X        ratio = 0.0;
  558. X    else if (((rotation == 0 || rotation == 180) && !flip_eps_flag) ||
  559. X         (rotation != 0 && rotation != 180 && flip_eps_flag))
  560. X        ratio = fabs((float) dy / (float) dx);
  561. X    else
  562. X        ratio = fabs((float) dx / (float) dy);
  563. X
  564. X    int_label(rotation, "Rotation =       ", &rotn_panel);
  565. X    float_label(ratio, "Curr h/w Ratio =", &hw_ratio_panel);
  566. X    float_label(new_l->eps->hw_ratio, "Orig h/w Ratio =", &orig_hw_panel);
  567. X    below = orig_hw_panel;
  568. X    FirstArg(XtNfromVert, below);
  569. X    NextArg(XtNborderWidth, 0);
  570. X    beside = XtCreateManagedWidget("Change h/w ratio", labelWidgetClass,
  571. X                       form, Args, ArgCount);
  572. X    FirstArg(XtNfromVert, below);
  573. X    NextArg(XtNsensitive, new_l->eps->hw_ratio ? True : False);
  574. X    NextArg(XtNfromHoriz, beside);
  575. X    shrink = XtCreateManagedWidget("Shrink to orig", commandWidgetClass,
  576. X                       form, Args, ArgCount);
  577. X    XtAddEventHandler(shrink, ButtonReleaseMask, (Boolean) 0,
  578. X              (XtEventHandler)shrink_eps, (XtPointer) NULL);
  579. X    beside = shrink;
  580. X
  581. X    ArgCount--;
  582. X    NextArg(XtNfromHoriz, beside);
  583. X    expand = XtCreateManagedWidget("Expand to orig", commandWidgetClass,
  584. X                       form, Args, ArgCount);
  585. X    XtAddEventHandler(expand, ButtonReleaseMask, (Boolean) 0,
  586. X              (XtEventHandler)expand_eps, (XtPointer) NULL);
  587. X
  588. X    below = expand;
  589. X    FirstArg(XtNfromVert, below);
  590. X    NextArg(XtNsensitive, new_l->eps->hw_ratio ? True : False);
  591. X    origsize = XtCreateManagedWidget("Use orig. size",
  592. X                     commandWidgetClass, form, Args,
  593. X                     ArgCount);
  594. X    XtAddEventHandler(origsize, ButtonReleaseMask, (Boolean) 0,
  595. X              (XtEventHandler)origsize_eps, (XtPointer) NULL);
  596. X    break;
  597. X    }
  598. X}
  599. X
  600. Xstatic
  601. Xget_new_line_values()
  602. X{
  603. X    struct f_point  p1, p2, *p;
  604. X    char       *s;
  605. X    int            dx, dy, rotation;
  606. X    float        ratio;
  607. X
  608. X    switch (new_l->type) {
  609. X    case T_POLYLINE:
  610. X    get_generic_vals(new_l);
  611. X    get_generic_arrows(new_l);
  612. X    get_points(new_l->points, False);
  613. X    return;
  614. X    case T_POLYGON:
  615. X    get_generic_vals(new_l);
  616. X    get_points(new_l->points, True);
  617. X    return;
  618. X    case T_ARC_BOX:
  619. X    new_l->radius = atoi(panel_get_value(radius));
  620. X    case T_BOX:
  621. X    get_generic_vals(new_l);
  622. X    p1.x = atoi(panel_get_value(x1_panel));
  623. X    p1.y = atoi(panel_get_value(y1_panel));
  624. X    p2.x = atoi(panel_get_value(x2_panel));
  625. X    p2.y = atoi(panel_get_value(y2_panel));
  626. X    break;
  627. X    case T_EPS_BOX:
  628. X    new_l->color = color;
  629. X    new_l->depth = atoi(panel_get_value(depth_panel));
  630. X    p1.x = atoi(panel_get_value(x1_panel));
  631. X    p1.y = atoi(panel_get_value(y1_panel));
  632. X    p2.x = atoi(panel_get_value(x2_panel));
  633. X    p2.y = atoi(panel_get_value(y2_panel));
  634. X
  635. X    dx = p2.x - p1.x;
  636. X    dy = p2.y - p1.y;
  637. X    rotation = 0;
  638. X    if (dx < 0 && dy < 0)
  639. X        rotation = 180;
  640. X    else if (dx < 0 && dy >= 0)
  641. X        rotation = 270;
  642. X    else if (dy < 0 && dx >= 0)
  643. X        rotation = 90;
  644. X    if (dx == 0 || dy == 0)
  645. X        ratio = 0.0;
  646. X    else if (((rotation == 0 || rotation == 180) && !flip_eps_flag) ||
  647. X         (rotation != 0 && rotation != 180 && flip_eps_flag))
  648. X        ratio = fabs((float) dy / (float) dx);
  649. X    else
  650. X        ratio = fabs((float) dx / (float) dy);
  651. X
  652. X    sprintf(buf, "%d", rotation);
  653. X    FirstArg(XtNlabel, buf);
  654. X    SetValues(rotn_panel);
  655. X    new_l->eps->flipped = flip_eps_flag;
  656. X    sprintf(buf, "%1.1f", ratio);
  657. X    FirstArg(XtNlabel, buf);
  658. X    SetValues(hw_ratio_panel);
  659. X    s = panel_get_value(eps_name_panel);
  660. X    if (s[0] == '\0')
  661. X        s = EMPTY_EPS;
  662. X    if (strcmp(s, new_l->eps->file)) {
  663. X        if (new_l->eps->bitmap) {
  664. X        free((char *) new_l->eps->bitmap);
  665. X        new_l->eps->bitmap = NULL;
  666. X        }
  667. X        strcpy(new_l->eps->file, s);
  668. X        new_l->eps->hw_ratio = 0.0;
  669. X        if (strcmp(new_l->eps->file, EMPTY_EPS))
  670. X        read_epsf(new_l->eps);
  671. X    }
  672. X    sprintf(buf, "%1.1f", new_l->eps->hw_ratio);
  673. X    FirstArg(XtNlabel, buf);
  674. X    SetValues(orig_hw_panel);
  675. X    FirstArg(XtNsensitive, new_l->eps->hw_ratio ? True : False);
  676. X    SetValues(shrink);
  677. X    SetValues(expand);
  678. X    SetValues(origsize);
  679. X    break;
  680. X    }
  681. X    p = new_l->points;
  682. X    p->x = p1.x;
  683. X    p->y = p1.y;
  684. X    p = p->next;
  685. X    p->x = p2.x;
  686. X    p->y = p1.y;
  687. X    p = p->next;
  688. X    p->x = p2.x;
  689. X    p->y = p2.y;
  690. X    p = p->next;
  691. X    p->x = p1.x;
  692. X    p->y = p2.y;
  693. X    p = p->next;
  694. X    p->x = p1.x;
  695. X    p->y = p1.y;
  696. X}
  697. X
  698. Xstatic
  699. Xdone_line()
  700. X{
  701. X    old_l = new_l->next;
  702. X    switch (button_result) {
  703. X    case APPLY:
  704. X    changed = 1;
  705. X    draw_line(new_l, ERASE);
  706. X    get_new_line_values();
  707. X    draw_line(new_l, PAINT);
  708. X    break;
  709. X    case DONE:
  710. X    get_new_line_values();
  711. X    new_l->next = NULL;
  712. X    change_line(old_l, new_l);
  713. X    redisplay_lines(old_l, new_l);
  714. X    reset_cursor();
  715. X    break;
  716. X    case CANCEL:
  717. X    if (changed)
  718. X        redisplay_lines(old_l, new_l);
  719. X    else
  720. X        mask_toggle_linemarker(old_l);
  721. X    new_l->next = NULL;
  722. X    free_line(&new_l);
  723. X    reset_cursor();
  724. X    break;
  725. X    }
  726. X
  727. X}
  728. X
  729. Xmake_window_text(t)
  730. X    F_text       *t;
  731. X{
  732. X    static char       *textjust_items[] = {
  733. X    "Left Justified ", "Centered       ", "Right Justified"};
  734. X    static char       *hidden_text_items[] = {
  735. X    "Normal ", "Hidden "};
  736. X    static char       *rigid_text_items[] = {
  737. X    "Normal ", "Rigid  "};
  738. X    static char       *special_text_items[] = {
  739. X    "Normal ", "Special"};
  740. X
  741. X    set_temp_cursor(panel_cursor);
  742. X    toggle_textmarker(t);
  743. X    new_t = copy_text(t);
  744. X    new_t->next = t;
  745. X
  746. X    textjust = new_t->type;    /* get current justification */
  747. X    hidden_text_flag = hidden_text(new_t) ? 1 : 0;
  748. X    new_psflag = psfont_text(new_t) ? 1 : 0;
  749. X    rigid_text_flag = rigid_text(new_t) ? 1 : 0;
  750. X    special_text_flag = special_text(new_t) ? 1 : 0;
  751. X    new_ps_font = cur_ps_font;
  752. X    new_latex_font = cur_latex_font;
  753. X    generic_vals.color = new_t->color;
  754. X
  755. X    color = new_t->color;
  756. X    if (new_psflag)
  757. X    new_ps_font = new_t->font;    /* get current font */
  758. X    else
  759. X    new_latex_font = new_t->font;    /* get current font */
  760. X    generic_window("TEXT", "", &text_ic, done_text, 0, 0);
  761. X
  762. X    int_panel(new_t->size, form, "Size  =", &cur_fontsize_panel);
  763. X    color_selection_panel();
  764. X    int_panel(new_t->depth, form, "Depth =", &depth_panel);
  765. X    int_panel(round(180 / M_PI * new_t->angle), form, "Angle (degrees) =",
  766. X          &angle_panel);
  767. X
  768. X    /* make text justification menu */
  769. X
  770. X    FirstArg(XtNfromVert, below);
  771. X    NextArg(XtNborderWidth, 0);
  772. X    beside = XtCreateManagedWidget("Justification   =", labelWidgetClass,
  773. X                   form, Args, ArgCount);
  774. X
  775. X    FirstArg(XtNlabel, textjust_items[textjust]);
  776. X    NextArg(XtNfromVert, below);
  777. X    NextArg(XtNfromHoriz, beside);
  778. X    textjust_panel = XtCreateManagedWidget(
  779. X                "justify", menuButtonWidgetClass,
  780. X                       form, Args, ArgCount);
  781. X    below = textjust_panel;
  782. X    textjust_menu = make_popup_menu(textjust_items, XtNumber(textjust_items),
  783. X                    textjust_panel, textjust_select);
  784. X
  785. X    /* make hidden text menu */
  786. X
  787. X    FirstArg(XtNfromVert, below);
  788. X    NextArg(XtNborderWidth, 0);
  789. X    beside = XtCreateManagedWidget("Hidden Flag     =", labelWidgetClass,
  790. X                   form, Args, ArgCount);
  791. X
  792. X    FirstArg(XtNfromVert, below);
  793. X    NextArg(XtNfromHoriz, beside);
  794. X    hidden_text_panel = XtCreateManagedWidget(
  795. X         hidden_text_items[hidden_text_flag], menuButtonWidgetClass,
  796. X                          form, Args, ArgCount);
  797. X    below = hidden_text_panel;
  798. X    hidden_text_menu = make_popup_menu(hidden_text_items,
  799. X                       XtNumber(hidden_text_items),
  800. X                     hidden_text_panel, hidden_text_select);
  801. X
  802. X    /* make rigid text menu */
  803. X
  804. X    FirstArg(XtNfromVert, below);
  805. X    NextArg(XtNborderWidth, 0);
  806. X    beside = XtCreateManagedWidget("Rigid Flag      =", labelWidgetClass,
  807. X                   form, Args, ArgCount);
  808. X
  809. X    FirstArg(XtNfromVert, below);
  810. X    NextArg(XtNfromHoriz, beside);
  811. X    rigid_text_panel = XtCreateManagedWidget(
  812. X           rigid_text_items[rigid_text_flag], menuButtonWidgetClass,
  813. X                         form, Args, ArgCount);
  814. X    below = rigid_text_panel;
  815. X    rigid_text_menu = make_popup_menu(rigid_text_items,
  816. X                      XtNumber(rigid_text_items),
  817. X                      rigid_text_panel, rigid_text_select);
  818. X
  819. X    /* make special text menu */
  820. X
  821. X    FirstArg(XtNfromVert, below);
  822. X    NextArg(XtNborderWidth, 0);
  823. X    beside = XtCreateManagedWidget("Special Flag    =", labelWidgetClass,
  824. X                   form, Args, ArgCount);
  825. X
  826. X    FirstArg(XtNfromVert, below);
  827. X    NextArg(XtNfromHoriz, beside);
  828. X    special_text_panel = XtCreateManagedWidget(
  829. X                      special_text_items[special_text_flag],
  830. X                   menuButtonWidgetClass, form, Args, ArgCount);
  831. X    below = special_text_panel;
  832. X    special_text_menu = make_popup_menu(special_text_items,
  833. X                    XtNumber(special_text_items),
  834. X                   special_text_panel, special_text_select);
  835. X
  836. X    xy_panel(new_t->base_x, new_t->base_y, "Origin:", &x1_panel, &y1_panel);
  837. X    font_image_panel(new_psflag ? psfont_menu_bitmaps[new_t->font + 1] :
  838. X         latexfont_menu_bitmaps[new_t->font], "Font:", &font_panel);
  839. X    str_panel(new_t->cstring, "Text:", &text_panel);
  840. X}
  841. X
  842. Xstatic
  843. Xget_new_text_values()
  844. X{
  845. X    char       *s;
  846. X    PR_SIZE        size;
  847. X
  848. X    new_t->type = textjust;
  849. X    new_t->flags =
  850. X    (rigid_text_flag ? RIGID_TEXT : 0)
  851. X    | (special_text_flag ? SPECIAL_TEXT : 0)
  852. X    | (hidden_text_flag ? HIDDEN_TEXT : 0)
  853. X    | (new_psflag ? PSFONT_TEXT : 0);
  854. X    if (psfont_text(new_t))
  855. X    new_t->font = new_ps_font;
  856. X    else
  857. X    new_t->font = new_latex_font;
  858. X    new_t->size = atoi(panel_get_value(cur_fontsize_panel));
  859. X    if (new_t->size < 1) {
  860. X    new_t->size = 1;
  861. X    panel_set_value(cur_fontsize_panel, "1");
  862. X    }
  863. X    new_t->color = color;
  864. X    new_t->depth = atoi(panel_get_value(depth_panel));
  865. X    new_t->angle = M_PI / 180 * atoi(panel_get_value(angle_panel));
  866. X    new_t->base_x = atoi(panel_get_value(x1_panel));
  867. X    new_t->base_y = atoi(panel_get_value(y1_panel));
  868. X    if (new_t->cstring)
  869. X    free(new_t->cstring);
  870. X    s = panel_get_value(text_panel);
  871. X    new_t->cstring = new_string(strlen(s) + 1);
  872. X    strcpy(new_t->cstring, s);
  873. X    canvas_font = lookfont(x_fontnum(new_t->flags, new_t->font), 
  874. X            new_t->size, new_t->angle*180.0/M_PI);
  875. X    new_t->fontstruct = canvas_font;
  876. X    size = pf_textwidth(canvas_font, strlen(s), s);
  877. X    new_t->height = size.y;
  878. X    new_t->length = size.x;
  879. X}
  880. X
  881. Xstatic
  882. Xdone_text()
  883. X{
  884. X    int            xmin, ymin, xmax, ymax;
  885. X
  886. X    old_t = new_t->next;
  887. X    switch (button_result) {
  888. X    case APPLY:
  889. X    draw_text(new_t, ERASE);
  890. X    changed = 1;
  891. X    get_new_text_values();
  892. X    draw_text(new_t, PAINT);
  893. X    break;
  894. X    case DONE:
  895. X    draw_text(old_t, ERASE);
  896. X    get_new_text_values();
  897. X    new_t->next = NULL;
  898. X    change_text(old_t, new_t);
  899. X    text_bound(new_t, &xmin, &ymin, &xmax, &ymax);
  900. X    redisplay_zoomed_region(xmin, ymin, xmax, ymax);
  901. X    reset_cursor();
  902. X    break;
  903. X    case CANCEL:
  904. X    if (changed) {
  905. X        draw_text(new_t, ERASE);
  906. X        text_bound(old_t, &xmin, &ymin, &xmax, &ymax);
  907. X        redisplay_zoomed_region(xmin, ymin, xmax, ymax);
  908. X    } else {
  909. X        toggle_textmarker(old_t);
  910. X    }
  911. X    new_t->next = NULL;
  912. X    free_text(&new_t);
  913. X    new_t = old_t;
  914. X    reset_cursor();
  915. X    break;
  916. X    }
  917. X}
  918. X
  919. Xmake_window_ellipse(e)
  920. X    F_ellipse       *e;
  921. X{
  922. X    char       *s1, *s2;
  923. X    PIXRECT        image;
  924. X
  925. X    set_temp_cursor(panel_cursor);
  926. X    toggle_ellipsemarker(e);
  927. X    new_e = copy_ellipse(e);
  928. X    new_e->next = e;
  929. X    color = new_e->color;
  930. X    switch (new_e->type) {
  931. X    case T_ELLIPSE_BY_RAD:
  932. X    s1 = "ELLIPSE";
  933. X    s2 = "specified by radius";
  934. X    ellipse_flag = 1;
  935. X    image = &ellrad_ic;
  936. X    break;
  937. X    case T_ELLIPSE_BY_DIA:
  938. X    s1 = "ELLIPSE";
  939. X    s2 = "specified by diameter";
  940. X    ellipse_flag = 1;
  941. X    image = &elldia_ic;
  942. X    break;
  943. X    case T_CIRCLE_BY_RAD:
  944. X    s1 = "CIRCLE";
  945. X    s2 = "specified by radius";
  946. X    ellipse_flag = 0;
  947. X    image = &cirrad_ic;
  948. X    break;
  949. X    case T_CIRCLE_BY_DIA:
  950. X    s1 = "CIRCLE";
  951. X    s2 = "specified by diameter";
  952. X    ellipse_flag = 0;
  953. X    image = &cirdia_ic;
  954. X    break;
  955. X    }
  956. X    put_generic_vals(new_e);
  957. X    generic_window(s1, s2, image, done_ellipse, 1, 0);
  958. X    int_panel(round(180 / M_PI * new_e->angle), form, "Angle (degrees) =",
  959. X          &angle_panel);
  960. X
  961. X    if (ellipse_flag) {
  962. X    f_pos_panel(&new_e->center, "Center:",
  963. X            &x1_panel, &y1_panel);
  964. X    f_pos_panel(&new_e->radiuses, "Radiuses:",
  965. X            &x2_panel, &y2_panel);
  966. X    } else {
  967. X    f_pos_panel(&new_e->center, "Center:",
  968. X            &x1_panel, &y1_panel);
  969. X    int_panel(new_e->radiuses.x, form, "Radius =",
  970. X          &x2_panel);
  971. X    }
  972. X}
  973. X
  974. Xstatic
  975. Xget_new_ellipse_values()
  976. X{
  977. X    get_generic_vals(new_e);
  978. X    new_e->angle = M_PI / 180 * atoi(panel_get_value(angle_panel));
  979. X    get_f_pos(&new_e->center, x1_panel, y1_panel);
  980. X    if (ellipse_flag)
  981. X    get_f_pos(&new_e->radiuses, x2_panel, y2_panel);
  982. X    else
  983. X    new_e->radiuses.x = new_e->radiuses.y =
  984. X        atoi(panel_get_value(x2_panel));
  985. X
  986. X    if (new_e->type == T_ELLIPSE_BY_RAD || new_e->type == T_CIRCLE_BY_RAD) {
  987. X    new_e->start = new_e->center;
  988. X    } else {
  989. X    new_e->start.x = new_e->center.x - new_e->radiuses.x;
  990. X    new_e->start.y = new_e->center.y - new_e->radiuses.y;
  991. X    }
  992. X    new_e->end.x = new_e->center.x + new_e->radiuses.x;
  993. X    new_e->end.y = new_e->center.y + new_e->radiuses.y;
  994. X}
  995. X
  996. Xstatic
  997. Xdone_ellipse()
  998. X{
  999. X    int            xmin, ymin, xmax, ymax;
  1000. X
  1001. X    old_e = new_e->next;
  1002. X    switch (button_result) {
  1003. X    case APPLY:
  1004. X    draw_ellipse(new_e, ERASE);
  1005. X    changed = 1;
  1006. X    get_new_ellipse_values();
  1007. X    draw_ellipse(new_e, PAINT);
  1008. X    break;
  1009. X    case DONE:
  1010. X    draw_ellipse(new_e, ERASE);
  1011. X    get_new_ellipse_values();
  1012. X    new_e->next = NULL;
  1013. X    change_ellipse(old_e, new_e);
  1014. X    draw_ellipse(new_e, PAINT);
  1015. X    toggle_ellipsemarker(new_e);
  1016. X    reset_cursor();
  1017. X    break;
  1018. X    case CANCEL:
  1019. X    if (changed) {
  1020. X        draw_ellipse(new_e, ERASE);
  1021. X        draw_ellipse(old_e, PAINT);
  1022. X    }
  1023. X    new_e->next = NULL;
  1024. X    free_ellipse(&new_e);
  1025. X    toggle_ellipsemarker(old_e);
  1026. X    reset_cursor();
  1027. X    break;
  1028. X    }
  1029. X
  1030. X}
  1031. X
  1032. Xmake_window_arc(a)
  1033. X    F_arc       *a;
  1034. X{
  1035. X    set_temp_cursor(panel_cursor);
  1036. X    toggle_arcmarker(a);
  1037. X    new_a = copy_arc(a);
  1038. X    new_a->next = a;
  1039. X    color = new_a->color;
  1040. X    put_generic_vals(new_a);
  1041. X    put_generic_arrows(new_a);
  1042. X    generic_window("ARC", "Specified by 3 points", &arc_ic, done_arc, 1, 1);
  1043. X    f_pos_panel(&new_a->point[0], "p1:", &x1_panel, &y1_panel);
  1044. X    f_pos_panel(&new_a->point[1], "p2:", &x2_panel, &y2_panel);
  1045. X    f_pos_panel(&new_a->point[2], "p3:", &x3_panel, &y3_panel);
  1046. X}
  1047. X
  1048. Xstatic
  1049. Xget_new_arc_values()
  1050. X{
  1051. X    F_pos        p0, p1, p2;
  1052. X    float        cx, cy;
  1053. X
  1054. X    get_generic_vals(new_a);
  1055. X    get_generic_arrows(new_a);
  1056. X    get_f_pos(&p0, x1_panel, y1_panel);
  1057. X    get_f_pos(&p1, x2_panel, y2_panel);
  1058. X    get_f_pos(&p2, x3_panel, y3_panel);
  1059. X    if (compute_arccenter(p0, p1, p2, &cx, &cy)) {
  1060. X    new_a->point[0] = p0;
  1061. X    new_a->point[1] = p1;
  1062. X    new_a->point[2] = p2;
  1063. X    new_a->center.x = cx;
  1064. X    new_a->center.y = cy;
  1065. X    new_a->direction = compute_direction(p0, p1, p2);
  1066. X    } else
  1067. X    put_msg("Invalid ARC points!");
  1068. X}
  1069. X
  1070. Xstatic
  1071. Xdone_arc()
  1072. X{
  1073. X    int            xmin, ymin, xmax, ymax;
  1074. X
  1075. X    old_a = new_a->next;
  1076. X    switch (button_result) {
  1077. X    case APPLY:
  1078. X    draw_arc(new_a, ERASE);
  1079. X    changed = 1;
  1080. X    get_new_arc_values();
  1081. X    draw_arc(new_a, PAINT);
  1082. X    break;
  1083. X    case DONE:
  1084. X    draw_arc(new_a, ERASE);
  1085. X    get_new_arc_values();
  1086. X    new_a->next = NULL;
  1087. X    change_arc(old_a, new_a);
  1088. X    draw_arc(new_a, PAINT);
  1089. X    toggle_arcmarker(new_a);
  1090. X    reset_cursor();
  1091. X    break;
  1092. X    case CANCEL:
  1093. X    if (changed) {
  1094. X        draw_arc(new_a, ERASE);
  1095. X        draw_arc(old_a, PAINT);
  1096. X    }
  1097. X    new_a->next = NULL;
  1098. X    free_arc(&new_a);
  1099. X    toggle_arcmarker(old_a);
  1100. X    reset_cursor();
  1101. X    break;
  1102. X    }
  1103. X
  1104. X}
  1105. X
  1106. Xmake_window_spline(s)
  1107. X    F_spline       *s;
  1108. X{
  1109. X    set_temp_cursor(panel_cursor);
  1110. X    toggle_splinemarker(s);
  1111. X    new_s = copy_spline(s);
  1112. X    new_s->next = s;
  1113. X    color = new_s->color;
  1114. X    put_generic_vals(new_s);
  1115. X    put_generic_arrows(new_s);
  1116. X    switch (new_s->type) {
  1117. X    case T_OPEN_NORMAL:
  1118. X    generic_window("SPLINE", "Normal open", &spl_ic,
  1119. X               done_spline, 1, 1);
  1120. X    points_panel(new_s->points, 0);
  1121. X    break;
  1122. X    case T_CLOSED_NORMAL:
  1123. X    generic_window("SPLINE", "Normal closed", &c_spl_ic,
  1124. X               done_spline, 1, 1);
  1125. X    points_panel(new_s->points, 1);
  1126. X    break;
  1127. X    case T_OPEN_INTERP:
  1128. X    generic_window("SPLINE", "Interpolated open", &intspl_ic,
  1129. X               done_spline, 1, 1);
  1130. X    points_panel(new_s->points, 0);
  1131. X    break;
  1132. X    case T_CLOSED_INTERP:
  1133. X    generic_window("SPLINE", "Interpolated closed", &c_intspl_ic,
  1134. X               done_spline, 1, 1);
  1135. X    points_panel(new_s->points, 1);
  1136. X    break;
  1137. X    }
  1138. X}
  1139. X
  1140. Xstatic
  1141. Xdone_spline()
  1142. X{
  1143. X    int            xmin, ymin, xmax, ymax;
  1144. X
  1145. X    old_s = new_s->next;
  1146. X    switch (button_result) {
  1147. X    case APPLY:
  1148. X    draw_spline(new_s, ERASE);
  1149. X    changed = 1;
  1150. X    get_generic_vals(new_s);
  1151. X    get_generic_arrows(new_s);
  1152. X    get_points(new_s->points, closed_spline(new_s));
  1153. X    if (int_spline(new_s))
  1154. X        remake_control_points(new_s);
  1155. X    draw_spline(new_s, PAINT);
  1156. X    break;
  1157. X    case DONE:
  1158. X    draw_spline(new_s, ERASE);
  1159. X    get_generic_vals(new_s);
  1160. X    get_generic_arrows(new_s);
  1161. X    get_points(new_s->points, closed_spline(new_s));
  1162. X    if (int_spline(new_s))
  1163. X        remake_control_points(new_s);
  1164. X    new_s->next = NULL;
  1165. X    change_spline(old_s, new_s);
  1166. X    draw_spline(new_s, PAINT);
  1167. X    toggle_splinemarker(new_s);
  1168. X    reset_cursor();
  1169. X    break;
  1170. X    case CANCEL:
  1171. X    if (changed) {
  1172. X        draw_spline(new_s, ERASE);
  1173. X        draw_spline(old_s, PAINT);
  1174. X    }
  1175. X    new_s->next = NULL;
  1176. X    free_spline(&new_s);
  1177. X    toggle_splinemarker(old_s);
  1178. X    reset_cursor();
  1179. X    break;
  1180. X    }
  1181. X}
  1182. X
  1183. Xstatic void
  1184. Xnew_generic_values()
  1185. X{
  1186. X    int            fill;
  1187. X    char       *val;
  1188. X
  1189. X    generic_vals.thickness = atoi(panel_get_value(thickness_panel));
  1190. X    generic_vals.color = color;
  1191. X    generic_vals.depth = atoi(panel_get_value(depth_panel));
  1192. X    /* include dash length in panel, too */
  1193. X    generic_vals.style_val = (float) atof(panel_get_value(style_val_panel));
  1194. X    if (fill_flag) {
  1195. X    val = panel_get_value(fill_style_panel);
  1196. X    if (*val >= ' ' && *val <= '9') {
  1197. X        if ((fill = atoi(val)) > 100)
  1198. X        fill = 100;
  1199. X        generic_vals.fill_style = (fill / (100 / (NUMFILLPATS - 1))) + 1;
  1200. X    }
  1201. X    fill = (generic_vals.fill_style - 1) * (100 / (NUMFILLPATS - 1));
  1202. X    sprintf(buf, "%d", fill);
  1203. X    panel_set_value(fill_style_panel, buf);
  1204. X    } else
  1205. X    generic_vals.fill_style = 0;
  1206. X}
  1207. X
  1208. Xstatic void
  1209. Xnew_arrow_values()
  1210. X{
  1211. X    generic_vals.for_arrow->thickness = 
  1212. X                (float) atof(panel_get_value(for_arrow_thick));
  1213. X    generic_vals.for_arrow->wid = 
  1214. X                (float) atof(panel_get_value(for_arrow_width));
  1215. X    generic_vals.for_arrow->ht = 
  1216. X                (float) atof(panel_get_value(for_arrow_height));
  1217. X    generic_vals.back_arrow->thickness = 
  1218. X                (float) atof(panel_get_value(back_arrow_thick));
  1219. X    generic_vals.back_arrow->wid = 
  1220. X                (float) atof(panel_get_value(back_arrow_width));
  1221. X    generic_vals.back_arrow->ht = 
  1222. X                (float) atof(panel_get_value(back_arrow_height));
  1223. X}
  1224. X
  1225. Xstatic        XtCallbackProc
  1226. Xdone_button(panel_local, item, event)
  1227. X    Widget        panel_local;
  1228. X    Widget       *item;
  1229. X    int           *event;
  1230. X{
  1231. X    button_result = DONE;
  1232. X    done_proc();
  1233. X    Quit(NULL, NULL, NULL);
  1234. X}
  1235. X
  1236. Xstatic        XtCallbackProc
  1237. Xapply_button(panel_local, item, event)
  1238. X    Widget        panel_local;
  1239. X    Widget       *item;
  1240. X    int           *event;
  1241. X{
  1242. X    button_result = APPLY;
  1243. X    done_proc();
  1244. X}
  1245. X
  1246. Xstatic        XtCallbackProc
  1247. Xcancel_button(panel_local, item, event)
  1248. X    Widget        panel_local;
  1249. X    Widget       *item;
  1250. X    int           *event;
  1251. X{
  1252. X    button_result = CANCEL;
  1253. X    done_proc();
  1254. X    Quit(NULL, NULL, NULL);
  1255. X}
  1256. X
  1257. Xstatic void
  1258. Xedit_cancel(w, ev)
  1259. X    Widget          w;
  1260. X    XButtonEvent   *ev;
  1261. X{
  1262. X    cancel_button(w, NULL, NULL);
  1263. X}
  1264. X
  1265. X
  1266. X/*
  1267. X * the following pix_table entries are guaranteed to be initialized to 0 by
  1268. X * the compiler
  1269. X */
  1270. X
  1271. Xstatic struct {
  1272. X    PIXRECT        image;
  1273. X    Pixmap        image_pm;
  1274. X}        pix_table[NUM_IMAGES];
  1275. X
  1276. Xstatic
  1277. Xgeneric_window(object_type, sub_type, icon, d_proc, generics, arrows)
  1278. X    char       *object_type, *sub_type;
  1279. X    PIXRECT        icon;
  1280. X    int            (*d_proc) ();
  1281. X    int            generics, arrows;
  1282. X
  1283. X{
  1284. X    Position        x_val, y_val;
  1285. X    Dimension        width, height;
  1286. X    Dimension        label_height, image_height;
  1287. X    int            button_distance;
  1288. X    int            i, fill, dist;
  1289. X    Widget        image;
  1290. X    Pixmap        image_pm;
  1291. X    static int      actions_added=0;
  1292. X
  1293. X#ifdef OPENWIN_BUG
  1294. X    /* to cater for OpenWindows bug - see below */
  1295. X    Pixel        fg, bg;
  1296. X
  1297. X#endif
  1298. X
  1299. X    static char       *linestyle_items[] = {
  1300. X    "Solid Line ", "Dashed Line", "Dotted Line"};
  1301. X    static char       *fill_style_items[] = {
  1302. X    "No fill", "Filled "};
  1303. X
  1304. X    FirstArg(XtNwidth, &width);
  1305. X    NextArg(XtNheight, &height);
  1306. X    GetValues(tool);
  1307. X    XtTranslateCoords(tool, (Position) (width / 2), (Position) (height / 5),
  1308. X              &x_val, &y_val);
  1309. X
  1310. X    FirstArg(XtNx, x_val);
  1311. X    NextArg(XtNy, y_val);
  1312. X    NextArg(XtNtitle, "Xfig: Edit panel");
  1313. X    popup = XtCreatePopupShell("xfig_edit_panel",
  1314. X                   transientShellWidgetClass, tool,
  1315. X                   Args, ArgCount);
  1316. X    XtOverrideTranslations(popup,
  1317. X            XtParseTranslationTable(edit_translations));
  1318. X    if (!actions_added) {
  1319. X        XtAppAddActions(tool_app, edit_actions, XtNumber(edit_actions));
  1320. X    actions_added = 1;
  1321. X    }
  1322. X
  1323. X    form = XtCreateManagedWidget("form", formWidgetClass, popup, NULL, 0);
  1324. X
  1325. X    done_proc = d_proc;
  1326. X
  1327. X    sprintf(buf, "%s:%s", object_type, sub_type);
  1328. X    FirstArg(XtNborderWidth, 0);
  1329. X    label = XtCreateManagedWidget(buf, labelWidgetClass, form, Args, ArgCount);
  1330. X
  1331. X    FirstArg(XtNfromHoriz, label);
  1332. X    NextArg(XtNbottom, XtChainTop);
  1333. X    NextArg(XtNleft, XtChainRight);
  1334. X    NextArg(XtNright, XtChainRight);
  1335. X    image = XtCreateManagedWidget("image", labelWidgetClass, form,
  1336. X                  Args, ArgCount);
  1337. X
  1338. X    /* put in the image */
  1339. X    /* search to see if that pixmap has already been created */
  1340. X    image_pm = 0;
  1341. X    for (i = 0; i < NUM_IMAGES; i++) {
  1342. X    if (pix_table[i].image == 0)
  1343. X        break;
  1344. X    if (pix_table[i].image == icon) {
  1345. X        image_pm = pix_table[i].image_pm;
  1346. X        break;
  1347. X    }
  1348. X    }
  1349. X
  1350. X    /* doesn't already exist, create a pixmap from the data (ala panel.c) */
  1351. X    /* OpenWindows bug doesn't handle a 1-plane bitmap on a n-plane display */
  1352. X    if (!image_pm) {
  1353. X#ifdef OPENWIN_BUG
  1354. X    /* get the foreground/background of the widget */
  1355. X    FirstArg(XtNforeground, &fg);
  1356. X    NextArg(XtNbackground, &bg);
  1357. X    GetValues(image);
  1358. X
  1359. X    image_pm = XCreatePixmapFromBitmapData(tool_d, canvas_win,
  1360. X                     (char *) icon->data, icon->width, icon->height,
  1361. X                     fg, bg, XDefaultDepthOfScreen(tool_s));
  1362. X#else
  1363. X    image_pm = XCreateBitmapFromData(tool_d, canvas_win,
  1364. X                     (char *) icon->data, icon->width, icon->height);
  1365. X#endif
  1366. X    pix_table[i].image_pm = image_pm;
  1367. X    pix_table[i].image = icon;
  1368. X    }
  1369. X    FirstArg(XtNbitmap, image_pm);
  1370. X    SetValues(image);
  1371. X
  1372. X    /* get height of label widget and distance between widgets */
  1373. X    FirstArg(XtNheight, &label_height);
  1374. X    NextArg(XtNvertDistance, &button_distance);
  1375. X    GetValues(label);
  1376. X    /* do the same for the image widget */
  1377. X    FirstArg(XtNheight, &image_height);
  1378. X    GetValues(image);
  1379. X
  1380. X    if (image_height > label_height)
  1381. X    dist = image_height - label_height + button_distance;
  1382. X    else
  1383. X    dist = button_distance;
  1384. X    FirstArg(XtNfromVert, label);
  1385. X    NextArg(XtNvertDistance, dist);
  1386. X    but1 = XtCreateManagedWidget("done", commandWidgetClass, form, Args, ArgCount);
  1387. X    XtAddCallback(but1, XtNcallback, (XtCallbackProc)done_button, (XtPointer) NULL);
  1388. X
  1389. X    below = but1;
  1390. X    FirstArg(XtNfromHoriz, but1);
  1391. X    NextArg(XtNfromVert, label);
  1392. X    NextArg(XtNvertDistance, dist);
  1393. X    but1 = XtCreateManagedWidget("apply", commandWidgetClass, form, Args, ArgCount);
  1394. X    XtAddCallback(but1, XtNcallback, (XtCallbackProc)apply_button, (XtPointer) NULL);
  1395. X
  1396. X    FirstArg(XtNfromHoriz, but1);
  1397. X    NextArg(XtNfromVert, label);
  1398. X    NextArg(XtNvertDistance, dist);
  1399. X    but1 = XtCreateManagedWidget("cancel", commandWidgetClass, form, Args, ArgCount);
  1400. X    XtAddCallback(but1, XtNcallback, (XtCallbackProc)cancel_button, (XtPointer) NULL);
  1401. X
  1402. X    FirstArg(XtNborderWidth, 0);
  1403. X    NextArg(XtNfromVert, below);
  1404. X    below = XtCreateManagedWidget(" ", labelWidgetClass, form, Args, ArgCount);
  1405. X
  1406. X    if (generics) {
  1407. X    int_panel(generic_vals.thickness, form, "Width =", &thickness_panel);
  1408. X
  1409. X    /* make color menu */
  1410. X    color_selection_panel();
  1411. X
  1412. X    int_panel(generic_vals.depth, form, "Depth =", &depth_panel);
  1413. X
  1414. X    if (generic_vals.fill_style == 0) {
  1415. X        fill = 0;
  1416. X        fill_flag = False;
  1417. X    } else {
  1418. X        fill = (generic_vals.fill_style - 1) * (100 / (NUMFILLPATS - 1));
  1419. X        fill_flag = True;
  1420. X    }
  1421. X
  1422. X    /* make popup fill style menu */
  1423. X    FirstArg(XtNfromVert, below);
  1424. X    NextArg(XtNborderWidth, 0);
  1425. X    beside = XtCreateManagedWidget("Fill style =", labelWidgetClass,
  1426. X                       form, Args, ArgCount);
  1427. X    FirstArg(XtNfromVert, below);
  1428. X    NextArg(XtNfromHoriz, beside);
  1429. X    fill_flag_panel = XtCreateManagedWidget(
  1430. X         fill_style_items[fill_flag ? 1 : 0], menuButtonWidgetClass,
  1431. X                        form, Args, ArgCount);
  1432. X    below = fill_flag_panel;
  1433. X    menu = make_popup_menu(fill_style_items, XtNumber(fill_style_items),
  1434. X                   fill_flag_panel, fill_style_select);
  1435. X
  1436. X    if (generic_vals.color==BLACK)
  1437. X        int_panel(fill, form, "Fill density % =", &fill_style_panel);
  1438. X    else
  1439. X        int_panel(fill, form, "Fill intensity % =", &fill_style_panel);
  1440. X    fill_style_label = beside;    /* save pointer to fill label */
  1441. X    FirstArg(XtNsensitive, fill_flag ? True : False);
  1442. X    SetValues(fill_style_panel);
  1443. X    NextArg(XtNhorizDistance, 30);
  1444. X    SetValues(fill_style_label);
  1445. X    /* if fill is off, blank out fill % value */
  1446. X    if (!fill_flag)
  1447. X        panel_clear_value(fill_style_panel);
  1448. X
  1449. X    /* make popup line style menu */
  1450. X    FirstArg(XtNfromVert, below);
  1451. X    NextArg(XtNborderWidth, 0);
  1452. X    beside = XtCreateManagedWidget("Line style =", labelWidgetClass,
  1453. X                       form, Args, ArgCount);
  1454. X    FirstArg(XtNfromVert, below);
  1455. X    NextArg(XtNfromHoriz, beside);
  1456. X    style_panel = XtCreateManagedWidget(
  1457. X         linestyle_items[generic_vals.style], menuButtonWidgetClass,
  1458. X                        form, Args, ArgCount);
  1459. X    below = style_panel;
  1460. X    menu = make_popup_menu(linestyle_items, XtNumber(linestyle_items),
  1461. X                   style_panel, line_style_select);
  1462. X
  1463. X    /* new field for style_val */
  1464. X    float_panel(generic_vals.style_val, form, "Dash length/Dot gap =",
  1465. X            &style_val_panel);
  1466. X    /* save pointer to dash/dot gap label panel */
  1467. X    style_val_label = beside;
  1468. X    FirstArg(XtNhorizDistance, 30);
  1469. X    SetValues(style_val_label);
  1470. X    if (generic_vals.style == SOLID_LINE) {
  1471. X        FirstArg(XtNsensitive, False);
  1472. X        SetValues(style_val_panel);
  1473. X        SetValues(style_val_label);
  1474. X        /* and clear any value from the dash length panel */
  1475. X        panel_clear_value(style_val_panel);
  1476. X    }
  1477. X
  1478. X    if (arrows) {
  1479. X        Widget    arrow_label,for_aform,back_aform,w;
  1480. X
  1481. X        FirstArg(XtNfromVert, below);
  1482. X        NextArg(XtNborderWidth, 0);
  1483. X        arrow_label = XtCreateManagedWidget("Arrows", labelWidgetClass,
  1484. X                       form, Args, ArgCount);
  1485. X        FirstArg(XtNfromVert, arrow_label);
  1486. X        for_aform = XtCreateManagedWidget("arrow_form", formWidgetClass, 
  1487. X                      form, Args, ArgCount);
  1488. X        FirstArg(XtNborderWidth, 0);
  1489. X        w = XtCreateManagedWidget("Forward", labelWidgetClass,
  1490. X                       for_aform, Args, ArgCount);
  1491. X        FirstArg(XtNfromHoriz, w);
  1492. X        NextArg(XtNhorizDistance, 10);
  1493. X        NextArg(XtNlabel, "->");
  1494. X        NextArg(XtNstate, (generic_vals.for_arrow? True: False));
  1495. X        beside = XtCreateManagedWidget("for.arrow", toggleWidgetClass,
  1496. X                       for_aform, Args, ArgCount);
  1497. X        XtAddCallback(beside, XtNcallback, (XtCallbackProc) toggle_for_arrow,
  1498. X              (XtPointer) NULL);
  1499. X        below = w;
  1500. X        for_arrow=True;
  1501. X        if (!generic_vals.for_arrow)
  1502. X        {
  1503. X        for_arrow=False;
  1504. X        generic_vals.for_arrow = forward_arrow();
  1505. X        }
  1506. X        float_panel(generic_vals.for_arrow->thickness, for_aform, 
  1507. X            "Thick  =", &for_arrow_thick);
  1508. X        for_thick_label = beside;
  1509. X        for_thick_val = below;
  1510. X        float_panel(generic_vals.for_arrow->wid, for_aform, 
  1511. X            "Width  =", &for_arrow_width);
  1512. X        for_width_label = beside;
  1513. X        for_width_val = below;
  1514. X        float_panel(generic_vals.for_arrow->ht, for_aform, 
  1515. X            "Height =", &for_arrow_height);
  1516. X        for_height_label = beside;
  1517. X        for_height_val = below;
  1518. X        if (!for_arrow)    /* make insensitive */
  1519. X        {
  1520. X        for_arrow = True;
  1521. X        toggle_for_arrow((Widget)0, (XtPointer)0, (XtPointer)0);
  1522. X        for_arrow = False;
  1523. X        }
  1524. X
  1525. X        FirstArg(XtNfromVert, arrow_label);
  1526. X        NextArg(XtNfromHoriz, for_aform);
  1527. X        back_aform = XtCreateManagedWidget("arrow_form", formWidgetClass, 
  1528. X                      form, Args, ArgCount);
  1529. X        FirstArg(XtNborderWidth, 0);
  1530. X        w = XtCreateManagedWidget("Backward", labelWidgetClass,
  1531. X                       back_aform, Args, ArgCount);
  1532. X        FirstArg(XtNfromHoriz, w);
  1533. X        NextArg(XtNhorizDistance, 10);
  1534. X        NextArg(XtNlabel, "<-");
  1535. X        NextArg(XtNstate, (generic_vals.back_arrow? True: False));
  1536. X        beside = XtCreateManagedWidget("back.arrow", toggleWidgetClass,
  1537. X                       back_aform, Args, ArgCount);
  1538. X        XtAddCallback(beside, XtNcallback, (XtCallbackProc) toggle_back_arrow,
  1539. X              (XtPointer) NULL);
  1540. X        below = w;
  1541. X        back_arrow=True;
  1542. X        if (!generic_vals.back_arrow)
  1543. X        {
  1544. X        back_arrow=False;
  1545. X        generic_vals.back_arrow = backward_arrow();
  1546. X        }
  1547. X        float_panel(generic_vals.back_arrow->thickness, back_aform, 
  1548. X            "Thick  =", &back_arrow_thick);
  1549. X        back_thick_label = beside;
  1550. X        back_thick_val = below;
  1551. X        float_panel(generic_vals.back_arrow->wid, back_aform, 
  1552. X            "Width  =", &back_arrow_width);
  1553. X        back_width_label = beside;
  1554. X        back_width_val = below;
  1555. X        float_panel(generic_vals.back_arrow->ht, back_aform, 
  1556. X            "Height =", &back_arrow_height);
  1557. X        back_height_label = beside;
  1558. X        back_height_val = below;
  1559. X        if (!back_arrow)    /* make insensitive */
  1560. X        {
  1561. X        back_arrow = True;
  1562. X        toggle_back_arrow((Widget)0, (XtPointer)0, (XtPointer)0);
  1563. X        back_arrow = False;
  1564. X        }
  1565. X        below = for_aform;    /* for the widget that follows us in the panel */
  1566. X    }
  1567. X    }
  1568. X}
  1569. X
  1570. Xstatic
  1571. XXtCallbackProc
  1572. Xtoggle_for_arrow(w, dummy, dummy2)
  1573. X    Widget       w;
  1574. X    XtPointer       dummy;
  1575. X    XtPointer       dummy2;
  1576. X{
  1577. X    /* either add or delete arrowhead */
  1578. X    for_arrow = !for_arrow;
  1579. X    FirstArg(XtNsensitive, (for_arrow? True: False));
  1580. X    SetValues(for_arrow_thick);
  1581. X    SetValues(for_thick_label);
  1582. X    SetValues(for_thick_val);
  1583. X    SetValues(for_arrow_width);
  1584. X    SetValues(for_width_label);
  1585. X    SetValues(for_width_val);
  1586. X    SetValues(for_arrow_height);
  1587. X    SetValues(for_height_label);
  1588. X    SetValues(for_height_val);
  1589. X}
  1590. X
  1591. Xstatic
  1592. XXtCallbackProc
  1593. Xtoggle_back_arrow(w, dummy, dummy2)
  1594. X    Widget       w;
  1595. X    XtPointer       dummy;
  1596. X    XtPointer       dummy2;
  1597. X{
  1598. X    /* either add or delete arrowhead */
  1599. X    back_arrow = !back_arrow;
  1600. X    FirstArg(XtNsensitive, (back_arrow? True: False));
  1601. X    SetValues(back_arrow_thick);
  1602. X    SetValues(back_thick_label);
  1603. X    SetValues(back_thick_val);
  1604. X    SetValues(back_arrow_width);
  1605. X    SetValues(back_width_label);
  1606. X    SetValues(back_width_val);
  1607. X    SetValues(back_arrow_height);
  1608. X    SetValues(back_height_label);
  1609. X    SetValues(back_height_val);
  1610. X}
  1611. X
  1612. X/* make a button panel with the image 'pixmap' in it */
  1613. X/* for the font selection */
  1614. X
  1615. Xvoid        f_menu_popup();
  1616. X
  1617. Xstatic XtCallbackRec f_sel_callback[] =
  1618. X{
  1619. X    {f_menu_popup, NULL},
  1620. X    {NULL, NULL},
  1621. X};
  1622. X
  1623. Xset_font_image(widget)
  1624. X    TOOL        widget;
  1625. X{
  1626. X    FirstArg(XtNbitmap, new_psflag ?
  1627. X         psfont_menu_bitmaps[new_ps_font + 1] :
  1628. X         latexfont_menu_bitmaps[new_latex_font]);
  1629. X    SetValues(widget);
  1630. X}
  1631. X
  1632. Xstatic
  1633. Xfont_image_panel(pixmap, label, pi_x)
  1634. X    Pixmap        pixmap;
  1635. X    char       *label;
  1636. X    Widget       *pi_x;
  1637. X{
  1638. X    FirstArg(XtNfromVert, below);
  1639. X    NextArg(XtNlabel, label);
  1640. X    NextArg(XtNborderWidth, 0);
  1641. X    below = XtCreateManagedWidget(label, labelWidgetClass, form, Args, ArgCount);
  1642. X
  1643. X    FirstArg(XtNfromVert, below);
  1644. X    NextArg(XtNvertDistance, 2);
  1645. X    NextArg(XtNbitmap, pixmap);
  1646. X    NextArg(XtNcallback, f_sel_callback);
  1647. X    *pi_x = XtCreateManagedWidget(label, commandWidgetClass, form, Args, ArgCount);
  1648. X    below = *pi_x;
  1649. X}
  1650. X
  1651. X/* come here when user presses font image button */
  1652. X
  1653. Xvoid
  1654. Xf_menu_popup()
  1655. X{
  1656. X    fontpane_popup(&new_ps_font, &new_latex_font, &new_psflag,
  1657. X           set_font_image, font_panel);
  1658. X}
  1659. X
  1660. X/*
  1661. X * make a popup menu with "nent" button entries (labels) that call "callback"
  1662. X * when pressed
  1663. X */
  1664. X
  1665. XWidget
  1666. Xmake_popup_menu(entries, nent, parent, callback)
  1667. X    char       *entries[];
  1668. X    Cardinal        nent;
  1669. X    Widget        parent;
  1670. X    XtCallbackProc  callback;
  1671. X
  1672. X{
  1673. X    Widget        pop_menu, entry;
  1674. X    int            i;
  1675. X
  1676. X    pop_menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, parent,
  1677. X                  NULL, ZERO);
  1678. X
  1679. X    for (i = 0; i < nent; i++) {
  1680. X    entry = XtCreateManagedWidget(entries[i], smeBSBObjectClass, pop_menu,
  1681. X                      NULL, ZERO);
  1682. X    XtAddCallback(entry, XtNcallback, callback, (XtPointer) i);
  1683. X    }
  1684. X    return pop_menu;
  1685. X}
  1686. X
  1687. Xstatic
  1688. Xcolor_selection_panel()
  1689. X{
  1690. X    FirstArg(XtNfromVert, below);
  1691. X    NextArg(XtNborderWidth, 0);
  1692. X    beside = XtCreateManagedWidget("Drawing color =", labelWidgetClass,
  1693. X                   form, Args, ArgCount);
  1694. X    /* warning: set_color_names uses FirstArg() etc. - put it here */
  1695. X    set_color_name(generic_vals.color);
  1696. X    FirstArg(XtNfromVert, below);
  1697. X    NextArg(XtNfromHoriz, beside);
  1698. X    color_panel = XtCreateManagedWidget(
  1699. X             "colors", menuButtonWidgetClass, form, Args, ArgCount);
  1700. X    /*
  1701. X     * cheat a little - set the initial fore/background colors by calling the
  1702. X     * callback
  1703. X     */
  1704. X    /* also set the label */
  1705. X    color_select(color_panel, generic_vals.color, NULL);
  1706. X    below = color_panel;
  1707. X    menu = make_color_popup_menu(color_panel, color_select);
  1708. X}
  1709. X
  1710. X
  1711. Xstatic        Widget
  1712. Xmake_color_popup_menu(parent, callback)
  1713. X    Widget        parent;
  1714. X    XtCallbackProc  callback;
  1715. X
  1716. X{
  1717. X    Widget        pop_menu, entry;
  1718. X    int            i;
  1719. X
  1720. X    pop_menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, parent,
  1721. X                  NULL, ZERO);
  1722. X
  1723. X    for (i = 0; i < NUMCOLORS; i++) {
  1724. X    set_color_name(i);
  1725. X    if (all_colors_available)
  1726. X        FirstArg(XtNforeground, appres.color[i])
  1727. X        else
  1728. X        ArgCount = 0;
  1729. X    entry = XtCreateManagedWidget(buf, smeBSBObjectClass, pop_menu,
  1730. X                      Args, ArgCount);
  1731. X    XtAddCallback(entry, XtNcallback, callback, (XtPointer) i);
  1732. X    }
  1733. X    set_color_name(DEFAULT_COLOR);
  1734. X    FirstArg(XtNforeground, x_fg_color.pixel);
  1735. X    entry = XtCreateManagedWidget(buf, smeBSBObjectClass, pop_menu,
  1736. X                  Args, ArgCount);
  1737. X    XtAddCallback(entry, XtNcallback, callback, (XtPointer) - 1);
  1738. X    return pop_menu;
  1739. X}
  1740. X
  1741. Xstatic
  1742. Xint_panel(x, parent, label, pi_x)
  1743. X    int            x;
  1744. X    Widget        parent;
  1745. X    char       *label;
  1746. X    Widget       *pi_x;
  1747. X{
  1748. X    FirstArg(XtNfromVert, below);
  1749. X    NextArg(XtNlabel, label);
  1750. X    NextArg(XtNborderWidth, 0);
  1751. X    beside = XtCreateManagedWidget(label, labelWidgetClass, parent, Args, ArgCount);
  1752. X
  1753. X    sprintf(buf, "%d", x);
  1754. X    ArgCount = 1;
  1755. X    NextArg(XtNstring, buf);
  1756. X    NextArg(XtNinsertPosition, strlen(buf));
  1757. X    NextArg(XtNfromHoriz, beside);
  1758. X    NextArg(XtNeditType, "append");
  1759. X    NextArg(XtNwidth, 40);
  1760. X    *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, parent, Args, ArgCount);
  1761. X    below = *pi_x;
  1762. X}
  1763. X
  1764. Xstatic
  1765. Xfloat_panel(x, parent, label, pi_x)
  1766. X    float        x;
  1767. X    Widget        parent;
  1768. X    char       *label;
  1769. X    Widget       *pi_x;
  1770. X{
  1771. X    FirstArg(XtNfromVert, below);
  1772. X    NextArg(XtNlabel, label);
  1773. X    NextArg(XtNborderWidth, 0);
  1774. X    beside = XtCreateManagedWidget(label, labelWidgetClass, parent,
  1775. X                   Args, ArgCount);
  1776. X    sprintf(buf, "%1.1f", x);
  1777. X    FirstArg(XtNfromVert, below);
  1778. X    NextArg(XtNstring, buf);
  1779. X    NextArg(XtNinsertPosition, strlen(buf));
  1780. X    NextArg(XtNfromHoriz, beside);
  1781. X    NextArg(XtNeditType, "append");
  1782. X    NextArg(XtNwidth, 40);
  1783. X    *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, parent,
  1784. X                  Args, ArgCount);
  1785. X    below = *pi_x;
  1786. X}
  1787. X
  1788. Xstatic
  1789. Xfloat_label(x, label, pi_x)
  1790. X    float        x;
  1791. X    char       *label;
  1792. X    Widget       *pi_x;
  1793. X{
  1794. X    FirstArg(XtNfromVert, below);
  1795. X    NextArg(XtNlabel, label);
  1796. X    NextArg(XtNborderWidth, 0);
  1797. X    beside = XtCreateManagedWidget(label, labelWidgetClass, form,
  1798. X                   Args, ArgCount);
  1799. X    sprintf(buf, "%1.1f", x);
  1800. X    FirstArg(XtNfromVert, below);
  1801. X    NextArg(XtNlabel, buf);
  1802. X    NextArg(XtNfromHoriz, beside);
  1803. X    NextArg(XtNwidth, 40);
  1804. X    NextArg(XtNborderWidth, 0);
  1805. X    *pi_x = XtCreateManagedWidget(label, labelWidgetClass, form,
  1806. X                  Args, ArgCount);
  1807. X    below = *pi_x;
  1808. X}
  1809. X
  1810. Xstatic
  1811. Xint_label(x, label, pi_x)
  1812. X    int            x;
  1813. X    char       *label;
  1814. X    Widget       *pi_x;
  1815. X{
  1816. X    FirstArg(XtNfromVert, below);
  1817. X    NextArg(XtNlabel, label);
  1818. X    NextArg(XtNborderWidth, 0);
  1819. X    beside = XtCreateManagedWidget(label, labelWidgetClass, form,
  1820. X                   Args, ArgCount);
  1821. X    sprintf(buf, "%d", x);
  1822. X    FirstArg(XtNfromVert, below);
  1823. X    NextArg(XtNlabel, buf);
  1824. X    NextArg(XtNfromHoriz, beside);
  1825. X    NextArg(XtNwidth, 40);
  1826. X    NextArg(XtNborderWidth, 0);
  1827. X    *pi_x = XtCreateManagedWidget(label, labelWidgetClass, form,
  1828. X                  Args, ArgCount);
  1829. X    below = *pi_x;
  1830. X}
  1831. X
  1832. X/* don't allow newlines in text until we handle multiple line texts */
  1833. XString        text_translations =
  1834. X    "<Key>Return: no-op(RingBell)\n\
  1835. X    Ctrl<Key>J: no-op(RingBell)\n\
  1836. X    Ctrl<Key>M: no-op(RingBell)\n\
  1837. X    Ctrl<Key>X: EmptyTextKey()\n\
  1838. X    Ctrl<Key>U: multiply(4)\n\
  1839. X    <Key>F18: PastePanelKey()\n";
  1840. X
  1841. Xstatic
  1842. Xstr_panel(string, label, pi_x)
  1843. X    char       *string;
  1844. X    char       *label;
  1845. X    Widget       *pi_x;
  1846. X{
  1847. X    int            width, nlines, i;
  1848. X    Dimension        pwidth;
  1849. X    PIX_FONT        temp_font;
  1850. X
  1851. X    FirstArg(XtNfromVert, below);
  1852. X    NextArg(XtNlabel, label);
  1853. X    NextArg(XtNborderWidth, 0);
  1854. X    beside = XtCreateManagedWidget(label, labelWidgetClass, form, Args, ArgCount);
  1855. X
  1856. X    /* get the font and width of above label widget */
  1857. X    FirstArg(XtNfont, &temp_font);
  1858. X    NextArg(XtNwidth, &pwidth);
  1859. X    GetValues(beside);
  1860. X    /* make panel as wide as image pane above less the label widget's width */
  1861. X    /* but at least 200 pixels wide */
  1862. X    width = max2(PS_FONTPANE_WD - pwidth + 2, 200);
  1863. X
  1864. X    /* count number of lines in this text string */
  1865. X    nlines = 1;            /* number of lines in string */
  1866. X    for (i = 0; i < strlen(string); i++) {
  1867. X    if (string[i] == '\n') {
  1868. X        nlines++;
  1869. X    }
  1870. X    }
  1871. X    if (nlines > 4)    /* limit to displaying 4 lines and show scrollbars */
  1872. X    nlines = 4;
  1873. X    if (nlines == 1)    /* if only one line, allow space for scrollbar */
  1874. X    nlines = 2;
  1875. X    FirstArg(XtNfromVert, below);
  1876. X    NextArg(XtNstring, string);
  1877. X    NextArg(XtNinsertPosition, strlen(string));
  1878. X    NextArg(XtNfromHoriz, beside);
  1879. X    NextArg(XtNeditType, "edit");
  1880. X    NextArg(XtNwidth, width);
  1881. X    /* allow enough height for scrollbar */
  1882. X    NextArg(XtNheight, char_height(temp_font) * nlines + 10);
  1883. X    NextArg(XtNscrollHorizontal, XawtextScrollWhenNeeded);
  1884. X    NextArg(XtNscrollVertical, XawtextScrollWhenNeeded);
  1885. X
  1886. X    *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, Args, ArgCount);
  1887. X
  1888. X    /* make Newline do nothing for now */
  1889. X    XtOverrideTranslations(*pi_x, XtParseTranslationTable(text_translations));
  1890. X
  1891. X    /* read personal key configuration */
  1892. X    XtOverrideTranslations(*pi_x, XtParseTranslationTable(local_translations));
  1893. X
  1894. X    below = *pi_x;
  1895. X}
  1896. X
  1897. Xstatic
  1898. Xxy_panel(x, y, label, pi_x, pi_y)
  1899. X    int            x, y;
  1900. X    char       *label;
  1901. X    Widget       *pi_x, *pi_y;
  1902. X{
  1903. X    FirstArg(XtNfromVert, below);
  1904. X    NextArg(XtNlabel, label);
  1905. X    NextArg(XtNborderWidth, 0);
  1906. X    below = XtCreateManagedWidget(label, labelWidgetClass, form, Args, ArgCount);
  1907. X    FirstArg(XtNfromVert, below);
  1908. X    NextArg(XtNhorizDistance, 30);
  1909. X    NextArg(XtNlabel, "X =");
  1910. X    NextArg(XtNborderWidth, 0);
  1911. X    beside = XtCreateManagedWidget(label, labelWidgetClass, form, Args, ArgCount);
  1912. X
  1913. X    sprintf(buf, "%d", x);
  1914. X    ArgCount = 1;
  1915. X    NextArg(XtNstring, buf);
  1916. X    NextArg(XtNinsertPosition, strlen(buf));
  1917. X    NextArg(XtNfromHoriz, beside);
  1918. X    NextArg(XtNeditType, "append");
  1919. X    NextArg(XtNwidth, 40);
  1920. X    *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, Args, ArgCount);
  1921. X
  1922. X    ArgCount = 1;
  1923. X    NextArg(XtNlabel, "Y =");
  1924. X    NextArg(XtNborderWidth, 0);
  1925. X    NextArg(XtNfromHoriz, *pi_x);
  1926. X    beside = XtCreateManagedWidget(label, labelWidgetClass, form, Args, ArgCount);
  1927. X
  1928. X    sprintf(buf, "%d", y);
  1929. X    ArgCount = 1;
  1930. X    NextArg(XtNstring, buf);
  1931. X    NextArg(XtNfromHoriz, beside);
  1932. X    NextArg(XtNinsertPosition, strlen(buf));
  1933. X    NextArg(XtNeditType, "append");
  1934. X    NextArg(XtNwidth, 40);
  1935. X    *pi_y = XtCreateManagedWidget(label, asciiTextWidgetClass, form, Args, ArgCount);
  1936. X
  1937. X    below = *pi_x;
  1938. X}
  1939. X
  1940. Xstatic
  1941. Xf_pos_panel(fp, label, pi_x, pi_y)
  1942. X    F_pos       *fp;
  1943. X    char       *label;
  1944. X    Widget       *pi_x, *pi_y;
  1945. X{
  1946. X    FirstArg(XtNfromVert, below);
  1947. X    NextArg(XtNborderWidth, 0);
  1948. X    below = XtCreateManagedWidget(label, labelWidgetClass, form, Args, ArgCount);
  1949. X    FirstArg(XtNfromVert, below);
  1950. X    NextArg(XtNhorizDistance, 30);
  1951. X    NextArg(XtNlabel, "X =");
  1952. X    NextArg(XtNborderWidth, 0);
  1953. X    beside = XtCreateManagedWidget(label, labelWidgetClass, form, Args, ArgCount);
  1954. X    sprintf(buf, "%d", fp->x);
  1955. X    ArgCount = 1;
  1956. X    NextArg(XtNstring, buf);
  1957. X    NextArg(XtNinsertPosition, strlen(buf));
  1958. X    NextArg(XtNfromHoriz, beside);
  1959. X    NextArg(XtNeditType, "append");
  1960. X    NextArg(XtNwidth, 40);
  1961. X    *pi_x = XtCreateManagedWidget(label, asciiTextWidgetClass, form, Args, ArgCount);
  1962. X    ArgCount = 1;
  1963. X    NextArg(XtNlabel, "Y =");
  1964. X    NextArg(XtNborderWidth, 0);
  1965. X    NextArg(XtNfromHoriz, *pi_x);
  1966. X    beside = XtCreateManagedWidget(label, labelWidgetClass, form, Args, ArgCount);
  1967. X    sprintf(buf, "%d", fp->y);
  1968. X    ArgCount = 1;
  1969. X    NextArg(XtNstring, buf);
  1970. X    NextArg(XtNinsertPosition, strlen(buf));
  1971. X    NextArg(XtNfromHoriz, beside);
  1972. X    NextArg(XtNeditType, "append");
  1973. X    NextArg(XtNwidth, 40);
  1974. X    *pi_y = XtCreateManagedWidget(label, asciiTextWidgetClass, form, Args, ArgCount);
  1975. X    below = *pi_x;
  1976. X}
  1977. X
  1978. Xstatic
  1979. Xget_f_pos(fp, pi_x, pi_y)
  1980. X    F_pos       *fp;
  1981. X    Widget        pi_x, pi_y;
  1982. X{
  1983. X    fp->x = (atoi(panel_get_value(pi_x)));
  1984. X    fp->y = (atoi(panel_get_value(pi_y)));
  1985. X}
  1986. X
  1987. Xstatic
  1988. Xpoints_panel(p, closed)
  1989. X    struct f_point *p;
  1990. X    int            closed;
  1991. X{
  1992. X    struct f_point *pts;
  1993. X    char        buf[32];
  1994. X    char        bufxy[32];
  1995. X    int            i;
  1996. X    Widget        viewp,formw;
  1997. X
  1998. X    FirstArg(XtNfromVert, below);
  1999. X    NextArg(XtNborderWidth, 0);
  2000. X    below = XtCreateManagedWidget("Points", labelWidgetClass, form,
  2001. X                  Args, ArgCount);
  2002. X    FirstArg(XtNallowVert, True);
  2003. X    NextArg(XtNfromVert, below);
  2004. X    pts = p;
  2005. X    for (i = 0; pts != NULL; i++)
  2006. X    pts = pts->next;
  2007. X    /* limit size of points panel and scroll if more than 8 points */
  2008. X    if (i>8)
  2009. X        NextArg(XtNheight, 200);
  2010. X    viewp = XtCreateManagedWidget("Pointspanel", viewportWidgetClass, form,
  2011. X                  Args, ArgCount);
  2012. X    formw = XtCreateManagedWidget("pointsform", formWidgetClass, viewp,
  2013. X                  NULL, 0);
  2014. X    below = 0;
  2015. X    for (i = 0; p != NULL; i++) {
  2016. X    if (i >= MAXNUMPTS)
  2017. X        break;
  2018. X    FirstArg(XtNfromVert, below);
  2019. X    NextArg(XtNhorizDistance, 30);
  2020. X    NextArg(XtNborderWidth, 0);
  2021. X    sprintf(buf, "X%d =", i);
  2022. X    beside = XtCreateManagedWidget(buf, labelWidgetClass, formw,
  2023. X                       Args, ArgCount);
  2024. X    sprintf(bufxy, "%d", p->x);
  2025. X    ArgCount = 1;
  2026. X    NextArg(XtNstring, bufxy);
  2027. X    NextArg(XtNinsertPosition, strlen(bufxy));
  2028. X    NextArg(XtNfromHoriz, beside);
  2029. X    NextArg(XtNeditType, "append");
  2030. X    NextArg(XtNwidth, 40);
  2031. X    px_panel[i] = XtCreateManagedWidget("xy", asciiTextWidgetClass,
  2032. X                        formw, Args, ArgCount);
  2033. X
  2034. X    sprintf(buf, "Y%d =", i);
  2035. X    ArgCount = 1;
  2036. X    NextArg(XtNfromHoriz, px_panel[i]);
  2037. X    NextArg(XtNborderWidth, 0);
  2038. X    beside = XtCreateManagedWidget(buf, labelWidgetClass,
  2039. X                       formw, Args, ArgCount);
  2040. X
  2041. X    sprintf(bufxy, "%d", p->y);
  2042. X    ArgCount = 1;
  2043. X    NextArg(XtNstring, bufxy);
  2044. X    NextArg(XtNinsertPosition, strlen(bufxy));
  2045. X    NextArg(XtNfromHoriz, beside);
  2046. X    NextArg(XtNeditType, "append");
  2047. X    NextArg(XtNwidth, 40);
  2048. X
  2049. X    py_panel[i] = XtCreateManagedWidget("xy", asciiTextWidgetClass,
  2050. X                        formw, Args, ArgCount);
  2051. X    below = px_panel[i];
  2052. X
  2053. X    p = p->next;
  2054. X    if (closed && (p == NULL || p->next == NULL))
  2055. X        break;
  2056. X    }
  2057. X}
  2058. X
  2059. Xstatic
  2060. Xget_points(p, closed)
  2061. X    struct f_point *p;
  2062. X    Boolean       closed;
  2063. X{
  2064. X    struct f_point *q;
  2065. X    int            i;
  2066. X
  2067. X    for (q = p, i = 0; q != NULL; i++) {
  2068. X    if (i >= MAXNUMPTS)
  2069. X        break;
  2070. X    q->x = (atoi(panel_get_value(px_panel[i])));
  2071. X    q->y = (atoi(panel_get_value(py_panel[i])));
  2072. X    q = q->next;
  2073. X    if (closed) {
  2074. X        if (q == NULL)
  2075. X        break;
  2076. X        else if (q->next == NULL) {
  2077. X        q->x = p->x;
  2078. X        q->y = p->y;
  2079. X        break;
  2080. X        }
  2081. X    }
  2082. X    }
  2083. X}
  2084. X
  2085. Xvoid
  2086. XQuit(widget, client_data, call_data)
  2087. X    Widget        widget;
  2088. X    XtPointer        client_data, call_data;
  2089. X{
  2090. X    XtDestroyWidget(popup);
  2091. X}
  2092. X
  2093. Xchar           *
  2094. Xpanel_get_value(widg)
  2095. X    Widget        widg;
  2096. X{
  2097. X    char       *val;
  2098. X
  2099. X    FirstArg(XtNstring, &val);
  2100. X    GetValues(widg);
  2101. X    return val;
  2102. X
  2103. X}
  2104. X
  2105. Xpanel_clear_value(widg)
  2106. X    Widget        widg;
  2107. X{
  2108. X    FirstArg(XtNstring, " ");
  2109. X    NextArg(XtNinsertPosition, 0);
  2110. X    SetValues(widg);
  2111. X}
  2112. X
  2113. Xint
  2114. Xpanel_set_value(widg, val)
  2115. X    Widget        widg;
  2116. X    char       *val;
  2117. X{
  2118. X    FirstArg(XtNstring, val);
  2119. X    /* I don't know why this doesn't work? */
  2120. X    /* NextArg(XtNinsertPosition, strlen(val)); */
  2121. X    SetValues(widg);
  2122. X    XawTextSetInsertionPoint(widg, strlen(val));
  2123. X}
  2124. X
  2125. Xstatic void
  2126. Xline_style_select(w, new_style, garbage)
  2127. X    Widget        w;
  2128. X    XtPointer        new_style, garbage;
  2129. X{
  2130. X    FirstArg(XtNlabel, XtName(w));
  2131. X    SetValues(style_panel);
  2132. X
  2133. X    generic_vals.style = (int) new_style;
  2134. X
  2135. X    switch (generic_vals.style) {
  2136. X    case SOLID_LINE:
  2137. X    panel_clear_value(style_val_panel);
  2138. X    FirstArg(XtNsensitive, False);
  2139. X    break;
  2140. X    case DASH_LINE:
  2141. X    /*
  2142. X     * if style_val contains no useful value, set it to the default
  2143. X     * dashlength, scaled by the line thickness
  2144. X     */
  2145. X    if (generic_vals.style_val < 0.1)
  2146. X        generic_vals.style_val = cur_dashlength * (cur_linewidth + 1) / 2;
  2147. X    sprintf(buf, "%1.1f", generic_vals.style_val);
  2148. X    panel_set_value(style_val_panel, buf);
  2149. X    FirstArg(XtNsensitive, True);
  2150. X    break;
  2151. X    case DOTTED_LINE:
  2152. X    if (generic_vals.style_val < 0.1)
  2153. X        generic_vals.style_val = cur_dotgap * (cur_linewidth + 1) / 2;
  2154. X    sprintf(buf, "%1.1f", generic_vals.style_val);
  2155. X    panel_set_value(style_val_panel, buf);
  2156. X    FirstArg(XtNsensitive, True);
  2157. X    break;
  2158. X    }
  2159. X    /* make both the label and value panels sensitive or insensitive */
  2160. X    SetValues(style_val_panel);
  2161. X    SetValues(style_val_label);
  2162. X}
  2163. X
  2164. Xstatic void
  2165. Xcolor_select(w, new_color, garbage)
  2166. X    Widget        w;
  2167. X    XtPointer        new_color, garbage;
  2168. X{
  2169. X    XFontStruct       *f;
  2170. X    int            len;
  2171. X
  2172. X    FirstArg(XtNlabel, XtName(w));
  2173. X    SetValues(color_panel);
  2174. X    color = (Color) new_color;
  2175. X    set_color_name(color);
  2176. X    FirstArg(XtNfont, &f);
  2177. X    GetValues(w);
  2178. X    FirstArg(XtNlabel, buf);
  2179. X    len = XTextWidth(f, buf, strlen(buf)) + 8;
  2180. X    NextArg(XtNwidth, len);    /* set width of panel to width of colorname */
  2181. X    NextArg(XtNresizable, True);
  2182. X
  2183. X    if (all_colors_available) { /* set color if possible */
  2184. X    XColor        xcolor;
  2185. X    Pixel        col;
  2186. X
  2187. X    /* foreground in the color selected */
  2188. X    col = (color < 0 || color >= NUMCOLORS) ? x_fg_color.pixel : appres.color[color];
  2189. X    NextArg(XtNforeground, col);
  2190. X    xcolor.pixel = col;
  2191. X    /* get RGB of the color to check intensity */
  2192. X    XQueryColor(tool_d, DefaultColormapOfScreen(tool_s), &xcolor);
  2193. X    /* set the background in a contrasting color (white or black) */
  2194. X    if ((0.3 * xcolor.red + 0.59 * xcolor.green + 0.11 * xcolor.blue) < 0.55 * (255 << 8))
  2195. X        col = appres.color[WHITE];
  2196. X    else
  2197. X        col = appres.color[BLACK];
  2198. X    NextArg(XtNbackground, col);
  2199. X    }
  2200. X    SetValues(color_panel);
  2201. X}
  2202. X
  2203. Xstatic void
  2204. Xset_color_name(color)
  2205. X    Color        color;
  2206. X{
  2207. X    if (color == DEFAULT_COLOR || (color >= 0 && color < NUMCOLORS))
  2208. X    sprintf(buf, "%s", colorNames[color + 1]);
  2209. X    else
  2210. X    sprintf(buf, "%d", color);
  2211. X}
  2212. X
  2213. Xstatic void
  2214. Xhidden_text_select(w, new_hidden_text, garbage)
  2215. X    Widget        w;
  2216. X    XtPointer        new_hidden_text, garbage;
  2217. X{
  2218. X    FirstArg(XtNlabel, XtName(w));
  2219. X    SetValues(hidden_text_panel);
  2220. X    hidden_text_flag = (int) new_hidden_text;
  2221. X}
  2222. X
  2223. Xstatic void
  2224. Xrigid_text_select(w, new_rigid_text, garbage)
  2225. X    Widget        w;
  2226. X    XtPointer        new_rigid_text, garbage;
  2227. X{
  2228. X    FirstArg(XtNlabel, XtName(w));
  2229. X    SetValues(rigid_text_panel);
  2230. X    rigid_text_flag = (int) new_rigid_text;
  2231. X}
  2232. X
  2233. Xstatic void
  2234. Xspecial_text_select(w, new_special_text, garbage)
  2235. X    Widget        w;
  2236. X    XtPointer        new_special_text, garbage;
  2237. X{
  2238. X    FirstArg(XtNlabel, XtName(w));
  2239. X    SetValues(special_text_panel);
  2240. X    special_text_flag = (int) new_special_text;
  2241. X}
  2242. X
  2243. Xstatic void
  2244. Xtextjust_select(w, new_textjust, garbage)
  2245. X    Widget        w;
  2246. X    XtPointer        new_textjust, garbage;
  2247. X{
  2248. X    FirstArg(XtNlabel, XtName(w));
  2249. X    SetValues(textjust_panel);
  2250. X    textjust = (int) new_textjust;
  2251. X}
  2252. X
  2253. Xstatic void
  2254. Xflip_eps_select(w, new_flipflag, garbage)
  2255. X    Widget        w;
  2256. X    XtPointer        new_flipflag, garbage;
  2257. X{
  2258. X    struct f_point  p1, p2;
  2259. X    int            dx, dy, rotation;
  2260. X    float        ratio;
  2261. X
  2262. X    FirstArg(XtNlabel, XtName(w));
  2263. X    SetValues(flip_eps_panel);
  2264. X    flip_eps_flag = (int) new_flipflag;
  2265. X    p1.x = atoi(panel_get_value(x1_panel));
  2266. X    p1.y = atoi(panel_get_value(y1_panel));
  2267. X    p2.x = atoi(panel_get_value(x2_panel));
  2268. X    p2.y = atoi(panel_get_value(y2_panel));
  2269. X    dx = p2.x - p1.x;
  2270. X    dy = p2.y - p1.y;
  2271. X    rotation = 0;
  2272. X    if (dx < 0 && dy < 0)
  2273. X    rotation = 180;
  2274. X    else if (dx < 0 && dy >= 0)
  2275. X    rotation = 270;
  2276. X    else if (dy < 0 && dx >= 0)
  2277. X    rotation = 90;
  2278. X    if (dx == 0 || dy == 0)
  2279. X    ratio = 0.0;
  2280. X    else if (((rotation == 0 || rotation == 180) && !flip_eps_flag) ||
  2281. X         (rotation != 0 && rotation != 180 && flip_eps_flag))
  2282. X    ratio = fabs((float) dy / (float) dx);
  2283. X    else
  2284. X    ratio = fabs((float) dx / (float) dy);
  2285. X    sprintf(buf, "%1.1f", ratio);
  2286. X    FirstArg(XtNlabel, buf);
  2287. X    SetValues(hw_ratio_panel);
  2288. X}
  2289. X
  2290. Xstatic void
  2291. Xfill_style_select(w, new_fillflag, garbage)
  2292. X    Widget        w;
  2293. X    XtPointer        new_fillflag, garbage;
  2294. X{
  2295. X    int            fill;
  2296. X
  2297. X    FirstArg(XtNlabel, XtName(w));
  2298. X    SetValues(fill_flag_panel);
  2299. X    fill_flag = (int) new_fillflag;
  2300. X
  2301. X    if (fill_flag) {
  2302. X    fill = (generic_vals.fill_style - 1) * (100 / (NUMFILLPATS - 1));
  2303. X    if (fill < 0)
  2304. X        fill = 0;
  2305. X    /* if no fill, blank out fill density value */
  2306. X    sprintf(buf, "%d", fill);
  2307. X    panel_set_value(fill_style_panel, buf);
  2308. X    } else {
  2309. X    panel_clear_value(fill_style_panel);
  2310. X    }
  2311. X
  2312. X    /* make fill% panel sensitive or insensitive depending on fill flag */
  2313. X    FirstArg(XtNsensitive, fill_flag ? True : False);
  2314. X    SetValues(fill_style_panel);
  2315. X    SetValues(fill_style_label);
  2316. X}
  2317. X
  2318. Xvoid clear_text_key(w)
  2319. XWidget w;
  2320. X{
  2321. X    panel_set_value(w, "");
  2322. X}
  2323. X
  2324. Xstatic void get_clipboard();
  2325. X
  2326. Xvoid paste_panel_key(w, event)
  2327. XWidget w;
  2328. XXKeyEvent *event;
  2329. X{
  2330. X    Time event_time;
  2331. X
  2332. X        event_time = event->time;
  2333. X        XtGetSelectionValue(w, XA_PRIMARY, XA_STRING, get_clipboard, w, event_time);
  2334. X}
  2335. X
  2336. Xstatic void get_clipboard(w, client_data, selection, type, buf, length, format)
  2337. XWidget w;
  2338. XXtPointer client_data;
  2339. XAtom *selection;
  2340. XAtom *type;
  2341. XXtPointer buf;
  2342. Xunsigned long *length;
  2343. Xint *format;
  2344. X{
  2345. X    char *c, *p;
  2346. X    int i;
  2347. X    char s[256];
  2348. X
  2349. X    strcpy (s, panel_get_value(client_data));
  2350. X    p = strchr(s, '\0');
  2351. X    c = buf;
  2352. X    for (i=0; i<*length; i++) {
  2353. X        if (*c=='\0' || *c=='\n' || *c=='\r' || strlen(s)>=sizeof(s)-1)
  2354. X            break;
  2355. X        *p = *c;
  2356. X        p++;
  2357. X        *p = '\0';
  2358. X        c++;
  2359. X    }
  2360. X    XtFree(buf);
  2361. X    panel_set_value(client_data, s);
  2362. X}
  2363. END_OF_FILE
  2364. if test 64464 -ne `wc -c <'e_edit.c'`; then
  2365.     echo shar: \"'e_edit.c'\" unpacked with wrong size!
  2366. fi
  2367. # end of 'e_edit.c'
  2368. fi
  2369. echo shar: End of archive 25 \(of 27\).
  2370. cp /dev/null ark25isdone
  2371. MISSING=""
  2372. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ; do
  2373.     if test ! -f ark${I}isdone ; then
  2374.     MISSING="${MISSING} ${I}"
  2375.     fi
  2376. done
  2377. if test "${MISSING}" = "" ; then
  2378.     echo You have unpacked all 27 archives.
  2379.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2380. else
  2381.     echo You still need to unpack the following archives:
  2382.     echo "        " ${MISSING}
  2383. fi
  2384. ##  End of shell archive.
  2385. exit 0
  2386.  
  2387. exit 0 # Just in case...
  2388. -- 
  2389.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  2390. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  2391.  "It's intuitively obvious to the |
  2392.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  2393.