MapSelector has become a standalone class.
1.1 --- a/gui/Makefile.am Fri Jan 06 13:58:49 2006 +0000
1.2 +++ b/gui/Makefile.am Fri Jan 06 14:36:46 2006 +0000
1.3 @@ -27,7 +27,8 @@
1.4 mapstorage.h \
1.5 map_win.cc \
1.6 map_win.h \
1.7 - mw-mapselector.cc \
1.8 + mapselector.cc \
1.9 + mapselector.h \
1.10 nbtab.h \
1.11 nbtab.cc \
1.12 new_map_win.cc \
2.1 --- a/gui/map_win.h Fri Jan 06 13:58:49 2006 +0000
2.2 +++ b/gui/map_win.h Fri Jan 06 14:36:46 2006 +0000
2.3 @@ -7,6 +7,7 @@
2.4
2.5 #include <all_include.h>
2.6 #include <nbtab.h>
2.7 +#include <mapselector.h>
2.8 #include <libgnomecanvasmm.h>
2.9 #include <libgnomecanvasmm/polygon.h>
2.10
2.11 @@ -15,55 +16,6 @@
2.12 ///assigned to maps.
2.13 class MapWin : public Gtk::Window
2.14 {
2.15 -
2.16 - class MapSelector : public Gtk::HBox
2.17 - {
2.18 - protected:
2.19 - sigc::signal<void, std::string> signal_cbt;
2.20 - sigc::signal<void, bool> signal_newmapwin;
2.21 -
2.22 - int id;
2.23 -
2.24 - bool itisedge;
2.25 -
2.26 - bool default_state;
2.27 -
2.28 - bool set_new_map;
2.29 -
2.30 - Gtk::ComboBoxText cbt;
2.31 -
2.32 - Gtk::Button * newbut, * defbut;
2.33 -
2.34 - Gtk::HBox hbox;
2.35 -
2.36 - Gtk::Label * label;
2.37 -
2.38 - public:
2.39 -
2.40 - MapSelector(std::vector<std::string>, std::string, int, bool);
2.41 -
2.42 - sigc::signal<void, std::string> signal_cbt_ch();
2.43 - sigc::signal<void, bool> signal_newmapwin_needed();
2.44 -
2.45 - void update_list( std::vector<std::string> );
2.46 -
2.47 - ///If a radiobutton is clicked, this function determines
2.48 - ///which button was that and after that calls the
2.49 - ///appropriate function of the \ref GraphDisplayerCanvas
2.50 - ///to change the visible values of that attribute.
2.51 - virtual void comboChanged();
2.52 -
2.53 - virtual void new_but_pressed();
2.54 -
2.55 - virtual void reset();
2.56 -
2.57 - Glib::ustring get_active_text();
2.58 - void set_active_text(Glib::ustring);
2.59 - void append_text(Glib::ustring);
2.60 - };
2.61 -
2.62 -
2.63 -
2.64 protected:
2.65 NoteBookTab & mytab;
2.66
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/gui/mapselector.cc Fri Jan 06 14:36:46 2006 +0000
3.3 @@ -0,0 +1,136 @@
3.4 +#include "mapselector.h"
3.5 +
3.6 +MapSelector::MapSelector(std::vector<std::string> ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false)
3.7 +{
3.8 + update_list(ml);
3.9 +
3.10 + if(act=="")
3.11 + {
3.12 + cbt.set_active(0);
3.13 + default_state=true;
3.14 + }
3.15 + else
3.16 + {
3.17 + cbt.set_active_text((Glib::ustring)act);
3.18 + default_state=false;
3.19 + }
3.20 +
3.21 + //binding signal to the actual entry
3.22 + cbt.signal_changed().connect
3.23 + (
3.24 + sigc::mem_fun((*this), &MapSelector::comboChanged),
3.25 + false
3.26 + );
3.27 +
3.28 + if(itisedge)
3.29 + {
3.30 + label=new Gtk::Label(edge_property_strings[id]);
3.31 + }
3.32 + else
3.33 + {
3.34 + label=new Gtk::Label(node_property_strings[id]);
3.35 + }
3.36 +
3.37 + label->set_width_chars(longest_property_string_length);
3.38 +
3.39 + defbut=new Gtk::Button();
3.40 + defbut->set_label("Reset");
3.41 +
3.42 + defbut->signal_pressed().connect
3.43 + (
3.44 + sigc::mem_fun(*this, &MapSelector::reset)
3.45 + );
3.46 +
3.47 + newbut=new Gtk::Button(Gtk::Stock::NEW);
3.48 +
3.49 + newbut->signal_pressed().connect
3.50 + (
3.51 + sigc::mem_fun(*this, &MapSelector::new_but_pressed)
3.52 + );
3.53 +
3.54 + add(*label);
3.55 +
3.56 + add(cbt);
3.57 +
3.58 + add(*defbut);
3.59 + add(*newbut);
3.60 +}
3.61 +
3.62 +void MapSelector::new_but_pressed()
3.63 +{
3.64 + set_new_map=true;
3.65 + signal_newmapwin.emit(itisedge);
3.66 +}
3.67 +
3.68 +void MapSelector::update_list( std::vector< std::string > ml )
3.69 +{
3.70 + int prev_act=cbt.get_active_row_number();
3.71 + cbt.clear();
3.72 + std::vector< std::string >::iterator emsi=ml.begin();
3.73 + for(;emsi!=ml.end();emsi++)
3.74 + {
3.75 + cbt.append_text(*emsi);
3.76 + }
3.77 + cbt.prepend_text("Default values");
3.78 + if(prev_act!=-1)
3.79 + {
3.80 + cbt.set_active(prev_act);
3.81 + }
3.82 +}
3.83 +
3.84 +void MapSelector::comboChanged()
3.85 +{
3.86 + if(cbt.get_active_row_number()!=0)
3.87 + {
3.88 + default_state=false;
3.89 + Glib::ustring mapname = cbt.get_active_text();
3.90 + if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
3.91 + {
3.92 + signal_cbt.emit(mapname);
3.93 + }
3.94 + }
3.95 + else if((!default_state)&&(cbt.get_active_row_number()==0))
3.96 + {
3.97 + reset();
3.98 + }
3.99 +}
3.100 +
3.101 +void MapSelector::reset()
3.102 +{
3.103 + default_state=true;
3.104 +
3.105 + cbt.set_active(0);
3.106 +
3.107 + signal_cbt.emit("");
3.108 +}
3.109 +
3.110 +
3.111 +Glib::ustring MapSelector::get_active_text()
3.112 +{
3.113 + return cbt.get_active_text();
3.114 +}
3.115 +
3.116 +void MapSelector::set_active_text(Glib::ustring text)
3.117 +{
3.118 + cbt.set_active_text(text);
3.119 +}
3.120 +
3.121 +void MapSelector::append_text(Glib::ustring text)
3.122 +{
3.123 + cbt.append_text(text);
3.124 + if(set_new_map)
3.125 + {
3.126 + set_active_text(text);
3.127 + set_new_map=false;
3.128 + }
3.129 +}
3.130 +
3.131 +sigc::signal<void, std::string> MapSelector::signal_cbt_ch()
3.132 +{
3.133 + return signal_cbt;
3.134 +}
3.135 +
3.136 +sigc::signal<void, bool> MapSelector::signal_newmapwin_needed()
3.137 +{
3.138 + return signal_newmapwin;
3.139 +}
4.1 --- a/gui/mw-mapselector.cc Fri Jan 06 13:58:49 2006 +0000
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,136 +0,0 @@
4.4 -#include "map_win.h"
4.5 -
4.6 -MapWin::MapSelector::MapSelector(std::vector<std::string> ml, std::string act, int identifier, bool edge):id(identifier),itisedge(edge),set_new_map(false)
4.7 -{
4.8 - update_list(ml);
4.9 -
4.10 - if(act=="")
4.11 - {
4.12 - cbt.set_active(0);
4.13 - default_state=true;
4.14 - }
4.15 - else
4.16 - {
4.17 - cbt.set_active_text((Glib::ustring)act);
4.18 - default_state=false;
4.19 - }
4.20 -
4.21 - //binding signal to the actual entry
4.22 - cbt.signal_changed().connect
4.23 - (
4.24 - sigc::mem_fun((*this), &MapWin::MapSelector::comboChanged),
4.25 - false
4.26 - );
4.27 -
4.28 - if(itisedge)
4.29 - {
4.30 - label=new Gtk::Label(edge_property_strings[id]);
4.31 - }
4.32 - else
4.33 - {
4.34 - label=new Gtk::Label(node_property_strings[id]);
4.35 - }
4.36 -
4.37 - label->set_width_chars(longest_property_string_length);
4.38 -
4.39 - defbut=new Gtk::Button();
4.40 - defbut->set_label("Reset");
4.41 -
4.42 - defbut->signal_pressed().connect
4.43 - (
4.44 - sigc::mem_fun(*this, &MapWin::MapSelector::reset)
4.45 - );
4.46 -
4.47 - newbut=new Gtk::Button(Gtk::Stock::NEW);
4.48 -
4.49 - newbut->signal_pressed().connect
4.50 - (
4.51 - sigc::mem_fun(*this, &MapWin::MapSelector::new_but_pressed)
4.52 - );
4.53 -
4.54 - add(*label);
4.55 -
4.56 - add(cbt);
4.57 -
4.58 - add(*defbut);
4.59 - add(*newbut);
4.60 -}
4.61 -
4.62 -void MapWin::MapSelector::new_but_pressed()
4.63 -{
4.64 - set_new_map=true;
4.65 - signal_newmapwin.emit(itisedge);
4.66 -}
4.67 -
4.68 -void MapWin::MapSelector::update_list( std::vector< std::string > ml )
4.69 -{
4.70 - int prev_act=cbt.get_active_row_number();
4.71 - cbt.clear();
4.72 - std::vector< std::string >::iterator emsi=ml.begin();
4.73 - for(;emsi!=ml.end();emsi++)
4.74 - {
4.75 - cbt.append_text(*emsi);
4.76 - }
4.77 - cbt.prepend_text("Default values");
4.78 - if(prev_act!=-1)
4.79 - {
4.80 - cbt.set_active(prev_act);
4.81 - }
4.82 -}
4.83 -
4.84 -void MapWin::MapSelector::comboChanged()
4.85 -{
4.86 - if(cbt.get_active_row_number()!=0)
4.87 - {
4.88 - default_state=false;
4.89 - Glib::ustring mapname = cbt.get_active_text();
4.90 - if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
4.91 - {
4.92 - signal_cbt.emit(mapname);
4.93 - }
4.94 - }
4.95 - else if((!default_state)&&(cbt.get_active_row_number()==0))
4.96 - {
4.97 - reset();
4.98 - }
4.99 -}
4.100 -
4.101 -void MapWin::MapSelector::reset()
4.102 -{
4.103 - default_state=true;
4.104 -
4.105 - cbt.set_active(0);
4.106 -
4.107 - signal_cbt.emit("");
4.108 -}
4.109 -
4.110 -
4.111 -Glib::ustring MapWin::MapSelector::get_active_text()
4.112 -{
4.113 - return cbt.get_active_text();
4.114 -}
4.115 -
4.116 -void MapWin::MapSelector::set_active_text(Glib::ustring text)
4.117 -{
4.118 - cbt.set_active_text(text);
4.119 -}
4.120 -
4.121 -void MapWin::MapSelector::append_text(Glib::ustring text)
4.122 -{
4.123 - cbt.append_text(text);
4.124 - if(set_new_map)
4.125 - {
4.126 - set_active_text(text);
4.127 - set_new_map=false;
4.128 - }
4.129 -}
4.130 -
4.131 -sigc::signal<void, std::string> MapWin::MapSelector::signal_cbt_ch()
4.132 -{
4.133 - return signal_cbt;
4.134 -}
4.135 -
4.136 -sigc::signal<void, bool> MapWin::MapSelector::signal_newmapwin_needed()
4.137 -{
4.138 - return signal_newmapwin;
4.139 -}