]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Subo esto que compila pero se cuelga cuando soltas un item, y ademas no se como hacer...
authorNicolás Dimov <ndimov@gmail.com>
Thu, 23 Oct 2003 17:31:39 +0000 (17:31 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Thu, 23 Oct 2003 17:31:39 +0000 (17:31 +0000)
35 files changed:
Constructor/btn_salir.cpp [deleted file]
Constructor/btn_salir.h [deleted file]
Constructor/canio.cpp [new file with mode: 0644]
Constructor/canio.h [new file with mode: 0644]
Constructor/canio_n.png [new file with mode: 0644]
Constructor/canio_s.png [new file with mode: 0644]
Constructor/codo.cpp [new file with mode: 0644]
Constructor/codo.h [new file with mode: 0644]
Constructor/codo_e.png [new file with mode: 0644]
Constructor/codo_n.png [new file with mode: 0644]
Constructor/codo_o.png [new file with mode: 0644]
Constructor/codo_s.png [new file with mode: 0644]
Constructor/constructor.cpp [new file with mode: 0644]
Constructor/constructor.glade
Constructor/constructor.h [new file with mode: 0644]
Constructor/ico_canio.png [new file with mode: 0644]
Constructor/ico_codo.png [new file with mode: 0644]
Constructor/ico_y.png [new file with mode: 0644]
Constructor/item.cpp [new file with mode: 0644]
Constructor/item.h [new file with mode: 0644]
Constructor/item_canio.png [new file with mode: 0644]
Constructor/item_codo.png [new file with mode: 0644]
Constructor/item_y.png [new file with mode: 0644]
Constructor/main.cpp
Constructor/null.png [new file with mode: 0644]
Constructor/ventana.cpp [deleted file]
Constructor/ventana.h [deleted file]
Constructor/workplace.cpp [new file with mode: 0644]
Constructor/workplace.h [new file with mode: 0644]
Constructor/y.cpp [new file with mode: 0644]
Constructor/y.h [new file with mode: 0644]
Constructor/y_e.png [new file with mode: 0644]
Constructor/y_n.png [new file with mode: 0644]
Constructor/y_o.png [new file with mode: 0644]
Constructor/y_s.png [new file with mode: 0644]

diff --git a/Constructor/btn_salir.cpp b/Constructor/btn_salir.cpp
deleted file mode 100644 (file)
index 87a850b..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-//btn_salir.cpp
-#include "btn_salir.h"
-BtnSalir::BtnSalir(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& 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 (file)
index 6717254..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef BTN_SALIR_H
-#define BTN_SALIR_H
-#include <gtkmm.h>
-#include <gtkmm/button.h>
-#include <libglademm.h>
-class BtnSalir : public Gtk::Button{
-public: 
-               BtnSalir(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
-               virtual ~BtnSalir();
-protected:
-               virtual void on_pressed();
-};
-
-#endif
diff --git a/Constructor/canio.cpp b/Constructor/canio.cpp
new file mode 100644 (file)
index 0000000..387ce31
--- /dev/null
@@ -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 (file)
index 0000000..b014b5d
--- /dev/null
@@ -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<Gdk::Pixbuf> imageN; // 0 
+               Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
+               Glib::RefPtr<Gdk::Pixbuf> null; 
+};
+#endif
diff --git a/Constructor/canio_n.png b/Constructor/canio_n.png
new file mode 100644 (file)
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 (file)
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 (file)
index 0000000..baa3aaa
--- /dev/null
@@ -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 (file)
index 0000000..edbed25
--- /dev/null
@@ -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<Gdk::Pixbuf> imageN; // 0 
+               Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
+               Glib::RefPtr<Gdk::Pixbuf> imageE; // 2
+               Glib::RefPtr<Gdk::Pixbuf> imageO; // 3
+               Glib::RefPtr<Gdk::Pixbuf> null; 
+};
+#endif
diff --git a/Constructor/codo_e.png b/Constructor/codo_e.png
new file mode 100644 (file)
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 (file)
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 (file)
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 (file)
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 (file)
index 0000000..094ff23
--- /dev/null
@@ -0,0 +1,136 @@
+//constructor.cpp
+
+#include "constructor.h"
+
+Constructor::Constructor(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& 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<Gdk::DragContext>& 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<Gdk::DragContext>& 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<Gdk::DragContext>& 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<Gdk::DragContext>& context)
+{
+       context->set_icon(ico_canio, 5, 5); 
+}
+
+void Constructor::on_y_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+       context->set_icon(ico_y, 5, 5); 
+}
+
+void Constructor::on_codo_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context)
+{
+       context->set_icon(ico_codo, 5, 5); 
+}
+       
+void Constructor::on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, CItem *item)
+{
+       context->set_icon(item->get_image(), 5, 5);
+}
+
+void Constructor::on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& 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<Gdk::DragContext>& 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);
+}
index 909386b0967214f8067987791e3221ee2580c5a5..d6cdbf0c965d2a0e97b444d86290af7bcf89c59c 100644 (file)
@@ -3,7 +3,7 @@
 
 <glade-interface>
 
