Editors are based. gui
authorhegyi
Tue, 12 Jul 2005 18:21:49 +0000
branchgui
changeset 321f45545f124c
parent 31 66e85f44a66f
child 33 8dc87bc15ec5
Editors are based.
all_include.h
graph_displayer_canvas-event.cc
graph_displayer_canvas.cc
graph_displayer_canvas.h
main_win.cc
     1.1 --- a/all_include.h	Wed Jun 29 19:44:30 2005 +0000
     1.2 +++ b/all_include.h	Tue Jul 12 18:21:49 2005 +0000
     1.3 @@ -18,7 +18,7 @@
     1.4  
     1.5  enum {E_WIDTH, E_COLOR, E_TEXT, EDGE_PROPERTY_NUM}; // edge properties;
     1.6  enum {N_RADIUS, N_COLOR, N_TEXT, NODE_PROPERTY_NUM}; // node properties;
     1.7 -enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, TOOL_NUM}; // tools;
     1.8 +enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, NODE_MAP_EDIT, TOOL_NUM}; // tools;
     1.9  #define RANGE 3
    1.10  #define WIN_WIDTH 900
    1.11  #define WIN_HEIGHT 600
     2.1 --- a/graph_displayer_canvas-event.cc	Wed Jun 29 19:44:30 2005 +0000
     2.2 +++ b/graph_displayer_canvas-event.cc	Tue Jul 12 18:21:49 2005 +0000
     2.3 @@ -43,6 +43,14 @@
     2.4        actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
     2.5        break;
     2.6  
     2.7 +    case EDGE_MAP_EDIT:
     2.8 +      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false);
     2.9 +      break;
    2.10 +
    2.11 +    case NODE_MAP_EDIT:
    2.12 +      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false);
    2.13 +      break;
    2.14 +
    2.15      default:
    2.16        break;
    2.17      }
    2.18 @@ -210,7 +218,6 @@
    2.19        //move the new node
    2.20      case GDK_MOTION_NOTIFY:
    2.21        {
    2.22 -	double world_motion_x, world_motion_y;
    2.23  	GdkEvent * generated=new GdkEvent();
    2.24  	generated->motion.x=e->motion.x;
    2.25  	generated->motion.y=e->motion.y;
    2.26 @@ -476,6 +483,51 @@
    2.27    return false;
    2.28  }
    2.29  
    2.30 +bool GraphDisplayerCanvas::edgeMapEditEventHandler(GdkEvent* e)
    2.31 +{
    2.32 +  switch(e->type)
    2.33 +    {
    2.34 +    case GDK_BUTTON_PRESS:
    2.35 +      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
    2.36 +      active_item=(get_item_at(clicked_x, clicked_y));
    2.37 +      active_edge=INVALID;
    2.38 +      for (EdgeIt i(g); i!=INVALID; ++i)
    2.39 +	{
    2.40 +	  if(edgesmap[i]==active_item)
    2.41 +	    {
    2.42 +	      active_edge=i;
    2.43 +	    }
    2.44 +	}
    2.45 +      if(active_edge!=INVALID)
    2.46 +	{
    2.47 +	  if(canvasentrywidget)
    2.48 +	    {
    2.49 +	      delete(canvasentrywidget);
    2.50 +	    }
    2.51 +	  entrywidget.show();
    2.52 +	  entrywidget.set_text("Hello!");
    2.53 +	  //	  canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, clicked_x, clicked_y,entrywidget);
    2.54 +	  canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, e->button.x, e->button.y, entrywidget);
    2.55 +	  canvasentrywidget->property_width().set_value(70);
    2.56 +	  canvasentrywidget->property_height().set_value(50);
    2.57 +	  canvasentrywidget->show();
    2.58 +	  *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("red");
    2.59 +	}
    2.60 +      active_item=NULL;		// !!!!!!!!!!!!!!!!!!!!!!!!!!!
    2.61 +      active_edge=INVALID;	// !!!!!!!!!!!!!!!!!!!!!!!!!!!
    2.62 +      break;
    2.63 +    default:
    2.64 +      break;
    2.65 +    }
    2.66 +  return false;  
    2.67 +}
    2.68 +
    2.69 +bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e)
    2.70 +{
    2.71 +  e=e;
    2.72 +  return false;
    2.73 +}
    2.74 +
    2.75  void GraphDisplayerCanvas::deleteItem(NodeIt node_to_delete)
    2.76  {
    2.77    delete(nodetextmap[node_to_delete]);
    2.78 @@ -536,3 +588,4 @@
    2.79      }
    2.80  
    2.81  }
    2.82 +
     3.1 --- a/graph_displayer_canvas.cc	Wed Jun 29 19:44:30 2005 +0000
     3.2 +++ b/graph_displayer_canvas.cc	Tue Jul 12 18:21:49 2005 +0000
     3.3 @@ -2,7 +2,7 @@
     3.4  #include <broken_edge.h>
     3.5  #include <math.h>
     3.6  
     3.7 -GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms, MapWin * mw):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),nodetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL),mapwin(mw)
     3.8 +GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms, MapWin * mw):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),nodetextmap(g),displayed_graph(*(root()), 0, 0),canvasentrywidget(NULL),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL),mapwin(mw)
     3.9  {
    3.10    
    3.11    actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    3.12 @@ -70,6 +70,10 @@
    3.13  
    3.14  GraphDisplayerCanvas::~GraphDisplayerCanvas()
    3.15  {
    3.16 +  if(canvasentrywidget)
    3.17 +    {
    3.18 +      delete(canvasentrywidget);
    3.19 +    }
    3.20  
    3.21    //writing out the end state of the graph
    3.22    //\todo all the maps has to be write out!
     4.1 --- a/graph_displayer_canvas.h	Wed Jun 29 19:44:30 2005 +0000
     4.2 +++ b/graph_displayer_canvas.h	Tue Jul 12 18:21:49 2005 +0000
     4.3 @@ -85,8 +85,10 @@
     4.4    bool createEdgeEventHandler(GdkEvent*);
     4.5    ///event handler for the case when eraser-tool is active
     4.6    bool eraserEventHandler(GdkEvent*);
     4.7 -  ///event handler for the case when eraser-tool is active
     4.8 +  ///event handler for the case when edge map editor tool is active
     4.9    bool edgeMapEditEventHandler(GdkEvent*);
    4.10 +  ///event handler for the case when node map editor tool is active
    4.11 +  bool nodeMapEditEventHandler(GdkEvent*);
    4.12  
    4.13  public:
    4.14    ///Moves the text to new place
    4.15 @@ -126,6 +128,12 @@
    4.16    ///Group of graphical elements of displayed_graph
    4.17    Gnome::Canvas::Group displayed_graph;
    4.18  
    4.19 +  ///Map editor entry
    4.20 +  Gtk::Entry entrywidget;
    4.21 +
    4.22 +  ///GnomeCanvas holder for entry
    4.23 +  Gnome::Canvas::Widget * canvasentrywidget;
    4.24 +
    4.25    ///Here we store the maps that can be displayed through properties.
    4.26    MapStorage mapstorage;
    4.27  
     5.1 --- a/main_win.cc	Wed Jun 29 19:44:30 2005 +0000
     5.2 +++ b/main_win.cc	Tue Jul 12 18:21:49 2005 +0000
     5.3 @@ -45,6 +45,10 @@
     5.4        sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 3) );
     5.5    ag->add( Gtk::Action::create("MoveItem", Gtk::Stock::CONVERT),
     5.6        sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 0) );
     5.7 +  ag->add( Gtk::Action::create("EditEdgeMap", Gtk::Stock::PROPERTIES),
     5.8 +      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 4) );
     5.9 +  ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES),
    5.10 +      sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) );
    5.11  
    5.12    uim=Gtk::UIManager::create();
    5.13    uim->insert_action_group(ag);
    5.14 @@ -88,6 +92,8 @@
    5.15        "    <toolitem action='CreateEdge' />"
    5.16        "    <toolitem action='EraseItem' />"
    5.17        "    <toolitem action='MoveItem' />"
    5.18 +      "    <toolitem action='EditEdgeMap' />"
    5.19 +      "    <toolitem action='EditNodeMap' />"
    5.20        "  </toolbar>"
    5.21        "</ui>";
    5.22