]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/cistern.cpp
le cambie el nombre a las clases y a los archivos y ahora el popup anda bien, rotar...
[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("null.png");
8         imgActual = 0;
9         image = imageE;
10         set_size_request(image->get_width(), image->get_height());
11 }
12
13 Cistern::~Cistern()
14 {
15 }
16
17 bool Cistern::on_button_press_event(GdkEventButton *event)
18 {
19         int w, h;
20         if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
21                 image = null; 
22                 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);
23                 imgActual++;
24                 switch (imgActual) {
25                         case 1:
26                                 image = imageO;
27                                 break;
28                         default: 
29                                 imgActual = 0;
30                                 image = imageE;                 
31                 }
32                 get_size_request(w, h);
33                 set_size_request(h, w);         
34                 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);
35         }
36         if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
37                 menu_popup.popup(event->button, event->time);
38                  return true; //It has been handled.
39         }
40         return true;
41 }
42
43 void Cistern::on_menu_popup_rotar()
44 {
45         GdkEventButton event; 
46                 event.type = GDK_BUTTON_PRESS;
47                 event.button = 2;
48         Cistern::on_button_press_event(&event);
49 }