gui/main_win.cc
changeset 1838 b61682f0ee96
parent 1837 8dd6160ff699
child 1849 a4d1362397fe
     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 +}