From 60d025bd1152960ac9131128c7cea2b7af8a406e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicol=C3=A1s=20Dimov?= Date: Fri, 24 Oct 2003 04:56:44 +0000 Subject: [PATCH] Me vuelvo loco cd Constructor/cd Constructor/ pero hubo una regresion, para rotar hay que usar el boton del medio y la novedad descubranla con el boton derecho. Aleluya. --- Constructor/canio.cpp | 6 +++++- Constructor/codo.cpp | 6 +++++- Constructor/item.cpp | 14 +++++++++++--- Constructor/item.h | 9 +++++++-- Constructor/y.cpp | 6 +++++- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Constructor/canio.cpp b/Constructor/canio.cpp index 73dd6f1..0afb2bc 100644 --- a/Constructor/canio.cpp +++ b/Constructor/canio.cpp @@ -17,7 +17,7 @@ Canio::~Canio() bool Canio::on_button_press_event(GdkEventButton *event) { int w, h; - if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==3)){ + if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){ image = null; 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); imgActual++; @@ -33,5 +33,9 @@ bool Canio::on_button_press_event(GdkEventButton *event) set_size_request(h, w); 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); } + if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){ + menu_popup.popup(event->button, event->time); + return true; //It has been handled. + } return true; } diff --git a/Constructor/codo.cpp b/Constructor/codo.cpp index 6870e2d..75c9d26 100644 --- a/Constructor/codo.cpp +++ b/Constructor/codo.cpp @@ -18,7 +18,7 @@ Codo::~Codo() bool Codo::on_button_press_event(GdkEventButton *event) { - if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){ + if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){ image = null; 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); imgActual++; @@ -39,5 +39,9 @@ bool Codo::on_button_press_event(GdkEventButton *event) set_size_request(image->get_width(),image->get_height()); 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); } + if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){ + menu_popup.popup(event->button, event->time); + return true; //It has been handled. + } return true; } diff --git a/Constructor/item.cpp b/Constructor/item.cpp index 72106e2..15c3930 100644 --- a/Constructor/item.cpp +++ b/Constructor/item.cpp @@ -1,17 +1,20 @@ - - #include "item.h" #include CItem::CItem(const char *filename):Gtk::DrawingArea() { image = Gdk::Pixbuf::create_from_file(filename); - set_size_request(image->get_width(), image->get_height()); } CItem::CItem() { + menu_image.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU); + Gtk::Menu::MenuList& menulist = menu_popup.items(); + menulist.push_back( Gtk::Menu_Helpers::MenuElem("Opcion", SigC::slot(*this, &CItem::on_menu_file_popup_generic) ) ); + menulist.push_back( Gtk::Menu_Helpers::MenuElem("Rotar", Gtk::Menu::AccelKey("r"),SigC::slot(*this, &CItem::on_menu_file_popup_generic) ) ); + menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Eliminar", menu_image,SigC::slot(*this, &CItem::on_menu_file_popup_generic) ) ) ; + menu_popup.accelerate(*this); } CItem::~CItem() @@ -28,3 +31,8 @@ bool CItem::on_expose_event(GdkEventExpose* event) //Gtk::DrawingArea::on_expose_event(event); return true; } + +void CItem::on_menu_file_popup_generic() +{ + std::cout << "A popup menu item was selected." << std::endl; +} diff --git a/Constructor/item.h b/Constructor/item.h index 01b8f87..7a2f35b 100644 --- a/Constructor/item.h +++ b/Constructor/item.h @@ -4,18 +4,23 @@ #define GTKMM_EXAMPLE_DRAWINGAREALINES_H #include +#include +#include #include -//Custom drawing area with modified expose_event. + class CItem:public Gtk::DrawingArea { public: CItem(); CItem(const char *filename); ~CItem(); virtual bool on_expose_event(GdkEventExpose* event); + virtual void on_menu_file_popup_generic(); Glib::RefPtr get_image() { return image; } protected: + Gtk::Menu menu_popup; + Gtk::Image menu_image; Glib::RefPtr image; }; -#endif //GTKMM_EXAMPLE_DRAWINGAREALINES_H +#endif diff --git a/Constructor/y.cpp b/Constructor/y.cpp index 414bee6..9c4e197 100644 --- a/Constructor/y.cpp +++ b/Constructor/y.cpp @@ -19,7 +19,7 @@ Y::~Y() bool Y::on_button_press_event(GdkEventButton *event) { int w,h; - if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3 )){ + if ((event->type == GDK_BUTTON_PRESS) && (event->button == 2 )){ image = null; 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); imgActual++; @@ -41,5 +41,9 @@ bool Y::on_button_press_event(GdkEventButton *event) set_size_request(h, w); 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); } + if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){ + menu_popup.popup(event->button, event->time); + return true; //It has been handled. + } return true; } -- 2.43.0