]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Constructor/canio.cpp
popup del carajo, el unico que esta implementado es el de rotar.
[z.facultad/75.42/plaqui.git] / Constructor / canio.cpp
1 #include "canio.h"
2
3 Canio::Canio()
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 Canio::~Canio()
14 {
15 }
16
17 bool Canio::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 Canio::on_menu_popup_generic()
44 {
45         GdkEventButton event; 
46                 event.type = GDK_BUTTON_PRESS;
47                 event.button = 2;
48         Canio::on_button_press_event(&event);
49 }