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++;
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;
}
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++;
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;
}
-
-
#include "item.h"
#include <iostream>
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("<control>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()
//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;
+}
#define GTKMM_EXAMPLE_DRAWINGAREALINES_H
#include <gtkmm/drawingarea.h>
+#include <gtkmm/stock.h>
+#include <gtkmm.h>
#include <gdkmm.h>
-//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<Gdk::Pixbuf> get_image() { return image; }
protected:
+ Gtk::Menu menu_popup;
+ Gtk::Image menu_image;
Glib::RefPtr<Gdk::Pixbuf> image;
};
-#endif //GTKMM_EXAMPLE_DRAWINGAREALINES_H
+#endif
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++;
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;
}