home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xfig / part02 / d_arcbox.c next >
Encoding:
C/C++ Source or Header  |  1993-05-27  |  2.8 KB  |  106 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 procedures *********************/
  25.  
  26. static int    create_arc_boxobject(), cancel_arc_boxobject();
  27. static int    init_arc_box_drawing();
  28.  
  29. arcbox_drawing_selected()
  30. {
  31.     set_mousefun("corner point", "", "");
  32.     canvas_kbd_proc = null_proc;
  33.     canvas_locmove_proc = null_proc;
  34.     canvas_leftbut_proc = init_arc_box_drawing;
  35.     canvas_middlebut_proc = null_proc;
  36.     canvas_rightbut_proc = null_proc;
  37.     set_cursor(arrow_cursor);
  38.     reset_action_on();
  39. }
  40.  
  41. static
  42. init_arc_box_drawing(x, y)
  43.     int            x, y;
  44. {
  45.     cur_x = fix_x = x;
  46.     cur_y = fix_y = y;
  47.     set_mousefun("final point", "", "cancel");
  48.     draw_mousefun_canvas();
  49.     canvas_locmove_proc = resizing_box;
  50.     canvas_leftbut_proc = create_arc_boxobject;
  51.     canvas_middlebut_proc = null_proc;
  52.     canvas_rightbut_proc = cancel_arc_boxobject;
  53.     elastic_box(fix_x, fix_y, cur_x, cur_y);
  54.     set_temp_cursor(null_cursor);
  55.     set_action_on();
  56. }
  57.  
  58. static
  59. cancel_arc_boxobject()
  60. {
  61.     elastic_box(fix_x, fix_y, cur_x, cur_y);
  62.     arcbox_drawing_selected();
  63.     draw_mousefun_canvas();
  64. }
  65.  
  66. static
  67. create_arc_boxobject(x, y)
  68.     int            x, y;
  69. {
  70.     F_line       *box;
  71.     F_point       *point;
  72.  
  73.     elastic_box(fix_x, fix_y, cur_x, cur_y);
  74.  
  75.     if ((point = create_point()) == NULL)
  76.     return;
  77.  
  78.     point->x = x;
  79.     point->y = y;
  80.     point->next = NULL;
  81.  
  82.     if ((box = create_line()) == NULL) {
  83.     free((char *) point);
  84.     return;
  85.     }
  86.     box->type = T_ARC_BOX;
  87.     box->style = cur_linestyle;
  88.     box->thickness = cur_linewidth;
  89.     box->color = cur_color;
  90.     box->depth = cur_depth;
  91.     box->pen = 0;
  92.     box->fill_style = cur_fillstyle;
  93.     /* multiply     dash length by line thickness */
  94.     box->style_val = cur_styleval * (cur_linewidth + 1) / 2;
  95.     box->radius = cur_boxradius;/* corner radius */
  96.     box->points = point;
  97.     append_point(x, fix_y, &point);
  98.     append_point(fix_x, fix_y, &point);
  99.     append_point(fix_x, y, &point);
  100.     append_point(x, y, &point);
  101.     draw_line(box, PAINT);
  102.     add_line(box);
  103.     arcbox_drawing_selected();
  104.     draw_mousefun_canvas();
  105. }
  106.