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

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


Author: hegyi
Date: Mon Jun  6 19:01:12 2005
New Revision: 1926

Modified:
   hugo/trunk/gui/map_win.cc
   hugo/trunk/gui/map_win.h

Log:
Maps are now selectable through ComboBoxes, and Escape makes MapWin disappeared.

Modified: hugo/trunk/gui/map_win.cc
==============================================================================
--- hugo/trunk/gui/map_win.cc	(original)
+++ hugo/trunk/gui/map_win.cc	Mon Jun  6 19:01:12 2005
@@ -1,35 +1,41 @@
 #include <map_win.h>
 #include <set>
 
-MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
+bool MapWin::close_if_escape_is_pressed(GdkEventKey* e)
 {
+  if(e->keyval==GDK_Escape)
+  {
+    hide();
+  }
+  return true;
+}
 
-  //most nem kommentezem fel, mert ugyis valtozik
-
+MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst),table(PROPERTY_NUM, 2, false)
+{
   set_title(title);
-  set_default_size(400, 200);
+  set_default_size(200, 50);
+
+  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed));
+
+  combo_array=new Gtk::Combo [PROPERTY_NUM];
 
-  rb_array=new Gtk::RadioButton * [PROPERTY_NUM];
-  vbox_r1=new Gtk::VBox[PROPERTY_NUM];
-  vbox_r2=new Gtk::VBox[PROPERTY_NUM];
-  radios=new Gtk::HBox[PROPERTY_NUM];
   for(int i=0;i<PROPERTY_NUM;i++)
   {
-    rb_array[i]=new Gtk::RadioButton[ms.numOfEdgeMaps()+1];
-
-    Gtk::RadioButton::Group group;
 
     std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
     std::set<int> props;
 
     int actprop;
+
+    //here we find out, which map is the default in MapStorage for this property, which are not
     for(int j=0;j<ms.numOfEdgeMaps();j++)
     {
-
+      //this is the default value for this property
       if(emsi->second==&(ms.default_edgemaps[i]))
       {
 	actprop=j;
       }
+      //this is the other maps to show for this property
       for(int k=0;k<PROPERTY_NUM;k++)
       {
 	if(emsi->second==&(ms.default_edgemaps[k]))
@@ -40,83 +46,108 @@
       emsi++;
     }
 
-    rb_array[i][0].set_group(group);
-    rb_array[i][0].set_label("Default");
-    rb_array[i][0].signal_clicked().connect( sigc::bind( sigc::bind( sigc::mem_fun(*this, &MapWin::radio_click), 0), i) );
-    vbox_r1[i].pack_start(rb_array[i][0]);
+    //combo_array[i].set_group(group);
+
+    //filling in combo box with choices
+    std::list<Glib::ustring> listStrings;
 
+    listStrings.push_back("Default");
 
     emsi=ms.beginOfEdgeMaps();
-    int actpos=1;
+
     for(int j=0;j<ms.numOfEdgeMaps();j++)
     {
       if( ( props.find(j) )==( props.end() ) )
       {
-	rb_array[i][actpos].set_group(group);
-	rb_array[i][actpos].set_label(emsi->first);
-	rb_array[i][actpos].signal_clicked().connect
-	  (
-	   sigc::bind( 
-	    sigc::bind(
-	     sigc::mem_fun(*this, &MapWin::radio_click),
-	     actpos
-	    ),
-	    i
-	   ) 
-	  );
-
-    	if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2)
-        {
-          vbox_r1[i].pack_start(rb_array[i][actpos]);
-	}
-	else
-        {
-	  vbox_r2[i].pack_start(rb_array[i][actpos]);
-	}
-	actpos++;
+	listStrings.push_back(emsi->first);
       }
       emsi++;
     }
-    radios[i].pack_start(vbox_r1[i]);
-    radios[i].pack_start(vbox_r2[i]);
-    notebook.append_page(radios[i], property_strings[i]);
+
+    combo_array[i].set_popdown_strings(listStrings);
+
+    //Restrict it to these choices only:
+    combo_array[i].set_value_in_list();
+
+    //binding signal to thew actual entry
+    combo_array[i].get_entry()->signal_changed().connect
+    (
+     sigc::bind
+     (
+      sigc::mem_fun(*this, &MapWin::combo_changed),
+      i
+     )
+    );
+
+    //placing actual entry in the right place
+
+    label=new Gtk::Label;
+    label->set_text(property_strings[i]);
+
+    //    labelpluscombo=new Gtk::HBox;
+    //    labelpluscombo->pack_start(*label);
+    //    labelpluscombo->pack_start(combo_array[i]);
+        
+    table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
+    table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
+
+    /*
+    if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2)
+    {
+      vbox_r1.pack_start(*labelpluscombo);
+    }
+    else
+    {
+      vbox_r2.pack_start(*labelpluscombo);
+    }
+    actpos++;
+    //*/
+
   }
 
