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