Class: Glimmer::SWT::CTabItemProxy

Inherits:
TabItemProxy show all
Defined in:
lib/glimmer/swt/c_tab_item_proxy.rb

Constant Summary

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS, WidgetProxy::JS_KEY_CODE_TO_SWT_KEY_CODE_MAP, WidgetProxy::JS_LOCATION_TO_SWT_KEY_LOCATION_MAP, WidgetProxy::SWT_CURSOR_TO_CSS_CURSOR_MAP

Instance Attribute Summary collapse

Attributes inherited from TabItemProxy

#content_visible, #image, #text, #tool_tip_text

Attributes inherited from WidgetProxy

#args, #background, #children, #cursor, #disposed?, #enabled, #focus, #font, #foreground, #menu, #menu_requested, #menu_x, #menu_y, #parent, #path, #rendered

Instance Method Summary collapse

Methods inherited from TabItemProxy

#dispose, #dom, #listener_path, #observation_request_to_event_mapping, #selector, #tab_dom_element, #tab_id, #tab_path

Methods inherited from CompositeProxy

#background_image, #background_image=, #default_layout, #dom, #get_layout, #layout=, #layout​, #pack

Methods inherited from WidgetProxy

#add_content_on_render, #add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #attach, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #content_on_render_blocks, #css_classes, #default_observation_request_to_event_mapping, #dialog_ancestor, #dispose, #dom_element, #effective_observation_request_to_event_mapping, #element, #event_handling_suspended?, #event_listener_proxies, for, #get_data, #handle_javascript_observation_request, #handle_observation_request, #has_style?, #id, #id=, #listener_dom_element, #listener_path, #listeners, #listeners_for, max_id_number_for, max_id_numbers, #method_missing, #name, next_id_number_for, #observation_request_to_event_mapping, #observation_requests, #parent_dom_element, #parent_path, #parents, #post_add_content, #post_dispose_child, #post_initialize_child, #print, #property_type_converters, #reattach, #remove_all_listeners, #remove_css_class, #remove_css_classes, #remove_event_listener_proxies, #render, reset_max_id_numbers!, #resume_event_handling, #selector, #set_attribute, #set_data, #set_focus, #shell, #skip_content_on_render_blocks?, #style_element, #suspend_event_handling, #swt_data, #swt_widget, underscored_widget_name, widget_class, widget_exists?, widget_handling_listener, #widget_property_listener_installers

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Constructor Details

#initialize(parent, args, block) ⇒ CTabItemProxy

Returns a new instance of CTabItemProxy.



30
31
32
33
34
35
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 30

def initialize(parent, args, block)
  @closeable = args.detect { |arg| SWTProxy[arg] == SWTProxy[:close] }
  super(parent, args, block)
  # TODO attach listener if :close style is set
  close_dom_element.on('click') { dispose }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::WidgetProxy

Instance Attribute Details

#closeableObject

Returns the value of attribute closeable.



28
29
30
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 28

def closeable
  @closeable
end

#selection_foregroundObject

Returns the value of attribute selection_foreground.



27
28
29
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 27

def selection_foreground
  @selection_foreground
end

Instance Method Details

#close_dom_elementObject



80
81
82
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 80

def close_dom_element
  Document.find(close_path)
end

#close_pathObject



76
77
78
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 76

def close_path
  "#{tab_path} span.ui-icon-close"
end

#font=(value) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 52

def font=(value)
  @font = value.is_a?(FontProxy) ? value : FontProxy.new(self, value)
  tab_dom_element.css('font-family', @font.name) unless @font.nil?
  tab_dom_element.css('font-style', 'italic') if @font&.style == :italic || [@font&.style].flatten.compact.include?(:italic)
  tab_dom_element.css('font-weight', 'bold') if @font&.style == :bold || [@font&.style].flatten.compact.include?(:bold)
  tab_dom_element.css('font-size', "#{@font.height}px") unless @font.nil?
end

#foreground=(value) ⇒ Object



37
38
39
40
41
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 37

def foreground=(value)
  value = ColorProxy.new(value) if value.is_a?(String)
  @foreground = value
  tab_dom_element.css('color', foreground.to_css) unless foreground.nil?
end

#hideObject



68
69
70
71
72
73
74
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 68

def hide
  super
  if @old_foreground
    tab_dom_element.css('color', @old_foreground)
    @old_foreground = nil
  end
end

#showObject



60
61
62
63
64
65
66
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 60

def show
  super
  if @selection_foreground
    @old_foreground = tab_dom_element.css('color')
    tab_dom_element.css('color', @selection_foreground.to_css)
  end
end

#tab_domObject



84
85
86
87
88
89
90
91
92
# File 'lib/glimmer/swt/c_tab_item_proxy.rb', line 84

def tab_dom
  @tab_dom ||= html {
    a(href: '#', id: tab_id, class: "tab") {
      img {}
      span { @text }
      span(class: 'ui-icon ui-icon-close', role: 'presentation') { 'Remove Tab' } if @closeable
    }
  }.to_s
end