ladanyi@1442: #include ladanyi@1442: #include ladanyi@1442: hegyi@1446: bool MapWin::close_if_escape_is_pressed(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@1446: MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst),table(PROPERTY_NUM, 2, false) hegyi@1446: { hegyi@1446: set_title(title); hegyi@1446: set_default_size(200, 50); ladanyi@1442: hegyi@1446: signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed)); ladanyi@1442: hegyi@1446: combo_array=new Gtk::Combo [PROPERTY_NUM]; hegyi@1446: ladanyi@1442: for(int i=0;i * >::iterator emsi=ms.beginOfEdgeMaps(); ladanyi@1442: std::set props; ladanyi@1442: ladanyi@1442: int actprop; hegyi@1446: hegyi@1446: //here we find out, which map is the default in MapStorage for this property, which are not ladanyi@1442: for(int j=0;jsecond==&(ms.default_edgemaps[i])) ladanyi@1442: { ladanyi@1442: actprop=j; ladanyi@1442: } hegyi@1446: //this is the other maps to show for this property ladanyi@1442: for(int k=0;ksecond==&(ms.default_edgemaps[k])) ladanyi@1442: { ladanyi@1442: props.insert(j); ladanyi@1442: } ladanyi@1442: } ladanyi@1442: emsi++; ladanyi@1442: } ladanyi@1442: hegyi@1446: //combo_array[i].set_group(group); ladanyi@1442: hegyi@1446: //filling in combo box with choices hegyi@1446: std::list listStrings; hegyi@1446: hegyi@1446: listStrings.push_back("Default"); ladanyi@1442: ladanyi@1442: emsi=ms.beginOfEdgeMaps(); hegyi@1446: ladanyi@1442: for(int j=0;jfirst); ladanyi@1442: } ladanyi@1442: emsi++; ladanyi@1442: } hegyi@1446: hegyi@1446: combo_array[i].set_popdown_strings(listStrings); hegyi@1446: hegyi@1446: //Restrict it to these choices only: hegyi@1446: combo_array[i].set_value_in_list(); hegyi@1446: hegyi@1446: //binding signal to thew actual entry hegyi@1446: combo_array[i].get_entry()->signal_changed().connect hegyi@1446: ( hegyi@1446: sigc::bind hegyi@1446: ( hegyi@1446: sigc::mem_fun(*this, &MapWin::combo_changed), 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@1446: label->set_text(property_strings[i]); hegyi@1446: hegyi@1446: // labelpluscombo=new Gtk::HBox; hegyi@1446: // labelpluscombo->pack_start(*label); hegyi@1446: // labelpluscombo->pack_start(combo_array[i]); hegyi@1446: hegyi@1446: table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); hegyi@1446: table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); hegyi@1446: hegyi@1446: /* hegyi@1446: if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2) hegyi@1446: { hegyi@1446: vbox_r1.pack_start(*labelpluscombo); hegyi@1446: } hegyi@1446: else hegyi@1446: { hegyi@1446: vbox_r2.pack_start(*labelpluscombo); hegyi@1446: } hegyi@1446: actpos++; hegyi@1446: //*/ hegyi@1446: ladanyi@1442: } ladanyi@1442: hegyi@1446: combos.pack_start(vbox_r1); hegyi@1446: combos.pack_start(vbox_r2); hegyi@1446: hegyi@1446: //add(combos); hegyi@1446: add(table); ladanyi@1442: ladanyi@1442: show_all_children(); ladanyi@1442: ladanyi@1442: } ladanyi@1442: hegyi@1446: void MapWin::combo_changed(int prop) ladanyi@1442: { ladanyi@1442: ladanyi@1442: //most nem kommentezem fel, mert ugyis valtozik hegyi@1446: Gtk::Entry* entry = 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@1446: if(mapname=="Default") hegyi@1446: { hegyi@1446: mapname=property_strings[prop]; hegyi@1446: } ladanyi@1442: hegyi@1446: if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) hegyi@1446: { hegyi@1446: switch(prop) hegyi@1446: { hegyi@1446: case WIDTH: hegyi@1446: gdc.changeLineWidth(mapname); hegyi@1446: break; hegyi@1446: case COLOR: hegyi@1446: gdc.changeColor(mapname); hegyi@1446: break; hegyi@1446: case TEXT: hegyi@1446: gdc.changeText(mapname); hegyi@1446: break; hegyi@1446: default: hegyi@1446: std::cout<<"Error\n"; hegyi@1446: } hegyi@1446: } ladanyi@1442: } ladanyi@1442: } ladanyi@1442: };