]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/cistern.cpp
Se vuelve a poner el flag de debug, lo cambie sin querer el commit pasado.
[z.facultad/75.42/plaqui.git] / Constructor / cistern.cpp
1 #include "cistern.h"
2
3 Cistern::Cistern()
4 {
5         caudal = 56;
6         fluido_max = 23;
7         imageE = Gdk::Pixbuf::create_from_file("tanque_e.png");
8         imageO = Gdk::Pixbuf::create_from_file("tanque_o.png");
9         null = Gdk::Pixbuf::create_from_file("tanque_null.png");
10         imgActual = 0;
11         image = imageE;
12         set_size_request(image->get_width(), image->get_height());
13         
14         Glib::RefPtr<Gnome::Glade::Xml> ref;
15         try {
16                 ref = Gnome::Glade::Xml::create("constructor.glade", "cistern_pty_wnd");
17         }
18         catch(const Gnome::Glade::XmlError &ex) {
19                 std::cerr << ex.what() << std::endl;
20         }
21         ref->get_widget_derived("cistern_pty_wnd",cistern_pty_wnd);
22 }
23
24 Cistern::~Cistern()
25 {
26 }
27
28 bool Cistern::on_button_press_event(GdkEventButton *event)
29 {
30         if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
31                 image = null; 
32                 image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
33                 imgActual++;
34                 switch (imgActual) {
35                         case 1:
36                                 image = imageO;
37                                 break;
38                         default: 
39                                 imgActual = 0;
40                                 image = imageE;                 
41                 }
42                 set_size_request(image->get_width(),image->get_height());
43                 image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
44         }
45         
46         if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
47                 menu_popup.popup(event->button, event->time);
48                  return true; //It has been handled.
49         }
50         
51         if ((event->type == GDK_2BUTTON_PRESS) && (event->button ==1)){
52                 cistern_pty_wnd->spin_caudal->set_value((double)x);
53                 cistern_pty_wnd->spin_fluido_max->set_value((double)y);
54                 cistern_pty_wnd->show();
55         }               
56         return true;
57 }
58
59 void Cistern::on_menu_popup_rotar()
60 {
61         GdkEventButton event; 
62                 event.type = GDK_BUTTON_PRESS;
63                 event.button = 2;
64         Cistern::on_button_press_event(&event);
65 }
66
67 void Cistern::on_menu_popup_propiedades()
68 {
69 //      cistern_pty_wnd->spin_caudal->set_value(caudal);
70 //      cistern_pty_wnd->spin_fluido_max->set_value(fluido_max);
71         std::cout<< "posicion = "<< x <<" "<< y <<std::endl;
72         GdkEventButton event; 
73                 event.type = GDK_2BUTTON_PRESS;
74                 event.button = 1;
75         Cistern::on_button_press_event(&event);
76 }