From 421cf558f59e55ab31d7d11ca3bf64603fc9356d Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Sun, 12 Oct 2003 23:08:23 +0000 Subject: [PATCH] Agregue un intento de dibujar la grilla sobre el fondo, creando una clase heredada de Gtk::Fixed. sin saber por que las lineas comienzan desde el borde izquierdo de la ventana en lugar desde el borde derecho del widget. No documentacion no es clara y no encuentro el error. --- tests/GUI/Makefile.am | 4 +++- tests/GUI/dndwindow.cc | 20 +++++++++----------- tests/GUI/dndwindow.h | 4 ++-- tests/GUI/workplace.cc | 18 ++++++++++++++++++ tests/GUI/workplace.h | 15 +++++++++++++++ 5 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 tests/GUI/workplace.cc create mode 100644 tests/GUI/workplace.h diff --git a/tests/GUI/Makefile.am b/tests/GUI/Makefile.am index 6365795..f996496 100644 --- a/tests/GUI/Makefile.am +++ b/tests/GUI/Makefile.am @@ -11,7 +11,9 @@ drag_and_drop_SOURCES = main.cc \ dndwindow.cc \ dndwindow.h \ item.cc \ - item.h + item.h \ + workplace.h \ + workplace.cc drag_and_drop_LDADD = @PACKAGE_LIBS@ diff --git a/tests/GUI/dndwindow.cc b/tests/GUI/dndwindow.cc index daa5939..019591b 100644 --- a/tests/GUI/dndwindow.cc +++ b/tests/GUI/dndwindow.cc @@ -35,8 +35,13 @@ DnDWindow::DnDWindow() add(m_HBox); m_HBox.pack_start(m_VBox); + + 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_WorkPlace.set_size_request(300, 300); + m_WorkPlace.set_size_request(600, 600); //Targets: std::list listTargets; @@ -59,20 +64,12 @@ DnDWindow::DnDWindow() 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); - m_VBox.pack_start(m_Button_Codo); - - //Drop site: - - //Make m_Label_Drop a DnD drop destination: m_WorkPlace.drag_dest_set(listTargets); - - //Connect signals: + + //Connect signals: m_WorkPlace.signal_drag_data_received().connect( SigC::slot(*this, &DnDWindow::on_label_drop_drag_data_received) ); - show_all(); } @@ -152,3 +149,4 @@ void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtrdrag_finish(false, false, time); } + diff --git a/tests/GUI/dndwindow.h b/tests/GUI/dndwindow.h index 8c59028..eeda3e3 100644 --- a/tests/GUI/dndwindow.h +++ b/tests/GUI/dndwindow.h @@ -25,6 +25,7 @@ #include #include #include "item.h" +#include "workplace.h" class DnDWindow : public Gtk::Window { @@ -44,7 +45,6 @@ protected: virtual void on_y_drag_begin(const Glib::RefPtr& context); virtual void on_codo_drag_begin(const Glib::RefPtr& context); - void on_item_button_down(); //Member widgets: Gtk::HBox m_HBox; @@ -52,7 +52,7 @@ protected: Gtk::Button m_Button_Canio; Gtk::Button m_Button_Y; Gtk::Button m_Button_Codo; - Gtk::Fixed m_WorkPlace; + WorkPlace m_WorkPlace; std::list listaItems; }; diff --git a/tests/GUI/workplace.cc b/tests/GUI/workplace.cc new file mode 100644 index 0000000..4c11f6c --- /dev/null +++ b/tests/GUI/workplace.cc @@ -0,0 +1,18 @@ + + +#include "workplace.h" + +WorkPlace::WorkPlace():Gtk::Fixed() +{ +} + +bool WorkPlace::on_expose_event(GdkEventExpose *e) +{ + int i; + for(i=0; idraw_line(get_style()->get_black_gc(), i, 0, i, get_height()); + } + + return true; +} + diff --git a/tests/GUI/workplace.h b/tests/GUI/workplace.h new file mode 100644 index 0000000..421c000 --- /dev/null +++ b/tests/GUI/workplace.h @@ -0,0 +1,15 @@ + +#ifndef _H_WORKPLACE_ +#define _H_WORKPLACE_ + +#include +#include + +class WorkPlace:public Gtk::Fixed { +public: + WorkPlace(); + virtual ~WorkPlace() {} + virtual bool on_expose_event(GdkEventExpose *); +}; + +#endif -- 2.43.0