-<widget class="GtkWindow" id="window1">
+<widget class="GtkWindow" id="wnd_constructor">
   <property name="width_request">640</property>
   <property name="height_request">480</property>
   <property name="visible">True</property>
@@ -29,7 +29,7 @@
          <property name="yscale">1</property>
 
          <child>
-           <widget class="GtkMenuBar" id="menubar1">
+           <widget class="GtkMenuBar" id="menu">
              <property name="visible">True</property>
 
              <child>
@@ -39,7 +39,7 @@
                  <property name="use_underline">True</property>
 
                  <child>
-                   <widget class="GtkMenu" id="menu1">
+                   <widget class="GtkMenu" id="menuitem1_menu">
 
                      <child>
                        <widget class="GtkImageMenuItem" id="new1">
@@ -78,7 +78,7 @@
                      </child>
 
                      <child>
-                       <widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
+                       <widget class="GtkMenuItem" id="separatormenuitem1">
                          <property name="visible">True</property>
                        </widget>
                      </child>
                  <property name="use_underline">True</property>
 
                  <child>
-                   <widget class="GtkMenu" id="menu2">
+                   <widget class="GtkMenu" id="menuitem2_menu">
 
                      <child>
                        <widget class="GtkImageMenuItem" id="copy1">
                </widget>
              </child>
 
-             <child>
-               <widget class="GtkMenuItem" id="menuitem3">
-                 <property name="visible">True</property>
-                 <property name="label" translatable="yes">_View</property>
-                 <property name="use_underline">True</property>
-
-                 <child>
-                   <widget class="GtkMenu" id="menu3">
-                   </widget>
-                 </child>
-               </widget>
-             </child>
-
              <child>
                <widget class="GtkMenuItem" id="menuitem4">
                  <property name="visible">True</property>
                  <property name="use_underline">True</property>
 
                  <child>
-                   <widget class="GtkMenu" id="menu4">
+                   <widget class="GtkMenu" id="menuitem4_menu">
 
                      <child>
                        <widget class="GtkMenuItem" id="about1">
 
                  <child>
                    <widget class="GtkVButtonBox" id="vbuttonbox1">
-                     <property name="height_request">1</property>
                      <property name="visible">True</property>
                      <property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
                      <property name="spacing">0</property>
 
                      <child>
-                       <widget class="GtkButton" id="button6">
+                       <widget class="GtkButton" id="btn_canio">
+                         <property name="width_request">69</property>
+                         <property name="height_request">80</property>
                          <property name="visible">True</property>
                          <property name="can_default">True</property>
                          <property name="can_focus">True</property>
-                         <property name="label" translatable="yes">button6</property>
-                         <property name="use_underline">True</property>
                          <property name="relief">GTK_RELIEF_NORMAL</property>
