indexing description: "Information box with modal capabilities, static icon, and subpression check box." class INFORMATION_BOX inherit PUZZLE_COMPONENT WEL_FRAME_WINDOW redefine on_control_command, parent, on_paint, background_brush, on_get_min_max_info, closeable end creation make feature{NONE} -- private make( a_parent: like parent; title, msg : STRING; m_on : BOOLEAN ) is require proper_parent: a_parent /= Void proper_string_input: title /= Void and msg /= Void do make_child( a_parent, title ) set_gaps create_info_icon set_width_height set_positions create wp.make( box_width, box_height ) move_and_resize( box_x_pos, box_y_pos, box_width, box_height, false ) create message.make( Current, msg, message_x_pos, message_y_pos, message_width, message_height, - 1 ) create my_log_font.make( 16, "Arial" ) create my_font.make_indirect( my_log_font ) message.set_font( my_font ) create ok_button.make( Current, "OK", ok_button_x_pos, ok_button_y_pos, ok_button_width, ok_button_height, - 1 ) ok_button.set_font( my_font ) create check_box.make( Current, "Don't show this again", check_box_x_pos, check_box_y_pos, check_box_width, check_box_height, -1 ) create check_box_log_font.make( 12, "Arial" ) create check_box_font.make_indirect( check_box_log_font ) check_box.set_font( check_box_font ) modal_on := m_on check_modal end my_log_font, check_box_log_font : WEL_LOG_FONT my_font, check_box_font : WEL_FONT info_image : WEL_BITMAP -- Info box icon parent : V_DESIGN_SHELL message : WEL_STATIC -- Text displayed in the window ok_button : WEL_PUSH_BUTTON -- Button to accept the user input check_box : WEL_CHECK_BOX -- Supression check box modal_on : BOOLEAN -- Is the info box modal? feature -- Status closeable : BOOLEAN is false -- Prevent the user from closing the window via the title bar close button show_no_more : BOOLEAN is -- Did the user request not show this check box again? do Result := check_box.checked end feature -- Background color background_brush : WEL_BRUSH is -- Current window background color used to refresh the window when -- requested by the WM_ERASEBKGND windows message. do create Result.make_by_sys_color( Color_background ) end feature -- Messages on_get_min_max_info( min_max_info: WEL_MIN_MAX_INFO ) is -- Prevent resizing by the user. do min_max_info.set_max_track_size( wp ) min_max_info.set_min_track_size( wp ) min_max_info.set_max_size( wp ) end on_paint (paint_dc: WEL_PAINT_DC; invalid_rect: WEL_RECT) is -- Draw the icon bitmap do if info_image /= Void then paint_dc.draw_bitmap ( info_image, icon_x_pos, icon_y_pos, info_icon_width, info_icon_height ) end end on_control_command (control: WEL_CONTROL) is -- Process ok_button selection. do if control = ok_button then reset_on_exit end end feature{NONE} -- Implementation check_modal is do if modal_on then if parent.enabled then parent.disable else parent.enable end end end reset_on_exit is do check_modal hide parent.info_box_notify end create_info_icon is do info_image := configuration.info_box_pixmap( Current ) end wp : WEL_POINT -- Needed as the ordered pair (width, height) to prevent resizing. info_icon_width, info_icon_height, gap_north, gap_south, gap_east, gap_west, ok_button_width, ok_button_height, check_box_width, check_box_height, message_width, message_height : INTEGER box_width, box_height : INTEGER box_x_pos, box_y_pos : INTEGER icon_x_pos, icon_y_pos, ok_button_x_pos, ok_button_y_pos, check_box_x_pos, check_box_y_pos, message_x_pos, message_y_pos : INTEGER set_gaps is do gap_north := 10 gap_south := 25 gap_east := 10 gap_west := 10 end set_width_height is -- Need a layout manager. do info_icon_width := info_image.width info_icon_height := info_image.height ok_button_width := 60 ok_button_height := 23 check_box_width := 125 check_box_height := 23 message_width := 175 message_height := 35 -- The window should grow based to message height. box_width := gap_west + info_icon_width + message_width + gap_east box_height := gap_north + ok_button_height + check_box_height + gap_south if message_height > info_icon_height then box_height := box_height + message_height else box_height := box_height + info_icon_height end end set_positions is local y1, y2 : INTEGER do box_x_pos := 20 box_y_pos := 20 icon_x_pos := gap_west icon_y_pos := gap_north message_x_pos := gap_east + 15 + info_icon_width message_y_pos := gap_north check_box_x_pos := message_x_pos check_box_y_pos := message_y_pos + message_height + gap_north ok_button_x_pos := box_width // 2 - ok_button_width // 2 y1 := check_box_y_pos + ok_button_height + 20 y2 := icon_y_pos + info_icon_height + 5 if y1 > y2 then ok_button_y_pos := y1 else ok_button_y_pos := y2 end end end -- class INFORMATION_BOX