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 int CItem::get_position_x()
88 int CItem::get_position_y()
98 double CItem::get_caudal()
104 Glib::ustring CItem::get_name()
109 Glib::ustring CItem::get_other_name(int _id)
111 std::list<CItem *>::iterator i = listaItems->begin();
112 std::cout << name << " " << _id << std::endl;
113 while ( i != listaItems->end() ) {
114 if ( (*i)->get_id() == _id )
115 return (*i)->get_name();
121 int CItem::get_img_actual()
126 void CItem::set_position(int _x, int _y)
132 void CItem::set_id(int _id)
137 void CItem::set_caudal(double _caudal)
139 caudal_max = _caudal;
142 void CItem::set_name(Glib::ustring _name)
147 void CItem::set_out_connected(bool _o)
151 void CItem::set_in_connected(bool _o)
155 bool CItem::is_occupied_area(int _a, int _b)
157 if ( ( _a >= x ) && ( _a < x+image->get_width()) && (_b >= y) && (_b < y+image->get_height()) )
162 ConnectorType CItem::is_other_connection_area(int _a, int _b, CItem **_item)
165 std::list<CItem *>::iterator i = listaItems->begin();
166 while ( i != listaItems->end() ) {
169 if ( (temp2 = temp->get_connector_type(_a,_b)) != UNDEF ) {
177 ConnectorType CItem::get_connector_type( int _a, int _b )
181 void CItem::set_default_connector()
185 void CItem::get_in_logic_connect_position(int& _a, int& _b)
191 void CItem::get_out_logic_connect_position(int& _a, int& _b)
197 bool CItem::get_out_logic_connect()
202 void CItem::update_logic_position()
206 void CItem::draw_connectors()
209 Glib::RefPtr<Gdk::Window> window = get_window();
211 gc->set_foreground(red);
212 gc->set_background(red);
213 window->draw_rectangle(gc, 1, in_x-5-x, in_y-y, 10, 10);
214 gc->set_foreground(blue);
215 gc->set_background(blue);
216 window->draw_rectangle(gc, 1, out_x-5-x, out_y-y-10, 10, 10);