ladanyi@1442: #include ladanyi@1442: #include ladanyi@1442: hegyi@1524: bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e) ladanyi@1442: { hegyi@1446: if(e->keyval==GDK_Escape) hegyi@1446: { hegyi@1446: hide(); hegyi@1446: } hegyi@1446: return true; hegyi@1446: } ladanyi@1442: hegyi@1512: MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst) hegyi@1446: { hegyi@1446: set_title(title); hegyi@1446: set_default_size(200, 50); ladanyi@1442: hegyi@1524: signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed)); ladanyi@1442: hegyi@1512: e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM]; hegyi@1446: hegyi@1512: table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false); hegyi@1512: hegyi@1512: for(int i=0;i listStrings; hegyi@1446: hegyi@1446: listStrings.push_back("Default"); ladanyi@1442: hegyi@1525: std::map< std::string,Graph::EdgeMap * >::iterator emsi=ms.beginOfEdgeMaps(); hegyi@1525: for(;emsi!=ms.endOfEdgeMaps();emsi++) ladanyi@1442: { hegyi@1446: listStrings.push_back(emsi->first); ladanyi@1442: } hegyi@1446: hegyi@1512: e_combo_array[i].set_popdown_strings(listStrings); hegyi@1446: hegyi@1446: //Restrict it to these choices only: hegyi@1512: e_combo_array[i].set_value_in_list(); hegyi@1446: hegyi@1512: //binding signal to the actual entry hegyi@1512: e_combo_array[i].get_entry()->signal_changed().connect hegyi@1446: ( hegyi@1446: sigc::bind hegyi@1446: ( hegyi@1524: sigc::mem_fun(*this, &MapWin::eComboChanged), hegyi@1446: i hegyi@1446: ) hegyi@1446: ); hegyi@1446: hegyi@1446: //placing actual entry in the right place hegyi@1446: hegyi@1446: label=new Gtk::Label; hegyi@1512: label->set_text(edge_property_strings[i]); hegyi@1512: hegyi@1512: (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); hegyi@1512: (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); hegyi@1446: hegyi@1446: ladanyi@1442: } ladanyi@1442: hegyi@1512: vbox.pack_start(*(new Gtk::Label("Edge properties"))); hegyi@1446: hegyi@1512: vbox.pack_start(*table); hegyi@1512: hegyi@1512: vbox.pack_start(*(new Gtk::HSeparator)); hegyi@1512: hegyi@1512: n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM]; hegyi@1512: hegyi@1512: table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false); hegyi@1512: hegyi@1512: for(int i=0;i listStrings; hegyi@1512: hegyi@1512: listStrings.push_back("Default"); hegyi@1512: hegyi@1525: std::map< std::string,Graph::NodeMap * >::iterator emsi=ms.beginOfNodeMaps(); hegyi@1512: hegyi@1525: for(;emsi!=ms.endOfNodeMaps();emsi++) hegyi@1512: { hegyi@1525: listStrings.push_back(emsi->first); hegyi@1512: } hegyi@1512: hegyi@1512: n_combo_array[i].set_popdown_strings(listStrings); hegyi@1512: hegyi@1512: //Restrict it to these choices only: hegyi@1512: n_combo_array[i].set_value_in_list(); hegyi@1512: hegyi@1512: //binding signal to thew actual entry hegyi@1512: n_combo_array[i].get_entry()->signal_changed().connect hegyi@1512: ( hegyi@1512: sigc::bind hegyi@1512: ( hegyi@1524: sigc::mem_fun(*this, &MapWin::nComboChanged), hegyi@1512: i hegyi@1512: ) hegyi@1512: ); hegyi@1512: hegyi@1512: //placing actual entry in the right place hegyi@1512: hegyi@1512: label=new Gtk::Label; hegyi@1512: label->set_text(node_property_strings[i]); hegyi@1512: hegyi@1512: (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); hegyi@1512: (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); hegyi@1512: hegyi@1512: hegyi@1512: } hegyi@1512: hegyi@1512: add(vbox); hegyi@1512: hegyi@1512: vbox.pack_start(*(new Gtk::Label("Node properties"))); hegyi@1512: hegyi@1512: vbox.pack_start(*table); ladanyi@1442: ladanyi@1442: show_all_children(); ladanyi@1442: ladanyi@1442: } ladanyi@1442: hegyi@1524: void MapWin::eComboChanged(int prop) ladanyi@1442: { hegyi@1589: hegyi@1512: Gtk::Entry* entry = e_combo_array[prop].get_entry(); ladanyi@1442: hegyi@1446: if(entry) ladanyi@1442: { hegyi@1446: Glib::ustring mapname = entry->get_text(); hegyi@1446: if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. hegyi@1446: { hegyi@1525: if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") ) hegyi@1446: { hegyi@1446: switch(prop) hegyi@1446: { hegyi@1512: case E_WIDTH: hegyi@1512: gdc.changeEdgeWidth(mapname); hegyi@1446: break; hegyi@1512: case E_COLOR: hegyi@1512: gdc.changeEdgeColor(mapname); hegyi@1446: break; hegyi@1512: case E_TEXT: hegyi@1512: gdc.changeEdgeText(mapname); hegyi@1446: break; hegyi@1446: default: hegyi@1446: std::cout<<"Error\n"; hegyi@1446: } hegyi@1446: } ladanyi@1442: } ladanyi@1442: } ladanyi@1442: }; hegyi@1512: hegyi@1524: void MapWin::nComboChanged(int prop) hegyi@1512: { hegyi@1512: hegyi@1512: Gtk::Entry* entry = n_combo_array[prop].get_entry(); hegyi@1512: hegyi@1512: if(entry) hegyi@1512: { hegyi@1512: Glib::ustring mapname = entry->get_text(); hegyi@1512: if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. hegyi@1512: { hegyi@1525: if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") ) hegyi@1512: { hegyi@1512: switch(prop) hegyi@1512: { hegyi@1512: case N_RADIUS: hegyi@1512: gdc.changeNodeRadius(mapname); hegyi@1512: break; hegyi@1512: case N_COLOR: hegyi@1512: gdc.changeNodeColor(mapname); hegyi@1512: break; hegyi@1512: case N_TEXT: hegyi@1512: gdc.changeNodeText(mapname); hegyi@1512: break; hegyi@1512: default: hegyi@1512: std::cout<<"Error\n"; hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: }; hegyi@1512: hegyi@1524: void MapWin::updateNode(Graph::Node node) hegyi@1512: { hegyi@1512: for(int i=0;iget_text(); hegyi@1512: if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. hegyi@1512: { hegyi@1525: if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") ) hegyi@1512: { hegyi@1512: switch(i) hegyi@1512: { hegyi@1512: case N_RADIUS: hegyi@1525: gdc.changeNodeRadius(mapname, node); hegyi@1512: break; hegyi@1512: case N_COLOR: hegyi@1512: gdc.changeNodeColor(mapname, node); hegyi@1512: break; hegyi@1512: case N_TEXT: hegyi@1512: gdc.changeNodeText(mapname, node); hegyi@1512: break; hegyi@1512: default: hegyi@1512: std::cout<<"Error\n"; hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: hegyi@1524: void MapWin::updateEdge(Graph::Edge edge) hegyi@1512: { hegyi@1512: for(int i=0;iget_text(); hegyi@1512: if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. hegyi@1512: { hegyi@1512: hegyi@1525: if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") ) hegyi@1512: { hegyi@1512: switch(i) hegyi@1512: { hegyi@1512: case E_WIDTH: hegyi@1525: gdc.changeEdgeWidth(mapname, edge); hegyi@1512: break; hegyi@1512: case E_COLOR: hegyi@1512: gdc.changeEdgeColor(mapname, edge); hegyi@1512: break; hegyi@1512: case E_TEXT: hegyi@1512: gdc.changeEdgeText(mapname, edge); hegyi@1512: break; hegyi@1512: default: hegyi@1512: std::cout<<"Error\n"; hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1512: } hegyi@1586: hegyi@1589: void MapWin::registerNewEdgeMap(std::string newmapname) hegyi@1586: { hegyi@1589: for(int i=0;i listStrings=e_combo_array[i].get_popdown_strings(); hegyi@1589: listStrings.push_back(newmapname); hegyi@1589: e_combo_array[i].set_popdown_strings(listStrings); hegyi@1589: } hegyi@1589: Gtk::Entry* entry = e_combo_array[E_TEXT].get_entry(); hegyi@1589: entry->set_text((Glib::ustring)newmapname); hegyi@1586: } hegyi@1586: hegyi@1589: void MapWin::registerNewNodeMap(std::string newmapname) hegyi@1586: { hegyi@1592: for(int i=0;i listStrings=n_combo_array[i].get_popdown_strings(); hegyi@1589: listStrings.push_back(newmapname); hegyi@1589: n_combo_array[i].set_popdown_strings(listStrings); hegyi@1589: } hegyi@1592: Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry(); hegyi@1592: entry->set_text((Glib::ustring)newmapname); hegyi@1586: }