[Lemon-commits] [lemon_svn] hegyi: r2391 - hugo/trunk/gui

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:52:18 CET 2006


Author: hegyi
Date: Wed Nov 30 14:24:23 2005
New Revision: 2391

Modified:
   hugo/trunk/gui/main_win.cc
   hugo/trunk/gui/main_win.h
   hugo/trunk/gui/map_win.cc
   hugo/trunk/gui/map_win.h
   hugo/trunk/gui/mw-mapselector.cc

Log:
MapWin is created and disposed from now instead of being show and hide.

Modified: hugo/trunk/gui/main_win.cc
==============================================================================
--- hugo/trunk/gui/main_win.cc	(original)
+++ hugo/trunk/gui/main_win.cc	Wed Nov 30 14:24:23 2005
@@ -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;
 }

Modified: hugo/trunk/gui/main_win.h
==============================================================================
--- hugo/trunk/gui/main_win.h	(original)
+++ hugo/trunk/gui/main_win.h	Wed Nov 30 14:24:23 2005
@@ -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

Modified: hugo/trunk/gui/map_win.cc
==============================================================================
--- hugo/trunk/gui/map_win.cc	(original)
+++ hugo/trunk/gui/map_win.cc	Wed Nov 30 14:24:23 2005
@@ -5,7 +5,8 @@
 {
   if(e->keyval==GDK_Escape)
   {
-    hide();
+    mainwin.closeMapWin();
+    //    hide();
   }
   return true;
 }
@@ -23,7 +24,7 @@
 
   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   {
-    e_combo_array[i]=new MapSelector(eml, i, true);
+    e_combo_array[i]=new MapSelector(eml, mainwin.getActiveEdgeMap(i), i, true);
 
     (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
 
@@ -43,7 +44,7 @@
 
   for(int i=0;i<NODE_PROPERTY_NUM;i++)
   {
-    n_combo_array[i]=new MapSelector(nml, i, false);
+    n_combo_array[i]=new MapSelector(nml, mainwin.getActiveNodeMap(i), i, false);
 
     (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
 
@@ -61,6 +62,10 @@
 
 }
 
+MapWin::~MapWin()
+{
+}
+
 void MapWin::nodeMapChanged(std::string mapname, int prop)
 {
   mainwin.propertyChange(false, prop, mapname);
@@ -106,3 +111,10 @@
     n_combo_array[i]->append_text((Glib::ustring)newmapname);
   }
 }
+
+bool MapWin::on_delete_event(GdkEventAny * event)
+{
+  event=event;
+  mainwin.closeMapWin();
+  return true;
+}

Modified: hugo/trunk/gui/map_win.h
==============================================================================
--- hugo/trunk/gui/map_win.h	(original)
+++ hugo/trunk/gui/map_win.h	Wed Nov 30 14:24:23 2005
@@ -40,7 +40,7 @@
 
   public:
 
-    MapSelector(std::vector<std::string>, int, bool);
+    MapSelector(std::vector<std::string>, std::string, int, bool);
 
     sigc::signal<void, std::string> signal_cbt_ch();
     sigc::signal<void, bool> signal_newmapwin_needed();
@@ -79,6 +79,10 @@
   ///Constructor of MapWin creates the widgets shown in MapWin.
   MapWin(const std::string& title, std::vector<std::string>, std::vector<std::string>, MainWin & mw);
 
+  ~MapWin();
+
+  virtual bool on_delete_event(GdkEventAny *);
+
   void nodeMapChanged(std::string, int);
 
   void edgeMapChanged(std::string, int);

Modified: hugo/trunk/gui/mw-mapselector.cc
==============================================================================
--- hugo/trunk/gui/mw-mapselector.cc	(original)
+++ hugo/trunk/gui/mw-mapselector.cc	Wed Nov 30 14:24:23 2005
@@ -1,10 +1,19 @@
 #include "map_win.h"
 
-MapWin::MapSelector::MapSelector(std::vector<std::string> ml, int identifier, bool edge):id(identifier),itisedge(edge),default_state(true),set_new_map(false)
+MapWin::MapSelector::MapSelector(std::vector<std::string> 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("");



More information about the Lemon-commits mailing list