COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/mw-mapselector.cc @ 1837:8dd6160ff699

Last change on this file since 1837:8dd6160ff699 was 1837:8dd6160ff699, checked in by Hegyi Péter, 15 years ago

Structure of GUI is now more clear-cut than before.

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