COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/map_win.cc @ 1837:8dd6160ff699

Last change on this file since 1837:8dd6160ff699 was 1837:8dd6160ff699, checked in by Hegyi Péter, 18 years ago

Structure of GUI is now more clear-cut than before.

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