+
+                         <child>
+                           <widget class="GtkAlignment" id="alignment6">
+                             <property name="visible">True</property>
+                             <property name="xalign">0.5</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xscale">0</property>
+                             <property name="yscale">0</property>
+
+                             <child>
+                               <widget class="GtkHBox" id="hbox5">
+                                 <property name="visible">True</property>
+                                 <property name="homogeneous">False</property>
+                                 <property name="spacing">2</property>
+
+                                 <child>
+                                   <widget class="GtkImage" id="image4">
+                                     <property name="visible">True</property>
+                                     <property name="pixbuf">ico_canio.png</property>
+                                     <property name="xalign">0.5</property>
+                                     <property name="yalign">0.5</property>
+                                     <property name="xpad">0</property>
+                                     <property name="ypad">0</property>
+                                   </widget>
+                                   <packing>
+                                     <property name="padding">0</property>
+                                     <property name="expand">False</property>
+                                     <property name="fill">False</property>
+                                   </packing>
+                                 </child>
+
+                                 <child>
+                                   <widget class="GtkLabel" id="label7">
+                                     <property name="visible">True</property>
+                                     <property name="label" translatable="yes">Canio</property>
+                                     <property name="use_underline">True</property>
+                                     <property name="use_markup">False</property>
+                                     <property name="justify">GTK_JUSTIFY_LEFT</property>
+                                     <property name="wrap">False</property>
+                                     <property name="selectable">False</property>
+                                     <property name="xalign">0.5</property>
+                                     <property name="yalign">0.5</property>
+                                     <property name="xpad">0</property>
+                                     <property name="ypad">0</property>
+                                   </widget>
+                                   <packing>
+                                     <property name="padding">0</property>
+                                     <property name="expand">False</property>
+                                     <property name="fill">False</property>
+                                   </packing>
+                                 </child>
+                               </widget>
+                             </child>
+                           </widget>
+                         </child>
                        </widget>
                      </child>
 
                      <child>
-                       <widget class="GtkButton" id="button7">
+                       <widget class="GtkButton" id="btn_codo">
                          <property name="visible">True</property>
                          <property name="can_default">True</property>
                          <property name="can_focus">True</property>
-                         <property name="label" translatable="yes">button7</property>
-                         <property name="use_underline">True</property>
                          <property name="relief">GTK_RELIEF_NORMAL</property>
+
+                         <child>
+                           <widget class="GtkAlignment" id="alignment7">
+                             <property name="visible">True</property>
+                             <property name="xalign">0.5</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xscale">0</property>
+                             <property name="yscale">0</property>
+
+                             <child>
+                               <widget class="GtkHBox" id="hbox6">
+                                 <property name="visible">True</property>
+                                 <property name="homogeneous">False</property>
+                                 <property name="spacing">2</property>
+
+                                 <child>
+                                   <widget class="GtkImage" id="image5">
+                                     <property name="visible">True</property>
+                                     <property name="pixbuf">ico_codo.png</property>
+                                     <property name="xalign">0.5</property>
+                                     <property name="yalign">0.5</property>
+                                     <property name="xpad">0</property>
+                                     <property name="ypad">0</property>
+                                   </widget>
+                                   <packing>
+                                     <property name="padding">0</property>
+                                     <property name="expand">False</property>
+                                     <property name="fill">False</property>
+                                   </packing>
+                                 </child>
+
+                                 <child>
+                                   <widget class="GtkLabel" id="label8">
+                                     <property name="visible">True</property>
+                                     <property name="label" translatable="yes">Codo</property>
+                                     <property name="use_underline">True</property>
+                                     <property name="use_markup">False</property>
+                                     <property name="justify">GTK_JUSTIFY_LEFT</property>
+                                     <property name="wrap">False</property>
+                                     <property name="selectable">False</property>
+                                     <property name="xalign">0.5</property>
+                                     <property name="yalign">0.5</property>
+                                     <property name="xpad">0</property>
+                                     <property name="ypad">0</property>
+                                   </widget>
+                                   <packing>
+                                     <property name="padding">0</property>
+                                     <property name="expand">False</property>
+                                     <property name="fill">False</property>
+                                   </packing>
+                                 </child>
+                               </widget>
+                             </child>
+                           </widget>
+                         </child>
                        </widget>
                      </child>
 
                      <child>
