COIN-OR::LEMON - Graph Library

source: lemon-0.x/gui/mw-mapselector.cc @ 1857:2e3a4481901e

Last change on this file since 1857:2e3a4481901e was 1838:b61682f0ee96, checked in by Hegyi Péter, 15 years ago

MapWin? is created and disposed from now instead of being show and hide.

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