COIN-OR::LEMON - Graph Library

source: glemon-0.x/map_win.cc @ 146:afd1d8bfcccd

Last change on this file since 146:afd1d8bfcccd was 146:afd1d8bfcccd, checked in by Hegyi Péter, 14 years ago

Size of MapWin? cannot be changed.

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