MapWin is created and disposed from now instead of being show and hide.
authorhegyi
Wed, 30 Nov 2005 13:24:23 +0000
changeset 1838b61682f0ee96
parent 1837 8dd6160ff699
child 1839 b2dfd32b4895
MapWin is created and disposed from now instead of being show and hide.
gui/main_win.cc
gui/main_win.h
gui/map_win.cc
gui/map_win.h
gui/mw-mapselector.cc
     1.1 --- a/gui/main_win.cc	Tue Nov 29 19:31:58 2005 +0000
     1.2 +++ b/gui/main_win.cc	Wed Nov 30 13:24:23 2005 +0000
     1.3 @@ -1,9 +1,8 @@
     1.4  #include "main_win.h"
     1.5  #include "icons/guipixbufs.h"
     1.6  
     1.7 -MainWin::MainWin()
     1.8 +MainWin::MainWin():mapwinexists(false)
     1.9  {
    1.10 -  mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
    1.11    gd_canvas=new GraphDisplayerCanvas(*this);
    1.12  
    1.13    set_title ("unsaved file - " + prog_name);
    1.14 @@ -105,7 +104,7 @@
    1.15    
    1.16    ag->add( Gtk::Action::create("ShowMenu", "_Show") );
    1.17    ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
    1.18 -      sigc::mem_fun(*(this->mapwin), &MapWin::show));
    1.19 +	   sigc::mem_fun(*this, &MainWin::createMapWin));
    1.20  
    1.21    Gtk::RadioAction::Group tool_group;
    1.22    ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
    1.23 @@ -212,7 +211,10 @@
    1.24    mapstorage.file_name = file;
    1.25    mapstorage.modified = false;
    1.26    gd_canvas->drawGraph();
    1.27 -  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    1.28 +  if(mapwinexists)
    1.29 +    {
    1.30 +      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    1.31 +    }
    1.32    set_title(Glib::filename_display_basename(file) + " - " + prog_name);
    1.33  }
    1.34  
    1.35 @@ -238,7 +240,10 @@
    1.36    }
    1.37    gd_canvas->clear();
    1.38    mapstorage.clear();
    1.39 -  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    1.40 +  if(mapwinexists)
    1.41 +    {
    1.42 +      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    1.43 +    }
    1.44    set_title("unsaved file - " + prog_name);
    1.45  }
    1.46  
    1.47 @@ -275,7 +280,10 @@
    1.48        mapstorage.file_name = filename;
    1.49        mapstorage.modified = false;
    1.50        gd_canvas->drawGraph();
    1.51 -      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    1.52 +      if(mapwinexists)
    1.53 +	{
    1.54 +	  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    1.55 +	}
    1.56        set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
    1.57      }
    1.58    }
    1.59 @@ -332,7 +340,10 @@
    1.60    }
    1.61    gd_canvas->clear();
    1.62    mapstorage.clear();
    1.63 -  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    1.64 +  if(mapwinexists)
    1.65 +    {
    1.66 +      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
    1.67 +    }
    1.68    set_title("unsaved file - " + prog_name);
    1.69  }
    1.70  
    1.71 @@ -359,10 +370,32 @@
    1.72  
    1.73  void MainWin::registerNewEdgeMap(std::string mapname)
    1.74  {
    1.75 -  mapwin->registerNewEdgeMap(mapname);
    1.76 +  if(mapwinexists)
    1.77 +    {
    1.78 +      mapwin->registerNewEdgeMap(mapname);
    1.79 +    }
    1.80  }
    1.81  
    1.82  void MainWin::registerNewNodeMap(std::string mapname)
    1.83  {
    1.84 -  mapwin->registerNewNodeMap(mapname);
    1.85 +  if(mapwinexists)
    1.86 +    {
    1.87 +      mapwin->registerNewNodeMap(mapname);
    1.88 +    }
    1.89  }
    1.90 +
    1.91 +void MainWin::createMapWin()
    1.92 +{
    1.93 +  if(!mapwinexists)
    1.94 +    {
    1.95 +      mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
    1.96 +      mapwin->show();
    1.97 +      mapwinexists=true;
    1.98 +    }
    1.99 +}
   1.100 +
   1.101 +void MainWin::closeMapWin()
   1.102 +{
   1.103 +  mapwinexists=false;
   1.104 +  delete mapwin;
   1.105 +}
     2.1 --- a/gui/main_win.h	Tue Nov 29 19:31:58 2005 +0000
     2.2 +++ b/gui/main_win.h	Wed Nov 30 13:24:23 2005 +0000
     2.3 @@ -27,8 +27,8 @@
     2.4    void readFile(const std::string &);
     2.5  
     2.6  protected:
     2.7 -  ///Window of map-showing setup. Its type is \ref MapWin
     2.8    MapWin * mapwin;
     2.9 +  bool mapwinexists;
    2.10  
    2.11    ///The graph will be drawn on this \ref GraphDisplayerCanvas
    2.12    GraphDisplayerCanvas * gd_canvas;
    2.13 @@ -66,6 +66,8 @@
    2.14    void registerNewEdgeMap(std::string);
    2.15    void registerNewNodeMap(std::string);
    2.16  
    2.17 +  void createMapWin();
    2.18 +  void closeMapWin();
    2.19  };
    2.20  
    2.21  #endif //MAIN_WIN_H
     3.1 --- a/gui/map_win.cc	Tue Nov 29 19:31:58 2005 +0000
     3.2 +++ b/gui/map_win.cc	Wed Nov 30 13:24:23 2005 +0000
     3.3 @@ -5,7 +5,8 @@
     3.4  {
     3.5    if(e->keyval==GDK_Escape)
     3.6    {
     3.7 -    hide();
     3.8 +    mainwin.closeMapWin();
     3.9 +    //    hide();
    3.10    }
    3.11    return true;
    3.12  }
    3.13 @@ -23,7 +24,7 @@
    3.14  
    3.15    for(int i=0;i<EDGE_PROPERTY_NUM;i++)
    3.16    {
    3.17 -    e_combo_array[i]=new MapSelector(eml, i, true);
    3.18 +    e_combo_array[i]=new MapSelector(eml, mainwin.getActiveEdgeMap(i), i, true);
    3.19  
    3.20      (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    3.21  
    3.22 @@ -43,7 +44,7 @@
    3.23  
    3.24    for(int i=0;i<NODE_PROPERTY_NUM;i++)
    3.25    {
    3.26 -    n_combo_array[i]=new MapSelector(nml, i, false);
    3.27 +    n_combo_array[i]=new MapSelector(nml, mainwin.getActiveNodeMap(i), i, false);
    3.28  
    3.29      (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
    3.30  
    3.31 @@ -61,6 +62,10 @@
    3.32  
    3.33  }
    3.34  
    3.35 +MapWin::~MapWin()
    3.36 +{
    3.37 +}
    3.38 +
    3.39  void MapWin::nodeMapChanged(std::string mapname, int prop)
    3.40  {
    3.41    mainwin.propertyChange(false, prop, mapname);
    3.42 @@ -106,3 +111,10 @@
    3.43      n_combo_array[i]->append_text((Glib::ustring)newmapname);
    3.44    }
    3.45  }
    3.46 +
    3.47 +bool MapWin::on_delete_event(GdkEventAny * event)
    3.48 +{
    3.49 +  event=event;
    3.50 +  mainwin.closeMapWin();
    3.51 +  return true;
    3.52 +}
     4.1 --- a/gui/map_win.h	Tue Nov 29 19:31:58 2005 +0000
     4.2 +++ b/gui/map_win.h	Wed Nov 30 13:24:23 2005 +0000
     4.3 @@ -40,7 +40,7 @@
     4.4  
     4.5    public:
     4.6  
     4.7 -    MapSelector(std::vector<std::string>, int, bool);
     4.8 +    MapSelector(std::vector<std::string>, std::string, int, bool);
     4.9  
    4.10      sigc::signal<void, std::string> signal_cbt_ch();
    4.11      sigc::signal<void, bool> signal_newmapwin_needed();
    4.12 @@ -79,6 +79,10 @@
    4.13    ///Constructor of MapWin creates the widgets shown in MapWin.
    4.14    MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, MainWin & mw);
    4.15  
    4.16 +  ~MapWin();
    4.17 +
    4.18 +  virtual bool on_delete_event(GdkEventAny *);
    4.19 +
    4.20    void nodeMapChanged(std::string, int);
    4.21  
    4.22    void edgeMapChanged(std::string, int);
     5.1 --- a/gui/mw-mapselector.cc	Tue Nov 29 19:31:58 2005 +0000
     5.2 +++ b/gui/mw-mapselector.cc	Wed Nov 30 13:24:23 2005 +0000
     5.3 @@ -1,10 +1,19 @@
     5.4  #include "map_win.h"
     5.5  
     5.6 -MapWin::MapSelector::MapSelector(std::vector<std::string> ml, int identifier, bool edge):id(identifier),itisedge(edge),default_state(true),set_new_map(false)
     5.7 +MapWin::MapSelector::MapSelector(std::vector<std::string> ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false)
     5.8  {
     5.9    update_list(ml);
    5.10  
    5.11 -  cbt.set_active(0);
    5.12 +  if(act=="")
    5.13 +    {
    5.14 +      cbt.set_active(0);
    5.15 +      default_state=true;
    5.16 +    }
    5.17 +  else
    5.18 +    {
    5.19 +      cbt.set_active_text((Glib::ustring)act);
    5.20 +      default_state=false;
    5.21 +    }
    5.22  
    5.23    //binding signal to the actual entry
    5.24    cbt.signal_changed().connect
    5.25 @@ -55,6 +64,7 @@
    5.26  
    5.27  void MapWin::MapSelector::update_list( std::vector< std::string > ml )
    5.28  {
    5.29 +  int prev_act=cbt.get_active_row_number();
    5.30    cbt.clear();
    5.31    std::vector< std::string >::iterator emsi=ml.begin();
    5.32    for(;emsi!=ml.end();emsi++)
    5.33 @@ -62,6 +72,10 @@
    5.34        cbt.append_text(*emsi);
    5.35      }
    5.36    cbt.prepend_text("Default values");
    5.37 +  if(prev_act!=-1)
    5.38 +    {
    5.39 +      cbt.set_active(prev_act);
    5.40 +    }
    5.41  }
    5.42  
    5.43  void MapWin::MapSelector::comboChanged()
    5.44 @@ -77,7 +91,6 @@
    5.45      }
    5.46    else if((!default_state)&&(cbt.get_active_row_number()==0))
    5.47      {
    5.48 -      signal_cbt.emit("");
    5.49        reset();
    5.50      }
    5.51  }
    5.52 @@ -85,6 +98,7 @@
    5.53  void MapWin::MapSelector::reset()
    5.54  {
    5.55    default_state=true;
    5.56 +
    5.57    cbt.set_active(0);
    5.58  
    5.59    signal_cbt.emit("");