class Glimmer::SWT::CTabItemProxy

Attributes

closeable[RW]
selection_foreground[R]

Public Class Methods

new(parent, args, block) click to toggle source
Calls superclass method
# 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

Public Instance Methods

close_dom_element() click to toggle source
# File lib/glimmer/swt/c_tab_item_proxy.rb, line 80
def close_dom_element
  Document.find(close_path)
end
close_path() click to toggle source
# File lib/glimmer/swt/c_tab_item_proxy.rb, line 76
def close_path
  "#{tab_path} span.ui-icon-close"
end
font=(value) click to toggle source
# 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) click to toggle source
# 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
hide() click to toggle source
Calls superclass method
# 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
selection_foreground=(value) click to toggle source
# File lib/glimmer/swt/c_tab_item_proxy.rb, line 43
def selection_foreground=(value)
  value = ColorProxy.new(value) if value.is_a?(String)
  @selection_foreground = value
  if @selection_foreground && tab_dom_element.has_class?('selected')
    @old_foreground = tab_dom_element.css('color')
    tab_dom_element.css('color', @selection_foreground.to_css)
  end
end
show() click to toggle source
Calls superclass method
# 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_dom() click to toggle source
# 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