Index: graph_displayer_canvas-event.cc
===================================================================
--- graph_displayer_canvas-event.cc	(revision 30)
+++ graph_displayer_canvas-event.cc	(revision 31)
@@ -29,8 +29,7 @@
     {
     case MOVE:
-      actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
-      break;
-
-      //it has to assigned to canvas, because all the canvas has to be monitored, not only the elements of the already drawn group
+      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
+      break;
+
     case CREATE_NODE:
       actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false);
@@ -38,9 +37,9 @@
 
     case CREATE_EDGE:
-      actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
+      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
       break;
 
     case ERASER:
-      actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
+      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
       break;
 
@@ -61,7 +60,7 @@
     case GDK_BUTTON_PRESS:
       //we mark the location of the event to be able to calculate parameters of dragging
-      clicked_x=e->button.x;
-      clicked_y=e->button.y;
-      active_item=(get_item_at(e->button.x, e->button.y));
+      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
+
+      active_item=(get_item_at(clicked_x, clicked_y));
       active_node=INVALID;
       for (NodeIt i(g); i!=INVALID; ++i)
@@ -86,5 +85,4 @@
       active_item=NULL;
       active_node=INVALID;
-      updateScrollRegion();
       break;
     case GDK_MOTION_NOTIFY:
@@ -97,6 +95,10 @@
 	//has to be calculated from here
 
-        double dx=e->motion.x-clicked_x;
-        double dy=e->motion.y-clicked_y;
+	double new_x, new_y;
+
+	window_to_world (e->motion.x, e->motion.y, new_x, new_y);
+
+        double dx=new_x-clicked_x;
+        double dy=new_y-clicked_y;
 
 	//repositioning node and its text
@@ -104,6 +106,6 @@
 	nodetextmap[active_node]->move(dx, dy);
 
-        clicked_x=e->motion.x;
-        clicked_y=e->motion.y;
+        clicked_x=new_x;
+        clicked_y=new_y;
 
 	//all the edges connected to the moved point has to be redrawn
@@ -169,5 +171,5 @@
   }
 
-  return true;
+  return false;
 }
 
@@ -178,4 +180,7 @@
 
       //draw the new node in red at the clicked place
+    case GDK_2BUTTON_PRESS:
+      std::cout << "double click" << std::endl;
+      break;
     case GDK_BUTTON_PRESS:
       isbutton=1;
@@ -184,7 +189,9 @@
 
       //initiating values corresponding to new node in maps
-      
 
       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
+
+      target_item=NULL;
+      target_item=get_item_at(clicked_x, clicked_y);
 
       nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
@@ -206,7 +213,6 @@
 	double world_motion_x, world_motion_y;
 	GdkEvent * generated=new GdkEvent();
-	window_to_world (e->motion.x, e->motion.y, world_motion_x, world_motion_y);
-	generated->motion.x=world_motion_x;
-	generated->motion.y=world_motion_y;
+	generated->motion.x=e->motion.x;
+	generated->motion.y=e->motion.y;
 	generated->type=GDK_MOTION_NOTIFY;
 	moveEventHandler(generated);      
@@ -217,8 +223,17 @@
     case GDK_BUTTON_RELEASE:
       isbutton=0;
-      *active_item << Gnome::Canvas::Properties::fill_color("blue");
+      if(!target_item)
+	{
+	  //Its appropriate color is given by update.
+	  //*active_item << Gnome::Canvas::Properties::fill_color("blue");
+	}
+      else
+	{
+	  //In this case the given color has to be overwritten, because the noe covers an other item.
+	  *active_item << Gnome::Canvas::Properties::fill_color("lightblue");
+	}
+      target_item=NULL;
       active_item=NULL;
       active_node=INVALID;
-      updateScrollRegion();
       break;
     default:
