# HG changeset patch # User hegyi # Date 1160655500 0 # Node ID aef1fbfd9d602d3cc70b8d216b5aeaa4ae7eb2be # Parent 14a76109b5612c1b94f30df09b58ac1808c47922 Forget to commit the body, sorry\! diff -r 14a76109b561 -r aef1fbfd9d60 design_win.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/design_win.cc Thu Oct 12 12:18:20 2006 +0000 @@ -0,0 +1,66 @@ +#include + +bool DesignWin::closeIfEscapeIsPressed(GdkEventKey* e) +{ + if(e->keyval==GDK_Escape) + { + on_hide(); + } + return true; +} + +DesignWin::DesignWin(const std::string& title, double attraction_v, double propulsation_v, int iterations_v) +{ + set_title(title); + + signal_key_press_event().connect(sigc::mem_fun(*this, &DesignWin::closeIfEscapeIsPressed)); + + Gtk::VBox * vbox=new Gtk::VBox(); + vbox->set_spacing(5); + + Gtk::Label * attraction_label=new Gtk::Label("Edge elasticity: "); + Gtk::Label * propulsation_label=new Gtk::Label("Node propulsation: "); + Gtk::Label * iteration_label=new Gtk::Label("Iteration number: "); + + Gtk::Adjustment * attraction_adjustment=new Gtk::Adjustment(attraction_v, 0,1,0.01,0.1); + Gtk::Adjustment * propulsation_adjustment=new Gtk::Adjustment(propulsation_v,0,1000000,1000,10000); + Gtk::Adjustment * iteration_adjustment=new Gtk::Adjustment(iterations_v,1,20000,5,10); + + attraction = new Gtk::SpinButton(*attraction_adjustment,5,3); + propulsation = new Gtk::SpinButton(*propulsation_adjustment,5,0); + iteration = new Gtk::SpinButton(*iteration_adjustment,5,0); + + close_button=new Gtk::Button("Redesign"); + + attraction->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_attraction)); + propulsation->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_propulsation)); + iteration->signal_value_changed().connect(sigc::mem_fun(*this, &DesignWin::emit_iteration)); + close_button->signal_pressed().connect(sigc::mem_fun(*this, &DesignWin::emit_closerun)); + + table.attach(*attraction_label,0,1,0,1); + table.attach(*propulsation_label,0,1,1,2); + table.attach(*iteration_label,0,1,2,3); + table.attach(*attraction,1,2,0,1); + table.attach(*propulsation,1,2,1,2); + table.attach(*iteration,1,2,2,3); + table.attach(*close_button,0,2,3,4); + + add(table); + + show_all_children(); +}; + +void DesignWin::emit_attraction() +{ + signal_attraction_ch.emit(attraction->get_value()); +} + +void DesignWin::emit_propulsation() +{ + signal_propulsation_ch.emit(propulsation->get_value()); +} + +void DesignWin::emit_iteration() +{ + signal_iteration_ch.emit((int)iteration->get_value()); +} diff -r 14a76109b561 -r aef1fbfd9d60 design_win.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/design_win.h Thu Oct 12 12:18:20 2006 +0000 @@ -0,0 +1,43 @@ +// -*- C++ -*- // + +#ifndef DESWIN_H +#define DESWIN_H + +#include +#include +#include + +class DesignWin : public Gtk::Window +{ +private: + Gtk::SpinButton * attraction; + Gtk::SpinButton * propulsation; + Gtk::SpinButton * iteration; + Gtk::Table table; + Gtk::Button * close_button; + + sigc::signal signal_attraction_ch; + sigc::signal signal_propulsation_ch; + sigc::signal signal_iteration_ch; + sigc::signal close_run_pr; + + void emit_attraction(); + void emit_propulsation(); + void emit_iteration(); + void emit_closerun(){close_run_pr.emit();}; + +public: + ///Close window if escape key is pressed. + bool closeIfEscapeIsPressed(GdkEventKey* e); + + ///Constructor + + ///It builds the window. + DesignWin(const std::string&, double, double, int); + + sigc::signal signal_attraction(){return signal_attraction_ch;}; + sigc::signal signal_propulsation(){return signal_propulsation_ch;}; + sigc::signal signal_iteration(){return signal_iteration_ch;}; + sigc::signal close_run(){return close_run_pr;}; +}; +#endif //DESWIN_H