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