changeset 1819 | fd82adfbe905 |
parent 1737 | dc821d2668c1 |
child 1823 | cb082cdf3667 |
2:8211b7d7efd8 | 0:f67d5415bb08 |
---|---|
1 #include "mapselector.h" |
1 #include "map_win.h" |
2 |
2 |
3 MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, NewMapWin & newmapw, int identifier, bool edge):gdc(grdispc),ms(mapst),nmw(newmapw),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID) |
3 MapWin::MapSelector::MapSelector(GraphDisplayerCanvas & grdispc, MapStorage & mapst, NewMapWin & newmapw, int identifier, bool edge):gdc(grdispc),ms(mapst),nmw(newmapw),id(identifier),itisedge(edge),default_state(true),set_new_map(false),node_to_update(INVALID),edge_to_update(INVALID) |
4 { |
4 { |
5 update_list(); |
5 update_list(); |
6 |
6 |
7 cbt.set_active(0); |
7 cbt.set_active(0); |
8 |
8 |
9 //binding signal to the actual entry |
9 //binding signal to the actual entry |
10 cbt.signal_changed().connect |
10 cbt.signal_changed().connect |
11 ( |
11 ( |
12 sigc::mem_fun((*this), &MapSelector::comboChanged), |
12 sigc::mem_fun((*this), &MapWin::MapSelector::comboChanged), |
13 false |
13 false |
14 ); |
14 ); |
15 |
15 |
16 if(itisedge) |
16 if(itisedge) |
17 { |
17 { |
27 defbut=new Gtk::Button(); |
27 defbut=new Gtk::Button(); |
28 defbut->set_label("Reset"); |
28 defbut->set_label("Reset"); |
29 |
29 |
30 defbut->signal_pressed().connect |
30 defbut->signal_pressed().connect |
31 ( |
31 ( |
32 sigc::mem_fun(*this, &MapSelector::reset) |
32 sigc::mem_fun(*this, &MapWin::MapSelector::reset) |
33 ); |
33 ); |
34 |
34 |
35 newbut=new Gtk::Button(Gtk::Stock::NEW); |
35 newbut=new Gtk::Button(Gtk::Stock::NEW); |
36 |
36 |
37 newbut->signal_pressed().connect |
37 newbut->signal_pressed().connect |
38 ( |
38 ( |
39 sigc::mem_fun(*this, &MapSelector::new_but_pressed) |
39 sigc::mem_fun(*this, &MapWin::MapSelector::new_but_pressed) |
40 ); |
40 ); |
41 |
41 |
42 add(*label); |
42 add(*label); |
43 |
43 |
44 add(cbt); |
44 add(cbt); |
45 |
45 |
46 add(*defbut); |
46 add(*defbut); |
47 add(*newbut); |
47 add(*newbut); |
48 } |
48 } |
49 |
49 |
50 void MapSelector::new_but_pressed() |
50 void MapWin::MapSelector::new_but_pressed() |
51 { |
51 { |
52 set_new_map=true; |
52 set_new_map=true; |
53 nmw.showByPreChoose(itisedge); |
53 nmw.showByPreChoose(itisedge); |
54 } |
54 } |
55 |
55 |
56 void MapSelector::update_list() |
56 void MapWin::MapSelector::update_list() |
57 { |
57 { |
58 cbt.clear(); |
58 cbt.clear(); |
59 if(itisedge) |
59 if(itisedge) |
60 { |
60 { |
61 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps(); |
61 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps(); |
73 } |
73 } |
74 } |
74 } |
75 cbt.prepend_text("Default values"); |
75 cbt.prepend_text("Default values"); |
76 } |
76 } |
77 |
77 |
78 void MapSelector::comboChanged() |
78 void MapWin::MapSelector::comboChanged() |
79 { |
79 { |
80 if(cbt.get_active_row_number()!=0) |
80 if(cbt.get_active_row_number()!=0) |
81 { |
81 { |
82 default_state=false; |
82 default_state=false; |
83 Glib::ustring mapname = cbt.get_active_text(); |
83 Glib::ustring mapname = cbt.get_active_text(); |
131 { |
131 { |
132 reset(); |
132 reset(); |
133 } |
133 } |
134 } |
134 } |
135 |
135 |
136 void MapSelector::reset() |
136 void MapWin::MapSelector::reset() |
137 { |
137 { |
138 default_state=true; |
138 default_state=true; |
139 cbt.set_active(0); |
139 cbt.set_active(0); |
140 |
140 |
141 if(itisedge) |
141 if(itisedge) |
174 std::cerr<<"Error\n"; |
174 std::cerr<<"Error\n"; |
175 } |
175 } |
176 } |
176 } |
177 } |
177 } |
178 |
178 |
179 void MapSelector::update(Node node) |
179 void MapWin::MapSelector::update(Node node) |
180 { |
180 { |
181 node_to_update=node; |
181 node_to_update=node; |
182 if(default_state) |
182 if(default_state) |
183 { |
183 { |
184 reset(); |
184 reset(); |
188 comboChanged(); |
188 comboChanged(); |
189 } |
189 } |
190 node_to_update=INVALID; |
190 node_to_update=INVALID; |
191 } |
191 } |
192 |
192 |
193 void MapSelector::update(Edge edge) |
193 void MapWin::MapSelector::update(Edge edge) |
194 { |
194 { |
195 edge_to_update=edge; |
195 edge_to_update=edge; |
196 if(default_state) |
196 if(default_state) |
197 { |
197 { |
198 reset(); |
198 reset(); |
202 comboChanged(); |
202 comboChanged(); |
203 } |
203 } |
204 edge_to_update=INVALID; |
204 edge_to_update=INVALID; |
205 } |
205 } |
206 |
206 |
207 Glib::ustring MapSelector::get_active_text() |
207 Glib::ustring MapWin::MapSelector::get_active_text() |
208 { |
208 { |
209 return cbt.get_active_text(); |
209 return cbt.get_active_text(); |
210 } |
210 } |
211 |
211 |
212 void MapSelector::set_active_text(Glib::ustring text) |
212 void MapWin::MapSelector::set_active_text(Glib::ustring text) |
213 { |
213 { |
214 cbt.set_active_text(text); |
214 cbt.set_active_text(text); |
215 } |
215 } |
216 |
216 |
217 void MapSelector::append_text(Glib::ustring text) |
217 void MapWin::MapSelector::append_text(Glib::ustring text) |
218 { |
218 { |
219 cbt.append_text(text); |
219 cbt.append_text(text); |
220 if(set_new_map) |
220 if(set_new_map) |
221 { |
221 { |
222 set_active_text(text); |
222 set_active_text(text); |