X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/6757fcf0e0225e3a716662c8683719469498f0b1..e218a1f9cc4ccbe639a7f31610715f9bd66a8ee4:/tests/GUI/dndwindow.cc diff --git a/tests/GUI/dndwindow.cc b/tests/GUI/dndwindow.cc index f18ee57..47a18d4 100644 --- a/tests/GUI/dndwindow.cc +++ b/tests/GUI/dndwindow.cc @@ -34,19 +34,22 @@ DnDWindow::DnDWindow() 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 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: @@ -85,17 +88,17 @@ void DnDWindow::on_item_button_down() void DnDWindow::on_canio_drag_begin(const Glib::RefPtr &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 &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 &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()); } @@ -126,10 +129,6 @@ void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtrlength >= 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; @@ -137,7 +136,23 @@ void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtrformat == 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); } @@ -145,4 +160,15 @@ void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtrdrag_finish(false, false, time); } +void DnDWindow::on_item_drag_begin(const Glib::RefPtr& context) +{ +} + +void DnDWindow::on_item_drag_data_get(const Glib::RefPtr& 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); +} + +