X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/667418327423ba116d24751926a95a2f1235849c..fe35ed0badc6a1a01237027effb74b82acbdb9e5:/Constructor/src/item.cpp diff --git a/Constructor/src/item.cpp b/Constructor/src/item.cpp index de63b69..d3624db 100644 --- a/Constructor/src/item.cpp +++ b/Constructor/src/item.cpp @@ -1,13 +1,15 @@ #include "item.h" -bool CItem:: logic_connect = false; -int CItem::quien = -1; +bool CItem::logic_connect = false; +int CItem::gate_id = -1; -CItem::CItem(const char *filename):Gtk::DrawingArea() +CItem::CItem(const char *filename) { image = Gdk::Pixbuf::create_from_file(filename); set_size_request(image->get_width(), image->get_height()); + + add_events(Gdk::EXPOSURE_MASK); } CItem::CItem() @@ -15,7 +17,7 @@ CItem::CItem() Glib::RefPtr ref; ref = Gnome::Glade::Xml::create(PACKAGE_DATA_DIR"/plaqui-constructor/dialogs/constructor.glade", "item_pty_wnd"); ref->get_widget_derived("item_pty_wnd",property_wnd); - caudal_max = 0.0; + caudal_max = 10.0; is_union = true; is_connected = false; is_logic =false; @@ -36,14 +38,32 @@ CItem::~CItem() std::cout << "Item Die" << std::endl; } +void CItem::on_realize() +{ + Gtk::DrawingArea::on_realize(); + Glib::RefPtr window = get_window(); + gc = Gdk::GC::create(window); + + Glib::RefPtr colormap = get_colormap(); + + red = Gdk::Color("red"); + blue = Gdk::Color("blue"); + + colormap->alloc_color(red); + colormap->alloc_color(blue); +} + bool CItem::on_expose_event(GdkEventExpose* event) { - image->render_to_drawable ( get_window(), get_style()->get_black_gc(), 0, 0, 0, 0, image->get_width() ,image->get_height() , + get_window()->draw_pixbuf(gc, image, 0, 0, 0, 0, image->get_width() ,image->get_height(), Gdk::RGB_DITHER_NONE, 0, 0); // XXX Esto no deberia ser necesario! en todo caso devolves false en // vez de true para que siga llamando a los otros handlers :) //Gtk::DrawingArea::on_expose_event(event); + if (logic_connect && !is_logic) { + draw_connectors(); + } return true; } @@ -62,8 +82,6 @@ void CItem::on_menu_popup_eliminar() void CItem::on_menu_popup_conectar() { - CItem::logic_connect = true; - CItem::quien = ID; } int CItem::get_position_x() @@ -129,6 +147,14 @@ void CItem::set_name(Glib::ustring _name) name = _name; } +void CItem::set_out_connected(bool _o) +{ +} + +void CItem::set_in_connected(bool _o) +{ +} + bool CItem::is_occupied_area(int _a, int _b) { if ( ( _a >= x ) && ( _a < x+image->get_width()) && (_b >= y) && (_b < y+image->get_height()) ) @@ -158,3 +184,34 @@ ConnectorType CItem::get_connector_type( int _a, int _b ) void CItem::set_default_connector() { } + +void CItem::get_in_logic_connect_position(int& _a, int& _b) +{ + _a = x; + _b = y; +} + +void CItem::get_out_logic_connect_position(int& _a, int& _b) +{ + _a = x; + _b = y; +} + +void CItem::update_logic_position() +{ +} + +void CItem::draw_connectors() +{ + if ( in_x != -1 ) { + Glib::RefPtr window = get_window(); + + gc->set_foreground(red); + gc->set_background(red); + window->draw_rectangle(gc, 1, in_x-5-x, in_y-y, 10, 10); + gc->set_foreground(blue); + gc->set_background(blue); + window->draw_rectangle(gc, 1, out_x-5-x, out_y-y-10, 10, 10); + queue_draw(); + } +}