-                       <widget class="GtkButton" id="button8">
+                       <widget class="GtkButton" id="btn_y">
                          <property name="visible">True</property>
                          <property name="can_default">True</property>
                          <property name="can_focus">True</property>
-                         <property name="label" translatable="yes">button8</property>
-                         <property name="use_underline">True</property>
                          <property name="relief">GTK_RELIEF_NORMAL</property>
+
+                         <child>
+                           <widget class="GtkAlignment" id="alignment8">
+                             <property name="visible">True</property>
+                             <property name="xalign">0.5</property>
+                             <property name="yalign">0.5</property>
+                             <property name="xscale">0</property>
+                             <property name="yscale">0</property>
+
+                             <child>
+                               <widget class="GtkHBox" id="hbox7">
+                                 <property name="visible">True</property>
+                                 <property name="homogeneous">False</property>
+                                 <property name="spacing">2</property>
+
+                                 <child>
+                                   <widget class="GtkImage" id="image6">
+                                     <property name="visible">True</property>
+                                     <property name="pixbuf">ico_y.png</property>
+                                     <property name="xalign">0.5</property>
+                                     <property name="yalign">0.5</property>
+                                     <property name="xpad">0</property>
+                                     <property name="ypad">0</property>
+                                   </widget>
+                                   <packing>
+                                     <property name="padding">0</property>
+                                     <property name="expand">False</property>
+                                     <property name="fill">False</property>
+                                   </packing>
+                                 </child>
+
+                                 <child>
+                                   <widget class="GtkLabel" id="label9">
+                                     <property name="visible">True</property>
+                                     <property name="label" translatable="yes">Division
+Empalme</property>
+                                     <property name="use_underline">True</property>
+                                     <property name="use_markup">False</property>
+                                     <property name="justify">GTK_JUSTIFY_LEFT</property>
+                                     <property name="wrap">False</property>
+                                     <property name="selectable">False</property>
+                                     <property name="xalign">0.5</property>
+                                     <property name="yalign">0.5</property>
+                                     <property name="xpad">0</property>
+                                     <property name="ypad">0</property>
+                                   </widget>
+                                   <packing>
+                                     <property name="padding">0</property>
+                                     <property name="expand">False</property>
+                                     <property name="fill">False</property>
+                                   </packing>
+                                 </child>
+                               </widget>
+                             </child>
+                           </widget>
+                         </child>
                        </widget>
                      </child>
                    </widget>
                <widget class="GtkScrolledWindow" id="scrolledwindow1">
                  <property name="visible">True</property>
                  <property name="can_focus">True</property>
-                 <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
-                 <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+                 <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                 <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
                  <property name="shadow_type">GTK_SHADOW_NONE</property>
                  <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
 
                      <property name="shadow_type">GTK_SHADOW_IN</property>
 
                      <child>
-                       <widget class="GtkFixed" id="fixed1">
+                       <widget class="GtkFixed" id="workplace">
                          <property name="visible">True</property>
-
-                         <child>
-                           <widget class="GtkButton" id="button9">
-                             <property name="width_request">53</property>
-                             <property name="height_request">27</property>
-                             <property name="visible">True</property>
-                             <property name="can_focus">True</property>
-                             <property name="label" translatable="yes">button9</property>
-                             <property name="use_underline">True</property>
-                             <property name="relief">GTK_RELIEF_NORMAL</property>
-                           </widget>
-                           <packing>
-                             <property name="x">464</property>
-                             <property name="y">8</property>
-                           </packing>
-                         </child>
                        </widget>
                      </child>
                    </widget>
   </child>
 </widget>
 
