COIN-OR::LEMON - Graph Library

source: glemon-0.x/map_win.cc @ 82:ee009c0f4bcf

gui
Last change on this file since 82:ee009c0f4bcf was 82:ee009c0f4bcf, checked in by Hegyi Péter, 15 years ago

MapSelector? widget is able to pop up NewMap? window. At the moment I hope MapSelector? widget is done.

File size: 2.4 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, NewMapWin & newmapwin):gdc(grdispc),ms(mapst), nmw(newmapwin)
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, nmw, 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, nmw, 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  //setting text property for the new map
96  e_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
97}
98
99void MapWin::registerNewNodeMap(std::string newmapname)
100{
101  for(int i=0;i<NODE_PROPERTY_NUM;i++)
102  {
103    //filling in combo box with choices
104    n_combo_array[i]->append_text((Glib::ustring)newmapname);
105  }
106  //setting text property for the new map
107  n_combo_array[N_TEXT]->set_active_text((Glib::ustring)newmapname);
108}
Note: See TracBrowser for help on using the repository browser.