From: Nicolás Dimov Date: Thu, 23 Oct 2003 17:31:39 +0000 (+0000) Subject: Subo esto que compila pero se cuelga cuando soltas un item, y ademas no se como hacer... X-Git-Tag: svn_import~374 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/e5f9e15b59fc1ade287321c796ec7c4b9aa27600?ds=inline Subo esto que compila pero se cuelga cuando soltas un item, y ademas no se como hacer para que actualice la imagen cuando se rota. Supongo que se cuelga en el evento que recive el drag, pero no se donde ni porque. Voy a seguir probando. --- diff --git a/Constructor/btn_salir.cpp b/Constructor/btn_salir.cpp deleted file mode 100644 index 87a850b..0000000 --- a/Constructor/btn_salir.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//btn_salir.cpp -#include "btn_salir.h" -BtnSalir::BtnSalir(BaseObjectType* cobject, const Glib::RefPtr& refGlade) -{ - //btn_salir.signal_released().connect(SigC::slot(*this,&BtnSalir::on_pressed)); -} - -BtnSalir::~BtnSalir() -{ -} - -void BtnSalir::on_pressed() -{ - Gtk::Main::quit(); -} diff --git a/Constructor/btn_salir.h b/Constructor/btn_salir.h deleted file mode 100644 index 6717254..0000000 --- a/Constructor/btn_salir.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef BTN_SALIR_H -#define BTN_SALIR_H -#include -#include -#include -class BtnSalir : public Gtk::Button{ -public: - BtnSalir(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - virtual ~BtnSalir(); -protected: - virtual void on_pressed(); -}; - -#endif diff --git a/Constructor/canio.cpp b/Constructor/canio.cpp new file mode 100644 index 0000000..387ce31 --- /dev/null +++ b/Constructor/canio.cpp @@ -0,0 +1,34 @@ +#include "canio.h" + +Canio::Canio() +{ + imageN = Gdk::Pixbuf::create_from_file("canio_n.png"); + imageS = Gdk::Pixbuf::create_from_file("canio_s.png"); + null = Gdk::Pixbuf::create_from_file("null.png"); + imgActual = 0; + image = imageN; + set_size_request(image->get_width(), image->get_height()); +} + +Canio::~Canio() +{ +} + +bool Canio::on_button_press_event(GdkEventButton *event) +{ + if (event->type == GDK_2BUTTON_PRESS){ + image = null; //como hago para actualizar????? + 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++; + switch (imgActual) { + case 1: + image = imageS; + break; + default: + imgActual = 0; + image = imageN; + } + 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); + } + return true; +} diff --git a/Constructor/canio.h b/Constructor/canio.h new file mode 100644 index 0000000..b014b5d --- /dev/null +++ b/Constructor/canio.h @@ -0,0 +1,19 @@ +// canio.h +#ifndef _CANIO_H_ +#define _CANIO_H_ + +#include "item.h" + +class Canio : public CItem { + public: + Canio(); + virtual ~Canio(); + virtual bool on_button_press_event(GdkEventButton *event); + private: + int imgActual; + + Glib::RefPtr imageN; // 0 + Glib::RefPtr imageS; // 1 + Glib::RefPtr null; +}; +#endif diff --git a/Constructor/canio_n.png b/Constructor/canio_n.png new file mode 100644 index 0000000..8b7008e Binary files /dev/null and b/Constructor/canio_n.png differ diff --git a/Constructor/canio_s.png b/Constructor/canio_s.png new file mode 100644 index 0000000..6e867c3 Binary files /dev/null and b/Constructor/canio_s.png differ diff --git a/Constructor/codo.cpp b/Constructor/codo.cpp new file mode 100644 index 0000000..baa3aaa --- /dev/null +++ b/Constructor/codo.cpp @@ -0,0 +1,42 @@ +#include "codo.h" + +Codo::Codo() +{ + imageN = Gdk::Pixbuf::create_from_file("codo_n.png"); + imageS = Gdk::Pixbuf::create_from_file("codo_s.png"); + imageE = Gdk::Pixbuf::create_from_file("codo_e.png"); + imageO = Gdk::Pixbuf::create_from_file("codo_o.png"); + null = Gdk::Pixbuf::create_from_file("null.png"); + imgActual = 0; + image = imageN; + set_size_request(image->get_width(), image->get_height()); +} + +Codo::~Codo() +{ +} + +bool Codo::on_button_press_event(GdkEventButton *event) +{ + if (event->type == GDK_2BUTTON_PRESS){ + image = null; //como hago para actualizar????? + 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++; + switch (imgActual) { + case 1: + image = imageE; + break; + case 2: + image = imageS; + break; + case 3: + image = imageO; + break; + default: + imgActual = 0; + image = imageN; + } + 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); + } + return true; +} diff --git a/Constructor/codo.h b/Constructor/codo.h new file mode 100644 index 0000000..edbed25 --- /dev/null +++ b/Constructor/codo.h @@ -0,0 +1,21 @@ +// codo.h +#ifndef _CODO_H_ +#define _CODO_H_ + +#include "item.h" + +class Codo : public CItem { + public: + Codo(); + virtual ~Codo(); + virtual bool on_button_press_event(GdkEventButton *event); + private: + int imgActual; + + Glib::RefPtr imageN; // 0 + Glib::RefPtr imageS; // 1 + Glib::RefPtr imageE; // 2 + Glib::RefPtr imageO; // 3 + Glib::RefPtr null; +}; +#endif diff --git a/Constructor/codo_e.png b/Constructor/codo_e.png new file mode 100644 index 0000000..a2fe30c Binary files /dev/null and b/Constructor/codo_e.png differ diff --git a/Constructor/codo_n.png b/Constructor/codo_n.png new file mode 100644 index 0000000..75d86be Binary files /dev/null and b/Constructor/codo_n.png differ diff --git a/Constructor/codo_o.png b/Constructor/codo_o.png new file mode 100644 index 0000000..ade23a2 Binary files /dev/null and b/Constructor/codo_o.png differ diff --git a/Constructor/codo_s.png b/Constructor/codo_s.png new file mode 100644 index 0000000..9ed808b Binary files /dev/null and b/Constructor/codo_s.png differ diff --git a/Constructor/constructor.cpp b/Constructor/constructor.cpp new file mode 100644 index 0000000..094ff23 --- /dev/null +++ b/Constructor/constructor.cpp @@ -0,0 +1,136 @@ +//constructor.cpp + +#include "constructor.h" + +Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr& refGlade):Gtk::Window(cobject) +{ + set_title("Constructor"); + + + ico_canio = Gdk::Pixbuf::create_from_file("item_canio.png"); + ico_y = Gdk::Pixbuf::create_from_file("item_y.png"); + ico_codo = Gdk::Pixbuf::create_from_file("item_codo.png"); + + refGlade->get_widget("btn_canio", btn_canio); + refGlade->get_widget("btn_codo", btn_codo); + refGlade->get_widget("btn_y", btn_y); + + refGlade->get_widget_derived("workplace", workplace); //fixed + + + + //Targets: + 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") ); + + btn_canio->drag_source_set(listTargets); + btn_y->drag_source_set(listTargets); + btn_codo->drag_source_set(listTargets); + + btn_canio->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_canio_drag_get)); + btn_y->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_y_drag_get)); + btn_codo->signal_drag_data_get().connect( SigC::slot(*this, &Constructor::on_btn_codo_drag_get)); + // Señales para cambiar el icono cuando empieza el drag. + btn_canio->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_canio_drag_begin)); + btn_y->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_y_drag_begin)); + btn_codo->signal_drag_begin().connect( SigC::slot(*this, &Constructor::on_codo_drag_begin)); + + + workplace->drag_dest_set(listTargets); + workplace->signal_drag_data_received().connect( SigC::slot(*this, &Constructor::on_item_drop_drag_received) ); +} + +Constructor::~Constructor() +{ +} +void Constructor::on_btn_canio_drag_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time) +{ + gtk_selection_data_set (selection_data, selection_data->target, 8, (const guchar*)"item_canio.png", 14); +} + +void Constructor::on_btn_y_drag_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time) +{ + gtk_selection_data_set(selection_data, selection_data->target,8,(const guchar*)"item_y.png",10); +} + +void Constructor::on_btn_codo_drag_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time) +{ + gtk_selection_data_set(selection_data, selection_data->target,8,(const guchar*)"item_codo.png",13); +} + +void Constructor::on_canio_drag_begin(const Glib::RefPtr& context) +{ + context->set_icon(ico_canio, 5, 5); +} + +void Constructor::on_y_drag_begin(const Glib::RefPtr& context) +{ + context->set_icon(ico_y, 5, 5); +} + +void Constructor::on_codo_drag_begin(const Glib::RefPtr& context) +{ + context->set_icon(ico_codo, 5, 5); +} + +void Constructor::on_item_drag_begin(const Glib::RefPtr& context, CItem *item) +{ + context->set_icon(item->get_image(), 5, 5); +} + +void Constructor::on_item_drag_data_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time) +{ + if ( strcmp((const char *)selection_data->data,"item_codo.png")==0) + gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"item_codo.png", 13); + if ( strcmp((const char *)selection_data->data,"item_canio.png")==0) + gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"item_canio.png", 14); + if ( strcmp((const char *)selection_data->data,"item_y.png")==0) + gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"item_y.png", 10); +} + +void Constructor::on_item_drop_drag_received(const Glib::RefPtr& context, int x, int y, GtkSelectionData* selection_data, guint info, guint time) +{ + /* Ajusto coordenada x e y para que caigan en un lugar de una cuadricula de 32x32 */ + int i,j; + // el +1 es para evitar un bug cuando se selecciona muy cerce de la + // separacion de 2 cuadritos + i = (x+1)/32; + j = (y+1)/32; + // El drag es de un item + if (selection_data->format == 10) { + 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; + if (strcmp((const char *)selection_data->data, "item_codo.png")==0) + a = Gtk::manage( new Codo() ); + else if (strcmp((const char *)selection_data->data, "item_canio.png")==0) + a = Gtk::manage( new Canio() ); + else if (strcmp((const char *)selection_data->data, "item_y.png")==0) { + a = Gtk::manage( new Y() ); + } else { + a = Gtk::manage( new CItem((const char *)selection_data->data) ); + } + 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, &Constructor::on_item_drag_data_get)); + + // Utilizo el SigC::bind para que el callback on_drag_begin acepte un + // parametro extra, en este caso un CItem *. Esto se hace para + // que cuando el usuario quiera mover un item, saber que item es + // y pedirle su ícono para mostrar cono icono durante la operacion, + // Esto va a permitir, que si un widget tiene una imagen rotara o algo + // raro se vea el widget tal cual. + a->signal_drag_begin().connect(SigC::bind( SigC::slot(*this, &Constructor::on_item_drag_begin), a)); + a->show(); + listaItems.push_back(a); + } + context->drag_finish(false, false, time); +} diff --git a/Constructor/constructor.glade b/Constructor/constructor.glade index 909386b..d6cdbf0 100644 --- a/Constructor/constructor.glade +++ b/Constructor/constructor.glade @@ -3,7 +3,7 @@ - + 640 480 True @@ -29,7 +29,7 @@ 1 - + True @@ -39,7 +39,7 @@ True - + @@ -78,7 +78,7 @@ - + True @@ -103,7 +103,7 @@ True - + @@ -136,19 +136,6 @@ - - - True - _View - True - - - - - - - - True @@ -156,7 +143,7 @@ True - + @@ -202,41 +189,202 @@ - 1 True GTK_BUTTONBOX_SPREAD 0 - + + 69 + 80 True True True - button6 - True GTK_RELIEF_NORMAL + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + ico_canio.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Canio + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + - + True True True - button7 - True GTK_RELIEF_NORMAL + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + ico_codo.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Codo + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + - + True True True - button8 - True GTK_RELIEF_NORMAL + + + + True + 0.5 + 0.5 + 0 + 0 + + + + True + False + 2 + + + + True + ico_y.png + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Division +Empalme + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + @@ -258,8 +406,8 @@ True True - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC GTK_SHADOW_NONE GTK_CORNER_TOP_LEFT @@ -269,24 +417,8 @@ GTK_SHADOW_IN - + True - - - - 53 - 27 - True - True - button9 - True - GTK_RELIEF_NORMAL - - - 464 - 8 - - @@ -311,4 +443,198 @@ + + 271 + 194 + Propiedades + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + + + + 46 + 25 + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 168 + 16 + + + + + + 48 + 24 + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 168 + 56 + + + + + + 48 + 24 + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 168 + 96 + + + + + + 104 + 24 + True + Fluido Máximo + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 32 + 16 + + + + + + 120 + 24 + True + Fluido Mínimo + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 24 + 56 + + + + + + 96 + 24 + True + otra cosa + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 32 + 96 + + + + + 0 + True + True + + + + + + diff --git a/Constructor/constructor.h b/Constructor/constructor.h new file mode 100644 index 0000000..b19281b --- /dev/null +++ b/Constructor/constructor.h @@ -0,0 +1,48 @@ +// ventana principal +#ifndef _CONSTRUCTOR_H_ +#define _CONSTRUCTOR_H_ + +#include +#include +#include +#include +#include +#include +#include +#include "workplace.h" +#include "item.h" +#include "codo.h" +#include "canio.h" +#include "y.h" + + +class Constructor : public Gtk::Window { + public: + Constructor(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + virtual ~Constructor(); + protected: + // / defino los elementos de la ventana. + Gtk::Button *btn_canio, *btn_codo, *btn_y; + WorkPlace *workplace; + Glib::RefPtr ico_canio, ico_y, ico_codo; + std::list listTargets; + Glib::RefPtr ico_last; + std::list listaItems; + + // /señales de control para los elementos de la ventana. + + virtual void on_btn_canio_drag_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time); + virtual void on_btn_y_drag_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time); + virtual void on_btn_codo_drag_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time); + + // señales para cambiar el icono. + virtual void on_canio_drag_begin(const Glib::RefPtr& context); + virtual void on_y_drag_begin(const Glib::RefPtr& context); + virtual void on_codo_drag_begin(const Glib::RefPtr& context); + + virtual void on_item_drag_begin(const Glib::RefPtr& context, CItem *); + virtual void on_item_drag_data_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time); + + virtual void on_item_drop_drag_received(const Glib::RefPtr& context, int x, int y, GtkSelectionData* selection_data, guint info, guint time); +}; +#endif diff --git a/Constructor/ico_canio.png b/Constructor/ico_canio.png new file mode 100644 index 0000000..fb6f83d Binary files /dev/null and b/Constructor/ico_canio.png differ diff --git a/Constructor/ico_codo.png b/Constructor/ico_codo.png new file mode 100644 index 0000000..3a25c2b Binary files /dev/null and b/Constructor/ico_codo.png differ diff --git a/Constructor/ico_y.png b/Constructor/ico_y.png new file mode 100644 index 0000000..1fad922 Binary files /dev/null and b/Constructor/ico_y.png differ diff --git a/Constructor/item.cpp b/Constructor/item.cpp new file mode 100644 index 0000000..72106e2 --- /dev/null +++ b/Constructor/item.cpp @@ -0,0 +1,30 @@ + + +#include "item.h" +#include + +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() +{ +} + +CItem::~CItem() +{ +} + +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); + + // 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; +} diff --git a/Constructor/item.h b/Constructor/item.h new file mode 100644 index 0000000..01b8f87 --- /dev/null +++ b/Constructor/item.h @@ -0,0 +1,21 @@ + + +#ifndef GTKMM_EXAMPLE_DRAWINGAREALINES_H +#define GTKMM_EXAMPLE_DRAWINGAREALINES_H + +#include +#include + +//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); + Glib::RefPtr get_image() { return image; } +protected: + Glib::RefPtr image; +}; + +#endif //GTKMM_EXAMPLE_DRAWINGAREALINES_H diff --git a/Constructor/item_canio.png b/Constructor/item_canio.png new file mode 100644 index 0000000..96d6972 Binary files /dev/null and b/Constructor/item_canio.png differ diff --git a/Constructor/item_codo.png b/Constructor/item_codo.png new file mode 100644 index 0000000..5ea21e7 Binary files /dev/null and b/Constructor/item_codo.png differ diff --git a/Constructor/item_y.png b/Constructor/item_y.png new file mode 100644 index 0000000..13d84eb Binary files /dev/null and b/Constructor/item_y.png differ diff --git a/Constructor/main.cpp b/Constructor/main.cpp index 67c3ffc..715de7f 100644 --- a/Constructor/main.cpp +++ b/Constructor/main.cpp @@ -1,9 +1,9 @@ -// g++ -Wall -g `pkg-config --cflags --libs libglademm-2.0` -o ventana main.cc ventana.cc +// g++ -Wall -g `pkg-config --cflags --libs libglademm-2.0` -o ventana main.cpp #include #include #include -#include "ventana.h" +#include "constructor.h" int main (int argc, char **argv) { Gtk::Main kit(argc, argv); @@ -19,10 +19,9 @@ int main (int argc, char **argv) std::cerr << ex.what() << std::endl; return 1; } - - Ventana* pWindow = 0; - refXml->get_widget_derived("window1", pWindow); - pWindow->set_title("Una ventana posta"); - kit.run(*pWindow); + Constructor* pWindow = 0; + refXml->get_widget_derived("wnd_constructor", pWindow); + + kit.run(*pWindow); return 0; } diff --git a/Constructor/null.png b/Constructor/null.png new file mode 100644 index 0000000..b764134 Binary files /dev/null and b/Constructor/null.png differ diff --git a/Constructor/ventana.cpp b/Constructor/ventana.cpp deleted file mode 100644 index bebf3a8..0000000 --- a/Constructor/ventana.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//ventana.cpp -#include "ventana.h" -Ventana::Ventana(BaseObjectType* cobject, const Glib::RefPtr& refGlade): -Gtk::Window(cobject) -{ - refGlade->get_widget("button9", btn_salir); - refGlade->get_widget("fixed1", fixed); - refGlade->get_widget("button6",btn_dibujar); - btn_salir->signal_released().connect(SigC::slot(*this,&Ventana::on_btn_salir_pressed )); - btn_dibujar->signal_released().connect(SigC::slot(*this,&Ventana::on_btn_dibujar_released )); - //btn_dibujar->set_title("una N"); -} - -Ventana::~Ventana() -{ -} - -void Ventana::on_btn_salir_pressed() -{ - Gtk::Main::quit(); -} - -void Ventana::on_btn_dibujar_released() -{ - //quiero dibujar en el fixed - // como lo obtengo?? - Glib::RefPtr win = get_window(); - Glib::RefPtr gc = get_style()->get_black_gc(); - win->draw_line(gc,50,50, 50,100); - win->draw_line(gc,50,50, 80, 100); - win->draw_line (gc,80,100, 80,50); - - win->draw_line (gc,90,50, 90,100); - - win->draw_line (gc,100,50, 100,100); - win->draw_line (gc,100,50, 150,50); - win->draw_line (gc,100,100,150,100); - - win->draw_line (gc,160,50, 160,100); - win->draw_line (gc,160,50, 210,50); - win->draw_line (gc,160,100, 210,100); - win->draw_line (gc,210,50, 210,100); -} diff --git a/Constructor/ventana.h b/Constructor/ventana.h deleted file mode 100644 index df64078..0000000 --- a/Constructor/ventana.h +++ /dev/null @@ -1,23 +0,0 @@ -//ventana.h -#ifndef _VENTANA_H_ -#define _VENTANA_H_ -#include -#include -#include -#include -#include -class Ventana: public Gtk::Window -{ - public: - Ventana(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - virtual ~Ventana(); - protected: - Gtk::Button* btn_salir; - Gtk::Button* btn_dibujar; - Gtk::Fixed* fixed; - virtual void on_btn_salir_pressed(); - virtual void on_btn_dibujar_released(); - -}; - -#endif diff --git a/Constructor/workplace.cpp b/Constructor/workplace.cpp new file mode 100644 index 0000000..f3874e3 --- /dev/null +++ b/Constructor/workplace.cpp @@ -0,0 +1,22 @@ + + +#include "workplace.h" +#include "item.h" +WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr &refGlade):Gtk::Fixed(cobject) +{ + +} + +bool WorkPlace::on_expose_event(GdkEventExpose *e) +{ + int x, y; + for(x=0; xdraw_point (get_style()->get_black_gc(), x,y); + get_window()->draw_point (get_style()->get_black_gc(), x,y+1); + get_window()->draw_point (get_style()->get_black_gc(), x,y-1); + get_window()->draw_point (get_style()->get_black_gc(), x+1,y); + get_window()->draw_point (get_style()->get_black_gc(), x-1,y); + } + return true; +} diff --git a/Constructor/workplace.h b/Constructor/workplace.h new file mode 100644 index 0000000..8a26e1d --- /dev/null +++ b/Constructor/workplace.h @@ -0,0 +1,17 @@ + +#ifndef _H_WORKPLACE_ +#define _H_WORKPLACE_ + +#include +#include +#include +#include + +class WorkPlace:public Gtk::Fixed { +public: + WorkPlace(BaseObjectType* cobject, const Glib::RefPtr &refGlade); + virtual ~WorkPlace() {} + virtual bool on_expose_event(GdkEventExpose *); +}; + +#endif diff --git a/Constructor/y.cpp b/Constructor/y.cpp new file mode 100644 index 0000000..3d84582 --- /dev/null +++ b/Constructor/y.cpp @@ -0,0 +1,42 @@ +#include "y.h" + +Y::Y() +{ + imageN = Gdk::Pixbuf::create_from_file("y_n.png"); + imageS = Gdk::Pixbuf::create_from_file("y_s.png"); + imageE = Gdk::Pixbuf::create_from_file("y_e.png"); + imageO = Gdk::Pixbuf::create_from_file("y_o.png"); + null = Gdk::Pixbuf::create_from_file("null.png"); + imgActual = 0; + image = imageN; + set_size_request(image->get_width(), image->get_height()); +} + +Y::~Y() +{ +} + +bool Y::on_button_press_event(GdkEventButton *event) +{ + if (event->type == GDK_2BUTTON_PRESS){ + image = null; //como hago para actualizar????? + 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++; + switch (imgActual) { + case 1: + image = imageE; + break; + case 2: + image = imageS; + break; + case 3: + image = imageO; + break; + default: + imgActual = 0; + image = imageN; + } + 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); + } + return true; +} diff --git a/Constructor/y.h b/Constructor/y.h new file mode 100644 index 0000000..9ce089f --- /dev/null +++ b/Constructor/y.h @@ -0,0 +1,21 @@ +// y.h +#ifndef _Y_H_ +#define _Y_H_ + +#include "item.h" + +class Y : public CItem { + public: + Y(); + virtual ~Y(); + virtual bool on_button_press_event(GdkEventButton *event); + private: + int imgActual; + + Glib::RefPtr imageN; // 0 + Glib::RefPtr imageS; // 1 + Glib::RefPtr imageE; // 2 + Glib::RefPtr imageO; // 3 + Glib::RefPtr null; +}; +#endif diff --git a/Constructor/y_e.png b/Constructor/y_e.png new file mode 100644 index 0000000..7bd7428 Binary files /dev/null and b/Constructor/y_e.png differ diff --git a/Constructor/y_n.png b/Constructor/y_n.png new file mode 100644 index 0000000..655ea0f Binary files /dev/null and b/Constructor/y_n.png differ diff --git a/Constructor/y_o.png b/Constructor/y_o.png new file mode 100644 index 0000000..b3fb719 Binary files /dev/null and b/Constructor/y_o.png differ diff --git a/Constructor/y_s.png b/Constructor/y_s.png new file mode 100644 index 0000000..62be04c Binary files /dev/null and b/Constructor/y_s.png differ