m_Button_Canio.signal_drag_data_get().connect( SigC::slot(*this, &DnDWindow::on_canio_drag_data_get));
m_Button_Y.signal_drag_data_get().connect( SigC::slot(*this, &DnDWindow::on_y_drag_data_get));
m_Button_Codo.signal_drag_data_get().connect( SigC::slot(*this, &DnDWindow::on_codo_drag_data_get));
-
+ // Señales para cambiar el icono cuando empieza el drag.
+ m_Button_Canio.signal_drag_begin().connect( SigC::slot(*this, &DnDWindow::on_canio_drag_begin));
+ m_Button_Y.signal_drag_begin().connect( SigC::slot(*this, &DnDWindow::on_y_drag_begin));
+ m_Button_Codo.signal_drag_begin().connect( SigC::slot(*this, &DnDWindow::on_codo_drag_begin));
m_VBox.pack_start(m_Button_Canio);
m_VBox.pack_start(m_Button_Y);
}
-void DnDWindow::on_canio_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, GtkSelectionData* selection_data, guint, guint)
+void DnDWindow::on_canio_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint, guint)
{
//TODO: The gtkmm API needs to change to use a Gtk::SelectionData instead of a GtkSelectionData.
//That should happen for gtkmm 2.4.
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ image = Gdk::Pixbuf::create_from_file("canio.png");
+ // Cambio el icono de DND seteando el "hot spot" en el centro.
+ context->set_icon(image, image->get_width() / 2, image->get_height() / 2);
gtk_selection_data_set (selection_data, selection_data->target, 8, (const guchar*)"canio.png", 9);
}
context->drag_finish(false, false, time);
}
+void DnDWindow::on_canio_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ image = Gdk::Pixbuf::create_from_file("canio.png");
+ context->set_icon(image, image->get_width() / 2, image->get_height() / 4);
+}
+
+void DnDWindow::on_y_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ image = Gdk::Pixbuf::create_from_file("y.png");
+ context->set_icon(image, image->get_width() / 4, image->get_height() / 4);
+}
+
+void DnDWindow::on_codo_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+ Glib::RefPtr<Gdk::Pixbuf> image;
+ image = Gdk::Pixbuf::create_from_file("codo.png");
+ context->set_icon(image, 0, 0);//image->get_width() / 2, image->get_height() / 2);
+}
+
virtual void on_y_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_codo_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
virtual void on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, GtkSelectionData* selection_data, guint info, guint time);
+ // Señales para cambiar el icono cuando empieza el drag.
+ virtual void on_canio_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
+ virtual void on_y_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
+ virtual void on_codo_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
void on_item_button_down();
bool CItem::on_expose_event(GdkEventExpose* event)
{
- 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);
+ 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);
- Gtk::DrawingArea::on_expose_event(event);
+ // XXX Esto no deberia ser necesario! en todo caso devolves false en
+ // vez de true para que siga llamando a los otros handlers :)
+ //Gtk::DrawingArea::on_expose_event(event);
return true;
}