COIN-OR::LEMON - Graph Library

source: glemon-0.x/map_win.cc @ 90:e9f8f44f12a3

gui
Last change on this file since 90:e9f8f44f12a3 was 90:e9f8f44f12a3, checked in by Hegyi Péter, 18 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
RevLine 
[53]1#include "map_win.h"
[6]2#include <set>
3
[30]4bool MapWin::closeIfEscapeIsPressed(GdkEventKey* e)
[6]5{
[8]6  if(e->keyval==GDK_Escape)
7  {
8    hide();
9  }
10  return true;
11}
[6]12
[90]13MapWin::MapWin(const std::string& title, MapStorage & mapst, GraphDisplayerCanvas & grdispc):gdc(grdispc),ms(mapst)
[8]14{
15  set_title(title);
16  set_default_size(200, 50);
[6]17
[30]18  signal_key_press_event().connect(sigc::mem_fun(*this, &MapWin::closeIfEscapeIsPressed));
[6]19
[81]20  e_combo_array=new MapSelector * [EDGE_PROPERTY_NUM];
[8]21
[81]22  table=new Gtk::Table(EDGE_PROPERTY_NUM, 1, false);
[28]23
24  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
[6]25  {
[90]26    e_combo_array[i]=new MapSelector(gdc, ms, i, true);
[8]27
[81]28    (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
[6]29  }
30
[28]31  vbox.pack_start(*(new Gtk::Label("Edge properties")));
[8]32
[28]33  vbox.pack_start(*table);
34
35  vbox.pack_start(*(new Gtk::HSeparator));
36
[81]37  n_combo_array=new MapSelector * [NODE_PROPERTY_NUM];
[28]38
[81]39  table=new Gtk::Table(NODE_PROPERTY_NUM, 1, false);
[28]40
41  for(int i=0;i<NODE_PROPERTY_NUM;i++)
42  {
[90]43    n_combo_array[i]=new MapSelector(gdc, ms, i, false);
[28]44
[81]45    (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
[28]46  }
47
48  add(vbox);
49
50  vbox.pack_start(*(new Gtk::Label("Node properties")));
51
52  vbox.pack_start(*table);
[6]53
54  show_all_children();
55
56}
57
[53]58void MapWin::update()
59{
60  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
61  {
[81]62    e_combo_array[i]->update_list();
63  }
[53]64
65  for(int i=0;i<NODE_PROPERTY_NUM;i++)
66  {
[81]67    n_combo_array[i]->update_list();
[53]68  }
69}
70
[28]71
[62]72void MapWin::updateNode(Node node)
[28]73{
74  for(int i=0;i<NODE_PROPERTY_NUM;i++)
75    {
[81]76      n_combo_array[i]->update(node);
[28]77    }
78}
79
[62]80void MapWin::updateEdge(Edge edge)
[28]81{
82  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
83    {
[81]84      e_combo_array[i]->update(edge);
[28]85    }
86}
[38]87
[40]88void MapWin::registerNewEdgeMap(std::string newmapname)
[38]89{
[40]90  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
91  {
92    //filling in combo box with choices
[81]93    e_combo_array[i]->append_text((Glib::ustring)newmapname);
[40]94  }
[38]95}
96
[40]97void MapWin::registerNewNodeMap(std::string newmapname)
[38]98{
[41]99  for(int i=0;i<NODE_PROPERTY_NUM;i++)
[40]100  {
101    //filling in combo box with choices
[82]102    n_combo_array[i]->append_text((Glib::ustring)newmapname);
[40]103  }
[38]104}
Note: See TracBrowser for help on using the repository browser.