--- /dev/null
+#include "cistern.h"
+
+Cistern::Cistern()
+{
+ imageE = Gdk::Pixbuf::create_from_file("tanque_e.png");
+ imageO = Gdk::Pixbuf::create_from_file("tanque_o.png");
+ null = Gdk::Pixbuf::create_from_file("null.png");
+ imgActual = 0;
+ image = imageE;
+ set_size_request(image->get_width(), image->get_height());
+}
+
+Cistern::~Cistern()
+{
+}
+
+bool Cistern::on_button_press_event(GdkEventButton *event)
+{
+ int w, h;
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
+ image = null;
+ 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 = imageO;
+ break;
+ default:
+ imgActual = 0;
+ image = imageE;
+ }
+ get_size_request(w, h);
+ set_size_request(h, w);
+ 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);
+ }
+ if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
+ menu_popup.popup(event->button, event->time);
+ return true; //It has been handled.
+ }
+ return true;
+}
+
+void Cistern::on_menu_popup_rotar()
+{
+ GdkEventButton event;
+ event.type = GDK_BUTTON_PRESS;
+ event.button = 2;
+ Cistern::on_button_press_event(&event);
+}
--- /dev/null
+// cistern.h
+#ifndef _CISTERN_H_
+#define _CISTERN_H_
+
+#include "item.h"
+
+class Cistern : public CItem {
+ public:
+ Cistern();
+ virtual ~Cistern();
+ virtual bool on_button_press_event(GdkEventButton *event);
+ virtual void on_menu_popup_rotar();
+ private:
+ int imgActual;
+
+ Glib::RefPtr<Gdk::Pixbuf> imageE; // 0
+ Glib::RefPtr<Gdk::Pixbuf> imageO; // 1
+ Glib::RefPtr<Gdk::Pixbuf> null;
+};
+#endif
-#include "canio.h"
+#include "conduct.h"
-Canio::Canio()
+Conduct::Conduct()
{
imageN = Gdk::Pixbuf::create_from_file("canio_n.png");
imageS = Gdk::Pixbuf::create_from_file("canio_s.png");
set_size_request(image->get_width(), image->get_height());
}
-Canio::~Canio()
+Conduct::~Conduct()
{
}
-bool Canio::on_button_press_event(GdkEventButton *event)
+bool Conduct::on_button_press_event(GdkEventButton *event)
{
int w, h;
if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
return true;
}
-void Canio::on_menu_popup_generic()
+void Conduct::on_menu_popup_rotar()
{
GdkEventButton event;
event.type = GDK_BUTTON_PRESS;
event.button = 2;
- Canio::on_button_press_event(&event);
+ Conduct::on_button_press_event(&event);
}
-// canio.h
-#ifndef _CANIO_H_
-#define _CANIO_H_
+// Conduct.h
+#ifndef _CONDUCT_H_
+#define _CONDUCT_H_
#include "item.h"
-class Canio : public CItem {
+class Conduct : public CItem {
public:
- Canio();
- virtual ~Canio();
+ Conduct();
+ virtual ~Conduct();
virtual bool on_button_press_event(GdkEventButton *event);
- virtual void on_menu_popup_generic();
+ virtual void on_menu_popup_rotar();
private:
int imgActual;
{
CItem *a;
if (strcmp((const char *)selection_data->data, "item_codo.png")==0)
- a = Gtk::manage( new Codo() );
+ a = Gtk::manage( new Splitter() );
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) );
- }
+ a = Gtk::manage( new Conduct() );
+ else if (strcmp((const char *)selection_data->data, "item_y.png")==0)
+ a = Gtk::manage( new Union() );
+ else if (strcmp((const char *)selection_data->data, "item_tanque.png")==0)
+ a = Gtk::manage( new Cistern() );
+ 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);
#include <gtkmm/scrolledwindow.h>
#include "workplace.h"
#include "item.h"
-#include "codo.h"
-#include "canio.h"
-#include "y.h"
-
+#include "splitter.h"
+#include "conduct.h"
+#include "union.h"
+#include "cistern.h"
class Constructor : public Gtk::Window {
public:
{
menu_image.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU);
Gtk::Menu::MenuList& menulist = menu_popup.items();
- menulist.push_back( Gtk::Menu_Helpers::MenuElem("Opcion", SigC::slot(*this, &CItem::on_menu_popup_generic) ) );
- menulist.push_back( Gtk::Menu_Helpers::MenuElem("Rotar", Gtk::Menu::AccelKey("<control>r"),SigC::slot(*this, &CItem::on_menu_popup_generic) ) );
- menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Eliminar", menu_image,SigC::slot(*this, &CItem::on_menu_popup_generic) ) ) ;
+ menulist.push_back( Gtk::Menu_Helpers::MenuElem("Opcion", SigC::slot(*this, &CItem::on_menu_popup_opcion) ) );
+ menulist.push_back( Gtk::Menu_Helpers::MenuElem("Rotar", Gtk::Menu::AccelKey("<control>r"),SigC::slot(*this, &CItem::on_menu_popup_rotar) ) );
+ menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Eliminar", menu_image,SigC::slot(*this, &CItem::on_menu_popup_eliminar) ) ) ;
menu_popup.accelerate(*this);
}
return true;
}
-void CItem::on_menu_popup_generic()
+void CItem::on_menu_popup_opcion()
+{
+}
+
+void CItem::on_menu_popup_rotar()
+{
+}
+
+void CItem::on_menu_popup_eliminar()
{
- std::cout << "A popup menu item was selected." << std::endl;
}
#include <gtkmm.h>
#include <gdkmm.h>
-
class CItem:public Gtk::DrawingArea {
public:
CItem();
CItem(const char *filename);
~CItem();
virtual bool on_expose_event(GdkEventExpose* event);
- virtual void on_menu_popup_generic();
+ virtual void on_menu_popup_opcion();
+ virtual void on_menu_popup_rotar();
+ virtual void on_menu_popup_eliminar();
Glib::RefPtr<Gdk::Pixbuf> get_image() { return image; }
protected:
Gtk::Menu menu_popup;
-#include "codo.h"
+#include "splitter.h"
-Codo::Codo()
+Splitter::Splitter()
{
imageN = Gdk::Pixbuf::create_from_file("codo_n.png");
imageS = Gdk::Pixbuf::create_from_file("codo_s.png");
set_size_request(image->get_width(), image->get_height());
}
-Codo::~Codo()
+Splitter::~Splitter()
{
}
-bool Codo::on_button_press_event(GdkEventButton *event)
+bool Splitter::on_button_press_event(GdkEventButton *event)
{
if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
image = null;
}
return true;
}
-void Codo::on_menu_popup_generic()
+void Splitter::on_menu_popup_rotar()
{
GdkEventButton event;
event.type = GDK_BUTTON_PRESS;
event.button = 2;
- Codo::on_button_press_event(&event);
+ Splitter::on_button_press_event(&event);
}
-// y.h
-#ifndef _Y_H_
-#define _Y_H_
+// Splitter.h
+#ifndef _SPLITTER_H_
+#define _SPLITTER_H_
#include "item.h"
-class Y : public CItem {
+class Splitter : public CItem {
public:
- Y();
- virtual ~Y();
+ Splitter();
+ virtual ~Splitter();
virtual bool on_button_press_event(GdkEventButton *event);
- virtual void on_menu_popup_generic();
+ virtual void on_menu_popup_rotar();
private:
int imgActual;
-#include "y.h"
+#include "union.h"
-Y::Y()
+Union::Union()
{
imageN = Gdk::Pixbuf::create_from_file("y_n.png");
imageS = Gdk::Pixbuf::create_from_file("y_s.png");
set_size_request(image->get_width(), image->get_height());
}
-Y::~Y()
+Union::~Union()
{
}
-bool Y::on_button_press_event(GdkEventButton *event)
+bool Union::on_button_press_event(GdkEventButton *event)
{
int w,h;
if ((event->type == GDK_BUTTON_PRESS) && (event->button == 2 )){
return true;
}
-void Y::on_menu_popup_generic()
+void Union::on_menu_popup_rotar()
{
GdkEventButton event;
event.type = GDK_BUTTON_PRESS;
event.button = 2;
- Y::on_button_press_event(&event);
+ Union::on_button_press_event(&event);
+}
+
+void Union::on_menu_popup_eliminar()
+{
}
-// codo.h
-#ifndef _CODO_H_
-#define _CODO_H_
+// Union.h
+#ifndef _UNION_H_
+#define _UNION_H_
#include "item.h"
-class Codo : public CItem {
+class Union : public CItem {
public:
- Codo();
- virtual ~Codo();
+ Union();
+ virtual ~Union();
virtual bool on_button_press_event(GdkEventButton *event);
- virtual void on_menu_popup_generic();
+ virtual void on_menu_popup_rotar();
+ virtual void on_menu_popup_eliminar();
private:
int imgActual;