#include #include bool MapWin::close_if_escape_is_pressed(GdkEventKey* e) { if(e->keyval==GDK_Escape) { hide(); } return true; } MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst) { set_title(title); set_default_size(200, 50); signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed)); e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM]; table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false); for(int i=0;i * >::iterator emsi=ms.beginOfEdgeMaps(); std::set props; int actprop; //here we find out, which map is the default in MapStorage for this property, which are not for(int j=0;jsecond==&(ms.default_edgemaps[i])) { actprop=j; } //these are the maps NOT to show for this property for(int k=0;ksecond==&(ms.default_edgemaps[k])) { props.insert(j); } } emsi++; } //filling in combo box with choices std::list listStrings; listStrings.push_back("Default"); emsi=ms.beginOfEdgeMaps(); for(int j=0;jfirst); } emsi++; } 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::e_combo_changed), 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); } vbox.pack_start(*(new Gtk::Label("Edge properties"))); vbox.pack_start(*table); vbox.pack_start(*(new Gtk::HSeparator)); n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM]; table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false); for(int i=0;i * >::iterator emsi=ms.beginOfNodeMaps(); std::set props; int actprop; //here we find out, which map is the default in MapStorage for this property, which are not for(int j=0;jsecond==&(ms.default_nodemaps[i])) { actprop=j; } //this is the other maps to show for this property for(int k=0;ksecond==&(ms.default_nodemaps[k])) { props.insert(j); } } emsi++; } //filling in combo box with choices std::list listStrings; listStrings.push_back("Default"); emsi=ms.beginOfNodeMaps(); for(int j=0;jfirst); } emsi++; } 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::n_combo_changed), 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); } add(vbox); vbox.pack_start(*(new Gtk::Label("Node properties"))); vbox.pack_start(*table); show_all_children(); } void MapWin::e_combo_changed(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(mapname=="Default") { mapname=edge_property_strings[prop]; } if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) { 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::cout<<"Error\n"; } } } } }; void MapWin::n_combo_changed(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(mapname=="Default") { mapname=node_property_strings[prop]; } if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) { 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::cout<<"Error\n"; } } } } }; void MapWin::update_node(Graph::Node node) { for(int i=0;iget_text(); if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. { if(mapname=="Default") { mapname=node_property_strings[i]; } if( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) { switch(i) { case N_RADIUS: //gdc.changeNodeRadius(mapname, node); std::cout << "If default map-value problem is solved, uncomment line in MapWin::node_update!" << std::endl; break; case N_COLOR: gdc.changeNodeColor(mapname, node); break; case N_TEXT: gdc.changeNodeText(mapname, node); break; default: std::cout<<"Error\n"; } } } } } } void MapWin::update_edge(Graph::Edge edge) { for(int i=0;iget_text(); if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. { if(mapname=="Default") { mapname=edge_property_strings[i]; } if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) { switch(i) { case E_WIDTH: //gdc.changeEdgeWidth(mapname, edge); std::cout << "If default map-value problem is solved, uncomment line in MapWin::edge_update!" << std::endl; break; case E_COLOR: gdc.changeEdgeColor(mapname, edge); break; case E_TEXT: gdc.changeEdgeText(mapname, edge); break; default: std::cout<<"Error\n"; } } } } } }