COIN-OR::LEMON - Graph Library

source: glemon-0.x/design_win.cc @ 170:bff6d1c63cff

Last change on this file since 170:bff6d1c63cff was 161:aef1fbfd9d60, checked in by Hegyi Péter, 18 years ago

Forget to commit the body, sorry\!

File size: 2.1 KB
Line 
1#include <design_win.h>
2
3bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e)
4{
5  if(e->keyval==GDK_Escape)
6  {
7    on_hide();
8  }
9  return true;
10}
11
12DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v)
13{
14  set_title(title);
15
16  signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed));
17
18  Gtk::VBox * vbox=new Gtk::VBox();
19  vbox->set_spacing(5);
20
21  Gtk::Label * attraction_label=new Gtk::Label("Edge elasticity: ");
22  Gtk::Label * propulsation_label=new Gtk::Label("Node propulsation: ");
23  Gtk::Label * iteration_label=new Gtk::Label("Iteration number: ");
24
25  Gtk::Adjustment * attraction_adjustment=new Gtk::Adjustment(attraction_v, 0,1,0.01,0.1);
26  Gtk::Adjustment * propulsation_adjustment=new Gtk::Adjustment(propulsation_v,0,1000000,1000,10000);
27  Gtk::Adjustment * iteration_adjustment=new Gtk::Adjustment(iterations_v,1,20000,5,10);
28
29  attraction = new Gtk::SpinButton(*attraction_adjustment,5,3);
30  propulsation = new Gtk::SpinButton(*propulsation_adjustment,5,0);
31  iteration = new Gtk::SpinButton(*iteration_adjustment,5,0);
32
33  close_button=new Gtk::Button("Redesign");
34
35  attraction->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_attraction));
36  propulsation->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_propulsation));
37  iteration->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_iteration));
38  close_button->signal_pressed().connect(sigc::mem_fun(*this, &DesignWin::emit_closerun));
39
40  table.attach(*attraction_label,0,1,0,1);
41  table.attach(*propulsation_label,0,1,1,2);
42  table.attach(*iteration_label,0,1,2,3);
43  table.attach(*attraction,1,2,0,1);
44  table.attach(*propulsation,1,2,1,2);
45  table.attach(*iteration,1,2,2,3);
46  table.attach(*close_button,0,2,3,4);
47
48  add(table);
49
50  show_all_children();
51};
52
53void DesignWin::emit_attraction()
54{
55  signal_attraction_ch.emit(attraction->get_value());
56}
57
58void DesignWin::emit_propulsation()
59{
60  signal_propulsation_ch.emit(propulsation->get_value());
61}
62
63void DesignWin::emit_iteration()
64{
65  signal_iteration_ch.emit((int)iteration->get_value());
66}
Note: See TracBrowser for help on using the repository browser.