Class: Glimmer::SWT::ExpandItemProxy

Inherits:
WidgetProxy show all
Defined in:
lib/glimmer/swt/expand_item_proxy.rb

Overview

Proxy for org.eclipse.swt.widgets.ExpandItem

Functions differently from other widget proxies.

Glimmer instantiates an SWT Composite alongside the SWT ExpandItem and returns it for ‘#swt_widget` to allow adding widgets into it.

In order to get the SWT ExpandItem object, one must call ‘#swt_expand_item`.

Behind the scenes, this creates a tab item widget proxy separately from a composite that is set as the control of the tab item and ‘#swt_widget`.

In order to retrieve the tab item widget proxy, one must call ‘#widget_proxy`

Follows the Proxy Design Pattern

Constant Summary collapse

ATTRIBUTES =
['text', 'height', 'expanded']

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS, WidgetProxy::DEFAULT_STYLES, WidgetProxy::KEYWORD_ALIASES

Instance Attribute Summary collapse

Attributes inherited from WidgetProxy

#drag_source_proxy, #drag_source_style, #drag_source_transfer, #drop_target_proxy, #drop_target_transfer, #parent_proxy, #swt_widget

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_observer, #async_exec, #can_add_observer?, #can_handle_drag_observation_request?, #can_handle_drop_observation_request?, #can_handle_observation_request?, #content, create, #ensure_drag_source_proxy, #ensure_drop_target_proxy, #extract_args, #handle_observation_request, #has_style?, #method_missing, #pack_same_size, #post_initialize_child, #remove_observer, #respond_to?, swt_widget_class_for, #sync_exec, underscored_widget_name, widget_exists?, #widget_property_listener_installers, widget_proxy_class

Methods included from Packages

included

Constructor Details

#initialize(parent, style, &contents) ⇒ ExpandItemProxy

Returns a new instance of ExpandItemProxy.



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/glimmer/swt/expand_item_proxy.rb', line 49

def initialize(parent, style, &contents)
  super("composite", parent, style, &contents)
  layout = FillLayout.new(SWTProxy[:vertical])
  layout.marginWidth = 0
  layout.marginHeight = 0
  layout.spacing = 0
  swt_widget.layout = layout        
  @widget_proxy = SWT::WidgetProxy.new('expand_item', parent, style)
  @swt_expand_item = @widget_proxy.swt_widget
  @swt_expand_item.control = swt_widget        
  @swt_expand_item.expanded = true
end

Dynamic Method Handling

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

Instance Attribute Details

#swt_expand_itemObject (readonly)

Returns the value of attribute swt_expand_item.



47
48
49
# File 'lib/glimmer/swt/expand_item_proxy.rb', line 47

def swt_expand_item
  @swt_expand_item
end

#widget_proxyObject (readonly)

Returns the value of attribute widget_proxy.



47
48
49
# File 'lib/glimmer/swt/expand_item_proxy.rb', line 47

def widget_proxy
  @widget_proxy
end

Instance Method Details

#disposeObject



90
91
92
93
94
# File 'lib/glimmer/swt/expand_item_proxy.rb', line 90

def dispose
  swt_expand_item.setControl(nil)
  swt_widget.dispose
  swt_expand_item.dispose
end

#get_attribute(attribute_name) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/glimmer/swt/expand_item_proxy.rb', line 82

def get_attribute(attribute_name)
  if ATTRIBUTES.include?(attribute_name.to_s)
    @widget_proxy.get_attribute(attribute_name)
  else
    super(attribute_name)
  end
end

#has_attribute?(attribute_name, *args) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
# File 'lib/glimmer/swt/expand_item_proxy.rb', line 66

def has_attribute?(attribute_name, *args)
  if ATTRIBUTES.include?(attribute_name.to_s)
    true
  else
    super(attribute_name, *args)
  end
end

#post_add_contentObject



62
63
64
# File 'lib/glimmer/swt/expand_item_proxy.rb', line 62

def post_add_content
  @swt_expand_item.setHeight(swt_widget.computeSize(SWTProxy[:default], SWTProxy[:default]).y) unless @swt_expand_item.getHeight > 0
end

#set_attribute(attribute_name, *args) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/glimmer/swt/expand_item_proxy.rb', line 74

def set_attribute(attribute_name, *args)
  if ATTRIBUTES.include?(attribute_name.to_s)
    @widget_proxy.set_attribute(attribute_name, *args)
  else
    super(attribute_name, *args)
  end
end