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