+++ /dev/null
-//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();
-}
+++ /dev/null
-#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
--- /dev/null
+#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;
+}
--- /dev/null
+// 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
--- /dev/null
+#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;
+}
--- /dev/null
+// 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
--- /dev/null
+//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);
+}
<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>
<property name="yscale">1</property>
<child>
- <widget class="GtkMenuBar" id="menubar1">
+ <widget class="GtkMenuBar" id="menu">
<property name="visible">True</property>
<child>
<property name="use_underline">True</property>
<child>
- <widget class="GtkMenu" id="menu1">
+ <widget class="GtkMenu" id="menuitem1_menu">
<child>
<widget class="GtkImageMenuItem" id="new1">
</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>
--- /dev/null
+// 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
--- /dev/null
+
+
+#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;
+}
--- /dev/null
+
+
+#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
-// 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);
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;
}
+++ /dev/null
-//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);
-}
+++ /dev/null
-//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
--- /dev/null
+
+
+#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;
+}
--- /dev/null
+
+#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
--- /dev/null
+#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;
+}
--- /dev/null
+// 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