Sha256: 18479f4c59100e752ca7ba8b9fa7d9bfea41c76b160894188f6532f64d7237f0

Contents?: true

Size: 1.85 KB

Versions: 37

Compression:

Stored size: 1.85 KB

Contents

require 'glimmer/swt/widget_proxy'

module Glimmer
  module SWT
    # Proxy for org.eclipse.swt.widgets.TabItem
    #
    # Functions differently from other widget proxies.
    #
    # Glimmer instantiates an SWT Composite alongside the SWT TabItem
    # and returns it for `#swt_widget` to allow adding widgets into it.
    #
    # In order to get the SWT TabItem object, one must call `#swt_tab_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
    class TabItemProxy < WidgetProxy
      include_package 'org.eclipse.swt.widgets'

      attr_reader :widget_proxy, :swt_tab_item

      def initialize(parent, style, &contents)
        super("composite", parent, style, &contents)
        @widget_proxy = SWT::WidgetProxy.new('tab_item', parent, style)
        @swt_tab_item = @widget_proxy.swt_widget
        @widget_proxy.swt_widget.control = self.swt_widget
      end

      def has_attribute?(attribute_name, *args)
        if attribute_name.to_s == "text"
          true
        else
          super(attribute_name, *args)
        end
      end

      def set_attribute(attribute_name, *args)
        attribute_name
        if attribute_name.to_s == "text"
          text_value = args[0]
          @swt_tab_item.setText text_value
        else
          super(attribute_name, *args)
        end
      end

      def get_attribute(attribute_name)
        if attribute_name.to_s == "text"
          @swt_tab_item.getText
        else
          super(attribute_name)
        end
      end
      
      def dispose
        swt_tab_item.setControl(nil)
        swt_widget.dispose
        swt_tab_item.dispose
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
glimmer-dsl-swt-0.6.9 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.8 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.7 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.6 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.5 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.4 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.3 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.2 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.1 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.6.0 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.5.6 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.5.5 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.5.4 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.5.3 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.5.2 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.5.1 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.5.0 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.4.1 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.4.0 lib/glimmer/swt/tab_item_proxy.rb
glimmer-dsl-swt-0.3.1 lib/glimmer/swt/tab_item_proxy.rb