Alpar had the key, focus can be set in the window class. But it is not enough, the focused widget has to be activated, as well! Was a hard task to find out... By the way, two compilation warnings are removed.
authorhegyi
Sun, 07 Aug 2005 14:17:11 +0000
changeset 1614350c1d8bb7cc
parent 1613 cd237f1936f8
child 1615 b42385baaf3a
Alpar had the key, focus can be set in the window class. But it is not enough, the focused widget has to be activated, as well! Was a hard task to find out... By the way, two compilation warnings are removed.
gui/graph_displayer_canvas-edge.cc
gui/graph_displayer_canvas-event.cc
gui/graph_displayer_canvas-node.cc
gui/graph_displayer_canvas.cc
gui/graph_displayer_canvas.h
gui/main_win.cc
     1.1 --- a/gui/graph_displayer_canvas-edge.cc	Wed Aug 03 19:10:12 2005 +0000
     1.2 +++ b/gui/graph_displayer_canvas-edge.cc	Sun Aug 07 14:17:11 2005 +0000
     1.3 @@ -25,7 +25,7 @@
     1.4      {
     1.5        for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
     1.6  	{
     1.7 -	  double v=abs((*actual_map)[i]);
     1.8 +	  double v=fabs((*actual_map)[i]);
     1.9  	  int w;
    1.10  	  if(min==max)
    1.11  	    {
     2.1 --- a/gui/graph_displayer_canvas-event.cc	Wed Aug 03 19:10:12 2005 +0000
     2.2 +++ b/gui/graph_displayer_canvas-event.cc	Sun Aug 07 14:17:11 2005 +0000
     2.3 @@ -622,6 +622,10 @@
     2.4  			canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);
     2.5  			canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*4);
     2.6  			canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5);
     2.7 +
     2.8 +			//setting the focus to newly created widget
     2.9 +			parentwin->set_focus(entrywidget);
    2.10 +			parentwin->activate_focus();
    2.11  		      }
    2.12  		  }
    2.13  	      }
     3.1 --- a/gui/graph_displayer_canvas-node.cc	Wed Aug 03 19:10:12 2005 +0000
     3.2 +++ b/gui/graph_displayer_canvas-node.cc	Sun Aug 07 14:17:11 2005 +0000
     3.3 @@ -24,7 +24,7 @@
     3.4      {
     3.5        for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
     3.6  	{
     3.7 -	  double v=abs((*actual_map)[i]);
     3.8 +	  double v=fabs((*actual_map)[i]);
     3.9  	  int w;
    3.10  	  if(min==max)
    3.11  	    {
     4.1 --- a/gui/graph_displayer_canvas.cc	Wed Aug 03 19:10:12 2005 +0000
     4.2 +++ b/gui/graph_displayer_canvas.cc	Sun Aug 07 14:17:11 2005 +0000
     4.3 @@ -2,12 +2,14 @@
     4.4  #include "broken_edge.h"
     4.5  #include <math.h>
     4.6  
     4.7 -GraphDisplayerCanvas::GraphDisplayerCanvas(MapStorage & ms, MapWin & mw) :
     4.8 +GraphDisplayerCanvas::GraphDisplayerCanvas(MapStorage & ms, MapWin & mw, Gtk::Window * mainwin) :
     4.9    nodesmap(ms.graph), edgesmap(ms.graph), edgetextmap(ms.graph),
    4.10    nodetextmap(ms.graph), displayed_graph(*(root()), 0, 0),
    4.11    canvasentrywidget(NULL), mapstorage(ms), isbutton(0), active_item(NULL),
    4.12    target_item(NULL), nodemap_to_edit(""), edgemap_to_edit(""), mapwin(mw)
    4.13  {
    4.14 +  parentwin=mainwin;
    4.15 +
    4.16    //base event handler is move tool
    4.17    actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    4.18    actual_tool=MOVE;
     5.1 --- a/gui/graph_displayer_canvas.h	Wed Aug 03 19:10:12 2005 +0000
     5.2 +++ b/gui/graph_displayer_canvas.h	Sun Aug 07 14:17:11 2005 +0000
     5.3 @@ -18,7 +18,7 @@
     5.4    typedef Gnome::Canvas::CanvasAA Parent;
     5.5  
     5.6  public:
     5.7 -  GraphDisplayerCanvas(MapStorage &, MapWin &);
     5.8 +  GraphDisplayerCanvas(MapStorage &, MapWin &, Gtk::Window *);
     5.9    virtual ~GraphDisplayerCanvas();
    5.10  
    5.11    ///Changes the linewidth attribute according to the given map.
    5.12 @@ -177,6 +177,10 @@
    5.13    ///We need to store mapwin, to be able to ask the appropriate values for properties of new items.
    5.14    MapWin & mapwin;
    5.15  
    5.16 +  ///We need to store the parent window to be able to set the focus on a given widget
    5.17 +  ///We will use this variable to activate the set focus on entry widget in the case of editing map values.
    5.18 +  Gtk::Window * parentwin;
    5.19 +
    5.20  };
    5.21  
    5.22  #endif //GRAPH_DISPLAYER_CANVAS_H
     6.1 --- a/gui/main_win.cc	Wed Aug 03 19:10:12 2005 +0000
     6.2 +++ b/gui/main_win.cc	Sun Aug 07 14:17:11 2005 +0000
     6.3 @@ -2,9 +2,8 @@
     6.4  
     6.5  MainWin::MainWin(const std::string& title) :
     6.6    mapwin("Map Setup", mapstorage, gd_canvas),
     6.7 -  newmapwin("Creating new map", gd_canvas), gd_canvas(mapstorage, mapwin)
     6.8 +  newmapwin("Creating new map", gd_canvas), gd_canvas(mapstorage, mapwin, (Gtk::Window *)this)
     6.9  {
    6.10 -
    6.11    set_title (title);
    6.12    set_default_size(WIN_WIDTH,WIN_HEIGHT);
    6.13    add(vbox);