gui/main_win.cc
changeset 1840 173b53b28d7c
parent 1837 8dd6160ff699
child 1849 a4d1362397fe
equal deleted inserted replaced
24:64e6be26220a 25:425bced8d5b0
     1 #include "main_win.h"
     1 #include "main_win.h"
     2 #include "icons/guipixbufs.h"
     2 #include "icons/guipixbufs.h"
     3 
     3 
     4 MainWin::MainWin()
     4 MainWin::MainWin():mapwinexists(false)
     5 {
     5 {
     6   mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
       
     7   gd_canvas=new GraphDisplayerCanvas(*this);
     6   gd_canvas=new GraphDisplayerCanvas(*this);
     8 
     7 
     9   set_title ("unsaved file - " + prog_name);
     8   set_title ("unsaved file - " + prog_name);
    10   set_default_size(WIN_WIDTH,WIN_HEIGHT);
     9   set_default_size(WIN_WIDTH,WIN_HEIGHT);
    11   add(vbox);
    10   add(vbox);
   103   ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
   102   ag->add( Gtk::Action::create("ViewZoom100", Gtk::Stock::ZOOM_100),
   104       sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100));
   103       sigc::mem_fun(*(this->gd_canvas), &GraphDisplayerCanvas::zoom100));
   105   
   104   
   106   ag->add( Gtk::Action::create("ShowMenu", "_Show") );
   105   ag->add( Gtk::Action::create("ShowMenu", "_Show") );
   107   ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
   106   ag->add( Gtk::Action::create("ShowMaps", "_Maps"),
   108       sigc::mem_fun(*(this->mapwin), &MapWin::show));
   107 	   sigc::mem_fun(*this, &MainWin::createMapWin));
   109 
   108 
   110   Gtk::RadioAction::Group tool_group;
   109   Gtk::RadioAction::Group tool_group;
   111   ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
   110   ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"),
   112       sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) );
   111       sigc::bind( sigc::mem_fun ( *(this->gd_canvas), &GraphDisplayerCanvas::changeEditorialTool ), 0) );
   113   ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"),
   112   ag->add( Gtk::RadioAction::create(tool_group, "CreateNode", Gtk::StockID("gd-addnode"), "Create node"),
   210 {
   209 {
   211   mapstorage.readFromFile(file);
   210   mapstorage.readFromFile(file);
   212   mapstorage.file_name = file;
   211   mapstorage.file_name = file;
   213   mapstorage.modified = false;
   212   mapstorage.modified = false;
   214   gd_canvas->drawGraph();
   213   gd_canvas->drawGraph();
   215   mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
   214   if(mapwinexists)
       
   215     {
       
   216       mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
       
   217     }
   216   set_title(Glib::filename_display_basename(file) + " - " + prog_name);
   218   set_title(Glib::filename_display_basename(file) + " - " + prog_name);
   217 }
   219 }
   218 
   220 
   219 void MainWin::newFile()
   221 void MainWin::newFile()
   220 {
   222 {
   236         break;
   238         break;
   237     }
   239     }
   238   }
   240   }
   239   gd_canvas->clear();
   241   gd_canvas->clear();
   240   mapstorage.clear();
   242   mapstorage.clear();
   241   mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
   243   if(mapwinexists)
       
   244     {
       
   245       mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
       
   246     }
   242   set_title("unsaved file - " + prog_name);
   247   set_title("unsaved file - " + prog_name);
   243 }
   248 }
   244 
   249 
   245 void MainWin::openFile()
   250 void MainWin::openFile()
   246 {
   251 {
   273     if (!mapstorage.readFromFile(filename))
   278     if (!mapstorage.readFromFile(filename))
   274     {
   279     {
   275       mapstorage.file_name = filename;
   280       mapstorage.file_name = filename;
   276       mapstorage.modified = false;
   281       mapstorage.modified = false;
   277       gd_canvas->drawGraph();
   282       gd_canvas->drawGraph();
   278       mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
   283       if(mapwinexists)
       
   284 	{
       
   285 	  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
       
   286 	}
   279       set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
   287       set_title(Glib::filename_display_basename(filename) + " - " + prog_name);
   280     }
   288     }
   281   }
   289   }
   282 }
   290 }
   283 
   291 
   330         break;
   338         break;
   331     }
   339     }
   332   }
   340   }
   333   gd_canvas->clear();
   341   gd_canvas->clear();
   334   mapstorage.clear();
   342   mapstorage.clear();
   335   mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
   343   if(mapwinexists)
       
   344     {
       
   345       mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
       
   346     }
   336   set_title("unsaved file - " + prog_name);
   347   set_title("unsaved file - " + prog_name);
   337 }
   348 }
   338 
   349 
   339 void MainWin::propertyChange(bool itisedge, int prop, std::string mapname)
   350 void MainWin::propertyChange(bool itisedge, int prop, std::string mapname)
   340 {
   351 {
   357   return mapstorage.getActiveNodeMap(prop);
   368   return mapstorage.getActiveNodeMap(prop);
   358 }
   369 }
   359 
   370 
   360 void MainWin::registerNewEdgeMap(std::string mapname)
   371 void MainWin::registerNewEdgeMap(std::string mapname)
   361 {
   372 {
   362   mapwin->registerNewEdgeMap(mapname);
   373   if(mapwinexists)
       
   374     {
       
   375       mapwin->registerNewEdgeMap(mapname);
       
   376     }
   363 }
   377 }
   364 
   378 
   365 void MainWin::registerNewNodeMap(std::string mapname)
   379 void MainWin::registerNewNodeMap(std::string mapname)
   366 {
   380 {
   367   mapwin->registerNewNodeMap(mapname);
   381   if(mapwinexists)
   368 }
   382     {
       
   383       mapwin->registerNewNodeMap(mapname);
       
   384     }
       
   385 }
       
   386 
       
   387 void MainWin::createMapWin()
       
   388 {
       
   389   if(!mapwinexists)
       
   390     {
       
   391       mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
       
   392       mapwin->show();
       
   393       mapwinexists=true;
       
   394     }
       
   395 }
       
   396 
       
   397 void MainWin::closeMapWin()
       
   398 {
       
   399   mapwinexists=false;
       
   400   delete mapwin;
       
   401 }