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