@@ -240,7 +255,8 @@
 	    {
 	      //we mark the location of the event to be able to calculate parameters of dragging
-	      clicked_x=e->button.x;
-	      clicked_y=e->button.y;
-	      active_item=(get_item_at(e->button.x, e->button.y));
+
+	      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
+
+	      active_item=(get_item_at(clicked_x, clicked_y));
 	      active_node=INVALID;
 	      for (NodeIt i(g); i!=INVALID; ++i)
@@ -270,5 +286,6 @@
 	  else
 	    {
-	      target_item=(get_item_at(e->button.x, e->button.y));
+	      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
+	      target_item=(get_item_at(clicked_x, clicked_y));
 	      Graph::NodeIt target_node=INVALID;
 	      for (NodeIt i(g); i!=INVALID; ++i)
@@ -367,5 +384,6 @@
     {
     case GDK_BUTTON_PRESS:
-      active_item=(get_item_at(e->button.x, e->button.y));
+      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
+      active_item=(get_item_at(clicked_x, clicked_y));
       active_node=INVALID;
       active_edge=INVALID;
@@ -387,54 +405,59 @@
 	    }
 	}
-    *active_item << Gnome::Canvas::Properties::fill_color("red");
+      if(active_item)
+	{
+	  *active_item << Gnome::Canvas::Properties::fill_color("red");
+	}
       break;
 
     case GDK_BUTTON_RELEASE:
-      if(active_item==(get_item_at(e->button.x, e->button.y)))
-	{
-	  if(active_node!=INVALID)
-	    {
-
-	      //collecting edges to delete
-	      EdgeIt e;
-	      std::set<Graph::Edge> edges_to_delete;
-
-	      g.firstOut(e,active_node);
-	      for(;e!=INVALID;g.nextOut(e))
-		{
+      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
+      if(active_item)
+	{
+	  if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
+	    {
+	      if(active_node!=INVALID)
+		{
+
+		  //collecting edges to delete
+		  EdgeIt e;
+		  std::set<Graph::Edge> edges_to_delete;
+
+		  g.firstOut(e,active_node);
+		  for(;e!=INVALID;g.nextOut(e))
+		    {
 		      edges_to_delete.insert(e);
-		}
-
-	      g.firstIn(e,active_node);
-	      for(;e!=INVALID;g.nextIn(e))
-		{
+		    }
+
+		  g.firstIn(e,active_node);
+		  for(;e!=INVALID;g.nextIn(e))
+		    {
 		      edges_to_delete.insert(e);
-		}
-
-	      //deleting collected edges
-	      for(std::set<Graph::Edge>::iterator edge_set_it=edges_to_delete.begin();edge_set_it!=edges_to_delete.end();edge_set_it++)
-		{
-		  deleteItem(*edge_set_it);
-		}
-	      deleteItem(active_node);
-	    }
-	  //a simple edge was chosen
+		    }
+
+		  //deleting collected edges
+		  for(std::set<Graph::Edge>::iterator edge_set_it=edges_to_delete.begin();edge_set_it!=edges_to_delete.end();edge_set_it++)
+		    {
+		      deleteItem(*edge_set_it);
+		    }
+		  deleteItem(active_node);
+		}
+	      //a simple edge was chosen
+	      else
+		{
+		  deleteItem(active_edge);
+		}
+	    }
+	  //pointer was moved, deletion is cancelled
 	  else
 	    {
-	      deleteItem(active_edge);
-	    }
-
-	  
-	}
-      //pointer was moved, deletion is cancelled
-      else
-	{
-	  if(active_node!=INVALID)
-	    {
-	      *active_item << Gnome::Canvas::Properties::fill_color("blue");
-	    }
-	  else
-	    {
-	      *active_item << Gnome::Canvas::Properties::fill_color("green");
+	      if(active_node!=INVALID)
+		{
+		  *active_item << Gnome::Canvas::Properties::fill_color("blue");
+		}
+	      else
+		{
+		  *active_item << Gnome::Canvas::Properties::fill_color("green");
+		}
 	    }
 	}
@@ -451,5 +474,5 @@
       break;
     }
-  return true;
+  return false;
 }
 
