home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / xfig2.8 / part03 / remove.c < prev    next >
C/C++ Source or Header  |  1990-07-02  |  3KB  |  136 lines

  1. /* 
  2.  *    FIG : Facility for Interactive Generation of figures
  3.  *
  4.  *    Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  5.  *    January 1985.
  6.  *    1st revision : Aug 1985.
  7.  *
  8.  *    %W%    %G%
  9. */
  10. #include "fig.h"
  11. #include "resources.h"
  12. #include "func.h"
  13. #include "object.h"
  14. #include "paintop.h"
  15.  
  16. #define            TOLERANCE    7
  17.  
  18. extern            (*canvas_kbd_proc)();
  19. extern            (*canvas_locmove_proc)();
  20. extern            (*canvas_leftbut_proc)();
  21. extern            (*canvas_middlebut_proc)();
  22. extern            (*canvas_rightbut_proc)();
  23. extern            null_proc();
  24. extern            set_popupmenu();
  25.  
  26.  
  27. extern int        foreground_color, background_color;
  28.  
  29. extern int        init_remove();
  30.  
  31. remove_selected()
  32. {
  33.     canvas_kbd_proc = null_proc;
  34.     canvas_locmove_proc = null_proc;
  35.     canvas_leftbut_proc = init_remove;
  36.     canvas_middlebut_proc = null_proc;
  37.     canvas_rightbut_proc = set_popupmenu;
  38.     set_cursor(&buster_cursor);
  39.     }
  40.  
  41. init_remove(x, y)
  42. int    x, y;
  43. {
  44.     extern F_line        *line_search();
  45.     extern F_arc        *arc_search();
  46.     extern F_ellipse    *ellipse_search();
  47.     extern F_text        *text_search();
  48.     extern F_spline        *spline_search();
  49.     extern F_compound    *compound_search();
  50.     extern F_compound    objects;
  51.     F_line        *l;
  52.     F_arc        *a;
  53.     F_ellipse    *e;
  54.     F_text        *t;
  55.     F_spline    *s;
  56.     F_compound    *c;
  57.     int        dummy;
  58.  
  59.     if ((c = compound_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
  60.         draw_compoundbox(c, INV_PAINT);
  61.         erase_compound(c);
  62.         delete_compound(&objects.compounds, c);
  63.         clean_up();
  64.         set_action_object(F_REMOVE, O_COMPOUND);
  65.         set_latestcompound(c);
  66.         set_modifiedflag();
  67.         }
  68.     else if ((l = line_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
  69.         toggle_linepointmarker(l);
  70.         draw_line(l, ERASE);
  71.         delete_line(&objects.lines, l);
  72.         clean_up();
  73.         set_action_object(F_REMOVE, O_POLYLINE);
  74.         set_latestline(l);
  75.         set_modifiedflag();
  76.         }
  77.     else if ((t = text_search(x, y)) != NULL) {
  78.         draw_text(t, INV_PAINT);
  79.         delete_text(&objects.texts, t);
  80.         clean_up();
  81.         set_action_object(F_REMOVE, O_TEXT);
  82.         set_latesttext(t);
  83.         set_modifiedflag();
  84.         }
  85.     else if ((e = ellipse_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
  86.         toggle_ellipsepointmarker(e);
  87.         draw_ellipse(e, background_color);
  88.         delete_ellipse(&objects.ellipses, e);
  89.         clean_up();
  90.         set_action_object(F_REMOVE, O_ELLIPSE);
  91.         set_latestellipse(e);
  92.         set_modifiedflag();
  93.         }
  94.     else if ((a = arc_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL){
  95.         toggle_arcpointmarker(a);
  96.         draw_arc(a, background_color);
  97.         delete_arc(&objects.arcs, a);
  98.         clean_up();
  99.         set_action_object(F_REMOVE, O_ARC);
  100.         set_latestarc(a);
  101.         set_modifiedflag();
  102.         }
  103.     else if ((s = spline_search(x, y, TOLERANCE, &dummy, &dummy)) != NULL) {
  104.         toggle_splinepointmarker(s);
  105.         draw_spline(s, ERASE);
  106.         delete_spline(&objects.splines, s);
  107.         clean_up();
  108.         set_action_object(F_REMOVE, O_SPLINE);
  109.         set_latestspline(s);
  110.         set_modifiedflag();
  111.         }
  112.     remove_selected();
  113.     }
  114.  
  115. remove_all()
  116. {
  117.     extern F_compound    objects;
  118.     extern F_compound    saved_objects;
  119.     extern int        last_action;
  120.  
  121.     clean_up();
  122.     set_action_object(F_REMOVE, O_ALL_OBJECT);
  123.  
  124.     /* Aggregate assignment between variables is allowed,
  125.     but not from constant (weird!?) */
  126.  
  127.     saved_objects = objects;
  128.  
  129.     objects.arcs = NULL;
  130.     objects.compounds = NULL;
  131.     objects.ellipses = NULL;
  132.     objects.lines = NULL;
  133.     objects.splines = NULL;
  134.     objects.texts = NULL;
  135.     }
  136.