Merge branches/akos to trunk.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #include <mapselector.h>
21 MapSelector::MapSelector(std::vector<std::string> n_ml,
22 std::vector<std::string> s_ml, std::string act,
23 std::string labeltext, bool edge, bool d, MapType type) :
29 newbut(Gtk::Stock::NEW)
31 update_list(n_ml, s_ml);
40 cbt.set_active_text((Glib::ustring)act);
44 //binding signal to the actual entry
45 cbt.signal_changed().connect
47 sigc::mem_fun((*this), &MapSelector::comboChanged),
51 label.set_width_chars(longest_property_string_length);
55 defbut.set_label("Reset");
56 defbut.signal_pressed().connect
58 sigc::mem_fun(*this, &MapSelector::reset)
63 newbut.signal_pressed().connect
65 sigc::mem_fun(*this, &MapSelector::new_but_pressed)
80 void MapSelector::new_but_pressed()
83 signal_newmapwin.emit(itisedge);
86 void MapSelector::update_list(std::vector<std::string> n_ml,
87 std::vector<std::string> s_ml)
89 int prev_act=cbt.get_active_row_number();
95 std::vector< std::string >::iterator emsi=n_ml.begin();
96 for(;emsi!=n_ml.end();emsi++)
98 cbt.append_text(*emsi);
99 cbt_content.push_back(*emsi);
104 std::vector< std::string >::iterator emsi=s_ml.begin();
105 for(;emsi!=s_ml.end();emsi++)
107 cbt.append_text(*emsi);
108 cbt_content.push_back(*emsi);
113 cbt.prepend_text("Default values");
114 cbt_content.push_back("Default values");
118 cbt.set_active(prev_act);
122 void MapSelector::comboChanged()
124 if(cbt.get_active_row_number()!=0 || !def)
127 Glib::ustring mapname = cbt.get_active_text();
128 if(!(mapname.empty())) //We seem to get 2 signals, one when the text is empty.
130 signal_cbt.emit(mapname);
133 else if((!default_state)&&(cbt.get_active_row_number()==0))
139 void MapSelector::reset()
149 Glib::ustring MapSelector::get_active_text()
151 return cbt.get_active_text();
154 void MapSelector::set_active_text(Glib::ustring text)
158 cbt.set_active_text(text);
162 cbt.set_active_text("Default values");
166 void MapSelector::append_text(Glib::ustring text, MapValue::Type type)
170 cbt.append_text(text);
171 cbt_content.push_back(text);
175 set_active_text(text);
181 sigc::signal<void, std::string> MapSelector::signal_cbt_ch()
186 sigc::signal<void, bool> MapSelector::signal_newmapwin_needed()
188 return signal_newmapwin;