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 (logic_connect && !is_logic) {
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 while ( i != listaItems->end() ) {
117 if ( (*i)->get_id() == _id )
118 return (*i)->get_name();
124 int CItem::get_img_actual()
129 void CItem::set_position(int _x, int _y)
135 void CItem::set_id(int _id)
140 void CItem::set_caudal(double _caudal)
142 caudal_max = _caudal;
145 void CItem::set_name(Glib::ustring _name)
150 bool CItem::is_occupied_area(int _a, int _b)
152 if ( ( _a >= x ) && ( _a < x+image->get_width()) && (_b >= y) && (_b < y+image->get_height()) )
157 ConnectorType CItem::is_other_connection_area(int _a, int _b, CItem **_item)
160 std::list<CItem *>::iterator i = listaItems->begin();
161 while ( i != listaItems->end() ) {
164 if ( (temp2 = temp->get_connector_type(_a,_b)) != UNDEF ) {
172 ConnectorType CItem::get_connector_type( int _a, int _b )
176 void CItem::set_default_connector()
180 void CItem::get_in_logic_connect_position(int& _a, int& _b)
186 void CItem::get_out_logic_connect_position(int& _a, int& _b)
192 void CItem::update_logic_position()
196 void CItem::draw_connectors()
199 Glib::RefPtr<Gdk::Window> window = get_window();
201 gc->set_foreground(red);
202 gc->set_background(red);
203 window->draw_rectangle(gc, 1, in_x-5-x, in_y-y, 10, 10);
204 gc->set_foreground(blue);
205 gc->set_background(blue);
206 window->draw_rectangle(gc, 1, out_x-5-x, out_y-y-10, 10, 10);