Newly created map is realized by the property givening by common sense.
1 #include "mapselector.h"
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)
9 //binding signal to the actual entry
10 cbt.signal_changed().connect
12 sigc::mem_fun((*this), &MapSelector::comboChanged),
18 label=new Gtk::Label(edge_property_strings[id]);
22 label=new Gtk::Label(node_property_strings[id]);
25 label->set_width_chars(longest_property_string_length);
27 defbut=new Gtk::Button();
28 defbut->set_label("Reset");
30 defbut->signal_pressed().connect
32 sigc::mem_fun(*this, &MapSelector::reset)
35 newbut=new Gtk::Button(Gtk::Stock::NEW);
37 newbut->signal_pressed().connect
39 sigc::mem_fun(*this, &MapSelector::new_but_pressed)
50 void MapSelector::new_but_pressed()
53 nmw.showByPreChoose(itisedge);
56 void MapSelector::update_list()
61 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
62 for(;emsi!=ms.endOfEdgeMaps();emsi++)
64 cbt.append_text(emsi->first);
69 std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
70 for(;emsi!=ms.endOfNodeMaps();emsi++)
72 cbt.append_text(emsi->first);
75 cbt.prepend_text("Default values");
78 void MapSelector::comboChanged()
80 if(cbt.get_active_row_number()!=0)
83 Glib::ustring mapname = cbt.get_active_text();
84 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
88 if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) )
90 Edge edge=edge_to_update;
94 gdc.changeEdgeWidth(mapname, edge);
97 gdc.changeEdgeColor(mapname, edge);
100 gdc.changeEdgeText(mapname, edge);
103 std::cerr<<"Error\n";
109 if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) )
111 Node node=node_to_update;
115 gdc.changeNodeRadius(mapname, node);
118 gdc.changeNodeColor(mapname, node);
121 gdc.changeNodeText(mapname, node);
124 std::cerr<<"Error\n";
130 else if((!default_state)&&(cbt.get_active_row_number()==0))
136 void MapSelector::reset()
143 Edge edge=edge_to_update;
147 gdc.resetEdgeWidth(edge);
150 gdc.resetEdgeColor(edge);
153 gdc.resetEdgeText(edge);
156 std::cerr<<"Error\n";
161 Node node=node_to_update;
165 gdc.resetNodeRadius(node);
168 gdc.resetNodeColor(node);
171 gdc.resetNodeText(node);
174 std::cerr<<"Error\n";
179 void MapSelector::update(Node node)
190 node_to_update=INVALID;
193 void MapSelector::update(Edge edge)
204 edge_to_update=INVALID;
207 Glib::ustring MapSelector::get_active_text()
209 return cbt.get_active_text();
212 void MapSelector::set_active_text(Glib::ustring text)
214 cbt.set_active_text(text);
217 void MapSelector::append_text(Glib::ustring text)
219 cbt.append_text(text);
222 set_active_text(text);