[1606] | 1 | #include "map_win.h" |
---|
[1442] | 2 | #include <set> |
---|
| 3 | |
---|
[1524] | 4 | bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e) |
---|
[1442] | 5 | { |
---|
[1446] | 6 | if(e->keyval==GDK_Escape) |
---|
| 7 | { |
---|
| 8 | hide(); |
---|
| 9 | } |
---|
| 10 | return true; |
---|
| 11 | } |
---|
[1442] | 12 | |
---|
[1837] | 13 | MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, MainWin & mw):mainwin(mw) |
---|
[1446] | 14 | { |
---|
| 15 | set_title(title); |
---|
| 16 | set_default_size(200, 50); |
---|
[1442] | 17 | |
---|
[1524] | 18 | signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed)); |
---|
[1442] | 19 | |
---|
[1731] | 20 | e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM]; |
---|
[1446] | 21 | |
---|
[1731] | 22 | table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false); |
---|
[1512] | 23 | |
---|
| 24 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
[1442] | 25 | { |
---|
[1837] | 26 | e_combo_array[i]=new MapSelector(eml, i, true); |
---|
[1446] | 27 | |
---|
[1731] | 28 | (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); |
---|
[1837] | 29 | |
---|
| 30 | e_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::edgeMapChanged), i)); |
---|
| 31 | e_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i)); |
---|
[1442] | 32 | } |
---|
| 33 | |
---|
[1512] | 34 | vbox.pack_start(*(new Gtk::Label("Edge properties"))); |
---|
[1446] | 35 | |
---|
[1512] | 36 | vbox.pack_start(*table); |
---|
| 37 | |
---|
| 38 | vbox.pack_start(*(new Gtk::HSeparator)); |
---|
| 39 | |
---|
[1731] | 40 | n_combo_array=new MapSelector * [NODE_PROPERTY_NUM]; |
---|
[1512] | 41 | |
---|
[1731] | 42 | table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false); |
---|
[1512] | 43 | |
---|
| 44 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
| 45 | { |
---|
[1837] | 46 | n_combo_array[i]=new MapSelector(nml, i, false); |
---|
[1512] | 47 | |
---|
[1731] | 48 | (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3); |
---|
[1837] | 49 | |
---|
| 50 | n_combo_array[i]->signal_cbt_ch().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::nodeMapChanged), i)); |
---|
| 51 | n_combo_array[i]->signal_newmapwin_needed().connect(sigc::bind(sigc::mem_fun(*this, &MapWin::newMapWinNeeded), i)); |
---|
[1512] | 52 | } |
---|
| 53 | |
---|
| 54 | add(vbox); |
---|
| 55 | |
---|
| 56 | vbox.pack_start(*(new Gtk::Label("Node properties"))); |
---|
| 57 | |
---|
| 58 | vbox.pack_start(*table); |
---|
[1442] | 59 | |
---|
| 60 | show_all_children(); |
---|
| 61 | |
---|
| 62 | } |
---|
| 63 | |
---|
[1837] | 64 | void MapWin::nodeMapChanged(std::string mapname, int prop) |
---|
| 65 | { |
---|
| 66 | mainwin.propertyChange(false, prop, mapname); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | void MapWin::edgeMapChanged(std::string mapname, int prop) |
---|
| 70 | { |
---|
| 71 | mainwin.propertyChange(true, prop, mapname); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | void MapWin::newMapWinNeeded(bool itisedge, int prop) |
---|
| 75 | { |
---|
| 76 | mainwin.popupNewMapWin(itisedge, prop); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml) |
---|
[1606] | 80 | { |
---|
| 81 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
| 82 | { |
---|
[1837] | 83 | e_combo_array[i]->update_list(eml); |
---|
[1731] | 84 | } |
---|
[1606] | 85 | |
---|
| 86 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
| 87 | { |
---|
[1837] | 88 | n_combo_array[i]->update_list(nml); |
---|
[1606] | 89 | } |
---|
| 90 | } |
---|
| 91 | |
---|
[1589] | 92 | void MapWin::registerNewEdgeMap(std::string newmapname) |
---|
[1586] | 93 | { |
---|
[1589] | 94 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
| 95 | { |
---|
| 96 | //filling in combo box with choices |
---|
[1731] | 97 | e_combo_array[i]->append_text((Glib::ustring)newmapname); |
---|
[1589] | 98 | } |
---|
[1586] | 99 | } |
---|
| 100 | |
---|
[1589] | 101 | void MapWin::registerNewNodeMap(std::string newmapname) |
---|
[1586] | 102 | { |
---|
[1592] | 103 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
[1589] | 104 | { |
---|
| 105 | //filling in combo box with choices |
---|
[1733] | 106 | n_combo_array[i]->append_text((Glib::ustring)newmapname); |
---|
[1589] | 107 | } |
---|
[1586] | 108 | } |
---|