COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/algowin.cc @ 1884:9c061834b33b

Last change on this file since 1884:9c061834b33b was 1884:9c061834b33b, checked in by Hegyi Péter, 14 years ago

In algorithm window maps can be selected and reated through MapSelector? widget.

File size: 2.0 KB
Line 
1#include <algowin.h>
2#include <kruskalbox.h>
3
4sigc::signal<void, AlgoWin *> AlgoWin::signal_closing()
5{
6  return signal_closed;
7}
8
9sigc::signal<void, AlgoWin *, std::string> AlgoWin::signal_maplist_needed()
10{
11  return signal_maplist_need;
12}
13
14bool AlgoWin::closeIfEscapeIsPressed(GdkEventKey* e)
15{
16  if(e->keyval==GDK_Escape)
17  {
18    on_hide();
19  }
20  return true;
21}
22
23AlgoWin::AlgoWin(int algoid, std::vector<std::string> tabnames)
24{
25  signal_key_press_event().connect(sigc::mem_fun(*this, &AlgoWin::closeIfEscapeIsPressed));
26
27  Gtk::VBox * vbox=new Gtk::VBox();
28  vbox->set_spacing(5);
29
30  Gtk::Label * label=new Gtk::Label("Select graph:");
31
32  switch(algoid)
33    {
34    case 0:
35      ab=new AlgoBox(tabnames);
36      set_title("Algo Win Demo");
37      break;
38    case 1:
39      ab=new KruskalBox(tabnames);
40      set_title("Kruskal Algorithm");
41      break;
42    default:
43      break;
44    }
45  ab->signal_maplist_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_tab_change));
46  ab->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &AlgoWin::emit_new_map_signal));
47
48  runbutton=new Gtk::Button("Run");
49  runbutton->signal_released().connect(sigc::mem_fun(*ab,&AlgoBox::run));
50  runbutton->signal_activate().connect(sigc::mem_fun(*ab,&AlgoBox::run));
51
52  closebutton=new Gtk::Button("Close");
53  closebutton->signal_released().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
54  closebutton->signal_activate().connect(sigc::mem_fun(*this,&AlgoWin::on_hide));
55     
56  Gtk::HBox * hbox=new Gtk::HBox();
57
58  hbox->pack_start(*runbutton);
59  hbox->pack_start(*closebutton);
60
61  vbox->pack_start(*label);
62  vbox->pack_start(*ab);
63  vbox->pack_start(*hbox);
64     
65  add(*vbox);
66
67  show_all_children();
68};
69
70void AlgoWin::update_tablist(std::vector<std::string> tabnames)
71{
72  ab->update_tablist(tabnames);
73}
74
75void AlgoWin::update_maplist(MapStorage * mapstorage)
76{
77  ab->update_maplist(mapstorage);
78}
79
80void AlgoWin::on_hide()
81{
82  signal_closed.emit(this);
83  Gtk::Window::on_hide();
84}
85
86void AlgoWin::emit_tab_change(std::string newtab)
87{
88  signal_maplist_need.emit(this, newtab);
89}
Note: See TracBrowser for help on using the repository browser.