-  add(vbox_b);
-  vbox_b.pack_start(notebook);
+  combos.pack_start(vbox_r1);
+  combos.pack_start(vbox_r2);
+
+  //add(combos);
+  add(table);
 
   show_all_children();
 
 }
 
-void MapWin::radio_click(int prop, int actpos)
+void MapWin::combo_changed(int prop)
 {
 
   //most nem kommentezem fel, mert ugyis valtozik
+  Gtk::Entry* entry = combo_array[prop].get_entry();
 
-  if(rb_array[prop][actpos].get_active())
+  if(entry)
   {
-
-    std::string mapname=rb_array[prop][actpos].get_label();
-
-    if(mapname=="Default")
+    Glib::ustring mapname = entry->get_text();
+    if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
     {
-      mapname=property_strings[prop];
-    }
+      if(mapname=="Default")
+      {
+	mapname=property_strings[prop];
+      }
 
-    switch(prop)
-    {
-      case WIDTH:
-        gdc.changeLineWidth(mapname);
-        break;
-      case COLOR:
-        gdc.changeColor(mapname);
-        break;
-      case TEXT:
-        gdc.changeText(mapname);
-        break;
-      default:
-        std::cout<<"Error\n";
+      if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() )
+      {
+	switch(prop)
+	{
+          case WIDTH:
+	    gdc.changeLineWidth(mapname);
+	    break;
+          case COLOR:
+	    gdc.changeColor(mapname);
+	    break;
+          case TEXT:
+	    gdc.changeText(mapname);
+	    break;
+          default:
+	    std::cout<<"Error\n";
+	}
+      }
     }
   }
 };

Modified: hugo/trunk/gui/map_win.h
==============================================================================
--- hugo/trunk/gui/map_win.h	(original)
+++ hugo/trunk/gui/map_win.h	Mon Jun  6 19:01:12 2005
@@ -24,16 +24,14 @@
   ///The \ref MapStorage in which the visualizable maps are stored
   MapStorage & ms;
 
+  Gtk::Table table;
   
-  Gtk::HBox * radios;
-  Gtk::RadioButton ** rb_array;
+  Gtk::HBox combos, * labelpluscombo;
+  Gtk::Combo * combo_array;
 
-  Gtk::VBox vbox_b, * vbox_r1, * vbox_r2;
+  Gtk::VBox vbox_b, vbox_r1, vbox_r2;
 
-  ///The notebook has different pages for each attribute.
-  Gtk::Notebook notebook;
-
-  Gtk::Label * labels;
+  Gtk::Label * label;
 
 public:
   ///Constructor of MapWin creates the widgets shown in MapWin.
@@ -43,7 +41,8 @@
   ///which button was that and after that calls the
   ///appropriate function of the \ref GraphDisplayerCanvas
   ///to change the visible values of that attribute.
-  virtual void radio_click(int, int);
+  virtual void combo_changed(int);
+  virtual bool close_if_escape_is_pressed(GdkEventKey*);
 };
 
 #endif //MAP_WIN_H



More information about the Lemon-commits mailing list