]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Constructor/src/item.cpp
-Se carga la lista de items al ir haciendo click sobre ellos
[z.facultad/75.42/plaqui.git] / Constructor / src / item.cpp
index b4bf5416138a5dd90b39fc44c92ed5cd47c22e7f..5f5ac1581b370f88a2265110deb405d44978258f 100644 (file)
@@ -4,10 +4,12 @@ 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()
@@ -36,9 +38,24 @@ CItem::~CItem()
        std::cout << "Item Die" << std::endl;
 }
 
+void CItem::on_realize()
+{
+       Gtk::DrawingArea::on_realize();
+       Glib::RefPtr<Gdk::Window> window = get_window();
+       gc = Gdk::GC::create(window);
+       
+       Glib::RefPtr<Gdk::Colormap> 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
@@ -172,3 +189,19 @@ void CItem::get_out_logic_connect_position(int& _a, int& _b)
 void CItem::update_logic_position()
 {
 }
+
+void CItem::draw_connectors()
+{
+       GdkEventExpose event;
+       if ( in_x != -1 ) {
+               CItem::on_expose_event(&event);
+               Glib::RefPtr<Gdk::Window> 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);
+       }
+}