diff -r 9a0e6e92d06c -r b8ec84524fa2 graph_displayer_canvas-event.cc --- a/graph_displayer_canvas-event.cc Thu Jul 28 14:31:32 2005 +0000 +++ b/graph_displayer_canvas-event.cc Thu Jul 28 15:54:00 2005 +0000 @@ -216,7 +216,7 @@ //draw the new node in red at the clicked place case GDK_2BUTTON_PRESS: - std::cout << "double click" << std::endl; + //std::cout << "double click" << std::endl; break; case GDK_BUTTON_PRESS: isbutton=1; @@ -381,7 +381,7 @@ else { target_node=INVALID; - std::cout << "Loop edge is not yet implemented!" << std::endl; + std::cerr << "Loop edge is not yet implemented!" << std::endl; } } //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore. @@ -527,189 +527,225 @@ bool GraphDisplayerCanvas::edgeMapEditEventHandler(GdkEvent* e) { - switch(e->type) + if(actual_tool==EDGE_MAP_EDIT) { - case GDK_KEY_PRESS: - //for Escape or Enter hide the displayed widget - { - nodeMapEditEventHandler(e); - break; - } - case GDK_BUTTON_PRESS: - //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. - { - //find the activated item - window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); - active_item=(get_item_at(clicked_x, clicked_y)); + switch(e->type) + { + case GDK_KEY_PRESS: + //for Escape or Enter hide the displayed widget + { + nodeMapEditEventHandler(e); + break; + } + case GDK_BUTTON_PRESS: + //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. + { + //for determine, whether it was an edge + Graph::EdgeIt clicked_edge=INVALID; - //determine, whether it was an edge - Graph::EdgeIt clicked_edge=INVALID; - for (EdgeIt i(g); i!=INVALID; ++i) - { - if(edgesmap[i]==active_item) + //find the activated item between texts + active_item=(get_item_at(e->button.x, e->button.y)); + for (EdgeIt i(g); i!=INVALID; ++i) { - clicked_edge=i; + if(edgetextmap[i]==active_item) + { + clicked_edge=i; + } } - } - //if it was really an edge... - if(clicked_edge!=INVALID) - { - //If there is already edited edge, it has to be saved first - if(entrywidget.is_visible()) + + //if it was not between texts, search for it between edges + if(clicked_edge==INVALID) { + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + active_item=(get_item_at(clicked_x, clicked_y)); + + for (EdgeIt i(g); i!=INVALID; ++i) + { + //at the same time only one can be active + if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item)) + { + clicked_edge=i; + } + } + } + //if it was really an edge... + if(clicked_edge!=INVALID) + { + //If there is already edited edge, it has to be saved first + if(entrywidget.is_visible()) + { + GdkEvent * generated=new GdkEvent(); + generated->type=GDK_KEY_PRESS; + ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; + entryWidgetChangeHandler(generated); + } + //If the previous value could be saved, we can go further, otherwise not + if(!entrywidget.is_visible()) + { + //and there is activated map + if(edgetextmap[clicked_edge]->property_text().get_value()!="") + { + //activate the general variable for it + active_edge=clicked_edge; + //delete visible widget if there is + if(canvasentrywidget) + { + delete(canvasentrywidget); + } + + //initialize the entry + entrywidget.show(); + + //fill in the correct value + entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value()); + + //replace and resize the entry to the activated edge and put it in a Canvas::Widget to be able to display it on gdc + xy entry_coos; + entry_coos.x=(edgetextmap[active_edge])->property_x().get_value(); + entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2; + entry_coos.y=(edgetextmap[active_edge])->property_y().get_value(); + entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2; + canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); + canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*4); + canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5); + } + } + } + //if it was not an edge... + else + { + //In this case the click did not happen on an edge + //if there is visible entry we save the value in it + //we pretend like an Enter was presse din the Entry widget GdkEvent * generated=new GdkEvent(); generated->type=GDK_KEY_PRESS; ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; entryWidgetChangeHandler(generated); } - //If the previous value could be saved, we can go further, otherwise not - if(!entrywidget.is_visible()) - { - //and there is activated map - if(edgetextmap[clicked_edge]->property_text().get_value()!="") - { - //activate the general variable for it - active_edge=clicked_edge; - //delete visible widget if there is - if(canvasentrywidget) - { - delete(canvasentrywidget); - } - - //initialize the entry - entrywidget.show(); - - //fill in the correct value - entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value()); - - //replace and resize the entry to the activated edge and put it in a Canvas::Widget to be able to display it on gdc - xy entry_coos; - entry_coos.x=(edgetextmap[active_edge])->property_x().get_value(); - entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2; - entry_coos.y=(edgetextmap[active_edge])->property_y().get_value(); - entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2; - canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); - canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*4); - canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5); - } - } + break; } - //if it was not an edge... - else - { - //In this case the click did not happen on an edge - //if there is visible entry we save the value in it - //we pretend like an Enter was presse din the Entry widget - GdkEvent * generated=new GdkEvent(); - generated->type=GDK_KEY_PRESS; - ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; - entryWidgetChangeHandler(generated); - } - break; - } - default: - break; + default: + break; + } } return false; } bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e) { - switch(e->type) + if(actual_tool==NODE_MAP_EDIT) { - case GDK_KEY_PRESS: - //for Escape or Enter hide the displayed widget - { - switch(((GdkEventKey*)e)->keyval) + switch(e->type) + { + case GDK_KEY_PRESS: + //for Escape or Enter hide the displayed widget { - case GDK_Escape: - entrywidget.hide(); - break; - case GDK_Return: - case GDK_KP_Enter: - entrywidget.hide(); - break; - default: + switch(((GdkEventKey*)e)->keyval) + { + case GDK_Escape: + entrywidget.hide(); + break; + case GDK_Return: + case GDK_KP_Enter: + entrywidget.hide(); + break; + default: + break; + } + break; } - - break; - } - case GDK_BUTTON_PRESS: - //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. - { - //find the activated item - window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); - active_item=(get_item_at(clicked_x, clicked_y)); + case GDK_BUTTON_PRESS: + //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. + { + //for determine, whether it was a node + Graph::NodeIt clicked_node=INVALID; - //determine, whether it was a node - Graph::NodeIt clicked_node=INVALID; - for (NodeIt i(g); i!=INVALID; ++i) - { - if(nodesmap[i]==active_item) + //find the activated item between texts + active_item=(get_item_at(e->button.x, e->button.y)); + for (NodeIt i(g); i!=INVALID; ++i) { - clicked_node=i; + //at the same time only one can be active + if(nodetextmap[i]==active_item) + { + clicked_node=i; + } } - } - //if it was really an edge... - if(clicked_node!=INVALID) - { - //If there is already edited edge, it has to be saved first - if(entrywidget.is_visible()) + //if there was not, search for it between nodes + if(clicked_node==INVALID) { + window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); + active_item=(get_item_at(clicked_x, clicked_y)); + + for (NodeIt i(g); i!=INVALID; ++i) + { + //at the same time only one can be active + if(nodesmap[i]==active_item) + { + clicked_node=i; + } + } + } + //if it was really an edge... + if(clicked_node!=INVALID) + { + //If there is already edited edge, it has to be saved first + if(entrywidget.is_visible()) + { + GdkEvent * generated=new GdkEvent(); + generated->type=GDK_KEY_PRESS; + ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; + entryWidgetChangeHandler(generated); + } + //If the previous value could be saved, we can go further, otherwise not + if(!entrywidget.is_visible()) + { + //and there is activated map + if(nodetextmap[clicked_node]->property_text().get_value()!="") + { + //activate the general variable for it + active_node=clicked_node; + //delete visible widget if there is + if(canvasentrywidget) + { + delete(canvasentrywidget); + } + + //initialize the entry + entrywidget.show(); + + //fill in the correct value + entrywidget.set_text(nodetextmap[active_node]->property_text().get_value()); + + //replace and resize the entry to the activated node and put it in a Canvas::Widget to be able to display it on gdc + xy entry_coos; + entry_coos.x=(nodetextmap[active_node])->property_x().get_value(); + entry_coos.x-=nodetextmap[active_node]->property_text_width().get_value()/2; + entry_coos.y=(nodetextmap[active_node])->property_y().get_value(); + entry_coos.y-=nodetextmap[active_node]->property_text_height().get_value()*1.5/2; + canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); + canvasentrywidget->property_width().set_value(nodetextmap[active_node]->property_text_width().get_value()*4); + canvasentrywidget->property_height().set_value(nodetextmap[active_node]->property_text_height().get_value()*1.5); + } + } + } + //if it was not an edge... + else + { + //In this case the click did not happen on an edge + //if there is visible entry we save the value in it + //we pretend like an Enter was presse din the Entry widget GdkEvent * generated=new GdkEvent(); generated->type=GDK_KEY_PRESS; ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; entryWidgetChangeHandler(generated); } - //If the previous value could be saved, we can go further, otherwise not - if(!entrywidget.is_visible()) - { - //and there is activated map - if(nodetextmap[clicked_node]->property_text().get_value()!="") - { - //activate the general variable for it - active_node=clicked_node; - //delete visible widget if there is - if(canvasentrywidget) - { - delete(canvasentrywidget); - } - - //initialize the entry - entrywidget.show(); - - //fill in the correct value - entrywidget.set_text(nodetextmap[active_node]->property_text().get_value()); - - //replace and resize the entry to the activated node and put it in a Canvas::Widget to be able to display it on gdc - xy entry_coos; - entry_coos.x=(nodetextmap[active_node])->property_x().get_value(); - entry_coos.x-=nodetextmap[active_node]->property_text_width().get_value()/2; - entry_coos.y=(nodetextmap[active_node])->property_y().get_value(); - entry_coos.y-=nodetextmap[active_node]->property_text_height().get_value()*1.5/2; - canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); - canvasentrywidget->property_width().set_value(nodetextmap[active_node]->property_text_width().get_value()*1.5); - canvasentrywidget->property_height().set_value(nodetextmap[active_node]->property_text_height().get_value()*1.5); - } - } + break; } - //if it was not an edge... - else - { - //In this case the click did not happen on an edge - //if there is visible entry we save the value in it - //we pretend like an Enter was presse din the Entry widget - GdkEvent * generated=new GdkEvent(); - generated->type=GDK_KEY_PRESS; - ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; - entryWidgetChangeHandler(generated); - } - break; - } - default: - break; + default: + break; + } } return false; } @@ -782,7 +818,7 @@ //the text in the entry was not correct for a double else { - std::cout << "ERROR: only handling of double values is implemented yet!" << std::endl; + std::cerr << "ERROR: only handling of double values is implemented yet!" << std::endl; } break; @@ -829,7 +865,7 @@ { if(forming_edge!=INVALID) { - std::cout << "ERROR!!!! Valid edge found!" << std::endl; + std::cerr << "ERROR!!!! Valid edge found!" << std::endl; } else { @@ -850,7 +886,7 @@ } else { - std::cout << "ERROR!!!! Invalid edge found!" << std::endl; + std::cerr << "ERROR!!!! Invalid edge found!" << std::endl; } }