]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/conduct.cpp
Ahora el tanque gira bien
[z.facultad/75.42/plaqui.git] / Constructor / conduct.cpp
1 #include "conduct.h"
2
3 Conduct::Conduct()
4 {
5         imageN = Gdk::Pixbuf::create_from_file("canio_n.png");
6         imageS = Gdk::Pixbuf::create_from_file("canio_s.png");
7         null = Gdk::Pixbuf::create_from_file("null.png");
8         imgActual = 0;
9         image = imageN;
10         set_size_request(image->get_width(), image->get_height());
11 }
12
13 Conduct::~Conduct()
14 {
15 }
16
17 bool Conduct::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 = imageS;
27                                 break;
28                         default: 
29                                 imgActual = 0;
30                                 image = imageN;                 
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 Conduct::on_menu_popup_rotar()
44 {
45         GdkEventButton event; 
46                 event.type = GDK_BUTTON_PRESS;
47                 event.button = 2;
48         Conduct::on_button_press_event(&event);
49 }