]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/cistern.cpp
Corregido el typo reportado por ricky.
[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                 property_wnd->show();
51         }               
52         return true;
53 }
54
55 void Cistern::on_menu_popup_rotar()
56 {
57         GdkEventButton event; 
58                 event.type = GDK_BUTTON_PRESS;
59                 event.button = 2;
60         Cistern::on_button_press_event(&event);
61 }
62
63 void Cistern::on_menu_popup_propiedades()
64 {
65         GdkEventButton event; 
66                 event.type = GDK_2BUTTON_PRESS;
67                 event.button = 1;
68         Cistern::on_button_press_event(&event);
69 }