+<widget class="GtkDialog" id="dialog1">
+  <property name="width_request">271</property>
+  <property name="height_request">194</property>
+  <property name="title" translatable="yes">Propiedades</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_CENTER</property>
+  <property name="modal">False</property>
+  <property name="resizable">False</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox1">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+       <widget class="GtkHButtonBox" id="dialog-action_area1">
+         <property name="visible">True</property>
+         <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+         <child>
+           <widget class="GtkButton" id="cancelbutton1">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-cancel</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="response_id">-6</property>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkButton" id="okbutton1">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-ok</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="response_id">-5</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkFixed" id="fixed2">
+         <property name="visible">True</property>
+
+         <child>
+           <widget class="GtkSpinButton" id="spinbutton1">
+             <property name="width_request">46</property>
+             <property name="height_request">25</property>
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="climb_rate">1</property>
+             <property name="digits">0</property>
+             <property name="numeric">False</property>
+             <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+             <property name="snap_to_ticks">False</property>
+             <property name="wrap">False</property>
+             <property name="adjustment">1 0 100 1 10 10</property>
+           </widget>
+           <packing>
+             <property name="x">168</property>
+             <property name="y">16</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkSpinButton" id="spinbutton2">
+             <property name="width_request">48</property>
+             <property name="height_request">24</property>
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="climb_rate">1</property>
+             <property name="digits">0</property>
+             <property name="numeric">False</property>
+             <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+             <property name="snap_to_ticks">False</property>
+             <property name="wrap">False</property>
+             <property name="adjustment">1 0 100 1 10 10</property>
+           </widget>
+           <packing>
+             <property name="x">168</property>
+             <property name="y">56</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkSpinButton" id="spinbutton3">
+             <property name="width_request">48</property>
+             <property name="height_request">24</property>
+             <property name="visible">True</property>
+             <property name="can_focus">True</property>
+             <property name="climb_rate">1</property>
+             <property name="digits">0</property>
+             <property name="numeric">False</property>
+             <property name="update_policy">GTK_UPDATE_ALWAYS</property>
+             <property name="snap_to_ticks">False</property>
+             <property name="wrap">False</property>
+             <property name="adjustment">1 0 100 1 10 10</property>
+           </widget>
+           <packing>
+             <property name="x">168</property>
+             <property name="y">96</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="lb_max_fluid">
+             <property name="width_request">104</property>
+             <property name="height_request">24</property>
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">Fluido Máximo</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">False</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+           </widget>
+           <packing>
+             <property name="x">32</property>
+             <property name="y">16</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="lb_min_flui">
+             <property name="width_request">120</property>
+             <property name="height_request">24</property>
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">Fluido Mínimo</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">False</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+           </widget>
+           <packing>
+             <property name="x">24</property>
+             <property name="y">56</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="label3">
+             <property name="width_request">96</property>
+             <property name="height_request">24</property>
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">otra cosa</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">False</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+           </widget>
+           <packing>
+             <property name="x">32</property>
+             <property name="y">96</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
diff --git a/Constructor/constructor.h b/Constructor/constructor.h
new file mode 100644 (file)
index 0000000..b19281b
--- /dev/null
@@ -0,0 +1,48 @@
+// ventana principal
+#ifndef  _CONSTRUCTOR_H_
+#define _CONSTRUCTOR_H_
+
+#include <libglademm.h>
+#include <gtkmm.h>
+#include <gtkmm/window.h>
+#include <gtkmm/box.h>
+#include <gtkmm/button.h>
+#include <gtkmm/fixed.h>
+#include <gtkmm/scrolledwindow.h>
+#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<Gnome::Glade::Xml>& refGlade);
+               virtual ~Constructor();
+       protected: 
+               // / defino los elementos de la ventana.
+       Gtk::Button *btn_canio, *btn_codo, *btn_y;
+       WorkPlace *workplace;
+       Glib::RefPtr<Gdk::Pixbuf> ico_canio, ico_y, ico_codo;
+       std::list<Gtk::TargetEntry> listTargets;
+       Glib::RefPtr<Gdk::Pixbuf> ico_last;
+       std::list<CItem *> listaItems;
+       
+       // /señales de control para los elementos de la ventana.
+               
+       virtual void on_btn_canio_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
+       virtual void on_btn_y_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
+       virtual void on_btn_codo_drag_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
+
+       // señales para cambiar el icono.
+       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);
+       
+       virtual void on_item_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context, CItem *);
+       virtual void on_item_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, GtkSelectionData* selection_data, guint info, guint time);
+
+       virtual void on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext>& 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 (file)
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 (file)
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 (file)
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 (file)
index 0000000..72106e2
--- /dev/null
@@ -0,0 +1,30 @@
+
+
+#include "item.h"
+#include <iostream>
+
+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 (file)
index 0000000..01b8f87
--- /dev/null
@@ -0,0 +1,21 @@
+
+
+#ifndef GTKMM_EXAMPLE_DRAWINGAREALINES_H
+#define GTKMM_EXAMPLE_DRAWINGAREALINES_H
+
+#include <gtkmm/drawingarea.h>
+#include <gdkmm.h>
+
+//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<Gdk::Pixbuf> get_image() { return image; }
+protected:
+       Glib::RefPtr<Gdk::Pixbuf> image;
+};
+
+#endif //GTKMM_EXAMPLE_DRAWINGAREALINES_H
diff --git a/Constructor/item_canio.png b/Constructor/item_canio.png
new file mode 100644 (file)
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 (file)
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 (file)
index 0000000..13d84eb
Binary files /dev/null and b/Constructor/item_y.png differ
index 67c3ffce2f18dcd88251e880ce12d091fd7c79f8..715de7fe41fa868b5c32a19e9f2a10307837bc53 100644 (file)
@@ -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 <iostream>
 #include <libglademm.h>
 #include <gtkmm.h>
