Class: Glimmer::SWT::GLayoutData
- Inherits:
-
Object
- Object
- Glimmer::SWT::GLayoutData
- Includes:
- Parent
- Defined in:
- lib/glimmer/swt/g_layout_data.rb
Instance Attribute Summary collapse
-
#layout_data ⇒ Object
readonly
Returns the value of attribute layout_data.
-
#widget ⇒ Object
readonly
Returns the value of attribute widget.
Instance Method Summary collapse
- #apply_property_type_converters(attribute_name, args) ⇒ Object
- #attribute_setter(attribute_name) ⇒ Object
- #has_attribute?(attribute_name, *args) ⇒ Boolean
-
#initialize(widget, args) ⇒ GLayoutData
constructor
A new instance of GLayoutData.
- #process_block(block) ⇒ Object
- #set_attribute(attribute_name, *args) ⇒ Object
- #swt_layout_data_class ⇒ Object
Constructor Details
#initialize(widget, args) ⇒ GLayoutData
Returns a new instance of GLayoutData.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 14 def initialize(, args) @widget = args = GSWT.constantify_args(args) begin @layout_data = swt_layout_data_class.new(*args) rescue => e Glimmer.logger.debug "#{e.}\n#{e.backtrace.join("\n")}" @layout_data = args.first if args.count == 1 end @widget.setLayoutData(@layout_data) end |
Instance Attribute Details
#layout_data ⇒ Object (readonly)
Returns the value of attribute layout_data.
12 13 14 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 12 def layout_data @layout_data end |
#widget ⇒ Object (readonly)
Returns the value of attribute widget.
11 12 13 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 11 def @widget end |
Instance Method Details
#apply_property_type_converters(attribute_name, args) ⇒ Object
45 46 47 48 49 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 45 def apply_property_type_converters(attribute_name, args) if args.count == 1 && GSWT.has_constant?(args.first) args[0] = GSWT.constant(args.first) end end |
#attribute_setter(attribute_name) ⇒ Object
51 52 53 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 51 def attribute_setter(attribute_name) "#{attribute_name.to_s.camelcase(:lower)}=" end |
#has_attribute?(attribute_name, *args) ⇒ Boolean
36 37 38 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 36 def has_attribute?(attribute_name, *args) @layout_data.respond_to?(attribute_setter(attribute_name), args) end |
#process_block(block) ⇒ Object
26 27 28 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 26 def process_block(block) block.call(@layout) end |
#set_attribute(attribute_name, *args) ⇒ Object
40 41 42 43 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 40 def set_attribute(attribute_name, *args) apply_property_type_converters(attribute_name, args) @layout_data.send(attribute_setter(attribute_name), *args) end |
#swt_layout_data_class ⇒ Object
30 31 32 33 34 |
# File 'lib/glimmer/swt/g_layout_data.rb', line 30 def swt_layout_data_class parent_layout_class_name = @widget.getParent.getLayout.class.name layout_data_class_name = parent_layout_class_name.sub(/Layout$/, 'Data') eval(layout_data_class_name) end |