Class: Glimmer::SWT::LabelProxy
- Inherits:
-
WidgetProxy
- Object
- WidgetProxy
- Glimmer::SWT::LabelProxy
- Defined in:
- lib/glimmer/swt/label_proxy.rb
Constant Summary
Constants inherited from WidgetProxy
WidgetProxy::DEFAULT_INITIALIZERS
Instance Attribute Summary collapse
-
#background_image ⇒ Object
Returns the value of attribute background_image.
-
#image ⇒ Object
Returns the value of attribute image.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from WidgetProxy
#args, #background, #children, #disposed?, #enabled, #focus, #font, #foreground, #menu, #menu_requested, #parent, #path, #rendered
Instance Method Summary collapse
- #alignment ⇒ Object
- #alignment=(value) ⇒ Object
- #dom ⇒ Object
- #element ⇒ Object
- #html_text ⇒ Object
-
#initialize(parent, args, block) ⇒ LabelProxy
constructor
A new instance of LabelProxy.
Methods inherited from WidgetProxy
#add_content_on_render, #add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #content_on_render_blocks, #css_classes, #default_observation_request_to_event_mapping, #dispose, #dom_element, #effective_observation_request_to_event_mapping, #event_listener_proxies, for, #get_data, #handle_observation_request, #has_style?, #id, #id=, #layout, #listener_dom_element, #listener_path, max_id_number_for, max_id_numbers, #method_missing, #name, next_id_number_for, #observation_request_to_event_mapping, #observation_requests, #pack, #parent_dom_element, #parent_path, #post_add_content, #post_dispose_child, #post_initialize_child, #property_type_converters, #remove_all_listeners, #remove_css_class, #remove_css_classes, #remove_event_listener_proxies, #render, reset_max_id_numbers!, #selector, #set_attribute, #set_data, #set_focus, #skip_content_on_render_blocks?, #style_element, #swt_widget, underscored_widget_name, widget_class, widget_exists?, #widget_property_listener_installers
Methods included from PropertyOwner
#attribute_getter, #attribute_setter, #get_attribute, #set_attribute
Constructor Details
#initialize(parent, args, block) ⇒ LabelProxy
Returns a new instance of LabelProxy.
30 31 32 |
# File 'lib/glimmer/swt/label_proxy.rb', line 30 def initialize(parent, args, block) super(parent, args, block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::WidgetProxy
Instance Attribute Details
#background_image ⇒ Object
Returns the value of attribute background_image.
28 29 30 |
# File 'lib/glimmer/swt/label_proxy.rb', line 28 def background_image @background_image end |
#image ⇒ Object
Returns the value of attribute image.
28 29 30 |
# File 'lib/glimmer/swt/label_proxy.rb', line 28 def image @image end |
#text ⇒ Object
Returns the value of attribute text.
28 29 30 |
# File 'lib/glimmer/swt/label_proxy.rb', line 28 def text @text end |
Instance Method Details
#alignment ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/glimmer/swt/label_proxy.rb', line 60 def alignment if @alignment.nil? found_arg = nil @alignment = [:left, :center, :right].detect {|align| found_arg = args.detect { |arg| SWTProxy[align] == SWTProxy[arg] } } args.delete(found_arg) end @alignment end |
#alignment=(value) ⇒ Object
69 70 71 72 73 |
# File 'lib/glimmer/swt/label_proxy.rb', line 69 def alignment=(value) # TODO consider storing swt value in the future instead @alignment = value dom_element.css('text-align', @alignment.to_s) end |
#dom ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/glimmer/swt/label_proxy.rb', line 75 def dom label_id = id label_class = name @dom ||= html { label(id: label_id, class: label_class, style: "text-align: #{alignment};") { html_text } }.to_s end |
#element ⇒ Object
56 57 58 |
# File 'lib/glimmer/swt/label_proxy.rb', line 56 def element 'label' end |
#html_text ⇒ Object
39 40 41 |
# File 'lib/glimmer/swt/label_proxy.rb', line 39 def html_text text&.gsub("\n", '<br />') end |