# HG changeset patch # User hegyi # Date 1136558206 0 # Node ID 2c3f6c7e01b443eee02d5a37872415700bdd7155 # Parent f40cdc2057c26670d634aed8c70171eb8a8b171a MapSelector has become a standalone class. diff -r f40cdc2057c2 -r 2c3f6c7e01b4 gui/Makefile.am --- a/gui/Makefile.am Fri Jan 06 13:58:49 2006 +0000 +++ b/gui/Makefile.am Fri Jan 06 14:36:46 2006 +0000 @@ -27,7 +27,8 @@ mapstorage.h \ map_win.cc \ map_win.h \ - mw-mapselector.cc \ + mapselector.cc \ + mapselector.h \ nbtab.h \ nbtab.cc \ new_map_win.cc \ diff -r f40cdc2057c2 -r 2c3f6c7e01b4 gui/map_win.h --- a/gui/map_win.h Fri Jan 06 13:58:49 2006 +0000 +++ b/gui/map_win.h Fri Jan 06 14:36:46 2006 +0000 @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -15,55 +16,6 @@ ///assigned to maps. class MapWin : public Gtk::Window { - - class MapSelector : public Gtk::HBox - { - protected: - sigc::signal signal_cbt; - sigc::signal signal_newmapwin; - - int id; - - bool itisedge; - - bool default_state; - - bool set_new_map; - - Gtk::ComboBoxText cbt; - - Gtk::Button * newbut, * defbut; - - Gtk::HBox hbox; - - Gtk::Label * label; - - public: - - MapSelector(std::vector, std::string, int, bool); - - sigc::signal signal_cbt_ch(); - sigc::signal signal_newmapwin_needed(); - - void update_list( std::vector ); - - ///If a radiobutton is clicked, this function determines - ///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 comboChanged(); - - virtual void new_but_pressed(); - - virtual void reset(); - - Glib::ustring get_active_text(); - void set_active_text(Glib::ustring); - void append_text(Glib::ustring); - }; - - - protected: NoteBookTab & mytab; diff -r f40cdc2057c2 -r 2c3f6c7e01b4 gui/mapselector.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gui/mapselector.cc Fri Jan 06 14:36:46 2006 +0000 @@ -0,0 +1,136 @@ +#include "mapselector.h" + +MapSelector::MapSelector(std::vector ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false) +{ + update_list(ml); + + if(act=="") + { + cbt.set_active(0); + default_state=true; + } + else + { + cbt.set_active_text((Glib::ustring)act); + default_state=false; + } + + //binding signal to the actual entry + cbt.signal_changed().connect + ( + sigc::mem_fun((*this), &MapSelector::comboChanged), + false + ); + + if(itisedge) + { + label=new Gtk::Label(edge_property_strings[id]); + } + else + { + label=new Gtk::Label(node_property_strings[id]); + } + + label->set_width_chars(longest_property_string_length); + + defbut=new Gtk::Button(); + defbut->set_label("Reset"); + + defbut->signal_pressed().connect + ( + sigc::mem_fun(*this, &MapSelector::reset) + ); + + newbut=new Gtk::Button(Gtk::Stock::NEW); + + newbut->signal_pressed().connect + ( + sigc::mem_fun(*this, &MapSelector::new_but_pressed) + ); + + add(*label); + + add(cbt); + + add(*defbut); + add(*newbut); +} + +void MapSelector::new_but_pressed() +{ + set_new_map=true; + signal_newmapwin.emit(itisedge); +} + +void MapSelector::update_list( std::vector< std::string > ml ) +{ + int prev_act=cbt.get_active_row_number(); + cbt.clear(); + std::vector< std::string >::iterator emsi=ml.begin(); + for(;emsi!=ml.end();emsi++) + { + cbt.append_text(*emsi); + } + cbt.prepend_text("Default values"); + if(prev_act!=-1) + { + cbt.set_active(prev_act); + } +} + +void MapSelector::comboChanged() +{ + if(cbt.get_active_row_number()!=0) + { + default_state=false; + Glib::ustring mapname = cbt.get_active_text(); + if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. + { + signal_cbt.emit(mapname); + } + } + else if((!default_state)&&(cbt.get_active_row_number()==0)) + { + reset(); + } +} + +void MapSelector::reset() +{ + default_state=true; + + cbt.set_active(0); + + signal_cbt.emit(""); +} + + +Glib::ustring MapSelector::get_active_text() +{ + return cbt.get_active_text(); +} + +void MapSelector::set_active_text(Glib::ustring text) +{ + cbt.set_active_text(text); +} + +void MapSelector::append_text(Glib::ustring text) +{ + cbt.append_text(text); + if(set_new_map) + { + set_active_text(text); + set_new_map=false; + } +} + +sigc::signal MapSelector::signal_cbt_ch() +{ + return signal_cbt; +} + +sigc::signal MapSelector::signal_newmapwin_needed() +{ + return signal_newmapwin; +} diff -r f40cdc2057c2 -r 2c3f6c7e01b4 gui/mw-mapselector.cc --- a/gui/mw-mapselector.cc Fri Jan 06 13:58:49 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -#include "map_win.h" - -MapWin::MapSelector::MapSelector(std::vector ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false) -{ - update_list(ml); - - if(act=="") - { - cbt.set_active(0); - default_state=true; - } - else - { - cbt.set_active_text((Glib::ustring)act); - default_state=false; - } - - //binding signal to the actual entry - cbt.signal_changed().connect - ( - sigc::mem_fun((*this), &MapWin::MapSelector::comboChanged), - false - ); - - if(itisedge) - { - label=new Gtk::Label(edge_property_strings[id]); - } - else - { - label=new Gtk::Label(node_property_strings[id]); - } - - label->set_width_chars(longest_property_string_length); - - defbut=new Gtk::Button(); - defbut->set_label("Reset"); - - defbut->signal_pressed().connect - ( - sigc::mem_fun(*this, &MapWin::MapSelector::reset) - ); - - newbut=new Gtk::Button(Gtk::Stock::NEW); - - newbut->signal_pressed().connect - ( - sigc::mem_fun(*this, &MapWin::MapSelector::new_but_pressed) - ); - - add(*label); - - add(cbt); - - add(*defbut); - add(*newbut); -} - -void MapWin::MapSelector::new_but_pressed() -{ - set_new_map=true; - signal_newmapwin.emit(itisedge); -} - -void MapWin::MapSelector::update_list( std::vector< std::string > ml ) -{ - int prev_act=cbt.get_active_row_number(); - cbt.clear(); - std::vector< std::string >::iterator emsi=ml.begin(); - for(;emsi!=ml.end();emsi++) - { - cbt.append_text(*emsi); - } - cbt.prepend_text("Default values"); - if(prev_act!=-1) - { - cbt.set_active(prev_act); - } -} - -void MapWin::MapSelector::comboChanged() -{ - if(cbt.get_active_row_number()!=0) - { - default_state=false; - Glib::ustring mapname = cbt.get_active_text(); - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty. - { - signal_cbt.emit(mapname); - } - } - else if((!default_state)&&(cbt.get_active_row_number()==0)) - { - reset(); - } -} - -void MapWin::MapSelector::reset() -{ - default_state=true; - - cbt.set_active(0); - - signal_cbt.emit(""); -} - - -Glib::ustring MapWin::MapSelector::get_active_text() -{ - return cbt.get_active_text(); -} - -void MapWin::MapSelector::set_active_text(Glib::ustring text) -{ - cbt.set_active_text(text); -} - -void MapWin::MapSelector::append_text(Glib::ustring text) -{ - cbt.append_text(text); - if(set_new_map) - { - set_active_text(text); - set_new_map=false; - } -} - -sigc::signal MapWin::MapSelector::signal_cbt_ch() -{ - return signal_cbt; -} - -sigc::signal MapWin::MapSelector::signal_newmapwin_needed() -{ - return signal_newmapwin; -}