indexing description: "[ Basic delegate of an EM_CHECKBOX. ]" date: "$Date$" revision: "$Revision$" class EM_BASIC_CHECKBOX_DELEGATE inherit EM_WIDGET_DELEGATE redefine install, optimal_width, optimal_height, draw_body end feature -- Initialisation install (checkbox: EM_CHECKBOX) is -- Install style on `checkbox'. -- Set up all default values for background, border, font and colors. do Precursor {EM_WIDGET_DELEGATE} (checkbox) checkbox.set_transparent end feature -- Measurement optimal_width (checkbox: EM_CHECKBOX): INTEGER is -- Optimal width of `checkbox' do Result := checkbox.font.string_width (checkbox.text) + checkbox.border.left + checkbox.border.right + 16 end optimal_height (checkbox: EM_CHECKBOX): INTEGER is -- Optimal height of `checkbox' do Result := checkbox.font.string_height (checkbox.text) + checkbox.border.top + checkbox.border.bottom + 2 Result := Result.max (16) end feature -- Drawing draw_body (checkbox: EM_CHECKBOX) is -- Draw body of `checkbox'. local x, y: INTEGER do x := checkbox.border.left + 1 y := checkbox.border.top + 1 if checkbox.text.count > 0 then checkbox.surface.set_drawing_color (checkbox.foreground_color) checkbox.font.draw_string (checkbox.text, checkbox.surface, x+15, y+1) end checkbox.surface.put_rectangle_filled (x+3, y+3, x+11, y+11, theme_colors.standard_background) checkbox.surface.put_rectangle (x+2, y+2, x+12, y+12, checkbox.foreground_color) if checkbox.is_checked then checkbox.surface.put_wide_line_segment (x+4, y+4, x+10, y+10, 2, checkbox.foreground_color) checkbox.surface.put_wide_line_segment (x+4, y+10, x+10, y+4, 2, checkbox.foreground_color) end end end