Shape keeping movement is implemented, at last. Many thanks to Alpar.
4 bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
6 if(e->keyval==GDK_Escape)
13 MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
16 set_default_size(200, 50);
18 signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
20 e_combo_array=new Gtk::Combo [EDGE_PROPERTY_NUM];
22 table=new Gtk::Table(EDGE_PROPERTY_NUM, 2, false);
24 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
26 //filling in combo box with choices
27 std::list<Glib::ustring> listStrings;
29 listStrings.push_back("Default");
31 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
32 for(;emsi!=ms.endOfEdgeMaps();emsi++)
34 listStrings.push_back(emsi->first);
37 e_combo_array[i].set_popdown_strings(listStrings);
39 //Restrict it to these choices only:
40 e_combo_array[i].set_value_in_list();
42 //binding signal to the actual entry
43 e_combo_array[i].get_entry()->signal_changed().connect
47 sigc::mem_fun(*this, &MapWin::eComboChanged),
52 //placing actual entry in the right place
55 label->set_text(edge_property_strings[i]);
57 (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
58 (*table).attach(e_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
63 vbox.pack_start(*(new Gtk::Label("Edge properties")));
65 vbox.pack_start(*table);
67 vbox.pack_start(*(new Gtk::HSeparator));
69 n_combo_array=new Gtk::Combo [NODE_PROPERTY_NUM];
71 table=new Gtk::Table(NODE_PROPERTY_NUM, 2, false);
73 for(int i=0;i<NODE_PROPERTY_NUM;i++)
75 //filling in combo box with choices
76 std::list<Glib::ustring> listStrings;
78 listStrings.push_back("Default");
80 std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
82 for(;emsi!=ms.endOfNodeMaps();emsi++)
84 if ((emsi->first != "coordinates_x") && (emsi->first != "coordinates_y"))
86 listStrings.push_back(emsi->first);
90 n_combo_array[i].set_popdown_strings(listStrings);
92 //Restrict it to these choices only:
93 n_combo_array[i].set_value_in_list();
95 //binding signal to thew actual entry
96 n_combo_array[i].get_entry()->signal_changed().connect
100 sigc::mem_fun(*this, &MapWin::nComboChanged),
105 //placing actual entry in the right place
107 label=new Gtk::Label;
108 label->set_text(node_property_strings[i]);
110 (*table).attach(*label,0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
111 (*table).attach(n_combo_array[i],1,2,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
118 vbox.pack_start(*(new Gtk::Label("Node properties")));
120 vbox.pack_start(*table);
126 void MapWin::update()
128 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
130 //filling in combo box with choices
131 std::list<Glib::ustring> listStrings;
133 listStrings.push_back("Default");
135 std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=ms.beginOfEdgeMaps();
136 for(;emsi!=ms.endOfEdgeMaps();emsi++)
138 listStrings.push_back(emsi->first);
141 e_combo_array[i].set_popdown_strings(listStrings);
143 for(int i=0;i<NODE_PROPERTY_NUM;i++)
145 //filling in combo box with choices
146 std::list<Glib::ustring> listStrings;
148 listStrings.push_back("Default");
150 std::map< std::string,Graph::NodeMap<double> * >::iterator emsi=ms.beginOfNodeMaps();
152 for(;emsi!=ms.endOfNodeMaps();emsi++)
154 if ((emsi->first != "coordinates_x") && (emsi->first != "coordinates_y"))
156 listStrings.push_back(emsi->first);
160 n_combo_array[i].set_popdown_strings(listStrings);
164 void MapWin::eComboChanged(int prop)
167 Gtk::Entry* entry = e_combo_array[prop].get_entry();
171 Glib::ustring mapname = entry->get_text();
172 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
174 if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
179 gdc.changeEdgeWidth(mapname);
182 gdc.changeEdgeColor(mapname);
185 gdc.changeEdgeText(mapname);
188 std::cerr<<"Error\n";
195 void MapWin::nComboChanged(int prop)
198 Gtk::Entry* entry = n_combo_array[prop].get_entry();
202 Glib::ustring mapname = entry->get_text();
203 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
205 if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
210 gdc.changeNodeRadius(mapname);
213 gdc.changeNodeColor(mapname);
216 gdc.changeNodeText(mapname);
219 std::cerr<<"Error\n";
226 void MapWin::updateNode(Node node)
228 for(int i=0;i<NODE_PROPERTY_NUM;i++)
230 Gtk::Entry* entry = n_combo_array[i].get_entry();
234 Glib::ustring mapname = entry->get_text();
235 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
237 if( ( (ms.nodemap_storage).find(mapname) != (ms.nodemap_storage).end() ) || (mapname=="Default") )
242 gdc.changeNodeRadius(mapname, node);
245 gdc.changeNodeColor(mapname, node);
248 gdc.changeNodeText(mapname, node);
251 std::cerr<<"Error\n";
259 void MapWin::updateEdge(Edge edge)
261 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
264 Gtk::Entry* entry = e_combo_array[i].get_entry();
268 Glib::ustring mapname = entry->get_text();
269 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
272 if( ( (ms.edgemap_storage).find(mapname) != (ms.edgemap_storage).end() ) || (mapname=="Default") )
277 gdc.changeEdgeWidth(mapname, edge);
280 gdc.changeEdgeColor(mapname, edge);
283 gdc.changeEdgeText(mapname, edge);
286 std::cerr<<"Error\n";
294 void MapWin::registerNewEdgeMap(std::string newmapname)
296 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
298 //filling in combo box with choices
299 std::list<Glib::ustring> listStrings=e_combo_array[i].get_popdown_strings();
300 listStrings.push_back(newmapname);
301 e_combo_array[i].set_popdown_strings(listStrings);
303 //setting text property for the new map
304 Gtk::Entry* entry = e_combo_array[E_TEXT].get_entry();
305 entry->set_text((Glib::ustring)newmapname);
308 void MapWin::registerNewNodeMap(std::string newmapname)
310 for(int i=0;i<NODE_PROPERTY_NUM;i++)
312 //filling in combo box with choices
313 std::list<Glib::ustring> listStrings=n_combo_array[i].get_popdown_strings();
314 listStrings.push_back(newmapname);
315 n_combo_array[i].set_popdown_strings(listStrings);
317 //setting text property for the new map
318 Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry();
319 entry->set_text((Glib::ustring)newmapname);