MapSelector widget is able to pop up NewMap window. At the moment I hope MapSelector widget is done.
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),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(nmw, &NewMapWin::show)
50 void MapSelector::update_list()
55 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
56 for(;emsi!=ms.endOfEdgeMaps();emsi++)
58 cbt.append_text(emsi->first);
63 std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
64 for(;emsi!=ms.endOfNodeMaps();emsi++)
66 cbt.append_text(emsi->first);
69 cbt.prepend_text("Default values");
72 void MapSelector::comboChanged()
74 if(cbt.get_active_row_number()!=0)
77 Glib::ustring mapname = cbt.get_active_text();
78 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
82 if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) )
84 Edge edge=edge_to_update;
88 gdc.changeEdgeWidth(mapname, edge);
91 gdc.changeEdgeColor(mapname, edge);
94 gdc.changeEdgeText(mapname, edge);
103 if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) )
105 Node node=node_to_update;
109 gdc.changeNodeRadius(mapname, node);
112 gdc.changeNodeColor(mapname, node);
115 gdc.changeNodeText(mapname, node);
118 std::cerr<<"Error\n";
124 else if((!default_state)&&(cbt.get_active_row_number()==0))
130 void MapSelector::reset()
137 Edge edge=edge_to_update;
141 gdc.resetEdgeWidth(edge);
144 gdc.resetEdgeColor(edge);
147 gdc.resetEdgeText(edge);
150 std::cerr<<"Error\n";
155 Node node=node_to_update;
159 gdc.resetNodeRadius(node);
162 gdc.resetNodeColor(node);
165 gdc.resetNodeText(node);
168 std::cerr<<"Error\n";
173 void MapSelector::update(Node node)
184 node_to_update=INVALID;
187 void MapSelector::update(Edge edge)
198 edge_to_update=INVALID;
201 Glib::ustring MapSelector::get_active_text()
203 return cbt.get_active_text();
206 void MapSelector::set_active_text(Glib::ustring text)
208 cbt.set_active_text(text);
211 void MapSelector::append_text(Glib::ustring text)
213 cbt.append_text(text);