broken_edge.cc
branchgui
changeset 42 f1b70894b953
parent 25 c45a34eaa118
child 50 eedecee61922
equal deleted inserted replaced
5:e07b56fd9db8 6:f225b041569c
     5 {
     5 {
     6   my_points=new Gnome::Art::Point[3];
     6   my_points=new Gnome::Art::Point[3];
     7 
     7 
     8   arrow=new Gnome::Canvas::Polygon(g);
     8   arrow=new Gnome::Canvas::Polygon(g);
     9   *arrow << Gnome::Canvas::Properties::fill_color("red");
     9   *arrow << Gnome::Canvas::Properties::fill_color("red");
    10   arrow->signal_event().connect(sigc::mem_fun(*this, &BrokenEdge::edge_former_event_handler));
    10   arrow->signal_event().connect(sigc::mem_fun(*this, &BrokenEdge::edgeFormerEventHandler));
    11   set_points(p);
    11   setPoints(p);
    12 }
    12 }
    13 
    13 
    14 BrokenEdge::~BrokenEdge()
    14 BrokenEdge::~BrokenEdge()
    15 {
    15 {
    16   if(arrow)delete(arrow);
    16   if(arrow)delete(arrow);
    17 }
    17 }
    18 
    18 
    19 void BrokenEdge::set_points(Gnome::Canvas::Points p, bool move)
    19 void BrokenEdge::setPoints(Gnome::Canvas::Points p, bool move)
    20 {
    20 {
    21   bool set_arrow=false;
    21   bool set_arrow=false;
    22   if(!move)
    22   if(!move)
    23     {
    23     {
    24       if(p.size()==2)
    24       if(p.size()==2)
   101 
   101 
   102       arrow->property_points().set_value(arrow_points);
   102       arrow->property_points().set_value(arrow_points);
   103     }
   103     }
   104 }
   104 }
   105 
   105 
   106 bool BrokenEdge::edge_former_event_handler(GdkEvent* e)
   106 bool BrokenEdge::edgeFormerEventHandler(GdkEvent* e)
   107 {
   107 {
   108   switch(e->type)
   108   switch(e->type)
   109     {
   109     {
   110     case GDK_BUTTON_PRESS:
   110     case GDK_BUTTON_PRESS:
   111       //we mark the location of the event to be able to calculate parameters of dragging
   111       //we mark the location of the event to be able to calculate parameters of dragging
   112       if(gdc.get_actual_tool()!=CREATE_NODE)
   112       if(gdc.getActualTool()!=CREATE_NODE)
   113 	{
   113 	{
   114 	  gdc.toggle_edge_activity(this, true);
   114 	  gdc.toggleEdgeActivity(this, true);
   115 	  clicked_x=e->button.x;
   115 	  clicked_x=e->button.x;
   116 	  clicked_y=e->button.y;
   116 	  clicked_y=e->button.y;
   117 	  isbutton=true;
   117 	  isbutton=true;
   118 	}
   118 	}
   119       break;
   119       break;
   120     case GDK_BUTTON_RELEASE:
   120     case GDK_BUTTON_RELEASE:
   121       if(gdc.get_actual_tool()!=CREATE_NODE)
   121       if(gdc.getActualTool()!=CREATE_NODE)
   122 	{
   122 	{
   123 	  gdc.toggle_edge_activity(this, false);
   123 	  gdc.toggleEdgeActivity(this, false);
   124 	  isbutton=false;
   124 	  isbutton=false;
   125 	}
   125 	}
   126       break;
   126       break;
   127     case GDK_MOTION_NOTIFY:
   127     case GDK_MOTION_NOTIFY:
   128       //we only have to do sg. if the mouse button is pressed
   128       //we only have to do sg. if the mouse button is pressed
   140 
   140 
   141 	  points_new.push_back(my_points[0]);
   141 	  points_new.push_back(my_points[0]);
   142 	  points_new.push_back(my_points[1]=Gnome::Art::Point(my_points[1].get_x()+dx,my_points[1].get_y()+dy));
   142 	  points_new.push_back(my_points[1]=Gnome::Art::Point(my_points[1].get_x()+dx,my_points[1].get_y()+dy));
   143 	  points_new.push_back(my_points[2]);
   143 	  points_new.push_back(my_points[2]);
   144 
   144 
   145 	  set_points(points_new);
   145 	  setPoints(points_new);
   146 	  gdc.text_reposition(xy<double>(my_points[1].get_x(),my_points[1].get_y()));
   146 	  gdc.textReposition(xy<double>(my_points[1].get_x(),my_points[1].get_y()));
   147 
   147 
   148 	  clicked_x=e->motion.x;
   148 	  clicked_x=e->motion.x;
   149 	  clicked_y=e->motion.y;
   149 	  clicked_y=e->motion.y;
   150 
   150 
   151 	}
   151 	}
   153     }
   153     }
   154 
   154 
   155   return true;
   155   return true;
   156 }
   156 }
   157 
   157 
   158 xy<double> BrokenEdge::get_arrow_pos()
   158 xy<double> BrokenEdge::getArrowPos()
   159 {
   159 {
   160   xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
   160   xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
   161   return ret_val;
   161   return ret_val;
   162 }
   162 }