COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/map_win.cc @ 1733:5e0d97823ba2

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