Exemplo n.º 1
0
void
put_selected(void)
{
	int	 i, x,y;
	char	*com;

	set_mousefun("place object","new object","cancel library",
			"place and edit","change draw mode", "place at orig posn");
	set_action_on();
	cur_c = lib_compounds[cur_library_object]->compound;
	new_c = copy_compound(cur_c);
	/* add it to the depths so it is displayed */
	add_compound_depth(new_c);
	/* find lower-right corner for draw_box() */
	off_library_x = new_c->secorner.x;
	off_library_y = new_c->secorner.y;
	/* and upper-left in case the user wants to place it at its original position */
	/* this is saved here because the compound was shifted to 0,0 when reading in */
	orig_put_x = lib_compounds[cur_library_object]->corner.x;
	orig_put_y = lib_compounds[cur_library_object]->corner.y;

	canvas_locmove_proc = init_move_object;
	canvas_ref_proc = null_proc;
	canvas_leftbut_proc = place_lib_object;
	canvas_middlebut_proc = sel_place_lib_obj_proc;
	canvas_rightbut_proc = cancel_place_lib_obj;
	set_cursor(null_cursor);

	/* get the pointer position */
	get_pointer_win_xy(&x, &y);
	/* draw the first image */
	init_move_object(BACKX(x), BACKY(y));

	/* message that we're placing object so and so */
	com = strdup(lib_compounds[cur_library_object]->compound->comments);
	if (strlen(com)) {
	    /* change newlines to blanks */
	    for (i=strlen(com); i>=0; i--)
		if (com[i] == '\n')
		    com[i] = ' ';
	    put_msg("Placing library object \"%s\" (%s.fig)",
		com, library_objects_texts[cur_library_object]);
	} else {
	    put_msg("Placing library object %s.fig", library_objects_texts[cur_library_object]);
	}
}
Exemplo n.º 2
0
void undo_change(void)
{
    char	   *swp_comm;
    F_compound	    swp_c;
    F_line	    swp_l;
    F_spline	    swp_s;
    F_ellipse	    swp_e;
    F_arc	    swp_a;
    F_text	    swp_t;

    last_action = F_NULL;	/* to avoid a clean-up during "unchange" */
    switch (last_object) {
      case O_POLYLINE:
	new_l = saved_objects.lines;		/* the original */
	old_l = saved_objects.lines->next;	/* the changed object */
	/* account for depths */
	remove_depth(O_POLYLINE, old_l->depth);
	add_depth(O_POLYLINE, new_l->depth);
	/* swap old with new */
	bcopy((char*)old_l, (char*)&swp_l, sizeof(F_line));
	bcopy((char*)new_l, (char*)old_l, sizeof(F_line));
	bcopy((char*)&swp_l, (char*)new_l, sizeof(F_line));
	/* but keep the next pointers unchanged */
	swp_l.next = old_l->next;
	old_l->next = new_l->next;
	new_l->next = swp_l.next;
	set_action_object(F_EDIT, O_POLYLINE);
	redisplay_lines(new_l, old_l);
	break;
      case O_ELLIPSE:
	new_e = saved_objects.ellipses;
	old_e = saved_objects.ellipses->next;
	/* account for depths */
	remove_depth(O_ELLIPSE, old_e->depth);
	add_depth(O_ELLIPSE, new_e->depth);
	/* swap old with new */
	bcopy((char*)old_e, (char*)&swp_e, sizeof(F_ellipse));
	bcopy((char*)new_e, (char*)old_e, sizeof(F_ellipse));
	bcopy((char*)&swp_e, (char*)new_e, sizeof(F_ellipse));
	/* but keep the next pointers unchanged */
	swp_e.next = old_e->next;
	old_e->next = new_e->next;
	new_e->next = swp_e.next;
	set_action_object(F_EDIT, O_ELLIPSE);
	redisplay_ellipses(new_e, old_e);
	break;
      case O_TXT:
	new_t = saved_objects.texts;
	old_t = saved_objects.texts->next;
	/* account for depths */
	remove_depth(O_TXT, old_t->depth);
	add_depth(O_TXT, new_t->depth);
	/* swap old with new */
	bcopy((char*)old_t, (char*)&swp_t, sizeof(F_text));
	bcopy((char*)new_t, (char*)old_t, sizeof(F_text));
	bcopy((char*)&swp_t, (char*)new_t, sizeof(F_text));
	/* but keep the next pointers unchanged */
	swp_t.next = old_t->next;
	old_t->next = new_t->next;
	new_t->next = swp_t.next;
	set_action_object(F_EDIT, O_TXT);
	redisplay_texts(new_t, old_t);
	break;
      case O_SPLINE:
	new_s = saved_objects.splines;
	old_s = saved_objects.splines->next;
	/* account for depths */
	remove_depth(O_SPLINE, old_s->depth);
	add_depth(O_SPLINE, new_s->depth);
	/* swap old with new */
	bcopy((char*)old_s, (char*)&swp_s, sizeof(F_spline));
	bcopy((char*)new_s, (char*)old_s, sizeof(F_spline));
	bcopy((char*)&swp_s, (char*)new_s, sizeof(F_spline));
	/* but keep the next pointers unchanged */
	swp_s.next = old_s->next;
	old_s->next = new_s->next;
	new_s->next = swp_s.next;
	set_action_object(F_EDIT, O_SPLINE);
	redisplay_splines(new_s, old_s);
	break;
      case O_ARC:
	new_a = saved_objects.arcs;
	old_a = saved_objects.arcs->next;
	/* account for depths */
	remove_depth(O_ARC, old_a->depth);
	add_depth(O_ARC, new_a->depth);
	/* swap old with new */
	bcopy((char*)old_a, (char*)&swp_a, sizeof(F_arc));
	bcopy((char*)new_a, (char*)old_a, sizeof(F_arc));
	bcopy((char*)&swp_a, (char*)new_a, sizeof(F_arc));
	/* but keep the next pointers unchanged */
	swp_a.next = old_a->next;
	old_a->next = new_a->next;
	new_a->next = swp_a.next;
	set_action_object(F_EDIT, O_ARC);
	redisplay_arcs(new_a, old_a);
	break;
      case O_COMPOUND:
	new_c = saved_objects.compounds;
	old_c = saved_objects.compounds->next;
	/* account for depths */
	remove_compound_depth(old_c);
	add_compound_depth(new_c);
	/* swap old with new */
	bcopy((char*)old_c, (char*)&swp_c, sizeof(F_compound));
	bcopy((char*)new_c, (char*)old_c, sizeof(F_compound));
	bcopy((char*)&swp_c, (char*)new_c, sizeof(F_compound));
	/* but keep the next pointers unchanged */
	swp_c.next = old_c->next;
	old_c->next = new_c->next;
	new_c->next = swp_c.next;
	set_action_object(F_EDIT, O_COMPOUND);
	redisplay_compounds(new_c, old_c);
	break;
      case O_FIGURE:
	/* swap saved figure comments with current */
	swp_comm = objects.comments;
	objects.comments = saved_objects.comments;
	saved_objects.comments = swp_comm;
	set_action_object(F_EDIT, O_FIGURE);
	break;
      case O_ALL_OBJECT:
	swp_c = objects;
	objects = saved_objects;
	saved_objects = swp_c;
	new_c = &objects;
	old_c = &saved_objects;
	/* account for depths */
	remove_compound_depth(old_c);
	add_compound_depth(new_c);
	set_action_object(F_EDIT, O_ALL_OBJECT);
	set_modifiedflag();
	redisplay_zoomed_region(0, 0, BACKX(CANVAS_WD), BACKY(CANVAS_HT));
	break;
    }
}