indexing description: "[ A background consisting of a bitmap. The bitmap is repeated in x and y direction if necessary. ]" date: "$Date$" revision: "$Revision$" class EM_BITMAP_BACKGROUND inherit EM_BACKGROUND EM_SHARED_BITMAP_FACTORY export {NONE} all end EM_SHARED_ERROR_HANDLER export {NONE} all end create make_from_bitmap, make_from_file feature {NONE} -- Initialisation make_from_file (a_filename: STRING) is -- Initialise background with image denoted by `a_filename'. require a_filename_not_void: a_filename /= Void do Bitmap_factory.create_bitmap_from_image (a_filename) make_from_bitmap (Bitmap_factory.last_bitmap) ensure bitmap_created: bitmap /= Void end make_from_bitmap (a_bitmap: like bitmap) is -- Initialise background with image `a_bitmap'. require a_bitmap_not_void: a_bitmap /= Void do bitmap := a_bitmap ensure bitmap_set: bitmap = a_bitmap end feature -- Access bitmap: EM_BITMAP -- Bitmap that is drawn as background feature -- Element change set_bitmap (a_bitmap: like bitmap) is -- Set `bitmap' to `a_bitmap'. require a_bitmap_not_void: a_bitmap /= Void do bitmap := a_bitmap ensure bitmap_set: bitmap = a_bitmap end feature -- Drawing draw_on (a_widget: EM_WIDGET) is -- Draw background on `a_widget'. local current_x, current_y: INTEGER do from current_y := 0 variant a_widget.height + bitmap.height - current_y until current_y > a_widget.height loop from current_x := 0 variant a_widget.width + bitmap.width - current_x until current_x > a_widget.width loop a_widget.surface.blit_surface (bitmap, current_x, current_y) current_x := current_x + bitmap.width end current_y := current_y + bitmap.height end end invariant bitmap_not_void: bitmap /= Void end