1.1 --- a/map_win.cc Thu Oct 06 12:32:06 2005 +0000
1.2 +++ b/map_win.cc Thu Oct 20 15:50:23 2005 +0000
1.3 @@ -17,47 +17,15 @@
1.4
1.5 signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
1.6
1.7 - e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM];
1.8 + e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
1.9
1.10 - table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false);
1.11 + table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
1.12
1.13 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
1.14 {
1.15 - //filling in combo box with choices
1.16 - std::list<Glib::ustring> listStrings;
1.17 + e_combo_array[i]=new MapSelector(gdc, ms, *this, i, true);
1.18
1.19 - listStrings.push_back("Default");
1.20 -
1.21 - std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
1.22 - for(;emsi!=ms.endOfEdgeMaps();emsi++)
1.23 - {
1.24 - listStrings.push_back(emsi->first);
1.25 - }
1.26 -
1.27 - e_combo_array[i].set_popdown_strings(listStrings);
1.28 -
1.29 - //Restrict it to these choices only:
1.30 - e_combo_array[i].set_value_in_list();
1.31 -
1.32 - //binding signal to the actual entry
1.33 - e_combo_array[i].get_entry()->signal_changed().connect
1.34 - (
1.35 - sigc::bind
1.36 - (
1.37 - sigc::mem_fun(*this, &MapWin::eComboChanged),
1.38 - i
1.39 - )
1.40 - );
1.41 -
1.42 - //placing actual entry in the right place
1.43 -
1.44 - label=new Gtk::Label;
1.45 - label->set_text(edge_property_strings[i]);
1.46 -
1.47 - (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
1.48 - (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
1.49 -
1.50 -
1.51 + (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
1.52 }
1.53
1.54 vbox.pack_start(*(new Gtk::Label("Edge properties")));
1.55 @@ -66,51 +34,15 @@
1.56
1.57 vbox.pack_start(*(new Gtk::HSeparator));
1.58
1.59 - n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM];
1.60 + n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
1.61
1.62 - table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false);
1.63 + table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
1.64
1.65 for(int i=0;i<NODE_PROPERTY_NUM;i++)
1.66 {
1.67 - //filling in combo box with choices
1.68 - std::list<Glib::ustring> listStrings;
1.69 + n_combo_array[i]=new MapSelector(gdc, ms, *this, i, false);
1.70
1.71 - listStrings.push_back("Default");
1.72 -
1.73 - std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
1.74 -
1.75 - for(;emsi!=ms.endOfNodeMaps();emsi++)
1.76 - {
1.77 - if ((emsi->first != "coordinates_x") && (emsi->first != "coordinates_y"))
1.78 - {
1.79 - listStrings.push_back(emsi->first);
1.80 - }
1.81 - }
1.82 -
1.83 - n_combo_array[i].set_popdown_strings(listStrings);
1.84 -
1.85 - //Restrict it to these choices only:
1.86 - n_combo_array[i].set_value_in_list();
1.87 -
1.88 - //binding signal to thew actual entry
1.89 - n_combo_array[i].get_entry()->signal_changed().connect
1.90 - (
1.91 - sigc::bind
1.92 - (
1.93 - sigc::mem_fun(*this, &MapWin::nComboChanged),
1.94 - i
1.95 - )
1.96 - );
1.97 -
1.98 - //placing actual entry in the right place
1.99 -
1.100 - label=new Gtk::Label;
1.101 - label->set_text(node_property_strings[i]);
1.102 -
1.103 - (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
1.104 - (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
1.105 -
1.106 -
1.107 + (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
1.108 }
1.109
1.110 add(vbox);
1.111 @@ -127,132 +59,21 @@
1.112 {
1.113 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
1.114 {
1.115 - //filling in combo box with choices
1.116 - std::list<Glib::ustring> listStrings;
1.117 + e_combo_array[i]->update_list();
1.118 + }
1.119
1.120 - listStrings.push_back("Default");
1.121 -
1.122 - std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
1.123 - for(;emsi!=ms.endOfEdgeMaps();emsi++)
1.124 - {
1.125 - listStrings.push_back(emsi->first);
1.126 - }
1.127 -
1.128 - e_combo_array[i].set_popdown_strings(listStrings);
1.129 - }
1.130 for(int i=0;i<NODE_PROPERTY_NUM;i++)
1.131 {
1.132 - //filling in combo box with choices
1.133 - std::list<Glib::ustring> listStrings;
1.134 -
1.135 - listStrings.push_back("Default");
1.136 -
1.137 - std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
1.138 -
1.139 - for(;emsi!=ms.endOfNodeMaps();emsi++)
1.140 - {
1.141 - if ((emsi->first != "coordinates_x") && (emsi->first != "coordinates_y"))
1.142 - {
1.143 - listStrings.push_back(emsi->first);
1.144 - }
1.145 - }
1.146 -
1.147 - n_combo_array[i].set_popdown_strings(listStrings);
1.148 + n_combo_array[i]->update_list();
1.149 }
1.150 }
1.151
1.152 -void MapWin::eComboChanged(int prop)
1.153 -{
1.154 -
1.155 - Gtk::Entry* entry = e_combo_array[prop].get_entry();
1.156 -
1.157 - if(entry)
1.158 - {
1.159 - Glib::ustring mapname = entry->get_text();
1.160 - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
1.161 - {
1.162 - if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
1.163 - {
1.164 - switch(prop)
1.165 - {
1.166 - case E_WIDTH:
1.167 - gdc.changeEdgeWidth(mapname);
1.168 - break;
1.169 - case E_COLOR:
1.170 - gdc.changeEdgeColor(mapname);
1.171 - break;
1.172 - case E_TEXT:
1.173 - gdc.changeEdgeText(mapname);
1.174 - break;
1.175 - default:
1.176 - std::cerr<<"Error\n";
1.177 - }
1.178 - }
1.179 - }
1.180 - }
1.181 -};
1.182 -
1.183 -void MapWin::nComboChanged(int prop)
1.184 -{
1.185 -
1.186 - Gtk::Entry* entry = n_combo_array[prop].get_entry();
1.187 -
1.188 - if(entry)
1.189 - {
1.190 - Glib::ustring mapname = entry->get_text();
1.191 - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
1.192 - {
1.193 - if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
1.194 - {
1.195 - switch(prop)
1.196 - {
1.197 - case N_RADIUS:
1.198 - gdc.changeNodeRadius(mapname);
1.199 - break;
1.200 - case N_COLOR:
1.201 - gdc.changeNodeColor(mapname);
1.202 - break;
1.203 - case N_TEXT:
1.204 - gdc.changeNodeText(mapname);
1.205 - break;
1.206 - default:
1.207 - std::cerr<<"Error\n";
1.208 - }
1.209 - }
1.210 - }
1.211 - }
1.212 -};
1.213
1.214 void MapWin::updateNode(Node node)
1.215 {
1.216 for(int i=0;i<NODE_PROPERTY_NUM;i++)
1.217 {
1.218 - Gtk::Entry* entry = n_combo_array[i].get_entry();
1.219 -
1.220 - if(entry)
1.221 - {
1.222 - Glib::ustring mapname = entry->get_text();
1.223 - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
1.224 - {
1.225 - if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
1.226 - {
1.227 - switch(i)
1.228 - {
1.229 - case N_RADIUS:
1.230 - gdc.changeNodeRadius(mapname, node);
1.231 - break;
1.232 - case N_COLOR:
1.233 - gdc.changeNodeColor(mapname, node);
1.234 - break;
1.235 - case N_TEXT:
1.236 - gdc.changeNodeText(mapname, node);
1.237 - break;
1.238 - default:
1.239 - std::cerr<<"Error\n";
1.240 - }
1.241 - }
1.242 - }
1.243 - }
1.244 + n_combo_array[i]->update(node);
1.245 }
1.246 }
1.247
1.248 @@ -260,34 +81,7 @@
1.249 {
1.250 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
1.251 {
1.252 -
1.253 - Gtk::Entry* entry = e_combo_array[i].get_entry();
1.254 -
1.255 - if(entry)
1.256 - {
1.257 - Glib::ustring mapname = entry->get_text();
1.258 - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
1.259 - {
1.260 -
1.261 - if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
1.262 - {
1.263 - switch(i)
1.264 - {
1.265 - case E_WIDTH:
1.266 - gdc.changeEdgeWidth(mapname, edge);
1.267 - break;
1.268 - case E_COLOR:
1.269 - gdc.changeEdgeColor(mapname, edge);
1.270 - break;
1.271 - case E_TEXT:
1.272 - gdc.changeEdgeText(mapname, edge);
1.273 - break;
1.274 - default:
1.275 - std::cerr<<"Error\n";
1.276 - }
1.277 - }
1.278 - }
1.279 - }
1.280 + e_combo_array[i]->update(edge);
1.281 }
1.282 }
1.283
1.284 @@ -296,13 +90,10 @@
1.285 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
1.286 {
1.287 //filling in combo box with choices
1.288 - std::list<Glib::ustring> listStrings=e_combo_array[i].get_popdown_strings();
1.289 - listStrings.push_back(newmapname);
1.290 - e_combo_array[i].set_popdown_strings(listStrings);
1.291 + e_combo_array[i]->append_text((Glib::ustring)newmapname);
1.292 }
1.293 //setting text property for the new map
1.294 - Gtk::Entry* entry = e_combo_array[E_TEXT].get_entry();
1.295 - entry->set_text((Glib::ustring)newmapname);
1.296 + e_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
1.297 }
1.298
1.299 void MapWin::registerNewNodeMap(std::string newmapname)
1.300 @@ -310,11 +101,8 @@
1.301 for(int i=0;i<NODE_PROPERTY_NUM;i++)
1.302 {
1.303 //filling in combo box with choices
1.304 - std::list<Glib::ustring> listStrings=n_combo_array[i].get_popdown_strings();
1.305 - listStrings.push_back(newmapname);
1.306 - n_combo_array[i].set_popdown_strings(listStrings);
1.307 + e_combo_array[i]->append_text((Glib::ustring)newmapname);
1.308 }
1.309 //setting text property for the new map
1.310 - Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry();
1.311 - entry->set_text((Glib::ustring)newmapname);
1.312 + n_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
1.313 }