-#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 (file)
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 (file)
index bebf3a8..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-//ventana.cpp
-#include "ventana.h"
-Ventana::Ventana(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& 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<Gdk::Window> win = get_window();
-       Glib::RefPtr<Gdk::GC> 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 (file)
index df64078..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-//ventana.h
-#ifndef _VENTANA_H_
-#define _VENTANA_H_
-#include <gtkmm.h>
-#include <libglademm.h>
-#include <gtkmm/window.h>
-#include <gtkmm/button.h>
-#include <gtkmm/fixed.h>
-class Ventana: public Gtk::Window
-{
-       public: 
-                       Ventana(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& 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 (file)
index 0000000..f3874e3
--- /dev/null
@@ -0,0 +1,22 @@
+
+
+#include "workplace.h"
+#include "item.h"
+WorkPlace::WorkPlace( BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade):Gtk::Fixed(cobject)
+{
+       
+}
+
+bool WorkPlace::on_expose_event(GdkEventExpose *e)
+{
+       int x, y;
+       for(x=0; x<get_width(); x+=32) 
+               for (y=0; y<get_height();y+=32){
+                       get_window()->draw_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 (file)
index 0000000..8a26e1d
--- /dev/null
@@ -0,0 +1,17 @@
+
+#ifndef _H_WORKPLACE_
+#define _H_WORKPLACE_
+
+#include <gtkmm/fixed.h>
+#include <gdkmm/gc.h>
+#include <gtkmm.h>
+#include <libglademm.h>
+
+class WorkPlace:public Gtk::Fixed {
+public:
+       WorkPlace(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml> &refGlade);
+       virtual ~WorkPlace() {}
+       virtual bool on_expose_event(GdkEventExpose *);
+};
+
+#endif
diff --git a/Constructor/y.cpp b/Constructor/y.cpp
new file mode 100644 (file)
index 0000000..3d84582
--- /dev/null
@@ -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 (file)
index 0000000..9ce089f
--- /dev/null
@@ -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<Gdk::Pixbuf> imageN; // 0 
+               Glib::RefPtr<Gdk::Pixbuf> imageS; // 1
+               Glib::RefPtr<Gdk::Pixbuf> imageE; // 2
+               Glib::RefPtr<Gdk::Pixbuf> imageO; // 3
+               Glib::RefPtr<Gdk::Pixbuf> null; 
+};
+#endif
diff --git a/Constructor/y_e.png b/Constructor/y_e.png
new file mode 100644 (file)
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 (file)
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 (file)
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 (file)
index 0000000..62be04c
Binary files /dev/null and b/Constructor/y_s.png differ