# HG changeset patch # User hegyi # Date 1133357063 0 # Node ID b61682f0ee96602d10f3ccfd8a4479cfdb5ab920 # Parent 8dd6160ff6997802bfd54b07bb24e54a37ba4542 MapWin is created and disposed from now instead of being show and hide. diff -r 8dd6160ff699 -r b61682f0ee96 gui/main_win.cc --- a/gui/main_win.cc Tue Nov 29 19:31:58 2005 +0000 +++ b/gui/main_win.cc Wed Nov 30 13:24:23 2005 +0000 @@ -1,9 +1,8 @@ #include "main_win.h" #include "icons/guipixbufs.h" -MainWin::MainWin() +MainWin::MainWin():mapwinexists(false) { - mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); gd_canvas=new GraphDisplayerCanvas(*this); set_title ("unsaved file - " + prog_name); @@ -105,7 +104,7 @@ ag->add( Gtk::Action::create("ShowMenu", "_Show") ); ag->add( Gtk::Action::create("ShowMaps", "_Maps"), - sigc::mem_fun(*(this->mapwin), &MapWin::show)); + sigc::mem_fun(*this, &MainWin::createMapWin)); Gtk::RadioAction::Group tool_group; ag->add( Gtk::RadioAction::create(tool_group, "MoveItem", Gtk::StockID("gd-move"), "Move"), @@ -212,7 +211,10 @@ mapstorage.file_name = file; mapstorage.modified = false; gd_canvas->drawGraph(); - mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + if(mapwinexists) + { + mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + } set_title(Glib::filename_display_basename(file) + " - " + prog_name); } @@ -238,7 +240,10 @@ } gd_canvas->clear(); mapstorage.clear(); - mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + if(mapwinexists) + { + mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + } set_title("unsaved file - " + prog_name); } @@ -275,7 +280,10 @@ mapstorage.file_name = filename; mapstorage.modified = false; gd_canvas->drawGraph(); - mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + if(mapwinexists) + { + mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + } set_title(Glib::filename_display_basename(filename) + " - " + prog_name); } } @@ -332,7 +340,10 @@ } gd_canvas->clear(); mapstorage.clear(); - mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + if(mapwinexists) + { + mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList()); + } set_title("unsaved file - " + prog_name); } @@ -359,10 +370,32 @@ void MainWin::registerNewEdgeMap(std::string mapname) { - mapwin->registerNewEdgeMap(mapname); + if(mapwinexists) + { + mapwin->registerNewEdgeMap(mapname); + } } void MainWin::registerNewNodeMap(std::string mapname) { - mapwin->registerNewNodeMap(mapname); + if(mapwinexists) + { + mapwin->registerNewNodeMap(mapname); + } } + +void MainWin::createMapWin() +{ + if(!mapwinexists) + { + mapwin=new MapWin("Map Setup", mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this); + mapwin->show(); + mapwinexists=true; + } +} + +void MainWin::closeMapWin() +{ + mapwinexists=false; + delete mapwin; +} diff -r 8dd6160ff699 -r b61682f0ee96 gui/main_win.h --- a/gui/main_win.h Tue Nov 29 19:31:58 2005 +0000 +++ b/gui/main_win.h Wed Nov 30 13:24:23 2005 +0000 @@ -27,8 +27,8 @@ void readFile(const std::string &); protected: - ///Window of map-showing setup. Its type is \ref MapWin MapWin * mapwin; + bool mapwinexists; ///The graph will be drawn on this \ref GraphDisplayerCanvas GraphDisplayerCanvas * gd_canvas; @@ -66,6 +66,8 @@ void registerNewEdgeMap(std::string); void registerNewNodeMap(std::string); + void createMapWin(); + void closeMapWin(); }; #endif //MAIN_WIN_H diff -r 8dd6160ff699 -r b61682f0ee96 gui/map_win.cc --- a/gui/map_win.cc Tue Nov 29 19:31:58 2005 +0000 +++ b/gui/map_win.cc Wed Nov 30 13:24:23 2005 +0000 @@ -5,7 +5,8 @@ { if(e->keyval==GDK_Escape) { - hide(); + mainwin.closeMapWin(); + // hide(); } return true; } @@ -23,7 +24,7 @@ for(int i=0;iappend_text((Glib::ustring)newmapname); } } + +bool MapWin::on_delete_event(GdkEventAny * event) +{ + event=event; + mainwin.closeMapWin(); + return true; +} diff -r 8dd6160ff699 -r b61682f0ee96 gui/map_win.h --- a/gui/map_win.h Tue Nov 29 19:31:58 2005 +0000 +++ b/gui/map_win.h Wed Nov 30 13:24:23 2005 +0000 @@ -40,7 +40,7 @@ public: - MapSelector(std::vector, int, bool); + MapSelector(std::vector, std::string, int, bool); sigc::signal signal_cbt_ch(); sigc::signal signal_newmapwin_needed(); @@ -79,6 +79,10 @@ ///Constructor of MapWin creates the widgets shown in MapWin. MapWin(const std::string& title, std::vector, std::vector, MainWin & mw); + ~MapWin(); + + virtual bool on_delete_event(GdkEventAny *); + void nodeMapChanged(std::string, int); void edgeMapChanged(std::string, int); diff -r 8dd6160ff699 -r b61682f0ee96 gui/mw-mapselector.cc --- a/gui/mw-mapselector.cc Tue Nov 29 19:31:58 2005 +0000 +++ b/gui/mw-mapselector.cc Wed Nov 30 13:24:23 2005 +0000 @@ -1,10 +1,19 @@ #include "map_win.h" -MapWin::MapSelector::MapSelector(std::vector ml, int identifier, bool edge):id(identifier),itisedge(edge),default_state(true),set_new_map(false) +MapWin::MapSelector::MapSelector(std::vector ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false) { update_list(ml); - cbt.set_active(0); + if(act=="") + { + cbt.set_active(0); + default_state=true; + } + else + { + cbt.set_active_text((Glib::ustring)act); + default_state=false; + } //binding signal to the actual entry cbt.signal_changed().connect @@ -55,6 +64,7 @@ void MapWin::MapSelector::update_list( std::vector< std::string > ml ) { + int prev_act=cbt.get_active_row_number(); cbt.clear(); std::vector< std::string >::iterator emsi=ml.begin(); for(;emsi!=ml.end();emsi++) @@ -62,6 +72,10 @@ cbt.append_text(*emsi); } cbt.prepend_text("Default values"); + if(prev_act!=-1) + { + cbt.set_active(prev_act); + } } void MapWin::MapSelector::comboChanged() @@ -77,7 +91,6 @@ } else if((!default_state)&&(cbt.get_active_row_number()==0)) { - signal_cbt.emit(""); reset(); } } @@ -85,6 +98,7 @@ void MapWin::MapSelector::reset() { default_state=true; + cbt.set_active(0); signal_cbt.emit("");