home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xfig / part02 / d_epsobj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-27  |  2.8 KB  |  118 lines

  1. /*
  2.  * FIG : Facility for Interactive Generation of figures
  3.  * Copyright (c) 1985 by Supoj Sutanthavibul
  4.  *
  5.  * "Permission to use, copy, modify, distribute, and sell this software and its
  6.  * documentation for any purpose is hereby granted without fee, provided that
  7.  * the above copyright notice appear in all copies and that both the copyright
  8.  * notice and this permission notice appear in supporting documentation. 
  9.  * No representations are made about the suitability of this software for 
  10.  * any purpose.  It is provided "as is" without express or implied warranty."
  11.  */
  12.  
  13. #include "fig.h"
  14. #include "resources.h"
  15. #include "mode.h"
  16. #include "object.h"
  17. #include "paintop.h"
  18. #include "u_create.h"
  19. #include "u_elastic.h"
  20. #include "u_list.h"
  21. #include "w_canvas.h"
  22. #include "w_mousefun.h"
  23.  
  24. /*************************** local declarations *********************/
  25.  
  26. static
  27.         init_epsobj_drawing(), create_epsobj(),
  28.         cancel_epsobj();
  29.  
  30. epsobj_drawing_selected()
  31. {
  32.     set_mousefun("corner point", "", "");
  33.     canvas_kbd_proc = null_proc;
  34.     canvas_locmove_proc = null_proc;
  35.     canvas_leftbut_proc = init_epsobj_drawing;
  36.     canvas_middlebut_proc = null_proc;
  37.     canvas_rightbut_proc = null_proc;
  38.     set_cursor(arrow_cursor);
  39.     reset_action_on();
  40. }
  41.  
  42. static
  43. init_epsobj_drawing(x, y)
  44.     int            x, y;
  45. {
  46.     init_box_drawing(x, y);
  47.     canvas_leftbut_proc = create_epsobj;
  48.     canvas_rightbut_proc = cancel_epsobj;
  49. }
  50.  
  51. static
  52. cancel_epsobj()
  53. {
  54.     elastic_box(fix_x, fix_y, cur_x, cur_y);
  55.     epsobj_drawing_selected();
  56.     draw_mousefun_canvas();
  57. }
  58.  
  59. static
  60. create_epsobj(x, y)
  61.     int            x, y;
  62. {
  63.     F_line       *box;
  64.     F_point       *point;
  65.  
  66.     elastic_box(fix_x, fix_y, cur_x, cur_y);
  67.  
  68.     if ((point = create_point()) == NULL)
  69.     return;
  70.  
  71.     point->x = fix_x;
  72.     point->y = fix_y;
  73.     point->next = NULL;
  74.  
  75.     if ((box = create_line()) == NULL) {
  76.     free((char *) point);
  77.     return;
  78.     }
  79.     box->type = T_EPS_BOX;
  80.     box->style = SOLID_LINE;
  81.     box->thickness = 1;
  82.     box->color = cur_color;
  83.     box->depth = cur_depth;
  84.     box->pen = 0;
  85.     box->fill_style = 0;
  86.     box->style_val = 0;
  87.     box->radius = 0;
  88.  
  89.     if ((box->eps = create_eps()) == NULL) {
  90.     free((char *) point);
  91.     free((char *) box);
  92.     return;
  93.     }
  94.     box->eps->file[0] = '\0';
  95.     box->eps->bitmap = NULL;
  96.     box->eps->bit_size.x = 0;
  97.     box->eps->bit_size.y = 0;
  98.     box->eps->flipped = 0;
  99.     box->eps->hw_ratio = 0.0;
  100.     box->eps->pixmap = 0;
  101.     box->eps->pix_width = 0;
  102.     box->eps->pix_height = 0;
  103.     box->eps->pix_rotation = 0;
  104.     box->eps->pix_flipped = 0;
  105.  
  106.     box->points = point;
  107.     append_point(fix_x, y, &point);
  108.     append_point(x, y, &point);
  109.     append_point(x, fix_y, &point);
  110.     append_point(fix_x, fix_y, &point);
  111.     draw_line(box, PAINT);
  112.     add_line(box);
  113.     put_msg("Please enter name of EPS file in EDIT window");
  114.     edit_item((char *) box, O_POLYLINE);
  115.     epsobj_drawing_selected();
  116.     draw_mousefun_canvas();
  117. }
  118.