3 bool CItem::logic_connect = false;
4 int CItem::gate_id = -1;
7 CItem::CItem(const char *filename)
9 image = Gdk::Pixbuf::create_from_file(filename);
10 set_size_request(image->get_width(), image->get_height());
12 add_events(Gdk::EXPOSURE_MASK);
17 Glib::RefPtr<Gnome::Glade::Xml> ref;
18 ref = Gnome::Glade::Xml::create(PACKAGE_DATA_DIR"/plaqui-constructor/dialogs/constructor.glade", "item_pty_wnd");
19 ref->get_widget_derived("item_pty_wnd",property_wnd);
24 property_wnd->item = this;
25 menu_image_propiedades.set(Gtk::Stock::PREFERENCES, Gtk::ICON_SIZE_MENU);
26 menu_image_delete.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU);
27 menu_image_rotar.set(Gtk::Stock::REFRESH, Gtk::ICON_SIZE_MENU);
28 menu_image_linea.set(Gtk::Stock::CONVERT, Gtk::ICON_SIZE_MENU);
29 menulist = menu_popup.items();
30 menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Propiedades",menu_image_propiedades, SigC::slot(*this, &CItem::on_menu_popup_propiedades) ) );
31 menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Rotar", menu_image_rotar ,SigC::slot(*this, &CItem::on_menu_popup_rotar) ) );
32 menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Eliminar", menu_image_delete,SigC::slot(*this, &CItem::on_menu_popup_eliminar) ) ) ;
33 menu_popup.accelerate(*this);
38 std::cout << "Item Die" << std::endl;
41 void CItem::on_realize()
43 Gtk::DrawingArea::on_realize();
44 Glib::RefPtr<Gdk::Window> window = get_window();
45 gc = Gdk::GC::create(window);
47 Glib::RefPtr<Gdk::Colormap> colormap = get_colormap();
49 red = Gdk::Color("red");
50 blue = Gdk::Color("blue");
52 colormap->alloc_color(red);
53 colormap->alloc_color(blue);
56 bool CItem::on_expose_event(GdkEventExpose* event)
58 get_window()->draw_pixbuf(gc, image, 0, 0, 0, 0, image->get_width() ,image->get_height(),
59 Gdk::RGB_DITHER_NONE, 0, 0);
61 // XXX Esto no deberia ser necesario! en todo caso devolves false en
62 // vez de true para que siga llamando a los otros handlers :)
63 //Gtk::DrawingArea::on_expose_event(event);
64 if (CItem::logic_connect) {
70 void CItem::on_menu_popup_propiedades()
74 void CItem::on_menu_popup_rotar()
78 void CItem::on_menu_popup_eliminar()
80 workplace->delete_item(ID);
83 void CItem::on_menu_popup_conectar()
87 int CItem::get_position_x()
92 int CItem::get_position_y()
102 double CItem::get_caudal()
108 Glib::ustring CItem::get_name()
113 Glib::ustring CItem::get_other_name(int _id)
115 std::list<CItem *>::iterator i = listaItems->begin();
116 std::cout << name << " " << _id << std::endl;
117 while ( i != listaItems->end() ) {
118 if ( (*i)->get_id() == _id )
119 return (*i)->get_name();
125 int CItem::get_img_actual()
130 void CItem::set_position(int _x, int _y)
136 void CItem::set_id(int _id)
141 void CItem::set_caudal(double _caudal)
143 caudal_max = _caudal;
146 void CItem::set_name(Glib::ustring _name)
151 void CItem::set_out_connected(bool _o)
155 void CItem::set_in_connected(bool _o)
159 bool CItem::is_occupied_area(int _a, int _b)
161 if ( ( _a >= x ) && ( _a < x+image->get_width()) && (_b >= y) && (_b < y+image->get_height()) )
166 ConnectorType CItem::is_other_connection_area(int _a, int _b, CItem **_item)
169 std::list<CItem *>::iterator i = listaItems->begin();
170 while ( i != listaItems->end() ) {
173 if ( (temp2 = temp->get_connector_type(_a,_b)) != UNDEF ) {
181 ConnectorType CItem::get_connector_type( int _a, int _b )
185 void CItem::set_default_connector()
189 void CItem::get_in_logic_connect_position(int& _a, int& _b)
195 void CItem::get_out_logic_connect_position(int& _a, int& _b)
201 bool CItem::get_out_logic_connect()
206 void CItem::update_logic_position()
210 void CItem::draw_connectors()
213 Glib::RefPtr<Gdk::Window> window = get_window();
215 gc->set_foreground(red);
216 gc->set_background(red);
217 window->draw_rectangle(gc, 1, in_x-5-x, in_y-y, 10, 10);
218 gc->set_foreground(blue);
219 gc->set_background(blue);
220 window->draw_rectangle(gc, 1, out_x-5-x, out_y-y-10, 10, 10);