]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/src/cisternptywnd.cpp
seagregan propiedades al tanque
[z.facultad/75.42/plaqui.git] / Constructor / src / cisternptywnd.cpp
1 #include "cisternptywnd.h"
2 #include "cistern.h"
3
4 CisternPtyWnd::CisternPtyWnd(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade):PropertyWnd(cobject, refGlade)
5 {
6         refGlade->get_widget("spin_capacidad", spin_capacidad);
7         refGlade->get_widget("spin_inicial", spin_inicial);
8         refGlade->get_widget("txt_cistern_name", txt_cistern_name);
9         refGlade->get_widget("btn_select_color", btn_select_color);             
10         refGlade->get_widget("color_preview",color_preview);
11         refGlade->get_widget("spin_flot_inf", spin_flot_inf);
12         refGlade->get_widget("spin_flot_sup", spin_flot_sup);
13         
14         Glib::RefPtr<Gnome::Glade::Xml> ref = Gnome::Glade::Xml::create(PACKAGE_DATA_DIR"/plaqui-constructor/dialogs/constructor.glade", "color_select_dlg");
15         ref->get_widget("color_select_dlg",color_select_dlg);
16         ref->get_widget("dlg_select_color_cancel",dlg_select_color_cancel);
17         ref->get_widget("dlg_select_color_ok",dlg_select_color_ok);
18         
19         btn_select_color->signal_clicked().connect(SigC::slot(*this,&CisternPtyWnd::on_btn_select_color_clicked));
20         dlg_select_color_cancel->signal_clicked().connect(SigC::slot(*this,&CisternPtyWnd::on_dlg_select_color_cancel_clicked));
21         dlg_select_color_ok->signal_clicked().connect(SigC::slot(*this,&CisternPtyWnd::on_dlg_select_color_ok_clicked));
22         cistern = NULL;
23 }
24
25 void CisternPtyWnd::show()
26 {
27         if (cistern != NULL) {
28                 color_preview->modify_bg( Gtk::STATE_NORMAL , cistern->get_liquid_color() );
29         }
30         PropertyWnd::show();
31 }
32
33 CisternPtyWnd::~CisternPtyWnd()
34 {
35 }
36  
37 void CisternPtyWnd::on_btn_accept_clicked()
38 {
39         CisternPtyWnd::on_btn_apply_clicked();
40         if ( !cistern->workplace->chek_name(txt_cistern_name->get_text(), cistern->get_id()) ) 
41         hide();
42 }
43
44 void CisternPtyWnd::on_btn_apply_clicked()
45 {
46         cistern->set_capacidad( spin_capacidad->get_value() );
47         cistern->set_contenido_inicial( spin_inicial->get_value() );
48         cistern->set_name( txt_cistern_name->get_text() );
49         cistern->set_flotante_inf(spin_flot_inf->get_value() );
50         cistern->set_flotante_sup(spin_flot_sup->get_value() );
51         color_select_dlg->get_colorsel()->set_current_color(cistern->get_liquid_color());
52         if ( cistern->workplace->chek_name(txt_cistern_name->get_text(), cistern->get_id()) ) 
53                 dlg_name->show();
54         else 
55                 cistern->set_name( txt_cistern_name->get_text() );
56 }
57
58 void CisternPtyWnd::on_btn_select_color_clicked()
59 {
60         color_select_dlg->get_colorsel()->set_current_color(cistern->get_liquid_color());
61         color_select_dlg->show();
62 }
63
64 void CisternPtyWnd::on_dlg_select_color_cancel_clicked()
65 {
66         color_select_dlg->hide();
67 }
68
69 void CisternPtyWnd::on_dlg_select_color_ok_clicked()
70 {
71         cistern->set_liquid_color( color_select_dlg->get_colorsel()->get_current_color() );
72         color_preview->modify_bg( Gtk::STATE_NORMAL , cistern->get_liquid_color() );
73         color_select_dlg->hide();
74 }