1.1 --- a/map_win.cc Fri Jun 03 12:25:23 2005 +0000
1.2 +++ b/map_win.cc Mon Jun 06 17:01:12 2005 +0000
1.3 @@ -1,35 +1,41 @@
1.4 #include <map_win.h>
1.5 #include <set>
1.6
1.7 -MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
1.8 +bool MapWin::close_if_escape_is_pressed(GdkEventKey* e)
1.9 {
1.10 + if(e->keyval==GDK_Escape)
1.11 + {
1.12 + hide();
1.13 + }
1.14 + return true;
1.15 +}
1.16
1.17 - //most nem kommentezem fel, mert ugyis valtozik
1.18 +MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst),table(PROPERTY_NUM, 2, false)
1.19 +{
1.20 + set_title(title);
1.21 + set_default_size(200, 50);
1.22
1.23 - set_title(title);
1.24 - set_default_size(400, 200);
1.25 + signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed));
1.26
1.27 - rb_array=new Gtk::RadioButton * [PROPERTY_NUM];
1.28 - vbox_r1=new Gtk::VBox[PROPERTY_NUM];
1.29 - vbox_r2=new Gtk::VBox[PROPERTY_NUM];
1.30 - radios=new Gtk::HBox[PROPERTY_NUM];
1.31 + combo_array=new Gtk::Combo [PROPERTY_NUM];
1.32 +
1.33 for(int i=0;i<PROPERTY_NUM;i++)
1.34 {
1.35 - rb_array[i]=new Gtk::RadioButton[ms.numOfEdgeMaps()+1];
1.36 -
1.37 - Gtk::RadioButton::Group group;
1.38
1.39 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
1.40 std::set<int> props;
1.41
1.42 int actprop;
1.43 +
1.44 + //here we find out, which map is the default in MapStorage for this property, which are not
1.45 for(int j=0;j<ms.numOfEdgeMaps();j++)
1.46 {
1.47 -
1.48 + //this is the default value for this property
1.49 if(emsi->second==&(ms.default_edgemaps[i]))
1.50 {
1.51 actprop=j;
1.52 }
1.53 + //this is the other maps to show for this property
1.54 for(int k=0;k<PROPERTY_NUM;k++)
1.55 {
1.56 if(emsi->second==&(ms.default_edgemaps[k]))
1.57 @@ -40,83 +46,108 @@
1.58 emsi++;
1.59 }
1.60
1.61 - rb_array[i][0].set_group(group);
1.62 - rb_array[i][0].set_label("Default");
1.63 - rb_array[i][0].signal_clicked().connect( sigc::bind( sigc::bind( sigc::mem_fun(*this, &MapWin::radio_click), 0), i) );
1.64 - vbox_r1[i].pack_start(rb_array[i][0]);
1.65 + //combo_array[i].set_group(group);
1.66
1.67 + //filling in combo box with choices
1.68 + std::list<Glib::ustring> listStrings;
1.69 +
1.70 + listStrings.push_back("Default");
1.71
1.72 emsi=ms.beginOfEdgeMaps();
1.73 - int actpos=1;
1.74 +
1.75 for(int j=0;j<ms.numOfEdgeMaps();j++)
1.76 {
1.77 if( ( props.find(j) )==( props.end() ) )
1.78 {
1.79 - rb_array[i][actpos].set_group(group);
1.80 - rb_array[i][actpos].set_label(emsi->first);
1.81 - rb_array[i][actpos].signal_clicked().connect
1.82 - (
1.83 - sigc::bind(
1.84 - sigc::bind(
1.85 - sigc::mem_fun(*this, &MapWin::radio_click),
1.86 - actpos
1.87 - ),
1.88 - i
1.89 - )
1.90 - );
1.91 -
1.92 - if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2)
1.93 - {
1.94 - vbox_r1[i].pack_start(rb_array[i][actpos]);
1.95 - }
1.96 - else
1.97 - {
1.98 - vbox_r2[i].pack_start(rb_array[i][actpos]);
1.99 - }
1.100 - actpos++;
1.101 + listStrings.push_back(emsi->first);
1.102 }
1.103 emsi++;
1.104 }
1.105 - radios[i].pack_start(vbox_r1[i]);
1.106 - radios[i].pack_start(vbox_r2[i]);
1.107 - notebook.append_page(radios[i], property_strings[i]);
1.108 +
1.109 + combo_array[i].set_popdown_strings(listStrings);
1.110 +
1.111 + //Restrict it to these choices only:
1.112 + combo_array[i].set_value_in_list();
1.113 +
1.114 + //binding signal to thew actual entry
1.115 + combo_array[i].get_entry()->signal_changed().connect
1.116 + (
1.117 + sigc::bind
1.118 + (
1.119 + sigc::mem_fun(*this, &MapWin::combo_changed),
1.120 + i
1.121 + )
1.122 + );
1.123 +
1.124 + //placing actual entry in the right place
1.125 +
1.126 + label=new Gtk::Label;
1.127 + label->set_text(property_strings[i]);
1.128 +
1.129 + // labelpluscombo=new Gtk::HBox;
1.130 + // labelpluscombo->pack_start(*label);
1.131 + // labelpluscombo->pack_start(combo_array[i]);
1.132 +
1.133 + table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
1.134 + table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
1.135 +
1.136 + /*
1.137 + if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2)
1.138 + {
1.139 + vbox_r1.pack_start(*labelpluscombo);
1.140 + }
1.141 + else
1.142 + {
1.143 + vbox_r2.pack_start(*labelpluscombo);
1.144 + }
1.145 + actpos++;
1.146 + //*/
1.147 +
1.148 }
1.149
1.150 - add(vbox_b);
1.151 - vbox_b.pack_start(notebook);
1.152 + combos.pack_start(vbox_r1);
1.153 + combos.pack_start(vbox_r2);
1.154 +
1.155 + //add(combos);
1.156 + add(table);
1.157
1.158 show_all_children();
1.159
1.160 }
1.161
1.162 -void MapWin::radio_click(int prop, int actpos)
1.163 +void MapWin::combo_changed(int prop)
1.164 {
1.165
1.166 //most nem kommentezem fel, mert ugyis valtozik
1.167 + Gtk::Entry* entry = combo_array[prop].get_entry();
1.168
1.169 - if(rb_array[prop][actpos].get_active())
1.170 + if(entry)
1.171 {
1.172 + Glib::ustring mapname = entry->get_text();
1.173 + if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
1.174 + {
1.175 + if(mapname=="Default")
1.176 + {
1.177 + mapname=property_strings[prop];
1.178 + }
1.179
1.180 - std::string mapname=rb_array[prop][actpos].get_label();
1.181 -
1.182 - if(mapname=="Default")
1.183 - {
1.184 - mapname=property_strings[prop];
1.185 - }
1.186 -
1.187 - switch(prop)
1.188 - {
1.189 - case WIDTH:
1.190 - gdc.changeLineWidth(mapname);
1.191 - break;
1.192 - case COLOR:
1.193 - gdc.changeColor(mapname);
1.194 - break;
1.195 - case TEXT:
1.196 - gdc.changeText(mapname);
1.197 - break;
1.198 - default:
1.199 - std::cout<<"Error\n";
1.200 + if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() )
1.201 + {
1.202 + switch(prop)
1.203 + {
1.204 + case WIDTH:
1.205 + gdc.changeLineWidth(mapname);
1.206 + break;
1.207 + case COLOR:
1.208 + gdc.changeColor(mapname);
1.209 + break;
1.210 + case TEXT:
1.211 + gdc.changeText(mapname);
1.212 + break;
1.213 + default:
1.214 + std::cout<<"Error\n";
1.215 + }
1.216 + }
1.217 }
1.218 }
1.219 };