diff -r 231191361de5 -r 5ad61c33487c map_win.cc --- a/map_win.cc Thu Oct 06 12:32:06 2005 +0000 +++ b/map_win.cc Thu Oct 20 15:50:23 2005 +0000 @@ -17,47 +17,15 @@ signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed)); - e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM]; + e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM]; - table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false); + table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false); for(int i=0;i listStrings; + e_combo_array[i]=new MapSelector(gdc, ms, *this, i, true); - listStrings.push_back("Default"); - - std::map< std::string,Graph::EdgeMap * >::iterator emsi=ms.beginOfEdgeMaps(); - for(;emsi!=ms.endOfEdgeMaps();emsi++) - { - listStrings.push_back(emsi->first); - } - - e_combo_array[i].set_popdown_strings(listStrings); - - //Restrict it to these choices only: - e_combo_array[i].set_value_in_list(); - - //binding signal to the actual entry - e_combo_array[i].get_entry()->signal_changed().connect - ( - sigc::bind - ( - sigc::mem_fun(*this, &MapWin::eComboChanged), - i - ) - ); - - //placing actual entry in the right place - - label=new Gtk::Label; - label->set_text(edge_property_strings[i]); - - (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); - (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); - - + (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); } vbox.pack_start(*(new Gtk::Label("Edge properties"))); @@ -66,51 +34,15 @@ vbox.pack_start(*(new Gtk::HSeparator)); - n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM]; + n_combo_array=new MapSelector * [NODE_PROPERTY_NUM]; - table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false); + table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false); for(int i=0;i listStrings; + n_combo_array[i]=new MapSelector(gdc, ms, *this, i, false); - listStrings.push_back("Default"); - - std::map< std::string,Graph::NodeMap * >::iterator emsi=ms.beginOfNodeMaps(); - - for(;emsi!=ms.endOfNodeMaps();emsi++) - { - if ((emsi->first != "coordinates_x") && (emsi->first != "coordinates_y")) - { - listStrings.push_back(emsi->first); - } - } - - n_combo_array[i].set_popdown_strings(listStrings); - - //Restrict it to these choices only: - n_combo_array[i].set_value_in_list(); - - //binding signal to thew actual entry - n_combo_array[i].get_entry()->signal_changed().connect - ( - sigc::bind - ( - sigc::mem_fun(*this, &MapWin::nComboChanged), - i - ) - ); - - //placing actual entry in the right place - - label=new Gtk::Label; - label->set_text(node_property_strings[i]); - - (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); - (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); - - + (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); } add(vbox); @@ -127,132 +59,21 @@ { for(int i=0;i listStrings; + e_combo_array[i]->update_list(); + } - listStrings.push_back("Default"); - - std::map< std::string,Graph::EdgeMap * >::iterator emsi=ms.beginOfEdgeMaps(); - for(;emsi!=ms.endOfEdgeMaps();emsi++) - { - listStrings.push_back(emsi->first); - } - - e_combo_array[i].set_popdown_strings(listStrings); - } for(int i=0;i listStrings; - - listStrings.push_back("Default"); - - std::map< std::string,Graph::NodeMap * >::iterator emsi=ms.beginOfNodeMaps(); - - for(;emsi!=ms.endOfNodeMaps();emsi++) - { - if ((emsi->first != "coordinates_x") && (emsi->first != "coordinates_y")) - { - listStrings.push_back(emsi->first); - } - } - - n_combo_array[i].set_popdown_strings(listStrings); + n_combo_array[i]->update_list(); } } -void MapWin::eComboChanged(int prop) -{ - - Gtk::Entry* entry = e_combo_array[prop].get_entry(); - - if(entry) - { - Glib::ustring mapname = entry->get_text(); - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. - { - if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") ) - { - switch(prop) - { - case E_WIDTH: - gdc.changeEdgeWidth(mapname); - break; - case E_COLOR: - gdc.changeEdgeColor(mapname); - break; - case E_TEXT: - gdc.changeEdgeText(mapname); - break; - default: - std::cerr<<"Error\n"; - } - } - } - } -}; - -void MapWin::nComboChanged(int prop) -{ - - Gtk::Entry* entry = n_combo_array[prop].get_entry(); - - if(entry) - { - Glib::ustring mapname = entry->get_text(); - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. - { - if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") ) - { - switch(prop) - { - case N_RADIUS: - gdc.changeNodeRadius(mapname); - break; - case N_COLOR: - gdc.changeNodeColor(mapname); - break; - case N_TEXT: - gdc.changeNodeText(mapname); - break; - default: - std::cerr<<"Error\n"; - } - } - } - } -}; void MapWin::updateNode(Node node) { for(int i=0;iget_text(); - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. - { - if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") ) - { - switch(i) - { - case N_RADIUS: - gdc.changeNodeRadius(mapname, node); - break; - case N_COLOR: - gdc.changeNodeColor(mapname, node); - break; - case N_TEXT: - gdc.changeNodeText(mapname, node); - break; - default: - std::cerr<<"Error\n"; - } - } - } - } + n_combo_array[i]->update(node); } } @@ -260,34 +81,7 @@ { for(int i=0;iget_text(); - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. - { - - if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") ) - { - switch(i) - { - case E_WIDTH: - gdc.changeEdgeWidth(mapname, edge); - break; - case E_COLOR: - gdc.changeEdgeColor(mapname, edge); - break; - case E_TEXT: - gdc.changeEdgeText(mapname, edge); - break; - default: - std::cerr<<"Error\n"; - } - } - } - } + e_combo_array[i]->update(edge); } } @@ -296,13 +90,10 @@ for(int i=0;i listStrings=e_combo_array[i].get_popdown_strings(); - listStrings.push_back(newmapname); - e_combo_array[i].set_popdown_strings(listStrings); + e_combo_array[i]->append_text((Glib::ustring)newmapname); } //setting text property for the new map - Gtk::Entry* entry = e_combo_array[E_TEXT].get_entry(); - entry->set_text((Glib::ustring)newmapname); + e_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname); } void MapWin::registerNewNodeMap(std::string newmapname) @@ -310,11 +101,8 @@ for(int i=0;i listStrings=n_combo_array[i].get_popdown_strings(); - listStrings.push_back(newmapname); - n_combo_array[i].set_popdown_strings(listStrings); + e_combo_array[i]->append_text((Glib::ustring)newmapname); } //setting text property for the new map - Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry(); - entry->set_text((Glib::ustring)newmapname); + n_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname); }