hegyi@1819
|
1 |
#include "map_win.h"
|
hegyi@1731
|
2 |
|
hegyi@1837
|
3 |
MapWin::MapSelector::MapSelector(std::vector<std::string> ml, int identifier, bool edge):id(identifier),itisedge(edge),default_state(true),set_new_map(false)
|
hegyi@1731
|
4 |
{
|
hegyi@1837
|
5 |
update_list(ml);
|
hegyi@1731
|
6 |
|
hegyi@1731
|
7 |
cbt.set_active(0);
|
hegyi@1731
|
8 |
|
hegyi@1731
|
9 |
//binding signal to the actual entry
|
hegyi@1731
|
10 |
cbt.signal_changed().connect
|
hegyi@1731
|
11 |
(
|
hegyi@1819
|
12 |
sigc::mem_fun((*this), &MapWin::MapSelector::comboChanged),
|
hegyi@1731
|
13 |
false
|
hegyi@1731
|
14 |
);
|
hegyi@1731
|
15 |
|
hegyi@1731
|
16 |
if(itisedge)
|
hegyi@1731
|
17 |
{
|
hegyi@1731
|
18 |
label=new Gtk::Label(edge_property_strings[id]);
|
hegyi@1731
|
19 |
}
|
hegyi@1731
|
20 |
else
|
hegyi@1731
|
21 |
{
|
hegyi@1731
|
22 |
label=new Gtk::Label(node_property_strings[id]);
|
hegyi@1731
|
23 |
}
|
hegyi@1731
|
24 |
|
hegyi@1731
|
25 |
label->set_width_chars(longest_property_string_length);
|
hegyi@1731
|
26 |
|
hegyi@1731
|
27 |
defbut=new Gtk::Button();
|
hegyi@1731
|
28 |
defbut->set_label("Reset");
|
hegyi@1731
|
29 |
|
hegyi@1731
|
30 |
defbut->signal_pressed().connect
|
hegyi@1731
|
31 |
(
|
hegyi@1819
|
32 |
sigc::mem_fun(*this, &MapWin::MapSelector::reset)
|
hegyi@1731
|
33 |
);
|
hegyi@1731
|
34 |
|
hegyi@1731
|
35 |
newbut=new Gtk::Button(Gtk::Stock::NEW);
|
hegyi@1731
|
36 |
|
hegyi@1733
|
37 |
newbut->signal_pressed().connect
|
hegyi@1733
|
38 |
(
|
hegyi@1819
|
39 |
sigc::mem_fun(*this, &MapWin::MapSelector::new_but_pressed)
|
hegyi@1733
|
40 |
);
|
hegyi@1733
|
41 |
|
hegyi@1731
|
42 |
add(*label);
|
hegyi@1731
|
43 |
|
hegyi@1731
|
44 |
add(cbt);
|
hegyi@1731
|
45 |
|
hegyi@1731
|
46 |
add(*defbut);
|
hegyi@1731
|
47 |
add(*newbut);
|
hegyi@1731
|
48 |
}
|
hegyi@1731
|
49 |
|
hegyi@1819
|
50 |
void MapWin::MapSelector::new_but_pressed()
|
hegyi@1737
|
51 |
{
|
hegyi@1737
|
52 |
set_new_map=true;
|
hegyi@1837
|
53 |
signal_newmapwin.emit(itisedge);
|
hegyi@1737
|
54 |
}
|
hegyi@1737
|
55 |
|
hegyi@1837
|
56 |
void MapWin::MapSelector::update_list( std::vector< std::string > ml )
|
hegyi@1731
|
57 |
{
|
hegyi@1731
|
58 |
cbt.clear();
|
hegyi@1837
|
59 |
std::vector< std::string >::iterator emsi=ml.begin();
|
hegyi@1837
|
60 |
for(;emsi!=ml.end();emsi++)
|
hegyi@1731
|
61 |
{
|
hegyi@1837
|
62 |
cbt.append_text(*emsi);
|
hegyi@1731
|
63 |
}
|
hegyi@1731
|
64 |
cbt.prepend_text("Default values");
|
hegyi@1731
|
65 |
}
|
hegyi@1731
|
66 |
|
hegyi@1819
|
67 |
void MapWin::MapSelector::comboChanged()
|
hegyi@1731
|
68 |
{
|
hegyi@1731
|
69 |
if(cbt.get_active_row_number()!=0)
|
hegyi@1731
|
70 |
{
|
hegyi@1731
|
71 |
default_state=false;
|
hegyi@1731
|
72 |
Glib::ustring mapname = cbt.get_active_text();
|
hegyi@1731
|
73 |
if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
|
hegyi@1731
|
74 |
{
|
hegyi@1837
|
75 |
signal_cbt.emit(mapname);
|
hegyi@1731
|
76 |
}
|
hegyi@1731
|
77 |
}
|
hegyi@1731
|
78 |
else if((!default_state)&&(cbt.get_active_row_number()==0))
|
hegyi@1731
|
79 |
{
|
hegyi@1837
|
80 |
signal_cbt.emit("");
|
hegyi@1731
|
81 |
reset();
|
hegyi@1731
|
82 |
}
|
hegyi@1731
|
83 |
}
|
hegyi@1731
|
84 |
|
hegyi@1819
|
85 |
void MapWin::MapSelector::reset()
|
hegyi@1731
|
86 |
{
|
hegyi@1731
|
87 |
default_state=true;
|
hegyi@1731
|
88 |
cbt.set_active(0);
|
hegyi@1731
|
89 |
|
hegyi@1837
|
90 |
signal_cbt.emit("");
|
hegyi@1731
|
91 |
}
|
hegyi@1731
|
92 |
|
hegyi@1731
|
93 |
|
hegyi@1819
|
94 |
Glib::ustring MapWin::MapSelector::get_active_text()
|
hegyi@1731
|
95 |
{
|
hegyi@1731
|
96 |
return cbt.get_active_text();
|
hegyi@1731
|
97 |
}
|
hegyi@1731
|
98 |
|
hegyi@1819
|
99 |
void MapWin::MapSelector::set_active_text(Glib::ustring text)
|
hegyi@1731
|
100 |
{
|
hegyi@1731
|
101 |
cbt.set_active_text(text);
|
hegyi@1731
|
102 |
}
|
hegyi@1731
|
103 |
|
hegyi@1819
|
104 |
void MapWin::MapSelector::append_text(Glib::ustring text)
|
hegyi@1731
|
105 |
{
|
hegyi@1731
|
106 |
cbt.append_text(text);
|
hegyi@1737
|
107 |
if(set_new_map)
|
hegyi@1737
|
108 |
{
|
hegyi@1737
|
109 |
set_active_text(text);
|
hegyi@1737
|
110 |
set_new_map=false;
|
hegyi@1737
|
111 |
}
|
hegyi@1731
|
112 |
}
|
hegyi@1837
|
113 |
|
hegyi@1837
|
114 |
sigc::signal<void, std::string> MapWin::MapSelector::signal_cbt_ch()
|
hegyi@1837
|
115 |
{
|
hegyi@1837
|
116 |
return signal_cbt;
|
hegyi@1837
|
117 |
}
|
hegyi@1837
|
118 |
|
hegyi@1837
|
119 |
sigc::signal<void, bool> MapWin::MapSelector::signal_newmapwin_needed()
|
hegyi@1837
|
120 |
{
|
hegyi@1837
|
121 |
return signal_newmapwin;
|
hegyi@1837
|
122 |
}
|