indexing description: "[ A widget displaying a string. By default the label is left aligned and vertical centered. To change alignment use `align_*'. A shadow effect can be enabled and disabled using `enable_shadow' and `disable_shadow'. A shadow color will be derived from the drawing color, but can be overridden by `set_shadow_color'. ]" date: "$Date$" revision: "$Revision$" class EM_LABEL inherit EM_WIDGET create make_empty, make_from_text feature {NONE} -- Initialisation make_empty is -- Initialise with an empty text. do make_from_text ("") ensure label_emtpy: text.is_empty left_aligned: is_left_aligned vertical_centered: is_vertical_centered changed: is_changed end make_from_text (a_text: STRING) is -- Initialise with `a_text' as text. require a_text_not_void: a_text /= Void do text := a_text is_left_aligned := True is_vertical_centered := True make_void_surface resize_to_optimal_dimension ensure text_set: text = a_text left_aligned: is_left_aligned vertical_centered: is_vertical_centered changed: is_changed end delegate_factory: FUNCTION [ANY, TUPLE [], like delegate] is -- Factory to create default delegate do Result := theme_delegates.label_delegate_factory end feature -- Access text: STRING -- Text of label shadow_color: EM_COLOR -- Color of shadow. -- Default is complementary color. feature -- Status is_left_aligned: BOOLEAN -- Is label left aligned? is_centered: BOOLEAN -- Is label centered? is_right_aligned: BOOLEAN -- Is label right aligned? is_shadow_enabled: BOOLEAN -- Is a shadow effect enabled? is_multilined: BOOLEAN -- Is label multilined is_top_aligned: BOOLEAN -- Is label top aligned? is_vertical_centered: BOOLEAN -- Is label vertical centered? is_bottom_aligned: BOOLEAN -- Is label bottom aligned? feature -- Status setting align_left is -- Align label left. do is_left_aligned := True is_right_aligned := False is_centered := False set_changed ensure left_aligned: is_left_aligned changed: is_changed end align_right is -- Align label right. do is_left_aligned := False is_right_aligned := True is_centered := False set_changed ensure right_aligned: is_right_aligned changed: is_changed end align_center is -- Center label. do is_left_aligned := False is_right_aligned := False is_centered := True set_changed ensure centered: is_centered changed: is_changed end align_top is -- Align label to top do is_top_aligned := true is_vertical_centered := false is_bottom_aligned := false set_changed ensure top_aligned: is_top_aligned changed: is_changed end align_vertical_centered is -- Center label verticaly do is_top_aligned := false is_vertical_centered := true is_bottom_aligned := false set_changed ensure verticaly_centered: is_vertical_centered changed: is_changed end align_bottom is -- Align label to bottom do is_top_aligned := false is_vertical_centered := false is_bottom_aligned := true set_changed ensure bottom_aligned: is_bottom_aligned changed: is_changed end enable_shadow is -- Enable shadow effect. do is_shadow_enabled := True ensure shadow_enabled: is_shadow_enabled end disable_shadow is -- Disable shadow effect. do is_shadow_enabled := False ensure shadow_disabled: not is_shadow_enabled end enable_multilined is -- Enable multilining of text. do is_multilined := True ensure multilined_enabled: is_multilined end disable_multilined is -- Disable multilining of text. do is_multilined := False ensure multilined_disabled: not is_multilined end set_multilined (a_value: like is_multilined) is -- Set `is_multilined' to `a_value' do is_multilined := a_value set_changed ensure is_multilined_set: is_multilined = a_value changed: is_changed end feature -- Element change set_text (a_text: like text) is -- Set `text' to `a_text'. require a_text_not_void: a_text /= Void do text := a_text set_changed ensure text_set: text = a_text changed: is_changed end set_shadow_color (a_color: like shadow_color) is -- Set `shadow_color' to `a_color'. do shadow_color := a_color set_changed ensure shadow_color_set: shadow_color = a_color changed: is_changed end invariant text_not_void: text /= Void consistent_aligned: (is_left_aligned xor is_right_aligned xor is_centered) and not (is_left_aligned and is_right_aligned and is_centered) consistent_vertival_aligned: (is_top_aligned xor is_bottom_aligned xor is_vertical_centered) and not (is_top_aligned and is_bottom_aligned and is_vertical_centered) end