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