X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/60478d9e7985b9df7436c232301e124074948935..35080ef6d995a88668d59282a7b0d671ceb82a67:/Client/src/item_tank.cpp diff --git a/Client/src/item_tank.cpp b/Client/src/item_tank.cpp index b22b337..7f40997 100644 --- a/Client/src/item_tank.cpp +++ b/Client/src/item_tank.cpp @@ -7,11 +7,28 @@ ViewTank::ViewTank(Glib::ustring _name, int orientacion):ViewItem(_name) switch (orientacion) { case 0: image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/tanque_e.png"); + in_x = 5; + in_y = 16; + out_x = 64-16; + out_y = 64; + offset_x = 0; + offset_y = 0; + item_offset_x = 0; + item_offset_y = 0; break; case 1: image.set(PACKAGE_DATA_DIR"/plaqui-client/pixmaps/tanque_o.png"); + in_x = 64-5; + in_y = 16; + out_x = 16; + out_y = 64; + offset_x = 0; + offset_y = 0; + item_offset_x = 0; + item_offset_y = 0; } image.show(); + m_or = orientacion; set_size_request(); } @@ -28,3 +45,43 @@ std::string ViewTank::get_extra() return s; } +bool ViewTank::on_image_expose_event(GdkEventExpose *e) +{ + Glib::RefPtr colormap = Gtk::Widget::get_default_colormap(); + Gdk::Color negro = Gdk::Color("black"); + Gdk::Color blanco = Gdk::Color("white"); + colormap->alloc_color(negro); + colormap->alloc_color(blanco); + colormap->alloc_color(color); + gc->set_line_attributes(1, Gdk::LINE_SOLID, Gdk::CAP_NOT_LAST, Gdk::JOIN_MITER); + int w,h,x,y,h_offset,y_offset; + w = image.get_width(); + h = image.get_height(); + + if (actual_flow == 0) return true; + + switch (m_or) { + case 0: + x = 5; + break; + case 1: + x = w-w/2-5; + } + y = 15; + w = w/2; + h = h/2; + y_offset = static_cast(h*(1.0f-extra/actual_flow)); + h_offset = static_cast(h*(1.0f-extra/actual_flow)); + gc->set_foreground(negro); + gc->set_background(negro); + image.get_window()->draw_rectangle(gc, 1, x, y, w, h); + gc->set_foreground(color); + gc->set_background(color); + image.get_window()->draw_rectangle(gc, 1, x, y+y_offset, w, h-h_offset); + + /* Un borde para que se vea bien */ + gc->set_foreground(blanco); + gc->set_background(blanco); + image.get_window()->draw_rectangle(gc, 0, x-1, y-1, w+1, h+1); + return true; +}