home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / xfig2.8 / part02 / arcbox.c next >
Encoding:
C/C++ Source or Header  |  1990-07-02  |  2.5 KB  |  110 lines

  1. /* 
  2.  *    FIG : Facility for Interactive Generation of figures
  3.  *
  4.  *    Adapted by Brian V. Smith from box.c originally writen by:
  5.  *
  6.  *    Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  7.  *    January 1985.
  8.  *    1st revision : Aug 1985.
  9.  *
  10.  *    %W%    %G%
  11. */
  12. #include "fig.h"
  13. #include "resources.h"
  14. #include "alloc.h"
  15. #include "func.h"
  16. #include "object.h"
  17. #include "paintop.h"
  18.  
  19. extern int        line_style, line_thickness;
  20. extern float        cur_styleval;
  21. extern int        cur_color;
  22. extern int        cur_areafill;
  23. extern int        cur_radius;
  24. extern int        fill_mode;
  25. extern int        fix_x, fix_y, cur_x, cur_y;
  26. extern            (*canvas_kbd_proc)();
  27. extern            (*canvas_locmove_proc)();
  28. extern            (*canvas_leftbut_proc)();
  29. extern            (*canvas_middlebut_proc)();
  30. extern            (*canvas_rightbut_proc)();
  31. extern            null_proc();
  32. extern            set_popupmenu();
  33.  
  34. extern F_compound    objects;
  35.  
  36. /*************************** locally global procedures *********************/
  37.  
  38. extern int        elastic_box();
  39. extern int        create_arc_boxobject();
  40. extern int        init_arc_box_drawing();
  41.  
  42. arc_box_drawing_selected()
  43. {
  44.     canvas_kbd_proc = null_proc;
  45.     canvas_locmove_proc = null_proc;
  46.     canvas_leftbut_proc = init_arc_box_drawing;
  47.     canvas_middlebut_proc = null_proc;
  48.     canvas_rightbut_proc = set_popupmenu;
  49.     set_cursor(&arrow_cursor);
  50.     reset_action_on();
  51.     }
  52.  
  53. init_arc_box_drawing(x, y)
  54. int    x, y;
  55. {
  56.     cur_x = fix_x = x; 
  57.     cur_y = fix_y = y;
  58.     canvas_locmove_proc = elastic_box;
  59.     canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
  60.     canvas_middlebut_proc = create_arc_boxobject;
  61.     draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT);
  62.     set_temp_cursor(&null_cursor);
  63.     set_action_on();
  64.     }
  65.  
  66. create_arc_boxobject(x, y)
  67. int    x, y;
  68. {
  69.     F_line    *box;
  70.     F_point    *point;
  71.  
  72.     draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT);
  73.  
  74.     
  75.     if ((Point_malloc(point)) == NULL) {
  76.         blink_msg();
  77.         put_msg(Err_mem);
  78.         return;
  79.         }
  80.     point->x = x;
  81.     point->y = y;
  82.     point->next = NULL;
  83.  
  84.     Line_malloc(box);
  85.     box->type = T_ARC_BOX;
  86.     box->style = line_style;
  87.     box->thickness = line_thickness;
  88.     box->color = cur_color;
  89.     box->depth = 0;
  90.     box->pen = 0;
  91.     box->area_fill = fill_mode? cur_areafill : 0;
  92.     box->style_val = cur_styleval;
  93.     box->radius = cur_radius;    /* corner radius */
  94.     box->for_arrow = NULL;
  95.     box->back_arrow = NULL;
  96.     box->points = point;
  97.     box->next  = NULL;
  98.     append_point(x, fix_y, &point);
  99.     append_point(fix_x, fix_y, &point);
  100.     append_point(fix_x, y, &point);
  101.     append_point(x, y, &point);
  102.     draw_line(box, PAINT);
  103.     clean_up();
  104.     set_action_object(F_CREATE, O_POLYLINE);
  105.     insert_line(&objects.lines, box);
  106.     set_latestline(box);
  107.     set_modifiedflag();
  108.     arc_box_drawing_selected();
  109.     }
  110.