add(m_HBox);
- m_HBox.pack_start(m_VBox);
+ m_HBox.pack_start(m_VBox, false, false, 0);
m_VBox.pack_start(m_Button_Canio);
m_VBox.pack_start(m_Button_Y);
m_VBox.pack_start(m_Button_Codo);
- m_HBox.pack_start(m_WorkPlace);
+ m_HBox.pack_start(scroll);
+ scroll.add(m_WorkPlace);
+ scroll.set_size_request(600, 600);
m_WorkPlace.set_size_request(600, 600);
//Targets:
- std::list<Gtk::TargetEntry> listTargets;
listTargets.push_back( Gtk::TargetEntry("STRING") );
listTargets.push_back( Gtk::TargetEntry("text/plain") );
+ listTargets.push_back( Gtk::TargetEntry("POINTER") );
+ listTargets.push_back( Gtk::TargetEntry("application/pointer") );
//Drag site:
void DnDWindow::on_canio_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context)
{
- context->set_icon(ico_canio, 0, 0); //ico_canio->get_width(), ico_canio->get_height());
+ context->set_icon(ico_canio, 5, 5); //ico_canio->get_width(), ico_canio->get_height());
}
void DnDWindow::on_y_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context)
{
- context->set_icon(ico_y, 0, 0); //ico_canio->get_width(), ico_canio->get_height());
+ context->set_icon(ico_y, 5, 5); //ico_canio->get_width(), ico_canio->get_height());
}
void DnDWindow::on_codo_drag_begin(const Glib::RefPtr<Gdk::DragContext> &context)
{
- context->set_icon(ico_codo, 0, 0); //ico_canio->get_width(), ico_canio->get_height());
+ context->set_icon(ico_codo, 5, 5); //ico_canio->get_width(), ico_canio->get_height());
}
{
//TODO: The gtkmm API needs to change to use a Gtk::SelectionData instead of a GtkSelectionData.
//That should happen for gtkmm 2.4.
-
- if ((selection_data->length >= 0) && (selection_data->format == 8))
- {
- CItem *a = Gtk::manage( new CItem((const char *)selection_data->data) );
/* Ajusto coordenada x e y para que caigan en un lugar de una cuadricula de
* 32x32 */
int i,j;
// separacion de 2 cuadritos
i = (x+1)/32;
j = (y+1)/32;
+
+ // El drag es de un item
+ if (selection_data->format == 10) {
+ m_WorkPlace.move(*drag_get_source_widget(context), i*32, j*32);
+ }
+
+ // El Drag es desde la barra de tareas
+ if ((selection_data->length >= 0) && (selection_data->format == 8))
+ {
+ CItem *a = Gtk::manage( new CItem((const char *)selection_data->data) );
m_WorkPlace.put(*a, i*32, j*32);
+ // Seteo la lista de tipos de drags
+ a->drag_source_set(listTargets);
+ // Conecto las señales
+ a->signal_drag_data_get().connect( SigC::slot(*this, &DnDWindow::on_item_drag_data_get));
+ a->signal_drag_begin().connect( SigC::slot(*this, &DnDWindow::on_item_drag_begin));
+
a->show();
//listaItems.push_back(a);
}
context->drag_finish(false, false, time);
}
+void DnDWindow::on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+}
+
+void DnDWindow::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time)
+{
+ // El 10 creo que es el format
+ gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"codo.png", 8);
+}
+
+