COIN-OR::LEMON - Graph Library

source: glemon-0.x/map_win.cc @ 96:e664d8aa3f72

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

Notebook style is provided. Without opportunity to close tabs. :-) But with all other necessary things (I think).

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