indexing description: "[ Objects representing a background frame which has a diagonal edge in one of the four corners. You can specify the frame and fill colors for both normal and mouse hoovering state, frame thickness and size of the diagonal edge. This class is part of the XAE Extended Adventure Engine Project. ]" author: "Ralph Wiedemeier, ralphw@student.ethz.ch" date: "$Date$" revision: "$Revision$" class GUI_SPECIAL_FRAME inherit GUI_CLICKABLE redefine make_from_position_and_size, make_from_rect, execute_event_action_hoover_in, execute_event_action_hoover_out end GUI_DRAWABLE undefine out end OPEN_GL_LIBRARY export {NONE} all undefine default_create, out end create make_from_position_and_size, make_from_rect feature -- Initialization make_from_rect (a_rect: EM_RECT) is -- create new special frame from specified rectangle do make_from_position_and_size (a_rect.x, a_rect.y, a_rect.width, a_rect.height) end make_from_position_and_size (an_x: INTEGER; an_y: INTEGER; a_width: INTEGER; a_height: INTEGER) is -- create new special frame with specified position and size do Precursor (an_x, an_y, a_width, a_height) set_special_corner_top_right set_special_corner_size (a_width // 8) set_border_thickness (2) set_border_color_normal (create {EM_COLOR}.make_with_rgb (192, 192, 192)) set_fill_color_normal (create {EM_COLOR}.make_with_rgb (32, 32, 32)) end feature -- Appearance set_special_corner_none is -- do not display a diagonal corner do corner_mode := mode_none end set_special_corner_top_left is -- the top left corner is fractured diagonally do corner_mode := mode_top_left end set_special_corner_top_right is -- the top right corner is fractured diagonally do corner_mode := mode_top_right end set_special_corner_bottom_left is -- the bottom left corner is fractured diagonally do corner_mode := mode_bottom_left end set_special_corner_bottom_right is -- the bottom right corner is fractured diagonally do corner_mode := mode_bottom_right end set_special_corner_size (a_size: INTEGER) is -- set size of the diagonal corner edge require corner_size_valid: a_size > 0 and a_size < width and a_size < height do corner_size := a_size end set_border_thickness (a_thickness: INTEGER) is -- set border thickness require border_thickness_valid: a_thickness >= 0 and a_thickness < 5 do border_thickness := a_thickness end set_border_color_normal (a_color: EM_COLOR) is -- set border color in normal state require border_color_valid: a_color /= Void do border_color_normal := a_color border_color := border_color_normal end border_color_normal: EM_COLOR set_border_color_hoover (a_color: EM_COLOR) is -- set border color when hoovered do border_color_hoover := a_color end border_color_hoover: EM_COLOR set_fill_color_normal (a_color: EM_COLOR) is -- set fill color in normal state require fill_color_valid: a_color /= Void do fill_color_normal := a_color fill_color := fill_color_normal end fill_color_normal: EM_COLOR set_fill_color_hoover (a_color: EM_COLOR) is -- set fill color when hoovered require fill_color_valid: a_color /= Void do fill_color_hoover := a_color end fill_color_hoover: EM_COLOR feature -- Representation draw (a_surface: EM_VIDEO_SURFACE) is -- draw representation of the special frame to 'a_surface' do draw_gl_shape end feature -- Event handling execute_event_action_hoover_in is -- do if border_color_hoover /= Void then border_color := border_color_hoover end if fill_color_hoover /= Void then fill_color := fill_color_hoover end Precursor end execute_event_action_hoover_out is -- do border_color := border_color_normal fill_color := fill_color_normal Precursor end feature {NONE} -- Implementation attributes corner_size: INTEGER corner_mode: INTEGER mode_none: INTEGER is 0 mode_top_left: INTEGER is 1 mode_top_right: INTEGER is 2 mode_bottom_left: INTEGER is 3 mode_bottom_right: INTEGER is 4 border_thickness: INTEGER border_color: EM_COLOR fill_color: EM_COLOR feature {NONE} -- Implementation routines draw_gl_shape is -- draw openGL composite of special frame do macro_disable_texture_mapping macro_enable_alpha_blending emgl_begin (EM_gl_polygon) emgl_color4f (fill_color.red / 255, fill_color.green / 255, fill_color.blue / 255, fill_color.alpha / 255) -- CHANGES -> x if corner_mode = mode_top_left then emgl_vertex2i (x, y + corner_size) emgl_vertex2i (x + corner_size, y) else emgl_vertex2i (x, y) end if corner_mode = mode_top_right then emgl_vertex2i (x + width - corner_size, y) emgl_vertex2i (x + width, y + corner_size) else emgl_vertex2i (x + width, y) end if corner_mode = mode_bottom_right then emgl_vertex2i (x + width, y + height - corner_size) emgl_vertex2i (x + width - corner_size, y + height) else emgl_vertex2i (x + width, y + height) end if corner_mode = mode_bottom_left then emgl_vertex2i (x + corner_size, y + height) emgl_vertex2i (x, y + height - corner_size) else emgl_vertex2i (x, y + height) end emgl_end if border_thickness > 0 then emgl_line_width (border_thickness) emgl_begin (EM_gl_lines) emgl_color4d (border_color.red / 255, border_color.green / 255, border_color.blue / 255, border_color.alpha / 255) if corner_mode = mode_top_left then emgl_vertex2i (x, y + corner_size) emgl_vertex2i (x + corner_size, y) emgl_vertex2i (x + corner_size, y) else emgl_vertex2i (x, y) end if corner_mode = mode_top_right then emgl_vertex2i (x + width - corner_size, y) emgl_vertex2i (x + width - corner_size, y) emgl_vertex2i (x + width, y + corner_size) emgl_vertex2i (x + width, y + corner_size) else emgl_vertex2i (x + width, y) emgl_vertex2i (x + width, y) end if corner_mode = mode_bottom_right then emgl_vertex2i (x + width, y + height - corner_size) emgl_vertex2i (x + width, y + height - corner_size) emgl_vertex2i (x + width - corner_size, y + height) emgl_vertex2i (x + width - corner_size, y + height) else emgl_vertex2i (x + width, y + height) emgl_vertex2i (x + width, y + height) end if corner_mode = mode_bottom_left then emgl_vertex2i (x + corner_size, y + height) emgl_vertex2i (x + corner_size, y + height) emgl_vertex2i (x, y + height - corner_size) emgl_vertex2i (x, y + height - corner_size) else emgl_vertex2i (x, y + height) emgl_vertex2i (x, y + height) end if corner_mode = mode_top_left then emgl_vertex2i (x, y + corner_size) else emgl_vertex2i (x, y) end end emgl_end end end -- class GUI_SPECIAL_FRAME