]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/cistern.cpp
Creo que esto va a ser presentable para maniana. Luca si podes dale esto a Gonzalo...
[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->show();
53         }               
54         return true;
55 }
56
57 void Cistern::on_menu_popup_rotar()
58 {
59         GdkEventButton event; 
60                 event.type = GDK_BUTTON_PRESS;
61                 event.button = 2;
62         Cistern::on_button_press_event(&event);
63 }
64
65 void Cistern::on_menu_popup_propiedades()
66 {
67         cistern_pty_wnd->spin_caudal->set_value(caudal);
68         cistern_pty_wnd->spin_fluido_max->set_value(fluido_max);
69         GdkEventButton event; 
70                 event.type = GDK_2BUTTON_PRESS;
71                 event.button = 1;
72         Cistern::on_button_press_event(&event);
73 }