indexing description: "[ Delegate of an EM_CHECKBOX. ]" date: "$Date$" revision: "$Revision$" class EM_ECLIPSE_CHECKBOX_DELEGATE inherit EM_WIDGET_DELEGATE redefine install, optimal_width, optimal_height, draw_body end EM_WIDGET_DRAWING export {NONE} all 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 + 20 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 (20) 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+20, y+1) end checkbox.surface.put_rectangle_filled (x+3, y+3, x+13, y+13, theme_colors.standard_background) draw_bevel_border_down (x+2, y+2, x+15, y+15, checkbox.surface) if checkbox.is_checked then checkbox.surface.put_wide_line_segment (x+5, y+7, x+8, y+10, 2, checkbox.foreground_color) checkbox.surface.put_wide_line_segment (x+8, y+10, x+12, y+5, 2, checkbox.foreground_color) end end end