COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/map_win.cc @ 1825:535d2eccfc03

Last change on this file since 1825:535d2eccfc03 was 1823:cb082cdf3667, checked in by Hegyi Péter, 14 years ago

NewMapWin? has become Dialog instead of Window. Therefore it is created dynamically, when there is need for it, instead of keeping one instance in memory. This solution is slower, but more correct than before.

File size: 2.1 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, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
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(gdc, ms, i, true);
27
28    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
29  }
30
31  vbox.pack_start(*(new Gtk::Label("Edge properties")));
32
33  vbox.pack_start(*table);
34
35  vbox.pack_start(*(new Gtk::HSeparator));
36
37  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
38
39  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
40
41  for(int i=0;i<NODE_PROPERTY_NUM;i++)
42  {
43    n_combo_array[i]=new MapSelector(gdc, ms, i, false);
44
45    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
46  }
47
48  add(vbox);
49
50  vbox.pack_start(*(new Gtk::Label("Node properties")));
51
52  vbox.pack_start(*table);
53
54  show_all_children();
55
56}
57
58void MapWin::update()
59{
60  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
61  {
62    e_combo_array[i]->update_list();
63  }
64
65  for(int i=0;i<NODE_PROPERTY_NUM;i++)
66  {
67    n_combo_array[i]->update_list();
68  }
69}
70
71
72void MapWin::updateNode(Node node)
73{
74  for(int i=0;i<NODE_PROPERTY_NUM;i++)
75    {
76      n_combo_array[i]->update(node);
77    }
78}
79
80void MapWin::updateEdge(Edge edge)
81{
82  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
83    {
84      e_combo_array[i]->update(edge);
85    }
86}
87
88void MapWin::registerNewEdgeMap(std::string newmapname)
89{
90  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
91  {
92    //filling in combo box with choices
93    e_combo_array[i]->append_text((Glib::ustring)newmapname);
94  }
95}
96
97void MapWin::registerNewNodeMap(std::string newmapname)
98{
99  for(int i=0;i<NODE_PROPERTY_NUM;i++)
100  {
101    //filling in combo box with choices
102    n_combo_array[i]->append_text((Glib::ustring)newmapname);
103  }
104}
Note: See TracBrowser for help on using the repository browser.