indexing description: "[ Objects representing a memory surface (bitmaps). Bitmaps can also be drawn onto other surfaces (they conform to EM_DRAWABLE). Use EM_SHARED_BITMAP_FACTORY to create new bitmap objects. ]" date: "$Date$" revision: "$Revision$" class EM_BITMAP inherit EM_SURFACE EM_DRAWABLE redefine draw_part, publish_mouse_event end create {EM_BITMAP_FACTORY} make_from_pointer feature -- drawings draw (a_surface: EM_SURFACE) is -- Draw `Current' to `a_surface'. do if is_visible then a_surface.draw_bitmap (Current) end end draw_part (a_rect: EM_BLITTING_RECTANGLE; a_surface: EM_SURFACE) is -- Draws `a_rect' part of `Current' to `a_surface'. -- Use this feature to implement scrolling of `Current' over -- `a_surface'. -- -- Example: -- Your surface measures 10000 x 600 pixels but the screen only measures -- 800x600 pixels - then you can move `surface' across the -- screen like that: -- from x:=0 until x<10000-800 loop -- surface.draw_part(create {RECT}.make(x,0,800,600), screen) -- x := x + 1 -- end do if is_visible then src_rect_.make_from_coordinates (a_rect.x, a_rect.y, a_rect.x + a_rect.width, a_rect.y + a_rect.height) dst_rect_.make_from_coordinates (x, y, x + a_rect.width, y + a_rect.height) a_surface.draw_surface_part_stretched (Current, src_rect_, dst_rect_) end end feature {NONE} -- Implementation publish_mouse_event (a_mouse_event: EM_MOUSE_EVENT) is -- Publish mouse event when `a_mouse_event' occurred on `Current'. -- Only publishes mouse events, if according pixel -- is not transparent. local x_mouse: INTEGER y_mouse: INTEGER do -- Only publish mouse event when according pixel is not set to transparent -- and set mouse event `caught'. x_mouse := a_mouse_event.proportional_position.x.floor - x y_mouse := a_mouse_event.proportional_position.y.floor - y if x_mouse < width and x_mouse >= 0 and y_mouse < height and y_mouse >= 0 then if has_transparent_colorkey then lock if pixel_value (x_mouse, y_mouse) /= transparent_colorkey then dispatch_mouse_event (a_mouse_event) a_mouse_event.set_caught (True) end unlock else dispatch_mouse_event (a_mouse_event) a_mouse_event.set_caught (True) end end end end