/** * \brief Check that the userdata at the specified index is a drawable * object (surface, text surface of sprite) and returns it. * \param l a Lua context * \param index an index in the stack * \return The drawable. */ DrawablePtr LuaContext::check_drawable(lua_State* l, int index) { if (is_drawable(l, index)) { const ExportableToLuaPtr& userdata = *(static_cast<ExportableToLuaPtr*>( lua_touserdata(l, index) )); return std::static_pointer_cast<Drawable>(userdata); } else { LuaTools::type_error(l, index, "drawable"); throw; } }
bool GrBx::Area::on_motion_notify_event (GdkEventMotion *_motion) { bool ret = GrBx::Widget::on_motion_notify_event (_motion); if (_motion && window && is_drawable ()) { double width = get_width (), height = get_height (); const Glib::RefPtr<Gdk::GC> black_gc = get_style ()->get_black_gc (); if (pixbuf) window->draw_pixbuf (pixbuf, 0, 0, 0, 0, width, height, Gdk::RGB_DITHER_NONE, 0, 0); window->draw_line (black_gc, _motion->x, 0, _motion->x, height); window->draw_line (black_gc, 0, _motion->y, width, _motion->y); } return ret; }
/** * \brief Check that the userdata at the specified index is a drawable * object (surface, text surface of sprite) and returns it. * \param l a Lua context * \param index an index in the stack * \return the surface */ Drawable& LuaContext::check_drawable(lua_State* l, int index) { Drawable** drawable = NULL; if (is_drawable(l, index)) { drawable = static_cast<Drawable**>(lua_touserdata(l, index)); } else { luaL_typerror(l, index, "drawable"); } return **drawable; }
void GrBx::Area::draw_graphs () { if (window && is_drawable ()) { window->draw_rectangle (get_style ()->get_fg_gc (Gtk::STATE_NORMAL), true, 0, 0, get_width (), get_height ()); Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context (); Cairo::Matrix matrix (1, 0, 0, -1, - hadjustment.get_value (), get_height () + vadjustment.get_value ()); cr->transform (matrix); for (Graphs::iterator gitr = graphs.begin (); gitr != graphs.end (); ++gitr) if ((*gitr)->get_visible ()) (*gitr)->draw (cr, sx, sy); update_pixbuf (); } }