# HG changeset patch # User hegyi # Date 1118077272 0 # Node ID 320f73c5cfc1c66b462ebe3ceacc905ae7f71144 # Parent 4635352e5524292e65c37e49d7bb5db8d29299f5 Maps are now selectable through ComboBoxes, and Escape makes MapWin disappeared. diff -r 4635352e5524 -r 320f73c5cfc1 gui/map_win.cc --- a/gui/map_win.cc Sat Jun 04 12:50:15 2005 +0000 +++ b/gui/map_win.cc Mon Jun 06 17:01:12 2005 +0000 @@ -1,35 +1,41 @@ #include #include -MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst) +bool MapWin::close_if_escape_is_pressed(GdkEventKey* e) { + if(e->keyval==GDK_Escape) + { + hide(); + } + return true; +} - //most nem kommentezem fel, mert ugyis valtozik +MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst),table(PROPERTY_NUM, 2, false) +{ + set_title(title); + set_default_size(200, 50); - set_title(title); - set_default_size(400, 200); + signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::close_if_escape_is_pressed)); - rb_array=new Gtk::RadioButton * [PROPERTY_NUM]; - vbox_r1=new Gtk::VBox[PROPERTY_NUM]; - vbox_r2=new Gtk::VBox[PROPERTY_NUM]; - radios=new Gtk::HBox[PROPERTY_NUM]; + combo_array=new Gtk::Combo [PROPERTY_NUM]; + 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; } + //this is the other maps to show for this property for(int k=0;ksecond==&(ms.default_edgemaps[k])) @@ -40,83 +46,108 @@ emsi++; } - rb_array[i][0].set_group(group); - rb_array[i][0].set_label("Default"); - rb_array[i][0].signal_clicked().connect( sigc::bind( sigc::bind( sigc::mem_fun(*this, &MapWin::radio_click), 0), i) ); - vbox_r1[i].pack_start(rb_array[i][0]); + //combo_array[i].set_group(group); + //filling in combo box with choices + std::list listStrings; + + listStrings.push_back("Default"); emsi=ms.beginOfEdgeMaps(); - int actpos=1; + for(int j=0;jfirst); - rb_array[i][actpos].signal_clicked().connect - ( - sigc::bind( - sigc::bind( - sigc::mem_fun(*this, &MapWin::radio_click), - actpos - ), - i - ) - ); - - if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2) - { - vbox_r1[i].pack_start(rb_array[i][actpos]); - } - else - { - vbox_r2[i].pack_start(rb_array[i][actpos]); - } - actpos++; + listStrings.push_back(emsi->first); } emsi++; } - radios[i].pack_start(vbox_r1[i]); - radios[i].pack_start(vbox_r2[i]); - notebook.append_page(radios[i], property_strings[i]); + + combo_array[i].set_popdown_strings(listStrings); + + //Restrict it to these choices only: + combo_array[i].set_value_in_list(); + + //binding signal to thew actual entry + combo_array[i].get_entry()->signal_changed().connect + ( + sigc::bind + ( + sigc::mem_fun(*this, &MapWin::combo_changed), + i + ) + ); + + //placing actual entry in the right place + + label=new Gtk::Label; + label->set_text(property_strings[i]); + + // labelpluscombo=new Gtk::HBox; + // labelpluscombo->pack_start(*label); + // labelpluscombo->pack_start(combo_array[i]); + + table.attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); + table.attach(combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); + + /* + if(actpos<(ms.numOfEdgeMaps()-PROPERTY_NUM+1)/2) + { + vbox_r1.pack_start(*labelpluscombo); + } + else + { + vbox_r2.pack_start(*labelpluscombo); + } + actpos++; + //*/ + } - add(vbox_b); - vbox_b.pack_start(notebook); + combos.pack_start(vbox_r1); + combos.pack_start(vbox_r2); + + //add(combos); + add(table); show_all_children(); } -void MapWin::radio_click(int prop, int actpos) +void MapWin::combo_changed(int prop) { //most nem kommentezem fel, mert ugyis valtozik + Gtk::Entry* entry = combo_array[prop].get_entry(); - if(rb_array[prop][actpos].get_active()) + 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=property_strings[prop]; + } - std::string mapname=rb_array[prop][actpos].get_label(); - - if(mapname=="Default") - { - mapname=property_strings[prop]; - } - - switch(prop) - { - case WIDTH: - gdc.changeLineWidth(mapname); - break; - case COLOR: - gdc.changeColor(mapname); - break; - case TEXT: - gdc.changeText(mapname); - break; - default: - std::cout<<"Error\n"; + if( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) + { + switch(prop) + { + case WIDTH: + gdc.changeLineWidth(mapname); + break; + case COLOR: + gdc.changeColor(mapname); + break; + case TEXT: + gdc.changeText(mapname); + break; + default: + std::cout<<"Error\n"; + } + } } } }; diff -r 4635352e5524 -r 320f73c5cfc1 gui/map_win.h --- a/gui/map_win.h Sat Jun 04 12:50:15 2005 +0000 +++ b/gui/map_win.h Mon Jun 06 17:01:12 2005 +0000 @@ -24,16 +24,14 @@ ///The \ref MapStorage in which the visualizable maps are stored MapStorage & ms; + Gtk::Table table; - Gtk::HBox * radios; - Gtk::RadioButton ** rb_array; + Gtk::HBox combos, * labelpluscombo; + Gtk::Combo * combo_array; - Gtk::VBox vbox_b, * vbox_r1, * vbox_r2; + Gtk::VBox vbox_b, vbox_r1, vbox_r2; - ///The notebook has different pages for each attribute. - Gtk::Notebook notebook; - - Gtk::Label * labels; + Gtk::Label * label; public: ///Constructor of MapWin creates the widgets shown in MapWin. @@ -43,7 +41,8 @@ ///which button was that and after that calls the ///appropriate function of the \ref GraphDisplayerCanvas ///to change the visible values of that attribute. - virtual void radio_click(int, int); + virtual void combo_changed(int); + virtual bool close_if_escape_is_pressed(GdkEventKey*); }; #endif //MAP_WIN_H