#include "item.h"
-#include <iostream>
+#include "workplace.h"
CItem::CItem(const char *filename):Gtk::DrawingArea()
{
CItem::CItem()
{
- menu_image.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU);
+ Glib::RefPtr<Gnome::Glade::Xml> ref;
+ ref = Gnome::Glade::Xml::create("constructor.glade", "item_pty_wnd");
+ ref->get_widget_derived("item_pty_wnd",property_wnd);
+ caudal_max = 0.0;
+ property_wnd->item = this;
+ menu_image_propiedades.set(Gtk::Stock::PREFERENCES, Gtk::ICON_SIZE_MENU);
+ menu_image_delete.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU);
+ menu_image_rotar.set(Gtk::Stock::REFRESH, Gtk::ICON_SIZE_MENU);
+ menu_image_linea.set(Gtk::Stock::CONVERT, 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::ImageMenuElem("Propiedades",menu_image_propiedades, SigC::slot(*this, &CItem::on_menu_popup_propiedades) ) );
+ menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Rotar", menu_image_rotar ,SigC::slot(*this, &CItem::on_menu_popup_rotar) ) );
+ menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Eliminar", menu_image_delete,SigC::slot(*this, &CItem::on_menu_popup_eliminar) ) ) ;
+ menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Conectar", menu_image_linea,SigC::slot(*this, &CItem::on_menu_popup_conectar) ) ) ;
menu_popup.accelerate(*this);
}
CItem::~CItem()
{
+ std::cout << "Item Die" << std::endl;
}
bool CItem::on_expose_event(GdkEventExpose* event)
return true;
}
-void CItem::on_menu_popup_generic()
+void CItem::on_menu_popup_propiedades()
{
- std::cout << "A popup menu item was selected." << std::endl;
+}
+
+void CItem::on_menu_popup_rotar()
+{
+}
+
+void CItem::on_menu_popup_eliminar()
+{
+ workplace->delete_item(ID);
+}
+
+void CItem::on_menu_popup_conectar()
+{
+}
+
+void CItem::set_position(int _x, int _y)
+{
+ this->x = _x;
+ this->y = _y;
+}
+
+void CItem::set_id(int _id)
+{
+ ID = _id;
+}
+
+void CItem::set_caudal(double _caudal)
+{
+ caudal_max = _caudal;
+}
+
+void CItem::set_name(Glib::ustring _name)
+{
+ name = _name;
+}
+
+void CItem::set_conector_in(int _in)
+{
+ conector_in = _in;
+}
+
+void CItem::set_conector_out(int _out)
+{
+ conector_out = _out;
+}
+
+int CItem::get_position_x()
+{
+ return x;
+}
+
+int CItem::get_position_y()
+{
+ return y;
+}
+
+int CItem::get_id()
+{
+ return ID;
+}
+
+double CItem::get_caudal()
+{
+ return caudal_max;
+}
+
+
+Glib::ustring CItem::get_name()
+{
+ return name;
+}
+
+int CItem::get_conector_in()
+{
+ return conector_in;
+}
+
+int CItem::get_conector_out()
+{
+ return conector_out;
+}
+
+int CItem::get_img_actual()
+{
+ return imgActual;
+}
+
+bool CItem::is_occupied_area(int _a, int _b)
+{
+ if ( ( _a >= x ) && ( _a < x+image->get_width()) && (_b >= y) && (_b < y+image->get_height()) )
+ return true;
+ else return false;
+}
+
+bool CItem::is_other_connection_area(int _a, int _b)
+{
+ std::list<CItem *>::iterator i = listaItems->begin();
+ while ( i != listaItems->end() ){
+ CItem *temp = *i;
+ if ( temp->is_connection_area(_a,_b) )
+ return true;
+ i++;
+ }
+ return false;
}